Skip to content

Commit

Permalink
Change type of label tensor to int32/int64 in SoftmaxCrossEntropyLoss…
Browse files Browse the repository at this point in the history
… spec. (onnx#2667)
  • Loading branch information
codemzs authored Mar 18, 2020
1 parent c2fefcb commit ac1caf3
Show file tree
Hide file tree
Showing 27 changed files with 15 additions and 7 deletions.
4 changes: 3 additions & 1 deletion docs/Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -14965,7 +14965,7 @@ This version of the operator has been available since version 12 of the default
<dl>
<dt><tt>scores</tt> : T</dt>
<dd>The predicted outputs with shape [batch_size, class_size], or [batch_size, class_size, D1, D2 , ..., Dk], where K is the number of dimensions.</dd>
<dt><tt>labels</tt> : T</dt>
<dt><tt>labels</tt> : Tind</dt>
<dd>The ground truth output tensor, with shape [batch_size], or [batch_size, D1, D2, ..., Dk], where K is the number of dimensions.</dd>
<dt><tt>weights</tt> (optional) : T</dt>
<dd>A manual rescaling weight given to each class. If given, it has to be a 1D Tensor assigning weight to each of the classes. Otherwise, it is treated as if having all ones.</dd>
Expand All @@ -14985,6 +14985,8 @@ This version of the operator has been available since version 12 of the default
<dl>
<dt><tt>T</tt> : tensor(float16), tensor(float), tensor(double)</dt>
<dd>Constrain input and output types to float tensors.</dd>
<dt><tt>Tind</tt> : tensor(int32), tensor(int64)</dt>
<dd>Constrain target to integer types</dd>
</dl>

### <a name="UnfoldToDepth-12"></a>**UnfoldToDepth-12**</a>
Expand Down
4 changes: 3 additions & 1 deletion docs/Operators.md
Original file line number Diff line number Diff line change
Expand Up @@ -18218,7 +18218,7 @@ This version of the operator has been available since version 12 of the default
<dl>
<dt><tt>scores</tt> : T</dt>
<dd>The predicted outputs with shape [batch_size, class_size], or [batch_size, class_size, D1, D2 , ..., Dk], where K is the number of dimensions.</dd>
<dt><tt>labels</tt> : T</dt>
<dt><tt>labels</tt> : Tind</dt>
<dd>The ground truth output tensor, with shape [batch_size], or [batch_size, D1, D2, ..., Dk], where K is the number of dimensions.</dd>
<dt><tt>weights</tt> (optional) : T</dt>
<dd>A manual rescaling weight given to each class. If given, it has to be a 1D Tensor assigning weight to each of the classes. Otherwise, it is treated as if having all ones.</dd>
Expand All @@ -18238,6 +18238,8 @@ This version of the operator has been available since version 12 of the default
<dl>
<dt><tt>T</tt> : tensor(float16), tensor(float), tensor(double)</dt>
<dd>Constrain input and output types to float tensors.</dd>
<dt><tt>Tind</tt> : tensor(int32), tensor(int64)</dt>
<dd>Constrain target to integer types</dd>
</dl>


Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
Z
y



b
z

Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ QSoftmaxCrossEntropyLoss_test_softmax_cross_entropy_none_expanded_functionlog_pr
Z
y



b
z

Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
Z
y



Z
w

Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ YSoftmaxCrossEntropyLoss_test_softmax_cross_entropy_none_weights_expanded_functi
Z
y



Z
w

Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
6 changes: 5 additions & 1 deletion onnx/defs/math/defs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2340,7 +2340,7 @@ ONNX_OPERATOR_SET_SCHEMA(
"labels",
"The ground truth output tensor, with shape [batch_size], or "
"[batch_size, D1, D2, ..., Dk], where K is the number of dimensions.",
"T")
"Tind")
.Input(
2,
"weights",
Expand All @@ -2366,6 +2366,10 @@ ONNX_OPERATOR_SET_SCHEMA(
"T",
{"tensor(float16)", "tensor(float)", "tensor(double)"},
"Constrain input and output types to float tensors.")
.TypeConstraint(
"Tind",
{"tensor(int32)", "tensor(int64)"},
"Constrain target to integer types")
.SetContextDependentFunctionBodyBuilder(BuildContextDependentFunctionBodySCE)
.TypeAndShapeInferenceFunction([](InferenceContext& ctx) {
propagateElemTypeFromInputToOutput(ctx, 0, 0);
Expand Down

0 comments on commit ac1caf3

Please sign in to comment.