Skip to content

Commit

Permalink
Rel 1.7.0 (#2650)
Browse files Browse the repository at this point in the history
* Fix Greater/LessOrEqual function definition (#2645)

* Fix Greater/LessOrEqual function definition

* Update test data

Co-authored-by: Ke Zhang <kezhan@microsoft.com>

* Suppress a warning in unsqueeze (#2637)

I keep getting this warning when building PyTorch:

```
In file included from
/home/hong/wsrc/pytorch/third_party/onnx/onnx/defs/tensor/utils.h:6,
                 from
/home/hong/wsrc/pytorch/third_party/onnx/onnx/defs/tensor/defs.cc:4:
/home/hong/wsrc/pytorch/third_party/onnx/onnx/defs/tensor/defs.cc: In
lambda function:
/home/hong/wsrc/pytorch/third_party/onnx/onnx/defs/tensor/defs.cc:1414:22:
warning: unnecessary parentheses in declaration of �i�
[-Wparentheses]
           for (size_t(i) = 0; i < axes.size(); ++i) {
                      ^
/home/hong/wsrc/pytorch/third_party/onnx/onnx/defs/schema.h:959:12:
note: in definition of macro �ONNX_OPERATOR_SET_SCHEMA_EX�
     return impl.SetName(#name)
\
            ^~~~
/home/hong/wsrc/pytorch/third_party/onnx/onnx/defs/tensor/defs.cc:1369:1:
note: in expansion of macro �ONNX_OPERATOR_SET_SCHEMA�
 ONNX_OPERATOR_SET_SCHEMA(
```

This commit should fix it and modernize the code a bit.

Co-authored-by: Ke Zhang <kezhan@microsoft.com>

Co-authored-by: Takeshi Watanabe <take-cheeze@users.noreply.github.com>
Co-authored-by: Ke Zhang <kezhan@microsoft.com>
Co-authored-by: Hong Xu <hong@topbug.net>
  • Loading branch information
4 people committed Mar 10, 2020
1 parent b852d81 commit 9942125
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 18 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
 backend-test:�
I
 backend-test:�
L
x
y;GreaterOrEqual_test_greater_equal_bcast_expanded_functionO1"Less
y;GreaterOrEqual_test_greater_equal_bcast_expanded_functionO1"Greater
J
x
y;GreaterOrEqual_test_greater_equal_bcast_expanded_functionO2"Equal
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
 backend-test:�
C
 backend-test:�
F
x
y5GreaterOrEqual_test_greater_equal_expanded_functionO1"Less
y5GreaterOrEqual_test_greater_equal_expanded_functionO1"Greater
D
x
y5GreaterOrEqual_test_greater_equal_expanded_functionO2"Equal
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
 backend-test:�
F
 backend-test:�
C
x
y5LessOrEqual_test_less_equal_bcast_expanded_functionO1"Greater
y5LessOrEqual_test_less_equal_bcast_expanded_functionO1"Less
D
x
y5LessOrEqual_test_less_equal_bcast_expanded_functionO2"Equal
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
 backend-test:�
@
 backend-test:�
=
x
y/LessOrEqual_test_less_equal_expanded_functionO1"Greater
y/LessOrEqual_test_less_equal_expanded_functionO1"Less
>
x
y/LessOrEqual_test_less_equal_expanded_functionO2"Equal
Expand Down
4 changes: 2 additions & 2 deletions onnx/defs/logical/defs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ ONNX_OPERATOR_SET_SCHEMA(
.TypeAndShapeInferenceFunction(InferenceFunction())
.FunctionBody(FunctionBodyHelper::BuildNodes({
// nodes: {outputs, op, inputs, attributes}
{{"O1"}, "Greater", {"A", "B"}},
{{"O1"}, "Less", {"A", "B"}},
{{"O2"}, "Equal", {"A", "B"}},
{{"C"}, "Or", {"O1", "O2"}}
})));
Expand All @@ -236,7 +236,7 @@ ONNX_OPERATOR_SET_SCHEMA(
.TypeAndShapeInferenceFunction(InferenceFunction())
.FunctionBody(FunctionBodyHelper::BuildNodes({
// nodes: {outputs, op, inputs, attributes}
{{"O1"}, "Less", {"A", "B"}},
{{"O1"}, "Greater", {"A", "B"}},
{{"O2"}, "Equal", {"A", "B"}},
{{"C"}, "Or", {"O1", "O2"}}
})));
Expand Down
8 changes: 4 additions & 4 deletions onnx/defs/tensor/defs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1578,13 +1578,13 @@ ONNX_OPERATOR_SET_SCHEMA(
const auto& input_shape = ctx.getInputType(0)->tensor_type().shape();
const auto input_ndim = input_shape.dim_size();
const auto output_ndim = input_ndim + static_cast<int>(axes.size());
for (size_t(i) = 0; i < axes.size(); ++i) {
if (axes[i] < -output_ndim || axes[i] >= output_ndim) {
for (auto& axe : axes) {
if (axe < -output_ndim || axe >= output_ndim) {
fail_shape_inference(
"values in 'axes' are beyond the bounds of the computed output shape");
}
if (axes[i] < 0) {
axes[i] += output_ndim;
if (axe < 0) {
axe += output_ndim;
}
}

Expand Down

0 comments on commit 9942125

Please sign in to comment.