From 4e7289d05a08453b3f20efeb774d4590b5428903 Mon Sep 17 00:00:00 2001 From: Thiago Crepaldi Date: Thu, 25 Apr 2024 18:31:13 -0400 Subject: [PATCH] Add bfloat16 to all relevant ops (#6099) Reland https://github.com/onnx/onnx/pull/6079 Fixes https://github.com/onnx/onnx/issues/3842 Fixes https://github.com/onnx/onnx/issues/6071 Fixes https://github.com/onnx/onnx/issues/4051 @gramalingam @justinchuby FYI Signed-off-by: Thiago Crepaldi --- docs/Changelog.md | 2367 ++++++++++++++++- docs/Operators.md | 402 +-- .../test/data/node/test_acos/model.onnx | Bin 99 -> 99 bytes .../data/node/test_acos_example/model.onnx | Bin 91 -> 91 bytes .../test/data/node/test_acosh/model.onnx | Bin 101 -> 101 bytes .../data/node/test_acosh_example/model.onnx | Bin 93 -> 93 bytes .../test/data/node/test_asin/model.onnx | Bin 99 -> 99 bytes .../data/node/test_asin_example/model.onnx | Bin 91 -> 91 bytes .../test/data/node/test_asinh/model.onnx | Bin 101 -> 101 bytes .../data/node/test_asinh_example/model.onnx | Bin 93 -> 93 bytes .../test/data/node/test_atan/model.onnx | Bin 99 -> 99 bytes .../data/node/test_atan_example/model.onnx | Bin 91 -> 91 bytes .../test/data/node/test_atanh/model.onnx | Bin 101 -> 101 bytes .../data/node/test_atanh_example/model.onnx | Bin 93 -> 93 bytes .../test_averagepool_1d_default/model.onnx | Bin 145 -> 145 bytes .../node/test_averagepool_2d_ceil/model.onnx | Bin 189 -> 189 bytes .../test_averagepool_2d_default/model.onnx | Bin 156 -> 156 bytes .../test_averagepool_2d_dilations/model.onnx | Bin 214 -> 214 bytes .../node/test_averagepool_2d_pads/model.onnx | Bin 172 -> 172 bytes .../model.onnx | Bin 216 -> 216 bytes .../model.onnx | Bin 184 -> 184 bytes .../model.onnx | Bin 228 -> 228 bytes .../model.onnx | Bin 216 -> 216 bytes .../model.onnx | Bin 186 -> 186 bytes .../test_averagepool_2d_same_lower/model.onnx | Bin 186 -> 186 bytes .../test_averagepool_2d_same_upper/model.onnx | Bin 186 -> 186 bytes .../test_averagepool_2d_strides/model.onnx | Bin 174 -> 174 bytes .../test_averagepool_3d_default/model.onnx | Bin 166 -> 166 bytes .../model.onnx | Bin 303 -> 303 bytes .../model.onnx | Bin 302 -> 302 bytes .../model.onnx | Bin 303 -> 303 bytes .../model.onnx | Bin 302 -> 302 bytes .../model.onnx | Bin 234 -> 234 bytes .../test_basic_conv_with_padding/model.onnx | Bin 201 -> 201 bytes .../model.onnx | Bin 204 -> 204 bytes .../model.onnx | Bin 308 -> 308 bytes .../model.onnx | Bin 323 -> 323 bytes .../test/data/node/test_bernoulli/model.onnx | Bin 93 -> 93 bytes .../node/test_bernoulli_double/model.onnx | Bin 114 -> 114 bytes .../test_bernoulli_double_expanded/model.onnx | Bin 446 -> 446 bytes .../node/test_bernoulli_expanded/model.onnx | Bin 409 -> 409 bytes .../data/node/test_bernoulli_seed/model.onnx | Bin 114 -> 114 bytes .../test_bernoulli_seed_expanded/model.onnx | Bin 452 -> 452 bytes .../test_conv_with_autopad_same/model.onnx | Bin 226 -> 226 bytes .../model.onnx | Bin 236 -> 236 bytes .../model.onnx | Bin 224 -> 224 bytes .../test_conv_with_strides_padding/model.onnx | Bin 221 -> 221 bytes .../data/node/test_convtranspose/model.onnx | Bin 158 -> 158 bytes .../node/test_convtranspose_1d/model.onnx | Bin 148 -> 148 bytes .../node/test_convtranspose_3d/model.onnx | Bin 173 -> 173 bytes .../model.onnx | Bin 216 -> 216 bytes .../test_convtranspose_dilations/model.onnx | Bin 188 -> 188 bytes .../model.onnx | Bin 266 -> 266 bytes .../model.onnx | Bin 212 -> 212 bytes .../node/test_convtranspose_pad/model.onnx | Bin 205 -> 205 bytes .../node/test_convtranspose_pads/model.onnx | Bin 200 -> 200 bytes .../test/data/node/test_cos/model.onnx | Bin 97 -> 97 bytes .../data/node/test_cos_example/model.onnx | Bin 89 -> 89 bytes .../test/data/node/test_cosh/model.onnx | Bin 99 -> 99 bytes .../data/node/test_cosh_example/model.onnx | Bin 91 -> 91 bytes .../model.onnx | Bin 310 -> 310 bytes .../model.onnx | Bin 286 -> 286 bytes .../test/data/node/test_det_2d/model.onnx | Bin 84 -> 84 bytes .../test/data/node/test_det_nd/model.onnx | Bin 92 -> 92 bytes .../data/node/test_dropout_default/model.onnx | Bin 126 -> 126 bytes .../node/test_dropout_default_mask/model.onnx | Bin 160 -> 160 bytes .../model.onnx | Bin 182 -> 182 bytes .../test_dropout_default_ratio/model.onnx | Bin 148 -> 148 bytes .../test/data/node/test_elu/model.onnx | Bin 114 -> 114 bytes .../data/node/test_elu_default/model.onnx | Bin 105 -> 105 bytes .../data/node/test_elu_example/model.onnx | Bin 106 -> 106 bytes .../model.onnx | Bin 148 -> 148 bytes .../node/test_eyelike_with_dtype/model.onnx | Bin 122 -> 122 bytes .../test_eyelike_without_dtype/model.onnx | Bin 111 -> 111 bytes .../node/test_globalaveragepool/model.onnx | Bin 133 -> 133 bytes .../model.onnx | Bin 145 -> 145 bytes .../data/node/test_globalmaxpool/model.onnx | Bin 125 -> 125 bytes .../test_globalmaxpool_precomputed/model.onnx | Bin 137 -> 137 bytes .../test/data/node/test_gridsample/model.onnx | Bin 225 -> 225 bytes .../model.onnx | Bin 217 -> 217 bytes .../node/test_gridsample_bicubic/model.onnx | Bin 184 -> 184 bytes .../model.onnx | Bin 235 -> 235 bytes .../model.onnx | Bin 235 -> 235 bytes .../node/test_gridsample_bilinear/model.onnx | Bin 186 -> 186 bytes .../model.onnx | Bin 237 -> 237 bytes .../model.onnx | Bin 237 -> 237 bytes .../test_gridsample_border_padding/model.onnx | Bin 200 -> 200 bytes .../node/test_gridsample_nearest/model.onnx | Bin 186 -> 186 bytes .../model.onnx | Bin 237 -> 237 bytes .../model.onnx | Bin 237 -> 237 bytes .../model.onnx | Bin 208 -> 208 bytes .../model.onnx | Bin 247 -> 247 bytes .../model.onnx | Bin 247 -> 247 bytes .../model.onnx | Bin 247 -> 247 bytes .../model.onnx | Bin 247 -> 247 bytes .../test_gridsample_zeros_padding/model.onnx | Bin 198 -> 198 bytes .../data/node/test_gru_batchwise/model.onnx | Bin 235 -> 235 bytes .../data/node/test_gru_defaults/model.onnx | Bin 189 -> 189 bytes .../data/node/test_gru_seq_length/model.onnx | Bin 215 -> 215 bytes .../test_gru_with_initial_bias/model.onnx | Bin 222 -> 222 bytes .../data/node/test_hardsigmoid/model.onnx | Bin 146 -> 146 bytes .../node/test_hardsigmoid_default/model.onnx | Bin 121 -> 121 bytes .../node/test_hardsigmoid_example/model.onnx | Bin 138 -> 138 bytes .../test/data/node/test_hardswish/model.onnx | Bin 109 -> 109 bytes .../node/test_hardswish_expanded/model.onnx | Bin 266 -> 266 bytes .../test_data_set_0/input_0.pb | Bin 1901 -> 1901 bytes .../node/test_instancenorm_epsilon/model.onnx | Bin 206 -> 206 bytes .../node/test_instancenorm_example/model.onnx | Bin 187 -> 187 bytes .../node/test_lppool_1d_default/model.onnx | Bin 162 -> 162 bytes .../node/test_lppool_2d_default/model.onnx | Bin 156 -> 156 bytes .../node/test_lppool_2d_dilations/model.onnx | Bin 196 -> 196 bytes .../data/node/test_lppool_2d_pads/model.onnx | Bin 172 -> 172 bytes .../node/test_lppool_2d_same_lower/model.onnx | Bin 186 -> 186 bytes .../node/test_lppool_2d_same_upper/model.onnx | Bin 186 -> 186 bytes .../node/test_lppool_2d_strides/model.onnx | Bin 174 -> 174 bytes .../node/test_lppool_3d_default/model.onnx | Bin 166 -> 166 bytes .../data/node/test_lstm_batchwise/model.onnx | Bin 237 -> 237 bytes .../data/node/test_lstm_defaults/model.onnx | Bin 191 -> 191 bytes .../test_lstm_with_initial_bias/model.onnx | Bin 224 -> 224 bytes .../node/test_lstm_with_peepholes/model.onnx | Bin 377 -> 377 bytes .../node/test_maxpool_1d_default/model.onnx | Bin 137 -> 137 bytes .../data/node/test_maxpool_2d_ceil/model.onnx | Bin 181 -> 181 bytes .../model.onnx | Bin 207 -> 207 bytes .../node/test_maxpool_2d_default/model.onnx | Bin 147 -> 147 bytes .../node/test_maxpool_2d_dilations/model.onnx | Bin 188 -> 188 bytes .../data/node/test_maxpool_2d_pads/model.onnx | Bin 164 -> 164 bytes .../model.onnx | Bin 176 -> 176 bytes .../model.onnx | Bin 208 -> 208 bytes .../model.onnx | Bin 178 -> 178 bytes .../test_maxpool_2d_same_lower/model.onnx | Bin 178 -> 178 bytes .../test_maxpool_2d_same_upper/model.onnx | Bin 178 -> 178 bytes .../node/test_maxpool_2d_strides/model.onnx | Bin 166 -> 166 bytes .../node/test_maxpool_2d_uint8/model.onnx | Bin 165 -> 165 bytes .../node/test_maxpool_3d_default/model.onnx | Bin 158 -> 158 bytes .../node/test_maxpool_3d_dilations/model.onnx | Bin 202 -> 202 bytes .../model.onnx | Bin 215 -> 215 bytes .../model.onnx | Bin 239 -> 239 bytes .../model.onnx | Bin 220 -> 220 bytes .../model.onnx | Bin 244 -> 244 bytes .../model.onnx | Bin 262 -> 262 bytes .../model.onnx | Bin 223 -> 223 bytes .../test/data/node/test_mish/model.onnx | Bin 85 -> 85 bytes .../data/node/test_mish_expanded/model.onnx | Bin 309 -> 309 bytes .../test/data/node/test_nllloss_NC/model.onnx | Bin 181 -> 181 bytes .../node/test_nllloss_NC_expanded/model.onnx | Bin 1487 -> 1487 bytes .../data/node/test_nllloss_NCd1/model.onnx | Bin 187 -> 187 bytes .../test_nllloss_NCd1_expanded/model.onnx | Bin 1702 -> 1702 bytes .../data/node/test_nllloss_NCd1_ii/model.onnx | Bin 211 -> 211 bytes .../test_nllloss_NCd1_ii_expanded/model.onnx | Bin 4799 -> 4799 bytes .../model.onnx | Bin 271 -> 271 bytes .../model.onnx | Bin 6057 -> 6057 bytes .../node/test_nllloss_NCd1_weight/model.onnx | Bin 224 -> 224 bytes .../model.onnx | Bin 2696 -> 2696 bytes .../test_nllloss_NCd1_weight_ii/model.onnx | Bin 248 -> 248 bytes .../model.onnx | Bin 5288 -> 5288 bytes .../data/node/test_nllloss_NCd1d2/model.onnx | Bin 209 -> 209 bytes .../test_nllloss_NCd1d2_expanded/model.onnx | Bin 1579 -> 1579 bytes .../model.onnx | Bin 246 -> 246 bytes .../model.onnx | Bin 6244 -> 6244 bytes .../model.onnx | Bin 212 -> 212 bytes .../model.onnx | Bin 2033 -> 2033 bytes .../model.onnx | Bin 210 -> 210 bytes .../model.onnx | Bin 2013 -> 2013 bytes .../model.onnx | Bin 251 -> 251 bytes .../model.onnx | Bin 2211 -> 2211 bytes .../model.onnx | Bin 254 -> 254 bytes .../model.onnx | Bin 3324 -> 3324 bytes .../model.onnx | Bin 252 -> 252 bytes .../model.onnx | Bin 2730 -> 2730 bytes .../model.onnx | Bin 276 -> 276 bytes .../model.onnx | Bin 5854 -> 5854 bytes .../model.onnx | Bin 280 -> 280 bytes .../model.onnx | Bin 5510 -> 5510 bytes .../model.onnx | Bin 252 -> 252 bytes .../model.onnx | Bin 5445 -> 5445 bytes .../model.onnx | Bin 269 -> 269 bytes .../model.onnx | Bin 3092 -> 3092 bytes .../model.onnx | Bin 266 -> 266 bytes .../model.onnx | Bin 1974 -> 1974 bytes .../test_data_set_0/output_0.pb | 2 +- .../test_data_set_0/output_0.pb | 2 +- .../test_data_set_0/output_0.pb | 2 +- .../test_data_set_0/output_0.pb | 2 +- .../test_data_set_0/output_0.pb | 2 +- .../test_data_set_0/output_0.pb | 2 +- .../data/node/test_rnn_seq_length/model.onnx | Bin 215 -> 215 bytes .../test_roialign_aligned_false/model.onnx | Bin 352 -> 352 bytes .../test_roialign_aligned_true/model.onnx | Bin 344 -> 344 bytes .../node/test_roialign_mode_max/model.onnx | Bin 363 -> 363 bytes .../test/data/node/test_round/model.onnx | Bin 85 -> 85 bytes .../test/data/node/test_selu/model.onnx | Bin 133 -> 133 bytes .../data/node/test_selu_default/model.onnx | Bin 107 -> 107 bytes .../data/node/test_selu_example/model.onnx | Bin 125 -> 125 bytes .../node/test_simple_rnn_batchwise/model.onnx | Bin 242 -> 242 bytes .../node/test_simple_rnn_defaults/model.onnx | Bin 196 -> 196 bytes .../model.onnx | Bin 229 -> 229 bytes .../test/data/node/test_sin/model.onnx | Bin 97 -> 97 bytes .../data/node/test_sin_example/model.onnx | Bin 89 -> 89 bytes .../test/data/node/test_sinh/model.onnx | Bin 99 -> 99 bytes .../data/node/test_sinh_example/model.onnx | Bin 91 -> 91 bytes .../test/data/node/test_softplus/model.onnx | Bin 107 -> 107 bytes .../node/test_softplus_example/model.onnx | Bin 99 -> 99 bytes .../test/data/node/test_softsign/model.onnx | Bin 107 -> 107 bytes .../node/test_softsign_example/model.onnx | Bin 99 -> 99 bytes .../test/data/node/test_tan/model.onnx | Bin 97 -> 97 bytes .../data/node/test_tan_example/model.onnx | Bin 89 -> 89 bytes .../data/node/test_thresholdedrelu/model.onnx | Bin 138 -> 138 bytes .../test_thresholdedrelu_default/model.onnx | Bin 129 -> 129 bytes .../test_thresholdedrelu_example/model.onnx | Bin 130 -> 130 bytes .../node/test_training_dropout/model.onnx | Bin 160 -> 160 bytes .../test_training_dropout_default/model.onnx | Bin 168 -> 168 bytes .../model.onnx | Bin 201 -> 201 bytes .../test_training_dropout_mask/model.onnx | Bin 193 -> 193 bytes .../model.onnx | Bin 171 -> 171 bytes .../model.onnx | Bin 204 -> 204 bytes onnx/defs/generator/defs.cc | 116 +- onnx/defs/generator/old.cc | 389 +++ onnx/defs/math/defs.cc | 465 ++-- onnx/defs/math/old.cc | 973 +++++++ onnx/defs/math/utils.cc | 11 + onnx/defs/math/utils.h | 2 + onnx/defs/nn/defs.cc | 107 +- onnx/defs/nn/old.cc | 1535 ++++++++++- onnx/defs/object_detection/defs.cc | 11 +- onnx/defs/object_detection/old.cc | 117 + onnx/defs/operator_sets.h | 100 +- onnx/defs/rnn/defs.cc | 23 +- onnx/defs/rnn/old.cc | 519 +++- onnx/defs/schema.h | 40 +- onnx/defs/tensor/defs.cc | 29 +- onnx/defs/tensor/old.cc | 98 + onnx/helper.py | 1 + onnx/test/cpp/schema_registration_test.cc | 6 +- onnx/test/test_backend_onnxruntime.py | 262 ++ onnx/version_converter/convert.h | 107 + 235 files changed, 7029 insertions(+), 663 deletions(-) diff --git a/docs/Changelog.md b/docs/Changelog.md index 8f253ed0edc..8107fbfd86c 100644 --- a/docs/Changelog.md +++ b/docs/Changelog.md @@ -4629,7 +4629,7 @@ This version of the operator has been available since version 2 of the default O #### Type Constraints
-
T : tensor(float16), tensor(float), tensor(double)
+
T : tensor(bfloat16), tensor(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.
@@ -10750,7 +10750,7 @@ This version of the operator has been available since version 11 of the default #### Type Constraints
-
T : tensor(float16), tensor(float), tensor(double)
+
T : tensor(float16), tensor(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.
@@ -14497,7 +14497,7 @@ This version of the operator has been available since version 12 of the default ``` output_spatial_shape[i] = ceil((input_spatial_shape[i] + pad_shape[i] - dilation[i] * (kernel_shape[i] - 1) - 1) / strides_spatial_shape[i] + 1) ``` - if ceil_mode is enabled. `pad_shape[i]` is the sum of pads along axis `i`. Sliding windows that would start in the right padded region are ignored. + if ceil_mode is enabled. `pad_shape[i]` is the sum of pads along axis `i`. `auto_pad` is a DEPRECATED attribute. If you are using them currently, the output spatial shape will be following when ceil_mode is enabled: ``` @@ -15564,7 +15564,7 @@ This version of the operator has been available since version 13 of the default #### Type Constraints
-
T : tensor(float16), tensor(float), tensor(double), tensor(bfloat16)
+
T : tensor(bfloat16), tensor(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.
@@ -18593,7 +18593,7 @@ This version of the operator has been available since version 13 of the default #### Type Constraints
-
T : tensor(float16), tensor(float), tensor(double), tensor(bfloat16)
+
T : tensor(bfloat16), tensor(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.
@@ -22627,7 +22627,7 @@ This version of the operator has been available since version 18 of the default ``` output_spatial_shape[i] = ceil((input_spatial_shape[i] + pad_shape[i] - dilation[i] * (kernel_shape[i] - 1) - 1) / strides_spatial_shape[i] + 1) ``` - if ceil_mode is enabled. `pad_shape[i]` is the sum of pads along axis `i`. Sliding windows that would start in the right padded region are ignored. + if ceil_mode is enabled. `pad_shape[i]` is the sum of pads along axis `i`. `auto_pad` is a DEPRECATED attribute. If you are using them currently, the output spatial shape will be following when ceil_mode is enabled: ``` @@ -24673,9 +24673,9 @@ This version of the operator has been available since version 21 of the default #### Type Constraints
-
T1 : tensor(float16), tensor(float), tensor(double), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(bool), tensor(string), tensor(bfloat16), tensor(float8e4m3fn), tensor(float8e4m3fnuz), tensor(float8e5m2), tensor(float8e5m2fnuz), tensor(uint4), tensor(int4)
+
T1 : tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(bfloat16), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(float8e4m3fn), tensor(float8e4m3fnuz), tensor(float8e5m2), tensor(float8e5m2fnuz), tensor(uint4), tensor(int4)
Constrain input types. Casting from complex is not supported.
-
T2 : tensor(float16), tensor(float), tensor(double), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(bool), tensor(string), tensor(bfloat16), tensor(float8e4m3fn), tensor(float8e4m3fnuz), tensor(float8e5m2), tensor(float8e5m2fnuz), tensor(uint4), tensor(int4)
+
T2 : tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(bfloat16), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(float8e4m3fn), tensor(float8e4m3fnuz), tensor(float8e5m2), tensor(float8e5m2fnuz), tensor(uint4), tensor(int4)
Constrain output types. Casting to complex is not supported.
@@ -25878,6 +25878,2357 @@ This version of the operator has been available since version 21 of the default
Constrain input and output types to all tensor types up to IRv10.
+## Version 22 of the default ONNX operator set +### **Acos-22** + + Calculates the arccosine (inverse of cosine) of the given input tensor, element-wise. + +#### Version + +This version of the operator has been available since version 22 of the default ONNX operator set. + +#### Inputs + +
+
input (differentiable) : T
+
Input tensor
+
+ +#### Outputs + +
+
output (differentiable) : T
+
The arccosine of the input tensor computed element-wise
+
+ +#### Type Constraints + +
+
T : tensor(bfloat16), tensor(float16), tensor(float), tensor(double)
+
Constrain input and output types to float tensors.
+
+ +### **Acosh-22** + + Calculates the hyperbolic arccosine of the given input tensor element-wise. + +#### Version + +This version of the operator has been available since version 22 of the default ONNX operator set. + +#### Inputs + +
+
input (differentiable) : T
+
Input tensor
+
+ +#### Outputs + +
+
output (differentiable) : T
+
The hyperbolic arccosine values of the input tensor computed element-wise
+
+ +#### Type Constraints + +
+
T : tensor(bfloat16), tensor(float16), tensor(float), tensor(double)
+
Constrain input and output types to float tensors.
+
+ +### **Asin-22** + + Calculates the arcsine (inverse of sine) of the given input tensor, element-wise. + +#### Version + +This version of the operator has been available since version 22 of the default ONNX operator set. + +#### Inputs + +
+
input (differentiable) : T
+
Input tensor
+
+ +#### Outputs + +
+
output (differentiable) : T
+
The arcsine of the input tensor computed element-wise
+
+ +#### Type Constraints + +
+
T : tensor(bfloat16), tensor(float16), tensor(float), tensor(double)
+
Constrain input and output types to float tensors.
+
+ +### **Asinh-22** + + Calculates the hyperbolic arcsine of the given input tensor element-wise. + +#### Version + +This version of the operator has been available since version 22 of the default ONNX operator set. + +#### Inputs + +
+
input (differentiable) : T
+
Input tensor
+
+ +#### Outputs + +
+
output (differentiable) : T
+
The hyperbolic arcsine values of the input tensor computed element-wise
+
+ +#### Type Constraints + +
+
T : tensor(bfloat16), tensor(float16), tensor(float), tensor(double)
+
Constrain input and output types to float tensors.
+
+ +### **Atan-22** + + Calculates the arctangent (inverse of tangent) of the given input tensor, element-wise. + +#### Version + +This version of the operator has been available since version 22 of the default ONNX operator set. + +#### Inputs + +
+
input (differentiable) : T
+
Input tensor
+
+ +#### Outputs + +
+
output (differentiable) : T
+
The arctangent of the input tensor computed element-wise
+
+ +#### Type Constraints + +
+
T : tensor(bfloat16), tensor(float16), tensor(float), tensor(double)
+
Constrain input and output types to float tensors.
+
+ +### **Atanh-22** + + Calculates the hyperbolic arctangent of the given input tensor element-wise. + +#### Version + +This version of the operator has been available since version 22 of the default ONNX operator set. + +#### Inputs + +
+
input (differentiable) : T
+
Input tensor
+
+ +#### Outputs + +
+
output (differentiable) : T
+
The hyperbolic arctangent values of the input tensor computed element-wise
+
+ +#### Type Constraints + +
+
T : tensor(bfloat16), tensor(float16), tensor(float), tensor(double)
+
Constrain input and output types to float tensors.
+
+ +### **AveragePool-22** + + AveragePool consumes an input tensor X and applies average pooling across + the tensor according to kernel sizes, stride sizes, and pad lengths. + average pooling consisting of computing the average on all values of a + subset of the input tensor according to the kernel size and downsampling the + data into the output tensor Y for further processing. The output spatial shape is calculated differently + depending on whether explicit padding is used, where pads is employed, or auto padding is used, where auto_pad is utilized. + With explicit padding (https://pytorch.org/docs/stable/generated/torch.nn.MaxPool2d.html?highlight=maxpool#torch.nn.MaxPool2d): + ``` + output_spatial_shape[i] = floor((input_spatial_shape[i] + pad_shape[i] - dilation[i] * (kernel_shape[i] - 1) - 1) / strides_spatial_shape[i] + 1) + ``` + or + ``` + output_spatial_shape[i] = ceil((input_spatial_shape[i] + pad_shape[i] - dilation[i] * (kernel_shape[i] - 1) - 1) / strides_spatial_shape[i] + 1) + ``` + if ceil_mode is enabled. `pad_shape[i]` is the sum of pads along axis `i`. Sliding windows that would start in the right padded region are ignored. + + `auto_pad` is a DEPRECATED attribute. If you are using them currently, the output spatial shape will be following when ceil_mode is enabled: + ``` + VALID: output_spatial_shape[i] = ceil((input_spatial_shape[i] - ((kernel_spatial_shape[i] - 1) * dilations[i] + 1) + 1) / strides_spatial_shape[i]) + SAME_UPPER or SAME_LOWER: output_spatial_shape[i] = ceil(input_spatial_shape[i] / strides_spatial_shape[i]) + ``` + or when ceil_mode is disabled (https://www.tensorflow.org/api_docs/python/tf/keras/layers/AveragePooling2D): + ``` + VALID: output_spatial_shape[i] = floor((input_spatial_shape[i] - ((kernel_spatial_shape[i] - 1) * dilations[i] + 1)) / strides_spatial_shape[i]) + 1 + SAME_UPPER or SAME_LOWER: output_spatial_shape[i] = floor((input_spatial_shape[i] - 1) / strides_spatial_shape[i]) + 1 + ``` + And pad shape will be following if `SAME_UPPER` or `SAME_LOWER`: + ``` + pad_shape[i] = (output_spatial_shape[i] - 1) * strides_spatial_shape[i] + ((kernel_spatial_shape[i] - 1) * dilations[i] + 1) - input_spatial_shape[i] + ``` + The output of each pooling window is divided by the number of elements (exclude pad when attribute count_include_pad is zero). + + +#### Version + +This version of the operator has been available since version 22 of the default ONNX operator set. + +#### Attributes + +
+
auto_pad : string (default is NOTSET)
+
auto_pad must be either NOTSET, SAME_UPPER, SAME_LOWER or VALID. Where default value is NOTSET, which means explicit padding is used. SAME_UPPER or SAME_LOWER mean pad the input so that `output_shape[i] = ceil(input_shape[i] / strides[i])` for each axis `i`. The padding is split between the two sides equally or almost equally (depending on whether it is even or odd). In case the padding is an odd number, the extra padding is added at the end for SAME_UPPER and at the beginning for SAME_LOWER.
+
ceil_mode : int (default is 0)
+
Whether to use ceil or floor (default) to compute the output shape.
+
count_include_pad : int (default is 0)
+
Whether include pad pixels when calculating values for the edges. Default is 0, doesn't count include pad.
+
dilations : list of ints
+
Dilation value along each spatial axis of filter. If not present, the dilation defaults to 1 along each spatial axis.
+
kernel_shape : list of ints (required)
+
The size of the kernel along each axis.
+
pads : list of ints
+
Padding for the beginning and ending along each spatial axis, it can take any value greater than or equal to 0. The value represent the number of pixels added to the beginning and end part of the corresponding axis. `pads` format should be as follow [x1_begin, x2_begin...x1_end, x2_end,...], where xi_begin the number of pixels added at the beginning of axis `i` and xi_end, the number of pixels added at the end of axis `i`. This attribute cannot be used simultaneously with auto_pad attribute. If not present, the padding defaults to 0 along start and end of each spatial axis.
+
strides : list of ints
+
Stride along each spatial axis. If not present, the stride defaults to 1 along each spatial axis.
+
+ +#### Inputs + +
+
X (differentiable) : T
+
Input data tensor from the previous operator; dimensions for image case are (N x C x H x W), where N is the batch size, C is the number of channels, and H and W are the height and the width of the data. For non image case, the dimensions are in the form of (N x C x D1 x D2 ... Dn), where N is the batch size. Optionally, if dimension denotation is in effect, the operation expects the input data tensor to arrive with the dimension denotation of [DATA_BATCH, DATA_CHANNEL, DATA_FEATURE, DATA_FEATURE ...].
+
+ +#### Outputs + +
+
Y (differentiable) : T
+
Output data tensor from average or max pooling across the input tensor. Dimensions will vary based on various kernel, stride, and pad sizes. Floor value of the dimension is used
+
+ +#### Type Constraints + +
+
T : tensor(bfloat16), tensor(float16), tensor(float), tensor(double)
+
Constrain input and output types to float tensors.
+
+ +### **Bernoulli-22** + + Draws binary random numbers (0 or 1) from a Bernoulli distribution. The input tensor should be a tensor + containing probabilities p (a value in the range [0,1]) to be used for drawing the binary random number, + where an output of 1 is produced with probability p and an output of 0 is produced with probability (1-p). + + This operator is non-deterministic and may not produce the same values in different + implementations (even if a seed is specified). + +#### Version + +This version of the operator has been available since version 22 of the default ONNX operator set. + +#### Attributes + +
+
dtype : int
+
The data type for the elements of the output tensor. if not specified, we will use the data type of the input tensor.
+
seed : float
+
(Optional) Seed to the random generator, if not specified we will auto generate one.
+
+ +#### Inputs + +
+
input : T1
+
All values in input have to be in the range:[0, 1].
+
+ +#### Outputs + +
+
output : T2
+
The returned output tensor only has values 0 or 1, same shape as input tensor.
+
+ +#### Type Constraints + +
+
T1 : tensor(bfloat16), tensor(float16), tensor(float), tensor(double)
+
Constrain input types to float tensors.
+
T2 : tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(bfloat16), tensor(float16), tensor(float), tensor(double), tensor(bool)
+
Constrain output types to all numeric tensors and bool tensors.
+
+ +### **Conv-22** + + The convolution operator consumes an input tensor and a filter, and + computes the output. + +#### Version + +This version of the operator has been available since version 22 of the default ONNX operator set. + +#### Attributes + +
+
auto_pad : string (default is NOTSET)
+
auto_pad must be either NOTSET, SAME_UPPER, SAME_LOWER or VALID. Where default value is NOTSET, which means explicit padding is used. SAME_UPPER or SAME_LOWER mean pad the input so that `output_shape[i] = ceil(input_shape[i] / strides[i])` for each axis `i`. The padding is split between the two sides equally or almost equally (depending on whether it is even or odd). In case the padding is an odd number, the extra padding is added at the end for SAME_UPPER and at the beginning for SAME_LOWER.
+
dilations : list of ints
+
dilation value along each spatial axis of the filter. If not present, the dilation defaults is 1 along each spatial axis.
+
group : int (default is 1)
+
number of groups input channels and output channels are divided into.
+
kernel_shape : list of ints
+
The shape of the convolution kernel. If not present, should be inferred from input W.
+
pads : list of ints
+
Padding for the beginning and ending along each spatial axis, it can take any value greater than or equal to 0. The value represent the number of pixels added to the beginning and end part of the corresponding axis. `pads` format should be as follow [x1_begin, x2_begin...x1_end, x2_end,...], where xi_begin the number of pixels added at the beginning of axis `i` and xi_end, the number of pixels added at the end of axis `i`. This attribute cannot be used simultaneously with auto_pad attribute. If not present, the padding defaults to 0 along start and end of each spatial axis.
+
strides : list of ints
+
Stride along each spatial axis. If not present, the stride defaults is 1 along each spatial axis.
+
+ +#### Inputs (2 - 3) + +
+
X (differentiable) : T
+
Input data tensor from previous layer; has size (N x C x H x W), where N is the batch size, C is the number of channels, and H and W are the height and width. Note that this is for the 2D image. Otherwise the size is (N x C x D1 x D2 ... x Dn). Optionally, if dimension denotation is in effect, the operation expects input data tensor to arrive with the dimension denotation of [DATA_BATCH, DATA_CHANNEL, DATA_FEATURE, DATA_FEATURE ...].
+
W (differentiable) : T
+
The weight tensor that will be used in the convolutions; has size (M x C/group x kH x kW), where C is the number of channels, and kH and kW are the height and width of the kernel, and M is the number of feature maps. For more than 2 dimensions, the kernel shape will be (M x C/group x k1 x k2 x ... x kn), where (k1 x k2 x ... kn) is the dimension of the kernel. Optionally, if dimension denotation is in effect, the operation expects the weight tensor to arrive with the dimension denotation of [FILTER_OUT_CHANNEL, FILTER_IN_CHANNEL, FILTER_SPATIAL, FILTER_SPATIAL ...]. Assuming zero based indices for the shape array, X.shape[1] == (W.shape[1] * group) == C and W.shape[0] mod G == 0. Or in other words FILTER_IN_CHANNEL multiplied by the number of groups should be equal to DATA_CHANNEL and the number of feature maps M should be a multiple of the number of groups G.
+
B (optional, differentiable) : T
+
Optional 1D bias to be added to the convolution, has size of M.
+
+ +#### Outputs + +
+
Y (differentiable) : T
+
Output data tensor that contains the result of the convolution. The output dimensions are functions of the kernel size, stride size, and pad lengths.
+
+ +#### Type Constraints + +
+
T : tensor(bfloat16), tensor(float16), tensor(float), tensor(double)
+
Constrain input and output types to float tensors.
+
+ +### **ConvTranspose-22** + + The convolution transpose operator consumes an input tensor and a filter, + and computes the output. + + If the pads parameter is provided the shape of the output is calculated via the following equation: + + output_shape[i] = stride[i] * (input_size[i] - 1) + output_padding[i] + ((kernel_shape[i] - 1) * dilations[i] + 1) - pads[start_i] - pads[end_i] + + output_shape can also be explicitly specified in which case pads values are auto generated using these equations: + + total_padding[i] = stride[i] * (input_size[i] - 1) + output_padding[i] + ((kernel_shape[i] - 1) * dilations[i] + 1) - output_shape[i] + If (auto_pads == SAME_UPPER): pads[start_i] = total_padding[i]/2; pads[end_i] = total_padding[i] - (total_padding[i]/2) + Else: pads[start_i] = total_padding[i] - (total_padding[i]/2); pads[end_i] = (total_padding[i]/2). + + + +#### Version + +This version of the operator has been available since version 22 of the default ONNX operator set. + +#### Attributes + +
+
auto_pad : string (default is NOTSET)
+
auto_pad must be either NOTSET, SAME_UPPER, SAME_LOWER or VALID. Where default value is NOTSET, which means explicit padding is used. SAME_UPPER or SAME_LOWER mean pad the input so that `output_shape[i] = input_shape[i] * strides[i]` for each axis `i`. The padding is split between the two sides equally or almost equally (depending on whether it is even or odd). In case the padding is an odd number, the extra padding is added at the end for SAME_UPPER and at the beginning for SAME_LOWER.
+
dilations : list of ints
+
dilation value along each spatial axis of the filter. If not present, the dilation defaults to 1 along each spatial axis.
+
group : int (default is 1)
+
number of groups input channels and output channels are divided into.
+
kernel_shape : list of ints
+
The shape of the convolution kernel. If not present, should be inferred from input W.
+
output_padding : list of ints
+
Additional elements added to the side with higher coordinate indices in the output. Each padding value in "output_padding" must be less than the corresponding stride/dilation dimension. By default, this attribute is a zero vector. Note that this attribute doesn't directly affect the computed output values. It only controls the selection of the computed values, so changing this attribute only adds or removes output elements. If "output_shape" is explicitly provided, "output_padding" does not contribute additional size to "output_shape" but participates in the computation of the needed padding amount. This is also called adjs or adjustment in some frameworks.
+
output_shape : list of ints
+
The shape of the output can be explicitly set which will cause pads values to be auto generated. If output_shape is specified pads values are ignored. See doc for details for equations to generate pads. Note that the output_shape attribute value should not include dimensions for batch size and channels, which are automatically inferred.
+
pads : list of ints
+
Padding for the beginning and ending along each spatial axis, it can take any value greater than or equal to 0. The value represent the number of pixels added to the beginning and end part of the corresponding axis. `pads` format should be as follow [x1_begin, x2_begin...x1_end, x2_end,...], where xi_begin the number of pixels added at the beginning of axis `i` and xi_end, the number of pixels added at the end of axis `i`. This attribute cannot be used simultaneously with auto_pad attribute. If not present, the padding defaults to 0 along start and end of each spatial axis.
+
strides : list of ints
+
Stride along each spatial axis. If not present, the stride defaults to 1 along each spatial axis.
+
+ +#### Inputs (2 - 3) + +
+
X (differentiable) : T
+
Input data tensor from previous layer; has size (N x C x H x W), where N is the batch size, C is the number of channels, and H and W are the height and width. Note that this is for the 2D image. Otherwise the size is (N x C x D1 x D2 ... x Dn)
+
W (differentiable) : T
+
The weight tensor that will be used in the convolutions; has size (C x M/group x kH x kW), where C is the number of channels, and kH and kW are the height and width of the kernel, and M is the number of feature maps. For more than 2 dimensions, the weight shape will be (C x M/group x k1 x k2 x ... x kn), where (k1 x k2 x ... x kn) is the dimension of the kernel. The number of channels in the output should be equal to W.shape[1] * group (assuming zero based indices of the shape array)
+
B (optional, differentiable) : T
+
Optional 1D bias to be added to the convolution, has size of M.
+
+ +#### Outputs + +
+
Y (differentiable) : T
+
Output data tensor that contains the result of the convolution. The output dimensions are functions of the kernel size, stride size, pad lengths and group count. The number of channels in the output should be equal to W.shape[1] * group (assuming zero based indices of the shape array)
+
+ +#### Type Constraints + +
+
T : tensor(bfloat16), tensor(float16), tensor(float), tensor(double)
+
Constrain input and output types to float tensors.
+
+ +### **Cos-22** + + Calculates the cosine of the given input tensor, element-wise. + +#### Version + +This version of the operator has been available since version 22 of the default ONNX operator set. + +#### Inputs + +
+
input (differentiable) : T
+
Input tensor
+
+ +#### Outputs + +
+
output (differentiable) : T
+
The cosine of the input tensor computed element-wise
+
+ +#### Type Constraints + +
+
T : tensor(bfloat16), tensor(float16), tensor(float), tensor(double)
+
Constrain input and output types to float tensors.
+
+ +### **Cosh-22** + + Calculates the hyperbolic cosine of the given input tensor element-wise. + +#### Version + +This version of the operator has been available since version 22 of the default ONNX operator set. + +#### Inputs + +
+
input (differentiable) : T
+
Input tensor
+
+ +#### Outputs + +
+
output (differentiable) : T
+
The hyperbolic cosine values of the input tensor computed element-wise
+
+ +#### Type Constraints + +
+
T : tensor(bfloat16), tensor(float16), tensor(float), tensor(double)
+
Constrain input and output types to float tensors.
+
+ +### **DeformConv-22** + + Performs deformable convolution as described in https://arxiv.org/abs/1703.06211 and https://arxiv.org/abs/1811.11168. + This operator specification supports the general N-D case. Note that most common use cases have 2D or 3D data. + +#### Version + +This version of the operator has been available since version 22 of the default ONNX operator set. + +#### Attributes + +
+
dilations : list of ints
+
Dilation value along each spatial axis of the kernel. Default is 1 along each axis.
+
group : int (default is 1)
+
Number of groups the input and output channels, C and oC, are divided into. C and oC must both be divisible by group. Default is 1.
+
kernel_shape : list of ints
+
Shape of the convolution kernel. If not present, it is inferred from the shape of input W.
+
offset_group : int (default is 1)
+
Number of groups of offset. C must be divisible by offset_group. Default is 1.
+
pads : list of ints
+
Padding for the beginning and end along each spatial axis. The values represent the number of pixels added to the beginning and end of the corresponding axis and can take any nonnegative value. The format should be as follows: [x1_begin, x2_begin, ..., x1_end, x2_end, ...], where xi_begin is the number of pixels added at the beginning of axis `i` and xi_end is the number of pixels added at the end of axis `i`. Default is 0 along each axis.
+
strides : list of ints
+
Stride along each spatial axis. Default is 1 along each axis.
+
+ +#### Inputs (3 - 5) + +
+
X : T
+
Input data tensor. For 2D image data, it has shape (N, C, H, W) where N is the batch size, C is the number of input channels, and H and W are the height and width. In general, the shape is (N, C, D1, D2, ... , Dn) for n-dimensional data, where D1 to Dn are the spatial dimension sizes. Most common use cases have n = 2 or 3.
+
W : T
+
Weight tensor that will be used in the convolutions. It has shape (oC, C/group, kH, kW), where oC is the number of output channels and kH and kW are the kernel height and width. For more than 2 dimensions, it has shape (oC, C/group, k1, k2, ... , kn).
+
offset : T
+
Offset tensor denoting the offset for the sampling locations in the convolution kernel. It has shape (N, offset_group * kH * kW * 2, oH, oW) for 2D data or (N, offset_group * k1 * k2 * ... * kn * n, o1, o2, ... , on) for nD data. Use linear interpolationfor fractional offset values. Sampling locations outside of the padded input tensor gives zero.
+
B (optional) : T
+
Optional 1D bias of length oC to be added to the convolution. Default is a tensor of zeros.
+
mask (optional) : T
+
The mask tensor to be applied to each position in the convolution kernel. It has shape (N, offset_group * kH * kW, oH, oW) for 2D data or (N, offset_group * k1 * k2 * ... * kn * n, o1, o2, ... , on) for nD data. Default is a tensor of ones.
+
+ +#### Outputs + +
+
Y : T
+
Output data tensor that contains the result of convolution. It has shape (N, oC, oH, oW) for 2D data or (N, oC, o1, o2, ..., on) for nD data
+
+ +#### Type Constraints + +
+
T : tensor(bfloat16), tensor(float16), tensor(float), tensor(double)
+
Constrain input and output types to float tensors.
+
+ +### **Det-22** + + Det calculates determinant of a square matrix or batches of square matrices. + Det takes one input tensor of shape `[*, M, M]`, where `*` is zero or more batch dimensions, + and the inner-most 2 dimensions form square matrices. + The output is a tensor of shape `[*]`, containing the determinants of all input submatrices. + e.g., When the input is 2-D, the output is a scalar(shape is empty: `[]`). + +#### Version + +This version of the operator has been available since version 22 of the default ONNX operator set. + +#### Inputs + +
+
X (differentiable) : T
+
Input tensor
+
+ +#### Outputs + +
+
Y (differentiable) : T
+
Output tensor
+
+ +#### Type Constraints + +
+
T : tensor(bfloat16), tensor(float16), tensor(float), tensor(double)
+
Constrain input and output types to floating-point tensors.
+
+ +### **Dropout-22** + + Dropout takes an input floating-point tensor, an optional input ratio (floating-point scalar) and an optional input training_mode (boolean scalar). It produces two tensor outputs, + output (floating-point tensor) and mask (optional `Tensor`). If `training_mode` is true then the output Y will be a random dropout; + Note that this Dropout scales the masked input data by the following equation, so to convert the trained model into inference mode, + the user can simply not pass `training_mode` input or set it to false. + ``` + output = scale * data * mask, + ``` + where + ``` + scale = 1. / (1. - ratio). + ``` + This operator has **optional** inputs/outputs. See [the doc](IR.md) for more details about the representation of optional arguments. An empty string may be used in the place of an actual argument's name to indicate a missing argument. Trailing optional arguments (those not followed by an argument that is present) may also be simply omitted. + +#### Version + +This version of the operator has been available since version 22 of the default ONNX operator set. + +#### Attributes + +
+
seed : int
+
(Optional) Seed to the random generator, if not specified we will auto generate one.
+
+ +#### Inputs (1 - 3) + +
+
data (differentiable) : T
+
The input data as Tensor.
+
ratio (optional, non-differentiable) : T1
+
The ratio of random dropout, with value in [0, 1). If this input was not set, or if it was set to 0, the output would be a simple copy of the input. If it's non-zero, output will be a random dropout of the scaled input, which is typically the case during training. It is an optional value, if not specified it will default to 0.5.
+
training_mode (optional, non-differentiable) : T2
+
If set to true then it indicates dropout is being used for training. It is an optional value hence unless specified explicitly, it is false. If it is false, ratio is ignored and the operation mimics inference mode where nothing will be dropped from the input data and if mask is requested as output it will contain all ones.
+
+ +#### Outputs (1 - 2) + +
+
output (differentiable) : T
+
The output.
+
mask (optional, non-differentiable) : T2
+
The output mask.
+
+ +#### Type Constraints + +
+
T : tensor(bfloat16), tensor(float16), tensor(float), tensor(double), tensor(float8e4m3fn), tensor(float8e4m3fnuz), tensor(float8e5m2), tensor(float8e5m2fnuz)
+
Constrain input and output types to float tensors.
+
T1 : tensor(bfloat16), tensor(float16), tensor(float), tensor(double), tensor(float8e4m3fn), tensor(float8e4m3fnuz), tensor(float8e5m2), tensor(float8e5m2fnuz)
+
Constrain input 'ratio' types to float tensors.
+
T2 : tensor(bool)
+
Constrain output 'mask' types to boolean tensors.
+
+ +### **Elu-22** + + Elu takes one input data (Tensor) and produces one output data + (Tensor) where the function `f(x) = alpha * (exp(x) - 1.) for x < + 0`, `f(x) = x for x >= 0`., is applied to the tensor elementwise. + + +#### Version + +This version of the operator has been available since version 22 of the default ONNX operator set. + +#### Attributes + +
+
alpha : float (default is 1.0)
+
Coefficient of ELU.
+
+ +#### Inputs + +
+
X (differentiable) : T
+
1D input tensor
+
+ +#### Outputs + +
+
Y (differentiable) : T
+
1D output tensor
+
+ +#### Type Constraints + +
+
T : tensor(bfloat16), tensor(float16), tensor(float), tensor(double)
+
Constrain input and output types to float tensors.
+
+ +### **EyeLike-22** + + Generate a 2D tensor (matrix) with ones on the diagonal and zeros everywhere else. Only 2D + tensors are supported, i.e. input T1 must be of rank 2. The shape of the output tensor is the + same as the input tensor. The data type can be specified by the 'dtype' argument. If + 'dtype' is not specified, then the type of input tensor is used. By default, the main diagonal + is populated with ones, but attribute 'k' can be used to populate upper or lower diagonals. + The 'dtype' argument must be one of the data types specified in the 'DataType' enum field in the + TensorProto message and be valid as an output type. + +#### Version + +This version of the operator has been available since version 22 of the default ONNX operator set. + +#### Attributes + +
+
dtype : int
+
(Optional) The data type for the elements of the output tensor. If not specified,the data type of the input tensor T1 is used. If input tensor T1 is also notspecified, then type defaults to 'float'.
+
k : int (default is 0)
+
(Optional) Index of the diagonal to be populated with ones. Default is 0. If T2 is the output, this op sets T2[i, i+k] = 1. k = 0 populates the main diagonal, k > 0 populates an upper diagonal, and k < 0 populates a lower diagonal.
+
+ +#### Inputs + +
+
input : T1
+
2D input tensor to copy shape, and optionally, type information from.
+
+ +#### Outputs + +
+
output : T2
+
Output tensor, same shape as input tensor T1.
+
+ +#### Type Constraints + +
+
T1 : tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(bfloat16), tensor(float16), tensor(float), tensor(double), tensor(bool)
+
Constrain input types. Strings and complex are not supported.
+
T2 : tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(bfloat16), tensor(float16), tensor(float), tensor(double), tensor(bool)
+
Constrain output types. Strings and complex are not supported.
+
+ +### **GRU-22** + + Computes an one-layer GRU. This operator is usually supported via some custom + implementation such as CuDNN. + + Notations: + + * `X` - input tensor + * `z` - update gate + * `r` - reset gate + * `h` - hidden gate + * `t` - time step (t-1 means previous time step) + * `W[zrh]` - W parameter weight matrix for update, reset, and hidden gates + * `R[zrh]` - R recurrence weight matrix for update, reset, and hidden gates + * `Wb[zrh]` - W bias vectors for update, reset, and hidden gates + * `Rb[zrh]` - R bias vectors for update, reset, and hidden gates + * `WB[zrh]` - W parameter weight matrix for backward update, reset, and hidden gates + * `RB[zrh]` - R recurrence weight matrix for backward update, reset, and hidden gates + * `WBb[zrh]` - W bias vectors for backward update, reset, and hidden gates + * `RBb[zrh]` - R bias vectors for backward update, reset, and hidden gates + * `H` - Hidden state + * `num_directions` - 2 if direction == bidirectional else 1 + + Activation functions: + + * Relu(x) - max(0, x) + * Tanh(x) - (1 - e^{-2x})/(1 + e^{-2x}) + * Sigmoid(x) - 1/(1 + e^{-x}) + + NOTE: + Below are optional + + * Affine(x) - alpha * x + beta + * LeakyRelu(x) - x if x >= 0 else alpha * x + * ThresholdedRelu(x) - x if x >= alpha else 0 + * ScaledTanh(x) - alpha * Tanh(beta * x) + * HardSigmoid(x) - min(max(alpha * x + beta, 0), 1) + * Elu(x) - x if x >= 0 else alpha * (e^x - 1) + * Softsign(x) - x/(1 + |x|) + * Softplus(x) - log(1 + e^x) + + Equations (Default: f=Sigmoid, g=Tanh): + + * zt = f(Xt*(Wz^T) + Ht-1*(Rz^T) + Wbz + Rbz) + * rt = f(Xt*(Wr^T) + Ht-1*(Rr^T) + Wbr + Rbr) + * ht = g(Xt*(Wh^T) + (rt (.) Ht-1)*(Rh^T) + Rbh + Wbh) # default, when linear_before_reset = 0 + * ht = g(Xt*(Wh^T) + (rt (.) (Ht-1*(Rh^T) + Rbh)) + Wbh) # when linear_before_reset != 0 + * Ht = (1 - zt) (.) ht + zt (.) Ht-1 + This operator has **optional** inputs/outputs. See [the doc](IR.md) for more details about the representation of optional arguments. An empty string may be used in the place of an actual argument's name to indicate a missing argument. Trailing optional arguments (those not followed by an argument that is present) may also be simply omitted. + +#### Version + +This version of the operator has been available since version 22 of the default ONNX operator set. + +#### Attributes + +
+
activation_alpha : list of floats
+
Optional scaling values used by some activation functions. The values are consumed in the order of activation functions, for example (f, g, h) in LSTM. Default values are the same as of corresponding ONNX operators.For example with LeakyRelu, the default alpha is 0.01.
+
activation_beta : list of floats
+
Optional scaling values used by some activation functions. The values are consumed in the order of activation functions, for example (f, g, h) in LSTM. Default values are the same as of corresponding ONNX operators.
+
activations : list of strings
+
A list of 2 (or 4 if bidirectional) activation functions for update, reset, and hidden gates. The activation functions must be one of the activation functions specified above. Optional: See the equations for default if not specified.
+
clip : float
+
Cell clip threshold. Clipping bounds the elements of a tensor in the range of [-threshold, +threshold] and is applied to the input of activations. No clip if not specified.
+
direction : string (default is forward)
+
Specify if the RNN is forward, reverse, or bidirectional. Must be one of forward (default), reverse, or bidirectional.
+
hidden_size : int
+
Number of neurons in the hidden layer
+
layout : int (default is 0)
+
The shape format of inputs X, initial_h and outputs Y, Y_h. If 0, the following shapes are expected: X.shape = [seq_length, batch_size, input_size], Y.shape = [seq_length, num_directions, batch_size, hidden_size], initial_h.shape = Y_h.shape = [num_directions, batch_size, hidden_size]. If 1, the following shapes are expected: X.shape = [batch_size, seq_length, input_size], Y.shape = [batch_size, seq_length, num_directions, hidden_size], initial_h.shape = Y_h.shape = [batch_size, num_directions, hidden_size].
+
linear_before_reset : int (default is 0)
+
When computing the output of the hidden gate, apply the linear transformation before multiplying by the output of the reset gate.
+
+ +#### Inputs (3 - 6) + +
+
X (differentiable) : T
+
The input sequences packed (and potentially padded) into one 3-D tensor with the shape of `[seq_length, batch_size, input_size]`.
+
W (differentiable) : T
+
The weight tensor for the gates. Concatenation of `W[zrh]` and `WB[zrh]` (if bidirectional) along dimension 0. This tensor has shape `[num_directions, 3*hidden_size, input_size]`.
+
R (differentiable) : T
+
The recurrence weight tensor. Concatenation of `R[zrh]` and `RB[zrh]` (if bidirectional) along dimension 0. This tensor has shape `[num_directions, 3*hidden_size, hidden_size]`.
+
B (optional, differentiable) : T
+
The bias tensor for the gates. Concatenation of `[Wb[zrh], Rb[zrh]]` and `[WBb[zrh], RBb[zrh]]` (if bidirectional) along dimension 0. This tensor has shape `[num_directions, 6*hidden_size]`. Optional: If not specified - assumed to be 0
+
sequence_lens (optional, non-differentiable) : T1
+
Optional tensor specifying lengths of the sequences in a batch. If not specified - assumed all sequences in the batch to have length `seq_length`. It has shape `[batch_size]`.
+
initial_h (optional, non-differentiable) : T
+
Optional initial value of the hidden. If not specified - assumed to be 0. It has shape `[num_directions, batch_size, hidden_size]`.
+
+ +#### Outputs (0 - 2) + +
+
Y (optional, differentiable) : T
+
A tensor that concats all the intermediate output values of the hidden. It has shape `[seq_length, num_directions, batch_size, hidden_size]`.
+
Y_h (optional, differentiable) : T
+
The last output value of the hidden. It has shape `[num_directions, batch_size, hidden_size]`.
+
+ +#### Type Constraints + +
+
T : tensor(bfloat16), tensor(float16), tensor(float), tensor(double)
+
Constrain input and output types to float tensors.
+
T1 : tensor(int32)
+
Constrain seq_lens to integer tensor.
+
+ +### **GlobalAveragePool-22** + + GlobalAveragePool consumes an input tensor X and applies average pooling across + the values in the same channel. This is equivalent to AveragePool with kernel size + equal to the spatial dimension of input tensor. + +#### Version + +This version of the operator has been available since version 22 of the default ONNX operator set. + +#### Inputs + +
+
X (differentiable) : T
+
Input data tensor from the previous operator; dimensions for image case are (N x C x H x W), where N is the batch size, C is the number of channels, and H and W are the height and the width of the data. For non image case, the dimensions are in the form of (N x C x D1 x D2 ... Dn), where N is the batch size.
+
+ +#### Outputs + +
+
Y (differentiable) : T
+
Output data tensor from pooling across the input tensor. The output tensor has the same rank as the input. The first two dimensions of output shape are the same as the input (N x C), while the other dimensions are all 1.
+
+ +#### Type Constraints + +
+
T : tensor(bfloat16), tensor(float16), tensor(float), tensor(double)
+
Constrain input and output types to float tensors.
+
+ +### **GlobalLpPool-22** + + GlobalLpPool consumes an input tensor X and applies lp pool pooling across + the values in the same channel. This is equivalent to LpPool with kernel size + equal to the spatial dimension of input tensor. + +#### Version + +This version of the operator has been available since version 22 of the default ONNX operator set. + +#### Attributes + +
+
p : int (default is 2)
+
p value of the Lp norm used to pool over the input data.
+
+ +#### Inputs + +
+
X (differentiable) : T
+
Input data tensor from the previous operator; dimensions for image case are (N x C x H x W), where N is the batch size, C is the number of channels, and H and W are the height and the width of the data. For non image case, the dimensions are in the form of (N x C x D1 x D2 ... Dn), where N is the batch size.
+
+ +#### Outputs + +
+
Y (differentiable) : T
+
Output data tensor from pooling across the input tensor. The output tensor has the same rank as the input. The first two dimensions of output shape are the same as the input (N x C), while the other dimensions are all 1.
+
+ +#### Type Constraints + +
+
T : tensor(float16), tensor(float), tensor(double)
+
Constrain input and output types to float tensors.
+
+ +### **GlobalMaxPool-22** + + GlobalMaxPool consumes an input tensor X and applies max pooling across + the values in the same channel. This is equivalent to MaxPool with kernel size + equal to the spatial dimension of input tensor. + +#### Version + +This version of the operator has been available since version 22 of the default ONNX operator set. + +#### Inputs + +
+
X (differentiable) : T
+
Input data tensor from the previous operator; dimensions for image case are (N x C x H x W), where N is the batch size, C is the number of channels, and H and W are the height and the width of the data. For non image case, the dimensions are in the form of (N x C x D1 x D2 ... Dn), where N is the batch size.
+
+ +#### Outputs + +
+
Y (differentiable) : T
+
Output data tensor from pooling across the input tensor. The output tensor has the same rank as the input. The first two dimensions of output shape are the same as the input (N x C), while the other dimensions are all 1.
+
+ +#### Type Constraints + +
+
T : tensor(bfloat16), tensor(float16), tensor(float), tensor(double)
+
Constrain input and output types to float tensors.
+
+ +### **GridSample-22** + + Given an input `X` and a flow-field `grid`, computes the output `Y` using `X` values and pixel locations from the `grid`. + For spatial input `X` with shape (N, C, H, W), the `grid` will have shape (N, H_out, W_out, 2), + the output `Y` will have shape (N, C, H_out, W_out). For volumetric input `X` with shape (N, C, D, H, W), + the `grid` will have shape (N, D_out, H_out, W_out, 3), the output `Y` will have shape (N, C, D_out, H_out, W_out). + More generally, for an input `X` of rank r+2 with shape (N, C, d1, d2, ..., dr), + the `grid` will have shape (N, D1_out, D2_out, ..., Dr_out, r), the output `Y` will have shape (N, C, D1_out, D2_out, ..., Dr_out). + + The tensor `X` contains values at centers of square pixels (voxels, etc) locations such as (n, c, d1_in, d2_in, ..., dr_in). + The (n, d1_out, d2_out, ..., dr_out, :) values from the tensor `grid` are the normalized positions for interpolating the values + at the (n, c, d1_out, d2_out, ..., dr_out) locations from the output tensor `Y` using a specified interpolation method (the mode) + and a padding mode (for `grid` positions falling outside the 2-dimensional image). + + For example, the values in `grid[n, h_out, w_out, :]` are size-2 vectors specifying normalized positions in the 2-dimensional space of `X`. + They are used to interpolate output values of `Y[n, c, h_out, w_out]`. + + The GridSample operator is often used in doing grid generator and sampler in the + [Spatial Transformer Networks](https://arxiv.org/abs/1506.02025). + See also in [torch.nn.functional.grid_sample](https://pytorch.org/docs/stable/generated/torch.nn.functional.grid_sample.html). + +#### Version + +This version of the operator has been available since version 22 of the default ONNX operator set. + +#### Attributes + +
+
align_corners : int (default is 0)
+
If align_corners=1, the extrema (-1 and 1) are considered as referring to the center points of the input's corner pixels (voxels, etc.). If align_corners=0, they are instead considered as referring to the corner points of the input's corner pixels (voxels, etc.), making the sampling more resolution agnostic.
+
mode : string (default is linear)
+
Three interpolation modes: linear (default), nearest and cubic. The "linear" mode includes linear and N-linear interpolation modes depending on the number of spatial dimensions of the input tensor (i.e. linear for 1 spatial dimension, bilinear for 2 spatial dimensions, etc.). The "cubic" mode also includes N-cubic interpolation modes following the same rules. The "nearest" mode rounds to the nearest even index when the sampling point falls halfway between two indices.
+
padding_mode : string (default is zeros)
+
Support padding modes for outside grid values: `zeros`(default), `border`, `reflection`. zeros: use 0 for out-of-bound grid locations, border: use border values for out-of-bound grid locations, reflection: use values at locations reflected by the border for out-of-bound grid locations. If index 0 represents the margin pixel, the reflected value at index -1 will be the same as the value at index 1. For location far away from the border, it will keep being reflected until becoming in bound. If pixel location x = -3.5 reflects by border -1 and becomes x' = 1.5, then reflects by border 1 and becomes x'' = 0.5.
+
+ +#### Inputs + +
+
X (differentiable) : T1
+
Input tensor of rank r+2 that has shape (N, C, D1, D2, ..., Dr), where N is the batch size, C is the number of channels, D1, D2, ..., Dr are the spatial dimensions.
+
grid (non-differentiable) : T2
+
Input offset of shape (N, D1_out, D2_out, ..., Dr_out, r), where D1_out, D2_out, ..., Dr_out are the spatial dimensions of the grid and output, and r is the number of spatial dimensions. Grid specifies the sampling locations normalized by the input spatial dimensions. Therefore, it should have most values in the range of [-1, 1]. If the grid has values outside the range of [-1, 1], the corresponding outputs will be handled as defined by padding_mode. Following computer vision convention, the coordinates in the length-r location vector are listed from the innermost tensor dimension to the outermost, the opposite of regular tensor indexing.
+
+ +#### Outputs + +
+
Y (differentiable) : T1
+
Output tensor of rank r+2 that has shape (N, C, D1_out, D2_out, ..., Dr_out) of the sampled values. For integer input types, intermediate values are computed as floating point and cast to integer at the end.
+
+ +#### Type Constraints + +
+
T1 : tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(bfloat16), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128)
+
Constrain input `X` and output `Y` types to all tensor types.
+
T2 : tensor(bfloat16), tensor(float16), tensor(float), tensor(double)
+
Constrain grid types to float tensors.
+
+ +### **HardSigmoid-22** + + HardSigmoid takes one input data (Tensor) and produces one output data + (Tensor) where the HardSigmoid function, y = max(0, min(1, alpha * x + beta)), + is applied to the tensor elementwise. + +#### Version + +This version of the operator has been available since version 22 of the default ONNX operator set. + +#### Attributes + +
+
alpha : float (default is 0.2)
+
Value of alpha.
+
beta : float (default is 0.5)
+
Value of beta.
+
+ +#### Inputs + +
+
X (differentiable) : T
+
Input tensor
+
+ +#### Outputs + +
+
Y (differentiable) : T
+
Output tensor
+
+ +#### Type Constraints + +
+
T : tensor(bfloat16), tensor(float16), tensor(float), tensor(double)
+
Constrain input and output types to float tensors.
+
+ +### **HardSwish-22** + + HardSwish takes one input data (Tensor) and produces one output data (Tensor) where + the HardSwish function, y = x * max(0, min(1, alpha * x + beta)) = x * HardSigmoid(x), + where alpha = 1/6 and beta = 0.5, is applied to the tensor elementwise. + +#### Version + +This version of the operator has been available since version 22 of the default ONNX operator set. + +#### Inputs + +
+
X (differentiable) : T
+
Input tensor
+
+ +#### Outputs + +
+
Y (differentiable) : T
+
Output tensor
+
+ +#### Type Constraints + +
+
T : tensor(bfloat16), tensor(float16), tensor(float), tensor(double)
+
Constrain input and output types to float tensors.
+
+ +### **InstanceNormalization-22** + + Carries out instance normalization as described in the paper + https://arxiv.org/abs/1607.08022. + + y = scale * (x - mean) / sqrt(variance + epsilon) + B, + where mean and variance are computed per instance per channel. + + +#### Version + +This version of the operator has been available since version 22 of the default ONNX operator set. + +#### Attributes + +
+
epsilon : float (default is 1e-05)
+
The epsilon value to use to avoid division by zero.
+
+ +#### Inputs + +
+
input (differentiable) : T
+
Input data tensor from the previous operator; dimensions for image case are (N x C x H x W), where N is the batch size, C is the number of channels, and H and W are the height and the width of the data. For non image case, the dimensions are in the form of (N x C x D1 x D2 ... Dn), where N is the batch size.
+
scale (differentiable) : T
+
The input 1-dimensional scale tensor of size C.
+
B (differentiable) : T
+
The input 1-dimensional bias tensor of size C.
+
+ +#### Outputs + +
+
output (differentiable) : T
+
The output tensor of the same shape as input.
+
+ +#### Type Constraints + +
+
T : tensor(bfloat16), tensor(float16), tensor(float), tensor(double)
+
Constrain input and output types to float tensors.
+
+ +### **LSTM-22** + + Computes an one-layer LSTM. This operator is usually supported via some + custom implementation such as CuDNN. + + Notations: + + * `X` - input tensor + * `i` - input gate + * `o` - output gate + * `f` - forget gate + * `c` - cell gate + * `t` - time step (t-1 means previous time step) + * `W[iofc]` - W parameter weight matrix for input, output, forget, and cell gates + * `R[iofc]` - R recurrence weight matrix for input, output, forget, and cell gates + * `Wb[iofc]` - W bias vectors for input, output, forget, and cell gates + * `Rb[iofc]` - R bias vectors for input, output, forget, and cell gates + * `P[iof]` - P peephole weight vector for input, output, and forget gates + * `WB[iofc]` - W parameter weight matrix for backward input, output, forget, and cell gates + * `RB[iofc]` - R recurrence weight matrix for backward input, output, forget, and cell gates + * `WBb[iofc]` - W bias vectors for backward input, output, forget, and cell gates + * `RBb[iofc]` - R bias vectors for backward input, output, forget, and cell gates + * `PB[iof]` - P peephole weight vector for backward input, output, and forget gates + * `H` - Hidden state + * `num_directions` - 2 if direction == bidirectional else 1 + + Activation functions: + + * Relu(x) - max(0, x) + * Tanh(x) - (1 - e^{-2x})/(1 + e^{-2x}) + * Sigmoid(x) - 1/(1 + e^{-x}) + + NOTE: Below are optional + + * Affine(x) - alpha*x + beta + * LeakyRelu(x) - x if x >= 0 else alpha * x + * ThresholdedRelu(x) - x if x >= alpha else 0 + * ScaledTanh(x) - alpha*Tanh(beta*x) + * HardSigmoid(x) - min(max(alpha*x + beta, 0), 1) + * Elu(x) - x if x >= 0 else alpha*(e^x - 1) + * Softsign(x) - x/(1 + |x|) + * Softplus(x) - log(1 + e^x) + + Equations (Default: f=Sigmoid, g=Tanh, h=Tanh): + + * it = f(Xt*(Wi^T) + Ht-1*(Ri^T) + Pi (.) Ct-1 + Wbi + Rbi) + * ft = f(Xt*(Wf^T) + Ht-1*(Rf^T) + Pf (.) Ct-1 + Wbf + Rbf) + * ct = g(Xt*(Wc^T) + Ht-1*(Rc^T) + Wbc + Rbc) + * Ct = ft (.) Ct-1 + it (.) ct + * ot = f(Xt*(Wo^T) + Ht-1*(Ro^T) + Po (.) Ct + Wbo + Rbo) + * Ht = ot (.) h(Ct) + This operator has **optional** inputs/outputs. See [the doc](IR.md) for more details about the representation of optional arguments. An empty string may be used in the place of an actual argument's name to indicate a missing argument. Trailing optional arguments (those not followed by an argument that is present) may also be simply omitted. + +#### Version + +This version of the operator has been available since version 22 of the default ONNX operator set. + +#### Attributes + +
+
activation_alpha : list of floats
+
Optional scaling values used by some activation functions. The values are consumed in the order of activation functions, for example (f, g, h) in LSTM. Default values are the same as of corresponding ONNX operators.For example with LeakyRelu, the default alpha is 0.01.
+
activation_beta : list of floats
+
Optional scaling values used by some activation functions. The values are consumed in the order of activation functions, for example (f, g, h) in LSTM. Default values are the same as of corresponding ONNX operators.
+
activations : list of strings
+
A list of 3 (or 6 if bidirectional) activation functions for input, output, forget, cell, and hidden. The activation functions must be one of the activation functions specified above. Optional: See the equations for default if not specified.
+
clip : float
+
Cell clip threshold. Clipping bounds the elements of a tensor in the range of [-threshold, +threshold] and is applied to the input of activations. No clip if not specified.
+
direction : string (default is forward)
+
Specify if the RNN is forward, reverse, or bidirectional. Must be one of forward (default), reverse, or bidirectional.
+
hidden_size : int
+
Number of neurons in the hidden layer
+
input_forget : int (default is 0)
+
Couple the input and forget gates if 1.
+
layout : int (default is 0)
+
The shape format of inputs X, initial_h, initial_c and outputs Y, Y_h, Y_c. If 0, the following shapes are expected: X.shape = [seq_length, batch_size, input_size], Y.shape = [seq_length, num_directions, batch_size, hidden_size], initial_h.shape = Y_h.shape = initial_c.shape = Y_c.shape = [num_directions, batch_size, hidden_size]. If 1, the following shapes are expected: X.shape = [batch_size, seq_length, input_size], Y.shape = [batch_size, seq_length, num_directions, hidden_size], initial_h.shape = Y_h.shape = initial_c.shape = Y_c.shape = [batch_size, num_directions, hidden_size].
+
+ +#### Inputs (3 - 8) + +
+
X (differentiable) : T
+
The input sequences packed (and potentially padded) into one 3-D tensor with the shape of `[seq_length, batch_size, input_size]`.
+
W (differentiable) : T
+
The weight tensor for the gates. Concatenation of `W[iofc]` and `WB[iofc]` (if bidirectional) along dimension 0. The tensor has shape `[num_directions, 4*hidden_size, input_size]`.
+
R (differentiable) : T
+
The recurrence weight tensor. Concatenation of `R[iofc]` and `RB[iofc]` (if bidirectional) along dimension 0. This tensor has shape `[num_directions, 4*hidden_size, hidden_size]`.
+
B (optional, differentiable) : T
+
The bias tensor for input gate. Concatenation of `[Wb[iofc], Rb[iofc]]`, and `[WBb[iofc], RBb[iofc]]` (if bidirectional) along dimension 0. This tensor has shape `[num_directions, 8*hidden_size]`. Optional: If not specified - assumed to be 0.
+
sequence_lens (optional, non-differentiable) : T1
+
Optional tensor specifying lengths of the sequences in a batch. If not specified - assumed all sequences in the batch to have length `seq_length`. It has shape `[batch_size]`.
+
initial_h (optional, non-differentiable) : T
+
Optional initial value of the hidden. If not specified - assumed to be 0. It has shape `[num_directions, batch_size, hidden_size]`.
+
initial_c (optional, non-differentiable) : T
+
Optional initial value of the cell. If not specified - assumed to be 0. It has shape `[num_directions, batch_size, hidden_size]`.
+
P (optional, differentiable) : T
+
The weight tensor for peepholes. Concatenation of `P[iof]` and `PB[iof]` (if bidirectional) along dimension 0. It has shape `[num_directions, 3*hidde_size]`. Optional: If not specified - assumed to be 0.
+
+ +#### Outputs (0 - 3) + +
+
Y (optional, differentiable) : T
+
A tensor that concats all the intermediate output values of the hidden. It has shape `[seq_length, num_directions, batch_size, hidden_size]`.
+
Y_h (optional, differentiable) : T
+
The last output value of the hidden. It has shape `[num_directions, batch_size, hidden_size]`.
+
Y_c (optional, differentiable) : T
+
The last output value of the cell. It has shape `[num_directions, batch_size, hidden_size]`.
+
+ +#### Type Constraints + +
+
T : tensor(bfloat16), tensor(float16), tensor(float), tensor(double)
+
Constrain input and output types to float tensors.
+
T1 : tensor(int32)
+
Constrain seq_lens to integer tensor.
+
+ +### **LpNormalization-22** + + Given a matrix, apply Lp-normalization along the provided axis. + +#### Version + +This version of the operator has been available since version 22 of the default ONNX operator set. + +#### Attributes + +
+
axis : int (default is -1)
+
The axis on which to apply normalization, -1 mean last axis.
+
p : int (default is 2)
+
The order of the normalization, only 1 or 2 are supported.
+
+ +#### Inputs + +
+
input (differentiable) : T
+
Input matrix
+
+ +#### Outputs + +
+
output (differentiable) : T
+
Matrix after normalization
+
+ +#### Type Constraints + +
+
T : tensor(bfloat16), tensor(float16), tensor(float), tensor(double)
+
Constrain input and output types to float tensors.
+
+ +### **LpPool-22** + + LpPool consumes an input tensor X and applies Lp pooling across + the tensor according to kernel sizes, stride sizes, and pad lengths. + Lp pooling consisting of computing the Lp norm on all values of a subset + of the input tensor according to the kernel size and downsampling the + data into the output tensor Y for further processing. The output spatial shape will be following: + ``` + output_spatial_shape[i] = floor((input_spatial_shape[i] + pad_shape[i] - {kernelSpatialShape}) / strides_spatial_shape[i] + 1) + ``` + or + ``` + output_spatial_shape[i] = ceil((input_spatial_shape[i] + pad_shape[i] - {kernelSpatialShape}) / strides_spatial_shape[i] + 1) + ``` + if ceil_mode is enabled `pad_shape[i]` is the sum of pads along axis `i`. + + `auto_pad` is a DEPRECATED attribute. If you are using them currently, the output spatial shape will be following: + ``` + VALID: output_spatial_shape[i] = ceil((input_spatial_shape[i] - {kernelSpatialShape} + 1) / strides_spatial_shape[i]) + SAME_UPPER or SAME_LOWER: output_spatial_shape[i] = ceil(input_spatial_shape[i] / strides_spatial_shape[i]) + ``` + And pad shape will be following if `SAME_UPPER` or `SAME_LOWER`: + ``` + pad_shape[i] = (output_spatial_shape[i] - 1) * strides_spatial_shape[i] + {kernelSpatialShape} - input_spatial_shape[i] + ``` + +#### Version + +This version of the operator has been available since version 22 of the default ONNX operator set. + +#### Attributes + +
+
auto_pad : string (default is NOTSET)
+
auto_pad must be either NOTSET, SAME_UPPER, SAME_LOWER or VALID. Where default value is NOTSET, which means explicit padding is used. SAME_UPPER or SAME_LOWER mean pad the input so that `output_shape[i] = ceil(input_shape[i] / strides[i])` for each axis `i`. The padding is split between the two sides equally or almost equally (depending on whether it is even or odd). In case the padding is an odd number, the extra padding is added at the end for SAME_UPPER and at the beginning for SAME_LOWER.
+
ceil_mode : int (default is 0)
+
Whether to use ceil or floor (default) to compute the output shape.
+
dilations : list of ints
+
dilation value along each spatial axis of the filter. If not present, the dilation defaults is 1 along each spatial axis.
+
kernel_shape : list of ints (required)
+
The size of the kernel along each axis.
+
p : int (default is 2)
+
p value of the Lp norm used to pool over the input data.
+
pads : list of ints
+
Padding for the beginning and ending along each spatial axis, it can take any value greater than or equal to 0. The value represent the number of pixels added to the beginning and end part of the corresponding axis. `pads` format should be as follow [x1_begin, x2_begin...x1_end, x2_end,...], where xi_begin the number of pixels added at the beginning of axis `i` and xi_end, the number of pixels added at the end of axis `i`. This attribute cannot be used simultaneously with auto_pad attribute. If not present, the padding defaults to 0 along start and end of each spatial axis.
+
strides : list of ints
+
Stride along each spatial axis. If not present, the stride defaults to 1 along each spatial axis.
+
+ +#### Inputs + +
+
X (differentiable) : T
+
Input data tensor from the previous operator; dimensions for image case are (N x C x H x W), where N is the batch size, C is the number of channels, and H and W are the height and the width of the data. For non image case, the dimensions are in the form of (N x C x D1 x D2 ... Dn), where N is the batch size.
+
+ +#### Outputs + +
+
Y (differentiable) : T
+
Output data tensor from Lp pooling across the input tensor. Dimensions will vary based on various kernel, stride, and pad sizes.
+
+ +#### Type Constraints + +
+
T : tensor(bfloat16), tensor(float16), tensor(float), tensor(double)
+
Constrain input and output types to float tensors.
+
+ +### **MaxPool-22** + + MaxPool consumes an input tensor X and applies max pooling across + the tensor according to kernel sizes, stride sizes, and pad lengths. + max pooling consisting of computing the max on all values of a + subset of the input tensor according to the kernel size and downsampling the + data into the output tensor Y for further processing. The output spatial shape is calculated differently + depending on whether explicit padding is used, where pads is employed, or auto padding is used, where auto_pad is utilized. + With explicit padding (https://pytorch.org/docs/stable/generated/torch.nn.MaxPool2d.html?highlight=maxpool#torch.nn.MaxPool2d): + ``` + output_spatial_shape[i] = floor((input_spatial_shape[i] + pad_shape[i] - dilation[i] * (kernel_shape[i] - 1) - 1) / strides_spatial_shape[i] + 1) + ``` + or + ``` + output_spatial_shape[i] = ceil((input_spatial_shape[i] + pad_shape[i] - dilation[i] * (kernel_shape[i] - 1) - 1) / strides_spatial_shape[i] + 1) + ``` + if ceil_mode is enabled. `pad_shape[i]` is the sum of pads along axis `i`. Sliding windows that would start in the right padded region are ignored. + + `auto_pad` is a DEPRECATED attribute. If you are using them currently, the output spatial shape will be following when ceil_mode is enabled: + ``` + VALID: output_spatial_shape[i] = ceil((input_spatial_shape[i] - ((kernel_spatial_shape[i] - 1) * dilations[i] + 1) + 1) / strides_spatial_shape[i]) + SAME_UPPER or SAME_LOWER: output_spatial_shape[i] = ceil(input_spatial_shape[i] / strides_spatial_shape[i]) + ``` + or when ceil_mode is disabled (https://www.tensorflow.org/api_docs/python/tf/keras/layers/AveragePooling2D): + ``` + VALID: output_spatial_shape[i] = floor((input_spatial_shape[i] - ((kernel_spatial_shape[i] - 1) * dilations[i] + 1)) / strides_spatial_shape[i]) + 1 + SAME_UPPER or SAME_LOWER: output_spatial_shape[i] = floor((input_spatial_shape[i] - 1) / strides_spatial_shape[i]) + 1 + ``` + And pad shape will be following if `SAME_UPPER` or `SAME_LOWER`: + ``` + pad_shape[i] = (output_spatial_shape[i] - 1) * strides_spatial_shape[i] + ((kernel_spatial_shape[i] - 1) * dilations[i] + 1) - input_spatial_shape[i] + ``` + The output of each pooling window is maximum number of elements exclude pad. + + +#### Version + +This version of the operator has been available since version 22 of the default ONNX operator set. + +#### Attributes + +
+
auto_pad : string (default is NOTSET)
+
auto_pad must be either NOTSET, SAME_UPPER, SAME_LOWER or VALID. Where default value is NOTSET, which means explicit padding is used. SAME_UPPER or SAME_LOWER mean pad the input so that `output_shape[i] = ceil(input_shape[i] / strides[i])` for each axis `i`. The padding is split between the two sides equally or almost equally (depending on whether it is even or odd). In case the padding is an odd number, the extra padding is added at the end for SAME_UPPER and at the beginning for SAME_LOWER.
+
ceil_mode : int (default is 0)
+
Whether to use ceil or floor (default) to compute the output shape.
+
dilations : list of ints
+
Dilation value along each spatial axis of filter. If not present, the dilation defaults to 1 along each spatial axis.
+
kernel_shape : list of ints (required)
+
The size of the kernel along each axis.
+
pads : list of ints
+
Padding for the beginning and ending along each spatial axis, it can take any value greater than or equal to 0. The value represent the number of pixels added to the beginning and end part of the corresponding axis. `pads` format should be as follow [x1_begin, x2_begin...x1_end, x2_end,...], where xi_begin the number of pixels added at the beginning of axis `i` and xi_end, the number of pixels added at the end of axis `i`. This attribute cannot be used simultaneously with auto_pad attribute. If not present, the padding defaults to 0 along start and end of each spatial axis.
+
storage_order : int (default is 0)
+
The storage order of the tensor. 0 is row major, and 1 is column major. This attribute is used only to convert an n-tuple index value into a single integer value for producing the second output.
+
strides : list of ints
+
Stride along each spatial axis. If not present, the stride defaults to 1 along each spatial axis.
+
+ +#### Inputs + +
+
X (differentiable) : T
+
Input data tensor from the previous operator; dimensions for image case are (N x C x H x W), where N is the batch size, C is the number of channels, and H and W are the height and the width of the data. For non image case, the dimensions are in the form of (N x C x D1 x D2 ... Dn), where N is the batch size. Optionally, if dimension denotation is in effect, the operation expects the input data tensor to arrive with the dimension denotation of [DATA_BATCH, DATA_CHANNEL, DATA_FEATURE, DATA_FEATURE ...].
+
+ +#### Outputs (1 - 2) + +
+
Y (differentiable) : T
+
Output data tensor from average or max pooling across the input tensor. Dimensions will vary based on various kernel, stride, and pad sizes. Floor value of the dimension is used
+
Indices (optional, non-differentiable) : I
+
Indices tensor from max pooling across the input tensor. The dimensions of indices are the same as output tensor. The values in indices of are the indices of the selected values during pooling. The indices are computed as flatten 1-D tensor, and the indices do not consider padding. So the values in indices are in [0, N x C x D1 x ... x Dn).
+
+ +#### Type Constraints + +
+
T : tensor(bfloat16), tensor(float16), tensor(float), tensor(double), tensor(int8), tensor(uint8)
+
Constrain input and output types to float and 8 bit tensors.
+
I : tensor(int64)
+
Constrain index tensor to int64
+
+ +### **MaxRoiPool-22** + + ROI max pool consumes an input tensor X and region of interests (RoIs) to + apply max pooling across each RoI, to produce output 4-D tensor of shape + (num_rois, channels, pooled_shape[0], pooled_shape[1]). + +#### Version + +This version of the operator has been available since version 22 of the default ONNX operator set. + +#### Attributes + +
+
pooled_shape : list of ints (required)
+
ROI pool output shape (height, width).
+
spatial_scale : float (default is 1.0)
+
Multiplicative spatial scale factor to translate ROI coordinates from their input scale to the scale used when pooling.
+
+ +#### Inputs + +
+
X (differentiable) : T
+
Input data tensor from the previous operator; dimensions for image case are (N x C x H x W), where N is the batch size, C is the number of channels, and H and W are the height and the width of the data.
+
rois (non-differentiable) : T
+
RoIs (Regions of Interest) to pool over. Should be a 2-D tensor of shape (num_rois, 5) given as [[batch_id, x1, y1, x2, y2], ...].
+
+ +#### Outputs + +
+
Y (differentiable) : T
+
RoI pooled output 4-D tensor of shape (num_rois, channels, pooled_shape[0], pooled_shape[1]).
+
+ +#### Type Constraints + +
+
T : tensor(bfloat16), tensor(float16), tensor(float), tensor(double)
+
Constrain input and output types to float tensors.
+
+ +### **MaxUnpool-22** + + MaxUnpool essentially computes the partial inverse of the MaxPool op. + The input information to this op is typically the output information from a MaxPool op. The first + input tensor X is the tensor that needs to be unpooled, which is typically the pooled tensor (first output) + from MaxPool. The second input tensor, I, contains the indices to the (locally maximal) elements corresponding + to the elements in the first input tensor X. Input tensor I is typically the second output of the MaxPool op. + The third (optional) input is a tensor that specifies the output size of the unpooling operation. + + MaxUnpool is intended to do 'partial' inverse of the MaxPool op. 'Partial' because all the non-maximal + values from the original input to MaxPool are set to zero in the output of the MaxUnpool op. Pooling + the result of an unpooling operation should give back the original input to the unpooling op. + + MaxUnpool can produce the same output size for several input sizes, which makes unpooling op ambiguous. + The third input argument, output_size, is meant to disambiguate the op and produce output tensor of + known/predictable size. + + In addition to the inputs, MaxUnpool takes three attributes, namely kernel_shape, strides, and pads, + which define the exact unpooling op. The attributes typically have the same values as the corresponding + pooling op that the unpooling op is trying to invert. + +#### Version + +This version of the operator has been available since version 22 of the default ONNX operator set. + +#### Attributes + +
+
kernel_shape : list of ints (required)
+
The size of the kernel along each axis.
+
pads : list of ints
+
Padding for the beginning and ending along each spatial axis, it can take any value greater than or equal to 0. The value represent the number of pixels added to the beginning and end part of the corresponding axis. `pads` format should be as follow [x1_begin, x2_begin...x1_end, x2_end,...], where xi_begin the number of pixels added at the beginning of axis `i` and xi_end, the number of pixels added at the end of axis `i`. This attribute cannot be used simultaneously with auto_pad attribute. If not present, the padding defaults to 0 along start and end of each spatial axis.
+
strides : list of ints
+
Stride along each spatial axis. If not present, the stride defaults to 1 along each spatial axis.
+
+ +#### Inputs (2 - 3) + +
+
X (differentiable) : T1
+
Input data tensor that has to be unpooled. This tensor is typically the first output of the MaxPool op.Dimensions for image case are (N x C x H x W), where N is the batch size, C is the number of channels, and H and W are the height and the width of the data. For non-image case, the dimensions are in the form of (N x C x D1 x D2 ... Dn), where N is the batch size. Optionally, if dimension denotation is in effect, the operation expects the input data tensor to arrive with the dimension denotation of [DATA_BATCH, DATA_CHANNEL, DATA_FEATURE, DATA_FEATURE ...].
+
I (non-differentiable) : T2
+
Input data tensor containing the indices corresponding to elements in the first input tensor X.This tensor is typically the second output of the MaxPool op.Dimensions must be the same as input tensor X. The indices are linear, i.e. computed considering the tensor as flattened 1-D tensor, assuming row-major storage. Also, the linear indices should not consider padding. So the values in indices are in the range [0, N x C x D1 x ... x Dn).
+
output_shape (optional, non-differentiable) : T2
+
The shape of the output can be explicitly set which will cause pads values to be auto generated. If 'output_shape' is specified, 'pads' values are ignored.
+
+ +#### Outputs + +
+
output (differentiable) : T1
+
Output data tensor that contains the result of the unpooling.
+
+ +#### Type Constraints + +
+
T1 : tensor(bfloat16), tensor(float16), tensor(float), tensor(double)
+
Constrain input and output types to float tensors.
+
T2 : tensor(int64)
+
Constrain index tensor to int64
+
+ +### **Mish-22** + + Mish: A Self Regularized Non-Monotonic Neural Activation Function. + + Perform the linear unit element-wise on the input tensor X using formula: + + ``` + mish(x) = x * tanh(softplus(x)) = x * tanh(ln(1 + e^{x})) + ``` + +#### Version + +This version of the operator has been available since version 22 of the default ONNX operator set. + +#### Inputs + +
+
X (differentiable) : T
+
Input tensor
+
+ +#### Outputs + +
+
Y (differentiable) : T
+
Output tensor
+
+ +#### Type Constraints + +
+
T : tensor(bfloat16), tensor(float16), tensor(float), tensor(double)
+
Constrain input X and output types to float tensors.
+
+ +### **Multinomial-22** + + Generate a tensor of samples from a multinomial distribution according to the probabilities + of each of the possible outcomes. + +#### Version + +This version of the operator has been available since version 22 of the default ONNX operator set. + +#### Attributes + +
+
dtype : int (default is 6)
+
(Optional) The data type for the elements of the output tensor, if not specified, we will use int32.
+
sample_size : int (default is 1)
+
Number of times to sample.
+
seed : float
+
(Optional) Seed to the random generator, if not specified we will auto generate one.
+
+ +#### Inputs + +
+
input : T1
+
Input tensor with shape [batch_size, class_size], where class_size is the number of all possible outcomes. Each value along the axis zero represents the unnormalized log-probability of each corresponding outcome in a batch.
+
+ +#### Outputs + +
+
output : T2
+
Output tensor with shape [batch_size, sample_size], where sample_size is the number of times to sample. Each value along the axis zero represents the outcome of the corresponding sample in a batch.
+
+ +#### Type Constraints + +
+
T1 : tensor(bfloat16), tensor(float16), tensor(float), tensor(double)
+
Constrain input types to float tensors.
+
T2 : tensor(int32), tensor(int64)
+
Constrain output types to integral tensors.
+
+ +### **NegativeLogLikelihoodLoss-22** + + A NegativeLogLikelihoodLoss operator computes (weighted) negative log likelihood loss. + Its "input" tensor has the shape of (N, C, d1, d2, ..., dk) where k >= 0. + The "input" tensor contains log-probabilities for input[n, :, d_1, d_2,..., d_k] being in a class of [0, C). + The operator's "target" input tensor has the shape of (N, d1, d2, ..., dk). It encodes class labels (one of C classes) + or it may contain a special value (indicated by an attribute ignore_index) for N x d1 x d2 x ... x dk samples. + The loss value for input[n, :, d_1, d_2,...d_k] being classified as class c = target[n][d_1][d_2]...[d_k] is computed as: + + ``` + loss[n][d_1][d_2]...[d_k] = -input[n][c][d_1][d_2]...[d_k]. + ``` + + When an optional "weight" is provided, the sample loss is calculated as: + + ``` + loss[n][d_1][d_2]...[d_k] = -input[n][c][d_1][d_2]...[d_k] * weight[c]. + ``` + + loss is zero for the case when target-value equals ignore_index. + + ``` + loss[n][d_1][d_2]...[d_k] = 0, when target[n][d_1][d_2]...[d_k] = ignore_index + ``` + + If "reduction" attribute is set to "none", the operator's output will be the above loss with shape (N, d1, d2, ..., dk). + If "reduction" attribute is set to "mean" (the default attribute value), the output loss is (weight) averaged: + + ``` + mean(loss), if "weight" is not provided, + ``` + + or if weight is provided, + + ``` + sum(loss) / sum(weight[target[n][d_1][d_2]...[d_k]]]), for all samples. + ``` + + If "reduction" attribute is set to "sum", the output is a scalar: `sum(loss)`. + + See also https://pytorch.org/docs/stable/nn.html#torch.nn.NLLLoss. + + Example 1: + + ``` + // negative log likelihood loss, "none" reduction + N, C, d1 = 2, 3, 2 + input = [[[1.0, 2.0], [2.0, 2.0], [3.0, 2.0]], + [[0.0, 1.0], [2.0, 2.0], [1.0, 2]]] + target = [[2, 1], [0, 2]] + + loss = np.zeros((N, d1)) + for n in range(N): + for d_1 in range(d1): + c = target[n][d_1] + loss[n][d_1] = -input[n][c][d_1] + + // print(loss) + // [[-3. -2.] + // [-0. -2.]] + ``` + + Example 2: + + ``` + // weighted negative log likelihood loss, sum reduction + N, C, d1 = 2, 3, 2 + input = [[[1.0, 2.0], [2.0, 2.0], [3.0, 2.0]], + [[0.0, 1.0], [2.0, 2.0], [1.0, 2]]] + target = [[2, 1], [0, 2]] + weight = [0.2, 0.3, 0.1] + loss = np.zeros((N, d1)) + for n in range(N): + for d_1 in range(d1): + c = target[n][d_1] + loss[n][d_1] = -input[n][c][d_1] * weight[c] + + loss = np.sum(loss) + // print(loss) + // -1.1 + ``` + + Example 3: + + ``` + // weighted negative log likelihood loss, mean reduction + N, C, d1 = 2, 3, 2 + input = [[[1.0, 2.0], [2.0, 2.0], [3.0, 2.0]], + [[0.0, 1.0], [2.0, 2.0], [1.0, 2]]] + target = [[2, 1], [0, 2]] + weight = [0.2, 0.3, 0.1] + loss = np.zeros((N, d1)) + weight_total = 0 + for n in range(N): + for d_1 in range(d1): + c = target[n][d_1] + loss[n][d_1] = -input[n][c][d_1] * weight[c] + weight_total = weight_total + weight[c] + + loss = np.sum(loss) / weight_total + // print(loss) + // -1.57 + ``` + +#### Version + +This version of the operator has been available since version 22 of the default ONNX operator set. + +#### Attributes + +
+
ignore_index : int
+
Specifies a target value that is ignored and does not contribute to the input gradient. It's an optional value.
+
reduction : string (default is mean)
+
Type of reduction to apply to loss: none, sum, mean (default). 'none': the output is the loss for each sample. 'sum': the output will be summed. 'mean': the sum of the output will be divided by the sum of applied weights.
+
+ +#### Inputs (2 - 3) + +
+
input (differentiable) : T
+
Input tensor of shape (N, C) or (N, C, d1, d2, ..., dk).
+
target (non-differentiable) : Tind
+
Target tensor of shape (N) or (N, d1, d2, ..., dk). Target element value shall be in range of [0, C). If ignore_index is specified, it may have a value outside [0, C) and the target values should either be in the range [0, C) or have the value ignore_index.
+
weight (optional, non-differentiable) : T
+
Optional rescaling weight tensor. If given, it has to be a tensor of size C. Otherwise, it is treated as if having all ones.
+
+ +#### Outputs + +
+
loss (differentiable) : T
+
The negative log likelihood loss
+
+ +#### Type Constraints + +
+
T : tensor(bfloat16), tensor(float16), tensor(float), tensor(double)
+
Constrain input, weight, and output types to floating-point tensors.
+
Tind : tensor(int32), tensor(int64)
+
Constrain target to integer types
+
+ +### **RNN-22** + + Computes an one-layer simple RNN. This operator is usually supported + via some custom implementation such as CuDNN. + + Notations: + + * `X` - input tensor + * `i` - input gate + * `t` - time step (t-1 means previous time step) + * `Wi` - W parameter weight matrix for input gate + * `Ri` - R recurrence weight matrix for input gate + * `Wbi` - W parameter bias vector for input gate + * `Rbi` - R parameter bias vector for input gate + * `WBi` - W parameter weight matrix for backward input gate + * `RBi` - R recurrence weight matrix for backward input gate + * `WBbi` - WR bias vectors for backward input gate + * `RBbi` - RR bias vectors for backward input gate + * `H` - Hidden state + * `num_directions` - 2 if direction == bidirectional else 1 + + Activation functions: + + * Relu(x) - max(0, x) + * Tanh(x) - (1 - e^{-2x})/(1 + e^{-2x}) + * Sigmoid(x) - 1/(1 + e^{-x}) + + NOTE: Below are optional + + * Affine(x) - alpha*x + beta + * LeakyRelu(x) - x if x >= 0 else alpha * x + * ThresholdedRelu(x) - x if x >= alpha else 0 + * ScaledTanh(x) - alpha*Tanh(beta*x) + * HardSigmoid(x) - min(max(alpha*x + beta, 0), 1) + * Elu(x) - x if x >= 0 else alpha*(e^x - 1) + * Softsign(x) - x/(1 + |x|) + * Softplus(x) - log(1 + e^x) + + Equations (Default: f=Tanh): + + * Ht = f(Xt*(Wi^T) + Ht-1*(Ri^T) + Wbi + Rbi) + This operator has **optional** inputs/outputs. See [the doc](IR.md) for more details about the representation of optional arguments. An empty string may be used in the place of an actual argument's name to indicate a missing argument. Trailing optional arguments (those not followed by an argument that is present) may also be simply omitted. + +#### Version + +This version of the operator has been available since version 22 of the default ONNX operator set. + +#### Attributes + +
+
activation_alpha : list of floats
+
Optional scaling values used by some activation functions. The values are consumed in the order of activation functions, for example (f, g, h) in LSTM. Default values are the same as of corresponding ONNX operators.For example with LeakyRelu, the default alpha is 0.01.
+
activation_beta : list of floats
+
Optional scaling values used by some activation functions. The values are consumed in the order of activation functions, for example (f, g, h) in LSTM. Default values are the same as of corresponding ONNX operators.
+
activations : list of strings (default is ['Tanh', 'Tanh'])
+
One (or two if bidirectional) activation function for input gate. The activation function must be one of the activation functions specified above. Optional: Default `Tanh` if not specified.
+
clip : float
+
Cell clip threshold. Clipping bounds the elements of a tensor in the range of [-threshold, +threshold] and is applied to the input of activations. No clip if not specified.
+
direction : string (default is forward)
+
Specify if the RNN is forward, reverse, or bidirectional. Must be one of forward (default), reverse, or bidirectional.
+
hidden_size : int
+
Number of neurons in the hidden layer
+
layout : int (default is 0)
+
The shape format of inputs X, initial_h and outputs Y, Y_h. If 0, the following shapes are expected: X.shape = [seq_length, batch_size, input_size], Y.shape = [seq_length, num_directions, batch_size, hidden_size], initial_h.shape = Y_h.shape = [num_directions, batch_size, hidden_size]. If 1, the following shapes are expected: X.shape = [batch_size, seq_length, input_size], Y.shape = [batch_size, seq_length, num_directions, hidden_size], initial_h.shape = Y_h.shape = [batch_size, num_directions, hidden_size].
+
+ +#### Inputs (3 - 6) + +
+
X (differentiable) : T
+
The input sequences packed (and potentially padded) into one 3-D tensor with the shape of `[seq_length, batch_size, input_size]`.
+
W (differentiable) : T
+
The weight tensor for input gate. Concatenation of `Wi` and `WBi` (if bidirectional). The tensor has shape `[num_directions, hidden_size, input_size]`.
+
R (differentiable) : T
+
The recurrence weight tensor. Concatenation of `Ri` and `RBi` (if bidirectional). The tensor has shape `[num_directions, hidden_size, hidden_size]`.
+
B (optional, differentiable) : T
+
The bias tensor for input gate. Concatenation of `[Wbi, Rbi]` and `[WBbi, RBbi]` (if bidirectional). The tensor has shape `[num_directions, 2*hidden_size]`. Optional: If not specified - assumed to be 0.
+
sequence_lens (optional, non-differentiable) : T1
+
Optional tensor specifying lengths of the sequences in a batch. If not specified - assumed all sequences in the batch to have length `seq_length`. It has shape `[batch_size]`.
+
initial_h (optional, non-differentiable) : T
+
Optional initial value of the hidden. If not specified - assumed to be 0. It has shape `[num_directions, batch_size, hidden_size]`.
+
+ +#### Outputs (0 - 2) + +
+
Y (optional, differentiable) : T
+
A tensor that concats all the intermediate output values of the hidden. It has shape `[seq_length, num_directions, batch_size, hidden_size]`.
+
Y_h (optional, differentiable) : T
+
The last output value of the hidden. It has shape `[num_directions, batch_size, hidden_size]`.
+
+ +#### Type Constraints + +
+
T : tensor(bfloat16), tensor(float16), tensor(float), tensor(double)
+
Constrain input and output types to float tensors.
+
T1 : tensor(int32)
+
Constrain seq_lens to integer tensor.
+
+ +### **RandomNormal-22** + + Generate a tensor with random values drawn from a normal distribution. The shape + of the tensor is specified by the `shape` argument and the parameter of the normal distribution + specified by `mean` and `scale`. + + The data type is specified by the 'dtype' argument. The 'dtype' argument must + be one of the data types specified in the 'DataType' enum field in the + TensorProto message. + +#### Version + +This version of the operator has been available since version 22 of the default ONNX operator set. + +#### Attributes + +
+
dtype : int (default is 1)
+
The data type for the elements of the output tensor. Default is TensorProto::FLOAT.
+
mean : float (default is 0.0)
+
The mean of the normal distribution.
+
scale : float (default is 1.0)
+
The standard deviation of the normal distribution.
+
seed : float
+
(Optional) Seed to the random generator, if not specified we will auto generate one.
+
shape : list of ints (required)
+
The shape of the output tensor.
+
+ +#### Inputs + + +#### Outputs + +
+
output : T
+
Output tensor of random values drawn from normal distribution
+
+ +#### Type Constraints + +
+
T : tensor(bfloat16), tensor(float16), tensor(float), tensor(double)
+
Constrain output types to float tensors.
+
+ +### **RandomNormalLike-22** + + Generate a tensor with random values drawn from a normal distribution. + The shape of the output tensor is copied from the shape of the input tensor, + and the parameters of the normal distribution are specified by `mean` and `scale`. + + The data type is specified by the 'dtype' argument, or copied from the input tensor if not provided. + The 'dtype' argument must be one of the data types specified in the 'DataType' enum field in the + TensorProto message, and be valid as an output type. + +#### Version + +This version of the operator has been available since version 22 of the default ONNX operator set. + +#### Attributes + +
+
dtype : int
+
(Optional) The data type for the elements of the output tensor, if not specified, we will use the data type of the input tensor.
+
mean : float (default is 0.0)
+
The mean of the normal distribution.
+
scale : float (default is 1.0)
+
The standard deviation of the normal distribution.
+
seed : float
+
(Optional) Seed to the random generator, if not specified we will auto generate one.
+
+ +#### Inputs + +
+
input : T1
+
Input tensor to copy shape and optionally type information from.
+
+ +#### Outputs + +
+
output : T2
+
Output tensor of random values drawn from normal distribution
+
+ +#### Type Constraints + +
+
T1 : tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(bfloat16), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128)
+
Constrain to any tensor type. If the dtype attribute is not provided this must be a valid output type.
+
T2 : tensor(bfloat16), tensor(float16), tensor(float), tensor(double)
+
Constrain output types to float tensors.
+
+ +### **RandomUniform-22** + + Generate a tensor with random values drawn from a uniform distribution. The shape + of the tensor is specified by the `shape` argument and the range by `low` and `high`. + + The data type is specified by the 'dtype' argument. The 'dtype' argument must + be one of the data types specified in the 'DataType' enum field in the + TensorProto message. + +#### Version + +This version of the operator has been available since version 22 of the default ONNX operator set. + +#### Attributes + +
+
dtype : int (default is 1)
+
The data type for the elements of the output tensor. If not specified, default is TensorProto::FLOAT.
+
high : float (default is 1.0)
+
Upper boundary of the output values.
+
low : float (default is 0.0)
+
Lower boundary of the output values.
+
seed : float
+
(Optional) Seed to the random generator, if not specified we will auto generate one.
+
shape : list of ints (required)
+
The shape of the output tensor.
+
+ +#### Inputs + + +#### Outputs + +
+
output : T
+
Output tensor of random values drawn from uniform distribution
+
+ +#### Type Constraints + +
+
T : tensor(bfloat16), tensor(float16), tensor(float), tensor(double)
+
Constrain output types to float tensors.
+
+ +### **RandomUniformLike-22** + + Generate a tensor with random values drawn from a uniform distribution. + The shape of the output tensor is copied from the shape of the input tensor, + and the parameters of the uniform distribution are specified by `low` and `high`. + + The data type is specified by the 'dtype' argument, or copied from the input tensor if not provided. + The 'dtype' argument must be one of the data types specified in the 'DataType' enum field in the + TensorProto message and be valid as an output type. + +#### Version + +This version of the operator has been available since version 22 of the default ONNX operator set. + +#### Attributes + +
+
dtype : int
+
(Optional) The data type for the elements of the output tensor, if not specified, we will use the data type of the input tensor.
+
high : float (default is 1.0)
+
Upper boundary of the output values.
+
low : float (default is 0.0)
+
Lower boundary of the output values.
+
seed : float
+
(Optional) Seed to the random generator, if not specified we will auto generate one.
+
+ +#### Inputs + +
+
input : T1
+
Input tensor to copy shape and optionally type information from.
+
+ +#### Outputs + +
+
output : T2
+
Output tensor of random values drawn from uniform distribution
+
+ +#### Type Constraints + +
+
T1 : tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(bfloat16), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128)
+
Constrain to any tensor type. If the dtype attribute is not provided this must be a valid output type.
+
T2 : tensor(bfloat16), tensor(float16), tensor(float), tensor(double)
+
Constrain output types to float tensors.
+
+ +### **RoiAlign-22** + + Region of Interest (RoI) align operation described in the + [Mask R-CNN paper](https://arxiv.org/abs/1703.06870). + RoiAlign consumes an input tensor X and region of interests (rois) + to apply pooling across each RoI; it produces a 4-D tensor of shape + (num_rois, C, output_height, output_width). + + RoiAlign is proposed to avoid the misalignment by removing + quantizations while converting from original image into feature + map and from feature map into RoI feature; in each ROI bin, + the value of the sampled locations are computed directly + through bilinear interpolation. + +#### Version + +This version of the operator has been available since version 22 of the default ONNX operator set. + +#### Attributes + +
+
coordinate_transformation_mode : string (default is half_pixel)
+
Allowed values are 'half_pixel' and 'output_half_pixel'. Use the value 'half_pixel' to pixel shift the input coordinates by -0.5 (the recommended behavior). Use the value 'output_half_pixel' to omit the pixel shift for the input (use this for a backward-compatible behavior).
+
mode : string (default is avg)
+
The pooling method. Two modes are supported: 'avg' and 'max'. Default is 'avg'.
+
output_height : int (default is 1)
+
default 1; Pooled output Y's height.
+
output_width : int (default is 1)
+
default 1; Pooled output Y's width.
+
sampling_ratio : int (default is 0)
+
Number of sampling points in the interpolation grid used to compute the output value of each pooled output bin. If > 0, then exactly sampling_ratio x sampling_ratio grid points are used. If == 0, then an adaptive number of grid points are used (computed as ceil(roi_width / output_width), and likewise for height). Default is 0.
+
spatial_scale : float (default is 1.0)
+
Multiplicative spatial scale factor to translate ROI coordinates from their input spatial scale to the scale used when pooling, i.e., spatial scale of the input feature map X relative to the input image. E.g.; default is 1.0f.
+
+ +#### Inputs + +
+
X : T1
+
Input data tensor from the previous operator; 4-D feature map of shape (N, C, H, W), where N is the batch size, C is the number of channels, and H and W are the height and the width of the data.
+
rois : T1
+
RoIs (Regions of Interest) to pool over; rois is 2-D input of shape (num_rois, 4) given as [[x1, y1, x2, y2], ...]. The RoIs' coordinates are in the coordinate system of the input image. Each coordinate set has a 1:1 correspondence with the 'batch_indices' input.
+
batch_indices : T2
+
1-D tensor of shape (num_rois,) with each element denoting the index of the corresponding image in the batch.
+
+ +#### Outputs + +
+
Y : T1
+
RoI pooled output, 4-D tensor of shape (num_rois, C, output_height, output_width). The r-th batch element Y[r-1] is a pooled feature map corresponding to the r-th RoI X[r-1].
+
+ +#### Type Constraints + +
+
T1 : tensor(bfloat16), tensor(float16), tensor(float), tensor(double)
+
Constrain types to float tensors.
+
T2 : tensor(int64)
+
Constrain types to int tensors.
+
+ +### **Round-22** + + Round takes one input Tensor and rounds the values, element-wise, meaning + it finds the nearest integer for each value. + In case of halves, the rule is to round them to the nearest even integer. + If input x is integral, +0, -0, NaN, or infinite, x itself is returned. + The output tensor has the same shape and type as the input. + + Examples: + ``` + round([0.9]) = [1.0] + round([2.5]) = [2.0] + round([2.3]) = [2.0] + round([1.5]) = [2.0] + round([-4.5]) = [-4.0] + ``` + +#### Version + +This version of the operator has been available since version 22 of the default ONNX operator set. + +#### Inputs + +
+
X (non-differentiable) : T
+
Input tensor
+
+ +#### Outputs + +
+
Y (non-differentiable) : T
+
Output tensor
+
+ +#### Type Constraints + +
+
T : tensor(bfloat16), tensor(float16), tensor(float), tensor(double)
+
Constrain input and output types to float tensors.
+
+ +### **Selu-22** + + Selu takes one input data (Tensor) and produces one output data + (Tensor) where the scaled exponential linear unit function, + `y = gamma * (alpha * e^x - alpha) for x <= 0`, `y = gamma * x for x > 0`, + is applied to the tensor elementwise. + +#### Version + +This version of the operator has been available since version 22 of the default ONNX operator set. + +#### Attributes + +
+
alpha : float (default is 1.67326)
+
Coefficient of SELU default to 1.67326319217681884765625 (i.e., float32 approximation of 1.6732632423543772848170429916717).
+
gamma : float (default is 1.0507)
+
Coefficient of SELU default to 1.05070102214813232421875 (i.e., float32 approximation of 1.0507009873554804934193349852946).
+
+ +#### Inputs + +
+
X (differentiable) : T
+
Input tensor
+
+ +#### Outputs + +
+
Y (differentiable) : T
+
Output tensor
+
+ +#### Type Constraints + +
+
T : tensor(bfloat16), tensor(float16), tensor(float), tensor(double)
+
Constrain input and output types to float tensors.
+
+ +### **Sin-22** + + Calculates the sine of the given input tensor, element-wise. + +#### Version + +This version of the operator has been available since version 22 of the default ONNX operator set. + +#### Inputs + +
+
input (differentiable) : T
+
Input tensor
+
+ +#### Outputs + +
+
output (differentiable) : T
+
The sine of the input tensor computed element-wise
+
+ +#### Type Constraints + +
+
T : tensor(bfloat16), tensor(float16), tensor(float), tensor(double)
+
Constrain input and output types to float tensors.
+
+ +### **Sinh-22** + + Calculates the hyperbolic sine of the given input tensor element-wise. + +#### Version + +This version of the operator has been available since version 22 of the default ONNX operator set. + +#### Inputs + +
+
input (differentiable) : T
+
Input tensor
+
+ +#### Outputs + +
+
output (differentiable) : T
+
The hyperbolic sine values of the input tensor computed element-wise
+
+ +#### Type Constraints + +
+
T : tensor(bfloat16), tensor(float16), tensor(float), tensor(double)
+
Constrain input and output types to float tensors.
+
+ +### **Softplus-22** + + Softplus takes one input data (Tensor) and produces one output data + (Tensor) where the softplus function, y = ln(exp(x) + 1), is applied to + the tensor elementwise. + +#### Version + +This version of the operator has been available since version 22 of the default ONNX operator set. + +#### Inputs + +
+
X (differentiable) : T
+
1D input tensor
+
+ +#### Outputs + +
+
Y (differentiable) : T
+
1D input tensor
+
+ +#### Type Constraints + +
+
T : tensor(bfloat16), tensor(float16), tensor(float), tensor(double)
+
Constrain input and output types to float tensors.
+
+ +### **Softsign-22** + + Calculates the softsign (x/(1+|x|)) of the given input tensor element-wise. + +#### Version + +This version of the operator has been available since version 22 of the default ONNX operator set. + +#### Inputs + +
+
input (differentiable) : T
+
Input tensor
+
+ +#### Outputs + +
+
output (differentiable) : T
+
The softsign (x/(1+|x|)) values of the input tensor computed element-wise
+
+ +#### Type Constraints + +
+
T : tensor(bfloat16), tensor(float16), tensor(float), tensor(double)
+
Constrain input and output types to float tensors.
+
+ +### **Tan-22** + + Calculates the tangent of the given input tensor, element-wise. + +#### Version + +This version of the operator has been available since version 22 of the default ONNX operator set. + +#### Inputs + +
+
input (differentiable) : T
+
Input tensor
+
+ +#### Outputs + +
+
output (differentiable) : T
+
The tangent of the input tensor computed element-wise
+
+ +#### Type Constraints + +
+
T : tensor(bfloat16), tensor(float16), tensor(float), tensor(double)
+
Constrain input and output types to float tensors.
+
+ +### **ThresholdedRelu-22** + + ThresholdedRelu takes one input data (Tensor) and produces one output data + (Tensor) where the rectified linear function, y = x for x > alpha, y = 0 otherwise, + is applied to the tensor elementwise. + +#### Version + +This version of the operator has been available since version 22 of the default ONNX operator set. + +#### Attributes + +
+
alpha : float (default is 1.0)
+
Threshold value
+
+ +#### Inputs + +
+
X (differentiable) : T
+
Input tensor
+
+ +#### Outputs + +
+
Y (differentiable) : T
+
Output tensor
+
+ +#### Type Constraints + +
+
T : tensor(bfloat16), tensor(float16), tensor(float), tensor(double)
+
Constrain input and output types to float tensors.
+
+ # ai.onnx.preview.training ## Version 1 of the 'ai.onnx.preview.training' operator set ### **ai.onnx.preview.training.Adagrad-1** diff --git a/docs/Operators.md b/docs/Operators.md index 8716cb8e54e..e1601a74d89 100644 --- a/docs/Operators.md +++ b/docs/Operators.md @@ -12,17 +12,17 @@ For an operator input/output's differentiability, it can be differentiable, |**Operator**|**Since version**|| |-|-|-| |Abs|13, 6, 1| -|Acos|7| -|Acosh|9| +|Acos|22, 7| +|Acosh|22, 9| |Add|14, 13, 7, 6, 1| |And|7, 1| |ArgMax|13, 12, 11, 1| |ArgMin|13, 12, 11, 1| -|Asin|7| -|Asinh|9| -|Atan|7| -|Atanh|9| -|AveragePool|19, 11, 10, 7, 1| +|Asin|22, 7| +|Asinh|22, 9| +|Atan|22, 7| +|Atanh|22, 9| +|AveragePool|22, 19, 11, 10, 7, 1| |BatchNormalization|15, 14, 9, 7, 6, 1| |BitShift|11| |BitwiseAnd|18| @@ -37,63 +37,63 @@ For an operator input/output's differentiability, it can be differentiable, |ConcatFromSequence|11| |Constant|21, 19, 13, 12, 11, 9, 1| |ConstantOfShape|21, 20, 9| -|Conv|11, 1| +|Conv|22, 11, 1| |ConvInteger|10| -|ConvTranspose|11, 1| -|Cos|7| -|Cosh|9| +|ConvTranspose|22, 11, 1| +|Cos|22, 7| +|Cosh|22, 9| |CumSum|14, 11| |DFT|20, 17| -|DeformConv|19| +|DeformConv|22, 19| |DepthToSpace|13, 11, 1| |DequantizeLinear|21, 19, 13, 10| -|Det|11| +|Det|22, 11| |Div|14, 13, 7, 6, 1| -|Dropout|13, 12, 10, 7, 6, 1| +|Dropout|22, 13, 12, 10, 7, 6, 1| |Einsum|12| |Equal|19, 13, 11, 7, 1| |Erf|13, 9| |Exp|13, 6, 1| |Expand|13, 8| -|EyeLike|9| +|EyeLike|22, 9| |Flatten|21, 13, 11, 9, 1| |Floor|13, 6, 1| -|GRU|14, 7, 3, 1| +|GRU|22, 14, 7, 3, 1| |Gather|13, 11, 1| |GatherElements|13, 11| |GatherND|13, 12, 11| |Gemm|13, 11, 9, 7, 6, 1| -|GlobalAveragePool|1| -|GlobalLpPool|2, 1| -|GlobalMaxPool|1| +|GlobalAveragePool|22, 1| +|GlobalLpPool|22, 2, 1| +|GlobalMaxPool|22, 1| |Greater|13, 9, 7, 1| -|GridSample|20, 16| +|GridSample|22, 20, 16| |Hardmax|13, 11, 1| |Identity|21, 19, 16, 14, 13, 1| |If|21, 19, 16, 13, 11, 1| |ImageDecoder|20| -|InstanceNormalization|6, 1| +|InstanceNormalization|22, 6, 1| |IsInf|20, 10| |IsNaN|20, 13, 9| |LRN|13, 1| -|LSTM|14, 7, 1| +|LSTM|22, 14, 7, 1| |Less|13, 9, 7, 1| |Log|13, 6, 1| |Loop|21, 19, 16, 13, 11, 1| -|LpNormalization|1| -|LpPool|18, 11, 2, 1| +|LpNormalization|22, 1| +|LpPool|22, 18, 11, 2, 1| |MatMul|13, 9, 1| |MatMulInteger|10| |Max|13, 12, 8, 6, 1| -|MaxPool|12, 11, 10, 8, 1| -|MaxRoiPool|1| -|MaxUnpool|11, 9| +|MaxPool|22, 12, 11, 10, 8, 1| +|MaxRoiPool|22, 1| +|MaxUnpool|22, 11, 9| |Mean|13, 8, 6, 1| |MelWeightMatrix|17| |Min|13, 12, 8, 6, 1| |Mod|13, 10| |Mul|14, 13, 7, 6, 1| -|Multinomial|7| +|Multinomial|22, 7| |Neg|13, 6, 1| |NonMaxSuppression|11, 10| |NonZero|13, 9| @@ -108,11 +108,11 @@ For an operator input/output's differentiability, it can be differentiable, |QLinearConv|10| |QLinearMatMul|21, 10| |QuantizeLinear|21, 19, 13, 10| -|RNN|14, 7, 1| -|RandomNormal|1| -|RandomNormalLike|1| -|RandomUniform|1| -|RandomUniformLike|1| +|RNN|22, 14, 7, 1| +|RandomNormal|22, 1| +|RandomNormalLike|22, 1| +|RandomUniform|22, 1| +|RandomUniformLike|22, 1| |Reciprocal|13, 6, 1| |ReduceMax|20, 18, 13, 12, 11, 1| |ReduceMean|18, 13, 11, 1| @@ -123,8 +123,8 @@ For an operator input/output's differentiability, it can be differentiable, |Reshape|21, 19, 14, 13, 5, 1| |Resize|19, 18, 13, 11, 10| |ReverseSequence|10| -|RoiAlign|16, 10| -|Round|11| +|RoiAlign|22, 16, 10| +|Round|22, 11| |STFT|17| |Scan|21, 19, 16, 11, 9, 8| |Scatter (deprecated)|11, 9| @@ -139,8 +139,8 @@ For an operator input/output's differentiability, it can be differentiable, |Shape|21, 19, 15, 13, 1| |Sigmoid|13, 6, 1| |Sign|13, 9| -|Sin|7| -|Sinh|9| +|Sin|22, 7| +|Sinh|22, 9| |Size|21, 19, 13, 1| |Slice|13, 11, 10, 1| |SpaceToDepth|13, 1| @@ -153,7 +153,7 @@ For an operator input/output's differentiability, it can be differentiable, |StringSplit|20| |Sub|14, 13, 7, 6, 1| |Sum|13, 8, 6, 1| -|Tan|7| +|Tan|22, 7| |Tanh|13, 6, 1| |TfIdfVectorizer|9| |Tile|13, 6, 1| @@ -167,28 +167,28 @@ For an operator input/output's differentiability, it can be differentiable, |Xor|7, 1| |**Function**|**Since version**|**Function version**| |AffineGrid|20|20| -|Bernoulli|15|15| +|Bernoulli|22, 15|22| |BlackmanWindow|17|17| |CastLike|21, 19, 15|21| |Celu|12|12| |CenterCropPad|18|18| |Clip|13, 12, 11, 6, 1|13| |DynamicQuantizeLinear|11|11| -|Elu|6, 1|18| +|Elu|22, 6, 1|18| |Gelu|20|20| |GreaterOrEqual|16, 12|16| |GroupNormalization|21, 18|21| |HammingWindow|17|17| |HannWindow|17|17| -|HardSigmoid|6, 1|18| -|HardSwish|14|14| +|HardSigmoid|22, 6, 1|18| +|HardSwish|22, 14|22| |LayerNormalization|17|17, 18| |LeakyRelu|16, 6, 1|16| |LessOrEqual|16, 12|16| |LogSoftmax|13, 11, 1|13, 18| |MeanVarianceNormalization|13, 9|13, 18| -|Mish|18|18| -|NegativeLogLikelihoodLoss|13, 12|13| +|Mish|22, 18|22| +|NegativeLogLikelihoodLoss|22, 13, 12|22| |PRelu|16, 9, 7, 6, 1|16| |Range|11|11| |ReduceL1|18, 13, 11, 1|18| @@ -197,14 +197,14 @@ For an operator input/output's differentiability, it can be differentiable, |ReduceLogSumExp|18, 13, 11, 1|18| |ReduceSumSquare|18, 13, 11, 1|18| |Relu|14, 13, 6, 1|18| -|Selu|6, 1|18| +|Selu|22, 6, 1|18| |SequenceMap|17|17| |Shrink|9|18| |Softmax|13, 11, 1|13, 18| |SoftmaxCrossEntropyLoss|13, 12|13| -|Softplus|1|18| -|Softsign|1|18| -|ThresholdedRelu|10|18| +|Softplus|22, 1|18| +|Softsign|22, 1|18| +|ThresholdedRelu|22, 10|18| ### ai.onnx.preview.training |**Operator**|**Since version**|| @@ -296,7 +296,9 @@ def abs(input: np.ndarray) -> np.ndarray: # noqa: A001 #### Version -This version of the operator has been available since version 7 of the default ONNX operator set. +This version of the operator has been available since version 22 of the default ONNX operator set. + +Other versions of this operator: 7 #### Inputs @@ -315,7 +317,7 @@ This version of the operator has been available since version 7 of the default O #### Type Constraints
-
T : tensor(float16), tensor(float), tensor(double)
+
T : tensor(bfloat16), tensor(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.
@@ -350,7 +352,9 @@ expect(node, inputs=[x], outputs=[y], name="test_acos") #### Version -This version of the operator has been available since version 9 of the default ONNX operator set. +This version of the operator has been available since version 22 of the default ONNX operator set. + +Other versions of this operator: 9 #### Inputs @@ -369,7 +373,7 @@ This version of the operator has been available since version 9 of the default O #### Type Constraints
-
T : tensor(float16), tensor(float), tensor(double)
+
T : tensor(bfloat16), tensor(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.
@@ -1398,7 +1402,9 @@ expect( #### Version -This version of the operator has been available since version 7 of the default ONNX operator set. +This version of the operator has been available since version 22 of the default ONNX operator set. + +Other versions of this operator: 7 #### Inputs @@ -1417,7 +1423,7 @@ This version of the operator has been available since version 7 of the default O #### Type Constraints
-
T : tensor(float16), tensor(float), tensor(double)
+
T : tensor(bfloat16), tensor(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.
@@ -1452,7 +1458,9 @@ expect(node, inputs=[x], outputs=[y], name="test_asin") #### Version -This version of the operator has been available since version 9 of the default ONNX operator set. +This version of the operator has been available since version 22 of the default ONNX operator set. + +Other versions of this operator: 9 #### Inputs @@ -1471,7 +1479,7 @@ This version of the operator has been available since version 9 of the default O #### Type Constraints
-
T : tensor(float16), tensor(float), tensor(double)
+
T : tensor(bfloat16), tensor(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.
@@ -1506,7 +1514,9 @@ expect(node, inputs=[x], outputs=[y], name="test_asinh") #### Version -This version of the operator has been available since version 7 of the default ONNX operator set. +This version of the operator has been available since version 22 of the default ONNX operator set. + +Other versions of this operator: 7 #### Inputs @@ -1525,7 +1535,7 @@ This version of the operator has been available since version 7 of the default O #### Type Constraints
-
T : tensor(float16), tensor(float), tensor(double)
+
T : tensor(bfloat16), tensor(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.
@@ -1560,7 +1570,9 @@ expect(node, inputs=[x], outputs=[y], name="test_atan") #### Version -This version of the operator has been available since version 9 of the default ONNX operator set. +This version of the operator has been available since version 22 of the default ONNX operator set. + +Other versions of this operator: 9 #### Inputs @@ -1579,7 +1591,7 @@ This version of the operator has been available since version 9 of the default O #### Type Constraints
-
T : tensor(float16), tensor(float), tensor(double)
+
T : tensor(bfloat16), tensor(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.
@@ -1645,9 +1657,9 @@ expect(node, inputs=[x], outputs=[y], name="test_atanh") #### Version -This version of the operator has been available since version 19 of the default ONNX operator set. +This version of the operator has been available since version 22 of the default ONNX operator set. -Other versions of this operator: 1, 7, 10, 11 +Other versions of this operator: 1, 7, 10, 11, 19 #### Attributes @@ -1685,7 +1697,7 @@ Other versions of this operator: 1, -
T : tensor(float16), tensor(float), tensor(double)
+
T : tensor(bfloat16), tensor(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.
@@ -2611,7 +2623,9 @@ expect( #### Version -This version of the operator has been available since version 15 of the default ONNX operator set. +This version of the operator has been available since version 22 of the default ONNX operator set. + +Other versions of this operator:
15 #### Attributes @@ -2639,9 +2653,9 @@ This version of the operator has been available since version 15 of the default #### Type Constraints
-
T1 : tensor(float16), tensor(float), tensor(double)
+
T1 : tensor(bfloat16), tensor(float16), tensor(float), tensor(double)
Constrain input types to float tensors.
-
T2 : tensor(float16), tensor(float), tensor(double), tensor(bfloat16), tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(bool)
+
T2 : tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(bfloat16), tensor(float16), tensor(float), tensor(double), tensor(bool)
Constrain output types to all numeric tensors and bool tensors.
@@ -3874,9 +3888,9 @@ Other versions of this operator: 15, -
T1 : tensor(float16), tensor(float), tensor(double), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(bool), tensor(string), tensor(bfloat16), tensor(float8e4m3fn), tensor(float8e4m3fnuz), tensor(float8e5m2), tensor(float8e5m2fnuz), tensor(uint4), tensor(int4)
+
T1 : tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(bfloat16), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(float8e4m3fn), tensor(float8e4m3fnuz), tensor(float8e5m2), tensor(float8e5m2fnuz), tensor(uint4), tensor(int4)
Constrain input types. Casting from complex is not supported.
-
T2 : tensor(float16), tensor(float), tensor(double), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(bool), tensor(string), tensor(bfloat16), tensor(float8e4m3fn), tensor(float8e4m3fnuz), tensor(float8e5m2), tensor(float8e5m2fnuz), tensor(uint4), tensor(int4)
+
T2 : tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(bfloat16), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(float8e4m3fn), tensor(float8e4m3fnuz), tensor(float8e5m2), tensor(float8e5m2fnuz), tensor(uint4), tensor(int4)
Constrain output types. Casting to complex is not supported.
@@ -5547,9 +5561,9 @@ expect(node, inputs=[x], outputs=[y], name="test_constantofshape_int_zeros") #### Version -This version of the operator has been available since version 11 of the default ONNX operator set. +This version of the operator has been available since version 22 of the default ONNX operator set. -Other versions of this operator:
1 +Other versions of this operator: 1, 11 #### Attributes @@ -5589,7 +5603,7 @@ Other versions of this operator: 1 #### Type Constraints
-
T : tensor(float16), tensor(float), tensor(double)
+
T : tensor(bfloat16), tensor(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.
@@ -6005,9 +6019,9 @@ expect( #### Version -This version of the operator has been available since version 11 of the default ONNX operator set. +This version of the operator has been available since version 22 of the default ONNX operator set. -Other versions of this operator: 1 +Other versions of this operator: 1, 11 #### Attributes @@ -6051,7 +6065,7 @@ Other versions of this operator: 1 #### Type Constraints
-
T : tensor(float16), tensor(float), tensor(double)
+
T : tensor(bfloat16), tensor(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.
@@ -6492,7 +6506,9 @@ expect(node, inputs=[x, W], outputs=[y], name="test_convtranspose_pads") #### Version -This version of the operator has been available since version 7 of the default ONNX operator set. +This version of the operator has been available since version 22 of the default ONNX operator set. + +Other versions of this operator: 7 #### Inputs @@ -6511,7 +6527,7 @@ This version of the operator has been available since version 7 of the default O #### Type Constraints
-
T : tensor(float16), tensor(float), tensor(double)
+
T : tensor(bfloat16), tensor(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.
@@ -6546,7 +6562,9 @@ expect(node, inputs=[x], outputs=[y], name="test_cos") #### Version -This version of the operator has been available since version 9 of the default ONNX operator set. +This version of the operator has been available since version 22 of the default ONNX operator set. + +Other versions of this operator: 9 #### Inputs @@ -6565,7 +6583,7 @@ This version of the operator has been available since version 9 of the default O #### Type Constraints
-
T : tensor(float16), tensor(float), tensor(double)
+
T : tensor(bfloat16), tensor(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.
@@ -6942,7 +6960,9 @@ expect( #### Version -This version of the operator has been available since version 19 of the default ONNX operator set. +This version of the operator has been available since version 22 of the default ONNX operator set. + +Other versions of this operator: 19 #### Attributes @@ -6986,7 +7006,7 @@ This version of the operator has been available since version 19 of the default #### Type Constraints
-
T : tensor(float16), tensor(float), tensor(double)
+
T : tensor(bfloat16), tensor(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.
@@ -7758,7 +7778,9 @@ expect( #### Version -This version of the operator has been available since version 11 of the default ONNX operator set. +This version of the operator has been available since version 22 of the default ONNX operator set. + +Other versions of this operator: 11 #### Inputs @@ -7777,7 +7799,7 @@ This version of the operator has been available since version 11 of the default #### Type Constraints
-
T : tensor(float16), tensor(float), tensor(double)
+
T : tensor(bfloat16), tensor(float16), tensor(float), tensor(double)
Constrain input and output types to floating-point tensors.
@@ -7927,9 +7949,9 @@ expect(node, inputs=[x, y], outputs=[z], name="test_div_bcast") #### Version -This version of the operator has been available since version 13 of the default ONNX operator set. +This version of the operator has been available since version 22 of the default ONNX operator set. -Other versions of this operator: 1, 6, 7, 10, 12 +Other versions of this operator: 1, 6, 7, 10, 12, 13 #### Attributes @@ -7961,9 +7983,9 @@ Other versions of this operator: 1, -
T : tensor(float16), tensor(float), tensor(double), tensor(bfloat16)
+
T : tensor(bfloat16), tensor(float16), tensor(float), tensor(double), tensor(float8e4m3fn), tensor(float8e4m3fnuz), tensor(float8e5m2), tensor(float8e5m2fnuz)
Constrain input and output types to float tensors.
-
T1 : tensor(float16), tensor(float), tensor(double)
+
T1 : tensor(bfloat16), tensor(float16), tensor(float), tensor(double), tensor(float8e4m3fn), tensor(float8e4m3fnuz), tensor(float8e5m2), tensor(float8e5m2fnuz)
Constrain input 'ratio' types to float tensors.
T2 : tensor(bool)
Constrain output 'mask' types to boolean tensors.
@@ -8513,9 +8535,9 @@ expect(node, inputs=[X], outputs=[Y], name="test_einsum_transpose") #### Version -This version of the operator has been available since version 6 of the default ONNX operator set. +This version of the operator has been available since version 22 of the default ONNX operator set. -Other versions of this operator:
1 +Other versions of this operator: 1, 6 #### Attributes @@ -8541,7 +8563,7 @@ Other versions of this operator: 1 #### Type Constraints
-
T : tensor(float16), tensor(float), tensor(double)
+
T : tensor(bfloat16), tensor(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.
@@ -8779,7 +8801,7 @@ Other versions of this operator: 1, 9 #### Attributes @@ -8957,9 +8981,9 @@ This version of the operator has been available since version 9 of the default O #### Type Constraints
-
T1 : tensor(float16), tensor(float), tensor(double), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(bool)
+
T1 : tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(bfloat16), tensor(float16), tensor(float), tensor(double), tensor(bool)
Constrain input types. Strings and complex are not supported.
-
T2 : tensor(float16), tensor(float), tensor(double), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(bool)
+
T2 : tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(bfloat16), tensor(float16), tensor(float), tensor(double), tensor(bool)
Constrain output types. Strings and complex are not supported.
@@ -9256,9 +9280,9 @@ expect(node, inputs=[x], outputs=[y], name="test_floor") #### Version -This version of the operator has been available since version 14 of the default ONNX operator set. +This version of the operator has been available since version 22 of the default ONNX operator set. -Other versions of this operator: 1, 3, 7 +Other versions of this operator: 1, 3, 7, 14 #### Attributes @@ -9310,7 +9334,7 @@ Other versions of this operator: 1, 1 #### Inputs @@ -10451,7 +10477,7 @@ This version of the operator has been available since version 1 of the default O #### Type Constraints
-
T : tensor(float16), tensor(float), tensor(double)
+
T : tensor(bfloat16), tensor(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.
@@ -10510,9 +10536,9 @@ expect(node, inputs=[x], outputs=[y], name="test_globalaveragepool_precomputed") #### Version -This version of the operator has been available since version 2 of the default ONNX operator set. +This version of the operator has been available since version 22 of the default ONNX operator set. -Other versions of this operator: 1 +Other versions of this operator: 1, 2 #### Attributes @@ -10551,7 +10577,9 @@ Other versions of this operator: 1 #### Version -This version of the operator has been available since version 1 of the default ONNX operator set. +This version of the operator has been available since version 22 of the default ONNX operator set. + +Other versions of this operator: 1 #### Inputs @@ -10570,7 +10598,7 @@ This version of the operator has been available since version 1 of the default O #### Type Constraints
-
T : tensor(float16), tensor(float), tensor(double)
+
T : tensor(bfloat16), tensor(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.
@@ -10800,9 +10828,9 @@ Other versions of this operator: 12 #### Version -This version of the operator has been available since version 20 of the default ONNX operator set. +This version of the operator has been available since version 22 of the default ONNX operator set. -Other versions of this operator: 16 +Other versions of this operator: 16, 20 #### Attributes @@ -10834,9 +10862,9 @@ Other versions of this operator: 16 #### Type Constraints
-
T1 : tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128)
+
T1 : tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(bfloat16), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128)
Constrain input `X` and output `Y` types to all tensor types.
-
T2 : tensor(float16), tensor(float), tensor(double)
+
T2 : tensor(bfloat16), tensor(float16), tensor(float), tensor(double)
Constrain grid types to float tensors.
@@ -11757,9 +11785,9 @@ expect(node, inputs=[size], outputs=[y], name="test_hannwindow_symmetric") #### Version -This version of the operator has been available since version 6 of the default ONNX operator set. +This version of the operator has been available since version 22 of the default ONNX operator set. -Other versions of this operator: 1 +Other versions of this operator: 1, 6 #### Attributes @@ -11787,7 +11815,7 @@ Other versions of this operator: 1 #### Type Constraints
-
T : tensor(float16), tensor(float), tensor(double)
+
T : tensor(bfloat16), tensor(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.
@@ -11841,7 +11869,9 @@ expect(node, inputs=[x], outputs=[y], name="test_hardsigmoid_default") #### Version -This version of the operator has been available since version 14 of the default ONNX operator set. +This version of the operator has been available since version 22 of the default ONNX operator set. + +Other versions of this operator: 14 #### Inputs @@ -11860,7 +11890,7 @@ This version of the operator has been available since version 14 of the default #### Type Constraints
-
T : tensor(float16), tensor(float), tensor(double)
+
T : tensor(bfloat16), tensor(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.
@@ -12708,9 +12738,9 @@ expect( #### Version -This version of the operator has been available since version 6 of the default ONNX operator set. +This version of the operator has been available since version 22 of the default ONNX operator set. -Other versions of this operator: 1 +Other versions of this operator: 1, 6 #### Attributes @@ -12740,7 +12770,7 @@ Other versions of this operator: #### Type Constraints
-
T : tensor(float16), tensor(float), tensor(double)
+
T : tensor(bfloat16), tensor(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.
@@ -13161,9 +13191,9 @@ expect(node, inputs=[x], outputs=[y], name="test_lrn") #### Version -This version of the operator has been available since version 14 of the default ONNX operator set. +This version of the operator has been available since version 22 of the default ONNX operator set. -Other versions of this operator:
1, 7 +Other versions of this operator: 1, 7, 14 #### Attributes @@ -13221,7 +13251,7 @@ Other versions of this operator: 1, 1 #### Attributes @@ -14733,7 +14765,7 @@ This version of the operator has been available since version 1 of the default O #### Type Constraints
-
T : tensor(float16), tensor(float), tensor(double)
+
T : tensor(bfloat16), tensor(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.
@@ -14766,9 +14798,9 @@ This version of the operator has been available since version 1 of the default O #### Version -This version of the operator has been available since version 18 of the default ONNX operator set. +This version of the operator has been available since version 22 of the default ONNX operator set. -Other versions of this operator: 1, 2, 11 +Other versions of this operator: 1, 2, 11, 18 #### Attributes @@ -14806,7 +14838,7 @@ Other versions of this operator: 1, -
T : tensor(float16), tensor(float), tensor(double)
+
T : tensor(bfloat16), tensor(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.
@@ -15425,9 +15457,9 @@ for op_dtype in all_numeric_dtypes: #### Version -This version of the operator has been available since version 12 of the default ONNX operator set. +This version of the operator has been available since version 22 of the default ONNX operator set. -Other versions of this operator:
1, 8, 10, 11 +Other versions of this operator: 1, 8, 10, 11, 12 #### Attributes @@ -15467,7 +15499,7 @@ Other versions of this operator: 1, -
T : tensor(float16), tensor(float), tensor(double), tensor(int8), tensor(uint8)
+
T : tensor(bfloat16), tensor(float16), tensor(float), tensor(double), tensor(int8), tensor(uint8)
Constrain input and output types to float and 8 bit tensors.
I : tensor(int64)
Constrain index tensor to int64
@@ -16294,7 +16326,9 @@ expect( #### Version -This version of the operator has been available since version 1 of the default ONNX operator set. +This version of the operator has been available since version 22 of the default ONNX operator set. + +Other versions of this operator:
1 #### Attributes @@ -16324,7 +16358,7 @@ This version of the operator has been available since version 1 of the default O #### Type Constraints
-
T : tensor(float16), tensor(float), tensor(double)
+
T : tensor(bfloat16), tensor(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.
@@ -16352,9 +16386,9 @@ This version of the operator has been available since version 1 of the default O #### Version -This version of the operator has been available since version 11 of the default ONNX operator set. +This version of the operator has been available since version 22 of the default ONNX operator set. -Other versions of this operator: 9 +Other versions of this operator: 9, 11 #### Attributes @@ -16388,7 +16422,7 @@ Other versions of this operator: 9 #### Type Constraints
-
T1 : tensor(float16), tensor(float), tensor(double)
+
T1 : tensor(bfloat16), tensor(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.
T2 : tensor(int64)
Constrain index tensor to int64
@@ -16881,7 +16915,9 @@ for op_dtype in all_numeric_dtypes: #### Version -This version of the operator has been available since version 18 of the default ONNX operator set. +This version of the operator has been available since version 22 of the default ONNX operator set. + +Other versions of this operator: 18 #### Inputs @@ -16900,7 +16936,7 @@ This version of the operator has been available since version 18 of the default #### Type Constraints
-
T : tensor(float16), tensor(float), tensor(double)
+
T : tensor(bfloat16), tensor(float16), tensor(float), tensor(double)
Constrain input X and output types to float tensors.
@@ -17317,7 +17353,9 @@ expect(node, inputs=[x, y], outputs=[z], name="test_mul_bcast") #### Version -This version of the operator has been available since version 7 of the default ONNX operator set. +This version of the operator has been available since version 22 of the default ONNX operator set. + +Other versions of this operator: 7 #### Attributes @@ -17347,7 +17385,7 @@ This version of the operator has been available since version 7 of the default O #### Type Constraints
-
T1 : tensor(float16), tensor(float), tensor(double)
+
T1 : tensor(bfloat16), tensor(float16), tensor(float), tensor(double)
Constrain input types to float tensors.
T2 : tensor(int32), tensor(int64)
Constrain output types to integral tensors.
@@ -17518,9 +17556,9 @@ expect(node, inputs=[x], outputs=[y], name="test_neg") #### Version -This version of the operator has been available since version 13 of the default ONNX operator set. +This version of the operator has been available since version 22 of the default ONNX operator set. -Other versions of this operator: 12 +Other versions of this operator: 12, 13 #### Attributes @@ -17552,7 +17590,7 @@ Other versions of this operator: 1, 7 +Other versions of this operator: 1, 7, 14 #### Attributes @@ -20853,7 +20891,7 @@ Other versions of this operator: 1, 1 #### Attributes @@ -21052,7 +21092,7 @@ This version of the operator has been available since version 1 of the default O #### Type Constraints
-
T : tensor(float16), tensor(float), tensor(double)
+
T : tensor(bfloat16), tensor(float16), tensor(float), tensor(double)
Constrain output types to float tensors.
@@ -21069,7 +21109,9 @@ This version of the operator has been available since version 1 of the default O #### Version -This version of the operator has been available since version 1 of the default ONNX operator set. +This version of the operator has been available since version 22 of the default ONNX operator set. + +Other versions of this operator: 1 #### Attributes @@ -21101,9 +21143,9 @@ This version of the operator has been available since version 1 of the default O #### Type Constraints
-
T1 : tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128)
+
T1 : tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(bfloat16), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128)
Constrain to any tensor type. If the dtype attribute is not provided this must be a valid output type.
-
T2 : tensor(float16), tensor(float), tensor(double)
+
T2 : tensor(bfloat16), tensor(float16), tensor(float), tensor(double)
Constrain output types to float tensors.
@@ -21119,7 +21161,9 @@ This version of the operator has been available since version 1 of the default O #### Version -This version of the operator has been available since version 1 of the default ONNX operator set. +This version of the operator has been available since version 22 of the default ONNX operator set. + +Other versions of this operator: 1 #### Attributes @@ -21149,7 +21193,7 @@ This version of the operator has been available since version 1 of the default O #### Type Constraints
-
T : tensor(float16), tensor(float), tensor(double)
+
T : tensor(bfloat16), tensor(float16), tensor(float), tensor(double)
Constrain output types to float tensors.
@@ -21166,7 +21210,9 @@ This version of the operator has been available since version 1 of the default O #### Version -This version of the operator has been available since version 1 of the default ONNX operator set. +This version of the operator has been available since version 22 of the default ONNX operator set. + +Other versions of this operator: 1 #### Attributes @@ -21198,9 +21244,9 @@ This version of the operator has been available since version 1 of the default O #### Type Constraints
-
T1 : tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128)
+
T1 : tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(bfloat16), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128)
Constrain to any tensor type. If the dtype attribute is not provided this must be a valid output type.
-
T2 : tensor(float16), tensor(float), tensor(double)
+
T2 : tensor(bfloat16), tensor(float16), tensor(float), tensor(double)
Constrain output types to float tensors.
@@ -26592,9 +26638,9 @@ expect( #### Version -This version of the operator has been available since version 16 of the default ONNX operator set. +This version of the operator has been available since version 22 of the default ONNX operator set. -Other versions of this operator: 10 +Other versions of this operator: 10, 16 #### Attributes @@ -26634,7 +26680,7 @@ Other versions of this operator: 10 #### Type Constraints
-
T1 : tensor(float16), tensor(float), tensor(double)
+
T1 : tensor(bfloat16), tensor(float16), tensor(float), tensor(double)
Constrain types to float tensors.
T2 : tensor(int64)
Constrain types to int tensors.
@@ -26979,7 +27025,9 @@ expect( #### Version -This version of the operator has been available since version 11 of the default ONNX operator set. +This version of the operator has been available since version 22 of the default ONNX operator set. + +Other versions of this operator: 11 #### Inputs @@ -26998,7 +27046,7 @@ This version of the operator has been available since version 11 of the default #### Type Constraints
-
T : tensor(float16), tensor(float), tensor(double)
+
T : tensor(bfloat16), tensor(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.
@@ -28224,9 +28272,9 @@ expect( #### Version -This version of the operator has been available since version 6 of the default ONNX operator set. +This version of the operator has been available since version 22 of the default ONNX operator set. -Other versions of this operator: 1 +Other versions of this operator: 1, 6 #### Attributes @@ -28254,7 +28302,7 @@ Other versions of this operator: 1 #### Type Constraints
-
T : tensor(float16), tensor(float), tensor(double)
+
T : tensor(bfloat16), tensor(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.
@@ -29280,7 +29328,9 @@ expect(node, inputs=[x], outputs=[y], name="test_sign") #### Version -This version of the operator has been available since version 7 of the default ONNX operator set. +This version of the operator has been available since version 22 of the default ONNX operator set. + +Other versions of this operator: 7 #### Inputs @@ -29299,7 +29349,7 @@ This version of the operator has been available since version 7 of the default O #### Type Constraints
-
T : tensor(float16), tensor(float), tensor(double)
+
T : tensor(bfloat16), tensor(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.
@@ -29334,7 +29384,9 @@ expect(node, inputs=[x], outputs=[y], name="test_sin") #### Version -This version of the operator has been available since version 9 of the default ONNX operator set. +This version of the operator has been available since version 22 of the default ONNX operator set. + +Other versions of this operator: 9 #### Inputs @@ -29353,7 +29405,7 @@ This version of the operator has been available since version 9 of the default O #### Type Constraints
-
T : tensor(float16), tensor(float), tensor(double)
+
T : tensor(bfloat16), tensor(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.
@@ -31263,7 +31315,9 @@ expect( #### Version -This version of the operator has been available since version 1 of the default ONNX operator set. +This version of the operator has been available since version 22 of the default ONNX operator set. + +Other versions of this operator: 1 #### Inputs @@ -31282,7 +31336,7 @@ This version of the operator has been available since version 1 of the default O #### Type Constraints
-
T : tensor(float16), tensor(float), tensor(double)
+
T : tensor(bfloat16), tensor(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.
@@ -31319,7 +31373,9 @@ expect(node, inputs=[x], outputs=[y], name="test_softplus") #### Version -This version of the operator has been available since version 1 of the default ONNX operator set. +This version of the operator has been available since version 22 of the default ONNX operator set. + +Other versions of this operator: 1 #### Inputs @@ -31338,7 +31394,7 @@ This version of the operator has been available since version 1 of the default O #### Type Constraints
-
T : tensor(float16), tensor(float), tensor(double)
+
T : tensor(bfloat16), tensor(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.
@@ -32938,7 +32994,9 @@ expect( #### Version -This version of the operator has been available since version 7 of the default ONNX operator set. +This version of the operator has been available since version 22 of the default ONNX operator set. + +Other versions of this operator: 7 #### Inputs @@ -32957,7 +33015,7 @@ This version of the operator has been available since version 7 of the default O #### Type Constraints
-
T : tensor(float16), tensor(float), tensor(double)
+
T : tensor(bfloat16), tensor(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.
@@ -33013,7 +33071,7 @@ Other versions of this operator: 1, 10 #### Attributes @@ -33403,7 +33463,7 @@ This version of the operator has been available since version 10 of the default #### Type Constraints
-
T : tensor(float16), tensor(float), tensor(double)
+
T : tensor(bfloat16), tensor(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.
diff --git a/onnx/backend/test/data/node/test_acos/model.onnx b/onnx/backend/test/data/node/test_acos/model.onnx index cc7c695f5588ed43639e0722d75a83299f51f716..206ab391191916d449768262724d6fbc44399a16 100644 GIT binary patch delta 10 RcmYdJX5!$Q$dte+1^^5E0p$Py delta 10 RcmYdJX5wI;$dtgy4gd?o0nY#c diff --git a/onnx/backend/test/data/node/test_acos_example/model.onnx b/onnx/backend/test/data/node/test_acos_example/model.onnx index c986dd6ba90992524b98a16775de129aa618901f..8b29942f13fdea61b8ebcaa7ded79ed50712728c 100644 GIT binary patch delta 10 Rcma!!X5!$Q$P~dS1^^380nGpa delta 10 Rcma!!X5wI;$P~fI4gd=i0k;4E diff --git a/onnx/backend/test/data/node/test_acosh/model.onnx b/onnx/backend/test/data/node/test_acosh/model.onnx index 9651625d11c26d371c54d933778912aa4499995b..916010c59b8294b727797c6025fd15302404717c 100644 GIT binary patch delta 10 RcmYdIW#ZtP$dtq=1^^5w0qXz& delta 10 RcmYdIW#V9&$dts$2>=WC0oVWl diff --git a/onnx/backend/test/data/node/test_acosh_example/model.onnx b/onnx/backend/test/data/node/test_acosh_example/model.onnx index 42eb9a1641a6f19797462e4c0643e15df0c409d8..1fbfea14d9c8346f9f6a25e2415bc29eb155b73a 100644 GIT binary patch delta 10 Rcma!zW#ZtP$P~pW1^^3q0n-2g delta 10 Rcma!zW#V9&$P~rM2>=U60l)wN diff --git a/onnx/backend/test/data/node/test_asin/model.onnx b/onnx/backend/test/data/node/test_asin/model.onnx index a7caca1b1a5905f86e96e7c94f458978ac96f55e..e7d9804878429f691543d2d886c59fc5c6a87fdd 100644 GIT binary patch delta 10 RcmYdJX5!$Q$dte+1^^5E0p$Py delta 10 RcmYdJX5wI;$dtgy4gd?o0nY#c diff --git a/onnx/backend/test/data/node/test_asin_example/model.onnx b/onnx/backend/test/data/node/test_asin_example/model.onnx index a20be5821295924dc54cfb4101f826ffa5c6cd09..22ddea64b64239018f4ea8ff5ccdd48823ba3be1 100644 GIT binary patch delta 10 Rcma!!X5!$Q$P~dS1^^380nGpa delta 10 Rcma!!X5wI;$P~fI4gd=i0k;4E diff --git a/onnx/backend/test/data/node/test_asinh/model.onnx b/onnx/backend/test/data/node/test_asinh/model.onnx index 922c0aef88e7865eb008384168a723c177004bc7..96d1db46bdffb745c260aaf584df161ebcfa3170 100644 GIT binary patch delta 10 RcmYdIW#ZtP$dtq=1^^5w0qXz& delta 10 RcmYdIW#V9&$dts$2>=WC0oVWl diff --git a/onnx/backend/test/data/node/test_asinh_example/model.onnx b/onnx/backend/test/data/node/test_asinh_example/model.onnx index 7d02941a6752f8e6d7b738bb11c22981cdf21cc5..eb4778849764a833435fbb51a65e100ec261876d 100644 GIT binary patch delta 10 Rcma!zW#ZtP$P~pW1^^3q0n-2g delta 10 Rcma!zW#V9&$P~rM2>=U60l)wN diff --git a/onnx/backend/test/data/node/test_atan/model.onnx b/onnx/backend/test/data/node/test_atan/model.onnx index 7cd0e8e041693c6f36ae9defcf2c5ad23958aa8f..4f2f5deee1db2b71326397d3e6dede319da7e122 100644 GIT binary patch delta 10 RcmYdJX5!$Q$dte+1^^5E0p$Py delta 10 RcmYdJX5wI;$dtgy4gd?o0nY#c diff --git a/onnx/backend/test/data/node/test_atan_example/model.onnx b/onnx/backend/test/data/node/test_atan_example/model.onnx index 7b9525ee935dac2709820f7d56dd3f608718ded0..bfe9894a60d1613e3d3edd52488e54d58d831714 100644 GIT binary patch delta 10 Rcma!!X5!$Q$P~dS1^^380nGpa delta 10 Rcma!!X5wI;$P~fI4gd=i0k;4E diff --git a/onnx/backend/test/data/node/test_atanh/model.onnx b/onnx/backend/test/data/node/test_atanh/model.onnx index 3d1716d23a512d9ec9660f69629af9c2552a116a..a1db102d3e7c3fb11718e81f807604ddfdfb4033 100644 GIT binary patch delta 10 RcmYdIW#ZtP$dtq=1^^5w0qXz& delta 10 RcmYdIW#V9&$dts$2>=WC0oVWl diff --git a/onnx/backend/test/data/node/test_atanh_example/model.onnx b/onnx/backend/test/data/node/test_atanh_example/model.onnx index 4e6d72d6a750e45834d4bde0dc47441dd001ab9c..d0efa30625fce1d7a3678468ba5b586f47bf7bb9 100644 GIT binary patch delta 10 Rcma!zW#ZtP$P~pW1^^3q0n-2g delta 10 Rcma!zW#V9&$P~rM2>=U60l)wN diff --git a/onnx/backend/test/data/node/test_averagepool_1d_default/model.onnx b/onnx/backend/test/data/node/test_averagepool_1d_default/model.onnx index 14c0309706c7bffb898a3490193b2877a2b5de77..36f6b96a29b72520484a3c8b8dbc7b3333c2d89c 100644 GIT binary patch delta 12 TcmbQpIFXTwgKHvFAEOum5xD|! delta 12 TcmbQpIFXTwgL5KNAEPh;5wHSn diff --git a/onnx/backend/test/data/node/test_averagepool_2d_ceil/model.onnx b/onnx/backend/test/data/node/test_averagepool_2d_ceil/model.onnx index bb02ae58ca6dc045ee9ea61a7aab62368a61ace6..168a69574f57201bfc0fdf78529c9d5aba53ba90 100644 GIT binary patch delta 12 TcmdnXxR;TMgKHwwE=Dl`76k(J delta 12 TcmdnXxR;TMgL5L&E=FMh75oD6 diff --git a/onnx/backend/test/data/node/test_averagepool_2d_default/model.onnx b/onnx/backend/test/data/node/test_averagepool_2d_default/model.onnx index bd1efdecb29da0558795db8de0c3ea8d45285c0e..11a1b13ef759d46ceade4803416f70bab2667654 100644 GIT binary patch delta 12 TcmbQkIERsmgKHwwOhz#P63haU delta 12 TcmbQkIERsmgL5L&Oh#b<62k(H diff --git a/onnx/backend/test/data/node/test_averagepool_2d_dilations/model.onnx b/onnx/backend/test/data/node/test_averagepool_2d_dilations/model.onnx index 7de2313225ea1e6d2d1a341d9a3b0f3472bf20f0..ce3c86ed527fb2a459e7d0c12b45fc911981dd78 100644 GIT binary patch delta 12 Tcmcb{c#V;XgKHwwWkxXo7yDgKHwwYDO^t6pjMO delta 12 TcmZ3-xQ>yDgL5L&YDQrI6omrB diff --git a/onnx/backend/test/data/node/test_averagepool_3d_default/model.onnx b/onnx/backend/test/data/node/test_averagepool_3d_default/model.onnx index 638a15930cdd5abc52a2d7bd720e42d0ebbd03f8..4d1bcc84eb0b05b239a3745c7e0989d3aeb1a0c1 100644 GIT binary patch delta 12 TcmZ3+xQvmBgKHwwVn#6l6UG9t delta 12 TcmZ3+xQvmBgL5L&Vn$&A6TJeg diff --git a/onnx/backend/test/data/node/test_averagepool_3d_dilations_large_count_include_pad_is_0_ceil_mode_is_False/model.onnx b/onnx/backend/test/data/node/test_averagepool_3d_dilations_large_count_include_pad_is_0_ceil_mode_is_False/model.onnx index a46212cff768a169c6279de261732b73ecfc5584..7a757250d57b038290686e598571e50941c68a15 100644 GIT binary patch delta 13 UcmZ3_w4RBHgKHy`4kM!&02VX?ZU6uP delta 13 UcmZ3_w4RBHgL5O34kM#502V3&Y5)KL diff --git a/onnx/backend/test/data/node/test_averagepool_3d_dilations_large_count_include_pad_is_0_ceil_mode_is_True/model.onnx b/onnx/backend/test/data/node/test_averagepool_3d_dilations_large_count_include_pad_is_0_ceil_mode_is_True/model.onnx index 2354fbfb7b18381024c4a1553a5d26ce59766eef..894e85fdd48c3e02945dd87d4b4d894494d65d89 100644 GIT binary patch delta 13 UcmZ3-w2q01gKHy`HY1}L02UYmYXATM delta 13 UcmZ3-w2q01gL5O3HY1}j02U4cX8-^I diff --git a/onnx/backend/test/data/node/test_averagepool_3d_dilations_large_count_include_pad_is_1_ceil_mode_is_False/model.onnx b/onnx/backend/test/data/node/test_averagepool_3d_dilations_large_count_include_pad_is_1_ceil_mode_is_False/model.onnx index 79a25a22420d73b1149d910989b2c28d29b43455..eafe7769f21a050b69a64257bd0c57916969e5b3 100644 GIT binary patch delta 13 UcmZ3_w4RBHgKHy`4kM!&02VX?ZU6uP delta 13 UcmZ3_w4RBHgL5O34kM#502V3&Y5)KL diff --git a/onnx/backend/test/data/node/test_averagepool_3d_dilations_large_count_include_pad_is_1_ceil_mode_is_True/model.onnx b/onnx/backend/test/data/node/test_averagepool_3d_dilations_large_count_include_pad_is_1_ceil_mode_is_True/model.onnx index 310be73f5384725693a70c9086fb64e4eda2b486..27f6fb1f595bd2678be7a6c5f0665a15d175debb 100644 GIT binary patch delta 13 UcmZ3-w2q01gKHy`HY1}L02UYmYXATM delta 13 UcmZ3-w2q01gL5O3HY1}j02U4cX8-^I diff --git a/onnx/backend/test/data/node/test_averagepool_3d_dilations_small/model.onnx b/onnx/backend/test/data/node/test_averagepool_3d_dilations_small/model.onnx index 7a36e26fce9bc3d5fa2e1bbd3b3b3b6d7158e7a9..883cdbefa603396efaa86a823a32e6f4af833bbc 100644 GIT binary patch delta 12 TcmaFG_==Hn+a diff --git a/onnx/backend/test/data/node/test_basic_deform_conv_without_padding/model.onnx b/onnx/backend/test/data/node/test_basic_deform_conv_without_padding/model.onnx index 5cbe5291d4c7a1105c9236231fec4632b58d0503..1767e752c883e7c30837e54c032e363048a783a9 100644 GIT binary patch delta 13 UcmX@ibeM^WgKHy`10$mt02pKfssI20 delta 13 UcmX@ibeM^WgL5O310$m_02o>VrT_o{ diff --git a/onnx/backend/test/data/node/test_bernoulli/model.onnx b/onnx/backend/test/data/node/test_bernoulli/model.onnx index 47b791d688556421f70fa7a392a178e00ead5749..702c9960fd4579906c5ac7e04926532742cfdea1 100644 GIT binary patch delta 10 Rcma!zW#ZtP$P~pW1^^3q0n-2g delta 10 Rcma!zW#ZtN$P~rM4*&~g0m=XX diff --git a/onnx/backend/test/data/node/test_bernoulli_double/model.onnx b/onnx/backend/test/data/node/test_bernoulli_double/model.onnx index f954a8dc57f900d89b4100a9f7b24767cf5ac6ab..929e4196e3bb931de8541a8006ee106a9984720e 100644 GIT binary patch delta 10 RcmXRaV&dSM$du101^^940ulfK delta 10 RcmXRaV&dSK$du2>4*(4_0to;B diff --git a/onnx/backend/test/data/node/test_bernoulli_double_expanded/model.onnx b/onnx/backend/test/data/node/test_bernoulli_double_expanded/model.onnx index fcf5060902691c96cd7bdc04977dbc5efd0726b1..558e38225b0355325c4079ffce9b7157ec3555f6 100644 GIT binary patch delta 13 UcmdnTypNfQgKHzxZbn8i02%HB9RL6T delta 13 UcmdnTypNfQgJUDpZbn9a02$c>6aWAK diff --git a/onnx/backend/test/data/node/test_bernoulli_expanded/model.onnx b/onnx/backend/test/data/node/test_bernoulli_expanded/model.onnx index 785d12f46e8844b828436eebb26535324daaa94a..c510c81bf60d6b55982d726dde3859c11aa59225 100644 GIT binary patch delta 13 UcmbQqJd>G;gKHzxG)6`-02Sf_t^fc4 delta 13 UcmbQqJd>G;gJUDpG)6{#02R#wr2qf` diff --git a/onnx/backend/test/data/node/test_bernoulli_seed/model.onnx b/onnx/backend/test/data/node/test_bernoulli_seed/model.onnx index 85f1b82b5e2cd64bd83a9d0f76094fd604de82dd..ea69f01240e29ce6a26d1fcc8f7828d1fead8603 100644 GIT binary patch delta 10 RcmXRaV&dSM$du101^^940ulfK delta 10 RcmXRaV&dSK$du2>4*(4_0to;B diff --git a/onnx/backend/test/data/node/test_bernoulli_seed_expanded/model.onnx b/onnx/backend/test/data/node/test_bernoulli_seed_expanded/model.onnx index e195a6ce93c7db0da36e3fc0d79e30ed56b4b811..3236cbfec81e686d5317f62fb01fc11197520789 100644 GIT binary patch delta 13 UcmX@Ye1w^agKHzxK}JR~02-D9F8}}l delta 13 UcmX@Ye1w^agJUDpK}JS?02+YxR#NLgKHwwDn>B?6mxR#NLgKZ+yDn@Pq6jB1V diff --git a/onnx/backend/test/data/node/test_convtranspose_autopad_same/model.onnx b/onnx/backend/test/data/node/test_convtranspose_autopad_same/model.onnx index b65ac368787d02af907345cc30fc94c8943b9298..cce8a8eccef8455a596ed75f263dd01172092d0f 100644 GIT binary patch delta 12 Tcmcb?c!QCNgKHwwRYoxY7^nkA delta 12 Tcmcb?c!QCNgKZ+yRYq1? delta 12 TcmdnPxQCI6gKZ+yPDXA370CkQ diff --git a/onnx/backend/test/data/node/test_convtranspose_kernel_shape/model.onnx b/onnx/backend/test/data/node/test_convtranspose_kernel_shape/model.onnx index e0948814573b9b5132b2f623086d001d73bbaa62..4d328e9cdf2b47e26f5a0adac764b05673a34e8e 100644 GIT binary patch delta 13 UcmeBT>SAKz;M&N<&d4YR01_wx{{R30 delta 13 UcmeBT>SAKzVB5&V&dA6O01^QK@Bjb+ diff --git a/onnx/backend/test/data/node/test_convtranspose_output_shape/model.onnx b/onnx/backend/test/data/node/test_convtranspose_output_shape/model.onnx index 344a21a8c3c4fb86b54350f9a2450cd443d11ec3..8b9b86216a3e42b0ea9552f6518f3b283a8b8805 100644 GIT binary patch delta 12 Tcmcb@c!iOPgKHwwMMg0I7(@d) delta 12 Tcmcb@c!iOPgKZ+yMMiD_7$E~I diff --git a/onnx/backend/test/data/node/test_convtranspose_pad/model.onnx b/onnx/backend/test/data/node/test_convtranspose_pad/model.onnx index bb593e66f076af1002b2976e1b2017da44cc5ad5..b972e2653e20c1f338e781e970d91f93af23e38e 100644 GIT binary patch delta 12 TcmX@hc$SfggKHwwDMm2>7nK7g delta 12 TcmX@hc$SfggKZ+yDMoGp7jgp@ diff --git a/onnx/backend/test/data/node/test_convtranspose_pads/model.onnx b/onnx/backend/test/data/node/test_convtranspose_pads/model.onnx index b17ff879e67a54657ea0227e24f80196f9646866..1e7116447cb70685f3f58a884fe1b1162677a638 100644 GIT binary patch delta 12 TcmX@Xc!H6MgKHwwQARNU7Z?K; delta 12 TcmX@Xc!H6MgKZ+yQATb67WD%M diff --git a/onnx/backend/test/data/node/test_cos/model.onnx b/onnx/backend/test/data/node/test_cos/model.onnx index 5ec0d0c3247d06b1ca670c45f1a77f6985884e5e..9e1260acfac92ee79207aee84bab640f06c19183 100644 GIT binary patch delta 10 RcmYdHWa8kO$P~vY1^^4t0p9=s delta 10 RcmYdHWa40+$P~xO4gd?60m%RW diff --git a/onnx/backend/test/data/node/test_cos_example/model.onnx b/onnx/backend/test/data/node/test_cos_example/model.onnx index 6726ce0230ae08a60af3e7e6ad03b080ddbbf655..b74fcbe66e2cec92728b1c9d02e85d85b2bdddd9 100644 GIT binary patch delta 10 Rcma!yWa8kO$P~sX1^^2n0mlFU delta 10 Rcma!yWa40+$P~uN4gd=00kHr8 diff --git a/onnx/backend/test/data/node/test_cosh/model.onnx b/onnx/backend/test/data/node/test_cosh/model.onnx index 68d88a42c038c4c48b7bf432d188e0196ed1bdc9..e74ac53653ee14bc7b84f676b035010e7670a4d5 100644 GIT binary patch delta 10 RcmYdJX5!$Q$dte+1^^5E0p$Py delta 10 RcmYdJX5wI($dtgy2>=Vr0nz{f diff --git a/onnx/backend/test/data/node/test_cosh_example/model.onnx b/onnx/backend/test/data/node/test_cosh_example/model.onnx index db9eec4d05155d6b9d574783755525f7e0ca9cb2..7dc7ab4dc5f74b841c9db0bd978921edc14a5837 100644 GIT binary patch delta 10 Rcma!!X5!$Q$P~dS1^^380nGpa delta 10 Rcma!!X5wI($P~fI2>=Tl0lEMH diff --git a/onnx/backend/test/data/node/test_deform_conv_with_mask_bias/model.onnx b/onnx/backend/test/data/node/test_deform_conv_with_mask_bias/model.onnx index 3f5948c98a2284ff489fdaf87b2eed9e721602b2..a48939459b2258bbe04b252cc4f43eba13d7f441 100644 GIT binary patch delta 13 UcmdnSw2g_0gKHy`F(acG02cTHg8%>k delta 13 UcmdnSw2g_0gL5O3F(ace02b~7e*gdg diff --git a/onnx/backend/test/data/node/test_deform_conv_with_multiple_offset_groups/model.onnx b/onnx/backend/test/data/node/test_deform_conv_with_multiple_offset_groups/model.onnx index 2adbaa41881f32fb3f958393c9e0272c0626e66e..bb2b554d5b070f9843d73d262e5de136b134b857 100644 GIT binary patch delta 13 UcmbQoG>?gigKHy`G$W%J02EjPI{*Lx delta 13 UcmbQoG>?gigL5O3G$W%h02EFFHvj+t diff --git a/onnx/backend/test/data/node/test_det_2d/model.onnx b/onnx/backend/test/data/node/test_det_2d/model.onnx index c1ceae61c0ec21e5497e99ce49cd2c5446d0d2fc..b2f1c52802f34681b340255905c0392da7a83a9b 100644 GIT binary patch delta 10 RcmWFuVdCJL$P~yZ1^^1O0k{AF delta 10 RcmWFuVd7w$$P~!P4FC#{0jU50 diff --git a/onnx/backend/test/data/node/test_det_nd/model.onnx b/onnx/backend/test/data/node/test_det_nd/model.onnx index 07a153a1c58b26dca3ea9e1f61a521b52e1633f2..26d4c871da4e274940c070bb8017756069beb1e1 100644 GIT binary patch delta 10 Rcma!vVdCJL$P~#a1^^3U0nh*d delta 10 Rcma!vVd7w$$P~%Q4FC&20l@$O diff --git a/onnx/backend/test/data/node/test_dropout_default/model.onnx b/onnx/backend/test/data/node/test_dropout_default/model.onnx index 184e44851900156a0d8cb7b648db3f8ed5421857..be75e7dbb46ca7f0b1cc0984e644c2df07a32692 100644 GIT binary patch delta 10 Rcmb=cW8&bN$W+ZJ1^^CD0yY2u delta 10 Rcmb=cW8z?+$W+b93jhu?0xAFi diff --git a/onnx/backend/test/data/node/test_dropout_default_mask/model.onnx b/onnx/backend/test/data/node/test_dropout_default_mask/model.onnx index ef7b9fa8e33239015cfe83fc611b5b1a15a9ebb9..f45cd7a608049b61d1ef3456d90a72d673b6fb54 100644 GIT binary patch delta 12 TcmZ3$xPXy~gKHwwTt+bf6EFgv delta 12 TcmZ3$xPXy~gMA{?Tt;316BPoI diff --git a/onnx/backend/test/data/node/test_dropout_default_mask_ratio/model.onnx b/onnx/backend/test/data/node/test_dropout_default_mask_ratio/model.onnx index 5b1f07074959e9289a84cfc771b1a8c7c1895437..343482d6c83c816ce478e9c954c91a8567edd426 100644 GIT binary patch delta 12 TcmdnSxQ&sCgKHwwW=1gp6;=Y^ delta 12 TcmdnSxQ&sCgMA{?W=38B6*~gd diff --git a/onnx/backend/test/data/node/test_dropout_default_ratio/model.onnx b/onnx/backend/test/data/node/test_dropout_default_ratio/model.onnx index 8deb0febfd3d5a3837cd69b4a7ecf3bb1be40b81..3f079ba46215fe1d877fe3c777b1f3906c795475 100644 GIT binary patch delta 12 TcmbQjIE9gkgKHwwL`E?H5(ENz delta 12 TcmbQjIE9gkgMA{?L`Gf!5$OVM diff --git a/onnx/backend/test/data/node/test_elu/model.onnx b/onnx/backend/test/data/node/test_elu/model.onnx index 141d895bba6c22541df3449a66f9d3e187b35f01..dd1003b7c4c300cdcdce2d4233e024b32ed46891 100644 GIT binary patch delta 10 RcmXRaV&dSM$du101^^940ulfK delta 10 RcmXRaV&Y()$du2>1^^8V0s8;| diff --git a/onnx/backend/test/data/node/test_elu_default/model.onnx b/onnx/backend/test/data/node/test_elu_default/model.onnx index 4007dc3368838f7645f474faf7e6b147defc1168..3a979710e0214ae8c3045826ccc67aff8aa8fe40 100644 GIT binary patch delta 10 Rcmd1IWa8kO$dtw?1^^6z0rvm^ delta 10 Rcmd1IWa40+$dty&1^^630pI`t diff --git a/onnx/backend/test/data/node/test_elu_example/model.onnx b/onnx/backend/test/data/node/test_elu_example/model.onnx index 9ea0c1df665fc0de368d7264b0d67026e350332b..99091bb51347fb399c2107824b451015151db6e8 100644 GIT binary patch delta 10 Rcmd1GV&dSM$dt|~1^^6}0r~&{ delta 10 Rcmd1GV&Y()$dt~=1^^6P0pkDw diff --git a/onnx/backend/test/data/node/test_eyelike_populate_off_main_diagonal/model.onnx b/onnx/backend/test/data/node/test_eyelike_populate_off_main_diagonal/model.onnx index 0b98de4160d929140a1f5c4a8905d1690eca012c..60a068b8e20c3d02aa9aa29c92ad3f84b38fa0c3 100644 GIT binary patch delta 12 TcmbQjIE9gkgKHwwL`E?H5(ENz delta 12 TcmbQjIE9gkgJmMqL`F^k5z_)^ diff --git a/onnx/backend/test/data/node/test_eyelike_with_dtype/model.onnx b/onnx/backend/test/data/node/test_eyelike_with_dtype/model.onnx index ca799fb505d238c46936791742564f7b0df9b235..8599bfdb16a67ae6ab8fb832dab0219f5b4257ee 100644 GIT binary patch delta 10 Rcmb=bV&dSM$W+cK1^^BA0xAFi delta 10 Rcmb=bV&Y(#$W+eA2>=bn0v7-P diff --git a/onnx/backend/test/data/node/test_eyelike_without_dtype/model.onnx b/onnx/backend/test/data/node/test_eyelike_without_dtype/model.onnx index 6c7db0b132ad494e8cd819ace02277c087943364..584a3328605989a093883ae662e42c8a027cbbb3 100644 GIT binary patch delta 10 Rcmd1LXX4=Y!0rmg@ diff --git a/onnx/backend/test/data/node/test_globalaveragepool/model.onnx b/onnx/backend/test/data/node/test_globalaveragepool/model.onnx index f270439c98f13754cf48797109e695355428dcaa..1441d1ec365074d3507ad2de5505286440c57af1 100644 GIT binary patch delta 12 TcmZo=Y-MEP;F`$P#3%*;5RC#& delta 12 TcmZo=Y-MEPV4ld-#K;H$5KaOy diff --git a/onnx/backend/test/data/node/test_globalaveragepool_precomputed/model.onnx b/onnx/backend/test/data/node/test_globalaveragepool_precomputed/model.onnx index e2100fe8ce61f957b26c3b400f15624eef85bb4b..de1544e9697daac312bb874453b136938f8e7fc9 100644 GIT binary patch delta 12 TcmbQpIFXTwgKHvFAEOum5xD|! delta 12 TcmbQpIFXTwgLxuTA0s0G5qbhu diff --git a/onnx/backend/test/data/node/test_globalmaxpool/model.onnx b/onnx/backend/test/data/node/test_globalmaxpool/model.onnx index d641ee8bddb09c444a56e84f2128a7b4c2823bcc..007fe816ba56526128c7ad32011f00a45dd4ac97 100644 GIT binary patch delta 10 Rcmb=eW#ZtP$W+BB1^^B?0y6*r delta 10 Rcmb=eW#V9-$W+D12mlTF0v7-P diff --git a/onnx/backend/test/data/node/test_globalmaxpool_precomputed/model.onnx b/onnx/backend/test/data/node/test_globalmaxpool_precomputed/model.onnx index d1cac7c23be38c8c194128391d282fab1158ba7f..69ac33125c21c2de83e68e5c7d996e3d8997dd4c 100644 GIT binary patch delta 12 TcmeBV>||u(;F`$P#wZ2=5b*+8 delta 12 TcmeBV>||u(V4ld-#>fZ&5V8V2 diff --git a/onnx/backend/test/data/node/test_gridsample/model.onnx b/onnx/backend/test/data/node/test_gridsample/model.onnx index 334b8cca0ab2ae4675ba0a26123ba83e5f7a9546..1d17074133eb32dda2f02b32b0ab7053d2cd82e8 100644 GIT binary patch delta 12 TcmaFJ_>hr_gKHwwJw`DA8Hod7 delta 12 TcmaFJ_>hr_gL5L&Jw_1#8G!>{ diff --git a/onnx/backend/test/data/node/test_gridsample_aligncorners_true/model.onnx b/onnx/backend/test/data/node/test_gridsample_aligncorners_true/model.onnx index 40b0e8b6fab4feed92e827b4618d3a747c66747e..6def3c0df966c79be2c72f56a01e681693caeda2 100644 GIT binary patch delta 12 Tcmcb~c$1NdgKHwwHAXQ27{LQc delta 12 Tcmcb~c$1NdgL5L&HAWEt7`X#R diff --git a/onnx/backend/test/data/node/test_gridsample_bicubic/model.onnx b/onnx/backend/test/data/node/test_gridsample_bicubic/model.onnx index 14cb848688146427246d0712b1f0b48300550856..307d6519556d18aeccc5f870527bb2548f76454e 100644 GIT binary patch delta 12 TcmdnNxPy_2gKHwwRz@)Z6^H`n delta 12 TcmdnNxPy_2gL5L&Rz?v36@UWc diff --git a/onnx/backend/test/data/node/test_gridsample_bicubic_align_corners_0_additional_1/model.onnx b/onnx/backend/test/data/node/test_gridsample_bicubic_align_corners_0_additional_1/model.onnx index ec7876ecf275e9257b42cd67601fce658ec13078..cf230353d27e2afef8930dfb3bf24f560a544526 100644 GIT binary patch delta 12 TcmaFO_?nT4gKHww3q~;j8iNCW delta 12 TcmaFO_?nT4gL5L&3q}zD8hZnL diff --git a/onnx/backend/test/data/node/test_gridsample_bicubic_align_corners_1_additional_1/model.onnx b/onnx/backend/test/data/node/test_gridsample_bicubic_align_corners_1_additional_1/model.onnx index 19f37d045239bfaba7fff6243eb3dc0cd168fb9d..a617350a9af440934aff8c9e59dc30551ce2b84a 100644 GIT binary patch delta 12 TcmaFO_?nT4gKHww3q~;j8iNCW delta 12 TcmaFO_?nT4gL5L&3q}zD8hZnL diff --git a/onnx/backend/test/data/node/test_gridsample_bilinear/model.onnx b/onnx/backend/test/data/node/test_gridsample_bilinear/model.onnx index af5a0847336936466524592dbf2015e6a6cbe2c3..bb1b2ebd769ba8ba81f8cc6165235ef49e81a680 100644 GIT binary patch delta 12 TcmdnRxQmgAgKHwwc1AG(6}kfK delta 12 TcmdnRxQmgAgL5L&c195Z6|w^9 diff --git a/onnx/backend/test/data/node/test_gridsample_bilinear_align_corners_0_additional_1/model.onnx b/onnx/backend/test/data/node/test_gridsample_bilinear_align_corners_0_additional_1/model.onnx index 188342495b8a2cd40b5842b95742d68de11e9983..07ac23f070b6f472b8a219ecbd2b5a4e6931639f 100644 GIT binary patch delta 12 TcmaFM_?D50gKHwwD@HK@8npw3 delta 12 TcmaFM_?D50gL5L&D@G9j8m$9@ diff --git a/onnx/backend/test/data/node/test_gridsample_bilinear_align_corners_1_additional_1/model.onnx b/onnx/backend/test/data/node/test_gridsample_bilinear_align_corners_1_additional_1/model.onnx index e5686c3c37d5f5b1aee7a4c91a60ca6fb56ca52f..c17ad25317b924f1975699f2faf20e80edbfd7af 100644 GIT binary patch delta 12 TcmaFM_?D50gKHwwD@HK@8npw3 delta 12 TcmaFM_?D50gL5L&D@G9j8m$9@ diff --git a/onnx/backend/test/data/node/test_gridsample_border_padding/model.onnx b/onnx/backend/test/data/node/test_gridsample_border_padding/model.onnx index 01fbcef9853af9a67d7f6b35aa1ee0b7e0401779..3c548c90ff6c0e514e6466703f89ab734671d237 100644 GIT binary patch delta 12 TcmX@Xc!H6MgKHwwQARNU7Z?K; delta 12 TcmX@Xc!H6MgL5L&QAQB}7Z3vz diff --git a/onnx/backend/test/data/node/test_gridsample_nearest/model.onnx b/onnx/backend/test/data/node/test_gridsample_nearest/model.onnx index bacb4086e0d019d64cacfaa85cff9c6515d16e02..294090833dbdd69f2cedebded868ee607d6eec66 100644 GIT binary patch delta 12 TcmdnRxQmgAgKHwwc1AG(6}kfK delta 12 TcmdnRxQmgAgL5L&c195Z6|w^9 diff --git a/onnx/backend/test/data/node/test_gridsample_nearest_align_corners_0_additional_1/model.onnx b/onnx/backend/test/data/node/test_gridsample_nearest_align_corners_0_additional_1/model.onnx index 2003d009b6d9a0b13367dbfe2792e61703262059..245dcbfba8a9495f7f03b381390e69c5535d7783 100644 GIT binary patch delta 12 TcmaFM_?D50gKHwwD@HK@8npw3 delta 12 TcmaFM_?D50gL5L&D@G9j8m$9@ diff --git a/onnx/backend/test/data/node/test_gridsample_nearest_align_corners_1_additional_1/model.onnx b/onnx/backend/test/data/node/test_gridsample_nearest_align_corners_1_additional_1/model.onnx index 2a105639f0d92e47f23fe34ae28c96136ec3dec5..de22147ab3546b7cded516ae6d005bb9eda6bccf 100644 GIT binary patch delta 12 TcmaFM_?D50gKHwwD@HK@8npw3 delta 12 TcmaFM_?D50gL5L&D@G9j8m$9@ diff --git a/onnx/backend/test/data/node/test_gridsample_reflection_padding/model.onnx b/onnx/backend/test/data/node/test_gridsample_reflection_padding/model.onnx index 9c7f5cf9ab9c67ec6ad5d5aca4fd2e3bef8601c4..203f1434d3449e4d7f67478ce6f6503cb51ec988 100644 GIT binary patch delta 12 Tcmcb>c!80LgKHwwSw=Ac7vKXf delta 12 Tcmcb>c!80LgL5L&Sw;~67uW+U diff --git a/onnx/backend/test/data/node/test_gridsample_volumetric_bilinear_align_corners_0/model.onnx b/onnx/backend/test/data/node/test_gridsample_volumetric_bilinear_align_corners_0/model.onnx index 02d940fb147d64c5d205fafc279b7cbcfa8aff75..7f90268223a6c9897ad6c9c9c2070262690d53c3 100644 GIT binary patch delta 12 Tcmey)_??l7gKHww7e+Av8?OVS delta 12 Tcmey)_??l7gL5L&7e)~P8>a)H diff --git a/onnx/backend/test/data/node/test_gridsample_volumetric_bilinear_align_corners_1/model.onnx b/onnx/backend/test/data/node/test_gridsample_volumetric_bilinear_align_corners_1/model.onnx index af0b03cd424f5360f7d9fd4ba939eddb58bab0d2..e3781ffb3b6bc31b9173ab2f3d8cbdc5edb99506 100644 GIT binary patch delta 12 Tcmey)_??l7gKHww7e+Av8?OVS delta 12 Tcmey)_??l7gL5L&7e)~P8>a)H diff --git a/onnx/backend/test/data/node/test_gridsample_volumetric_nearest_align_corners_0/model.onnx b/onnx/backend/test/data/node/test_gridsample_volumetric_nearest_align_corners_0/model.onnx index d87cce0017be68d7840b273556765b0d6c50f64a..706252dc07350bfbf8708bfa0812572d6f5fe3e9 100644 GIT binary patch delta 12 Tcmey)_??l7gKHww7e+Av8?OVS delta 12 Tcmey)_??l7gL5L&7e)~P8>a)H diff --git a/onnx/backend/test/data/node/test_gridsample_volumetric_nearest_align_corners_1/model.onnx b/onnx/backend/test/data/node/test_gridsample_volumetric_nearest_align_corners_1/model.onnx index dd789c06a01c81b8cbb88d8d4bfaf4f07b985431..2eb750c678e7a06a3aa1a295831784dd8a972247 100644 GIT binary patch delta 12 Tcmey)_??l7gKHww7e+Av8?OVS delta 12 Tcmey)_??l7gL5L&7e)~P8>a)H diff --git a/onnx/backend/test/data/node/test_gridsample_zeros_padding/model.onnx b/onnx/backend/test/data/node/test_gridsample_zeros_padding/model.onnx index fb2b33369d93e5187a7770c211cabed731035977..7ed92ef5311a9825cbc09c9e8eac1610ae532c12 100644 GIT binary patch delta 12 TcmX@cc#M&WgKHwwVMZ|k7UlyG delta 12 TcmX@cc#M&WgL5L&VMY-E7TyC5 diff --git a/onnx/backend/test/data/node/test_gru_batchwise/model.onnx b/onnx/backend/test/data/node/test_gru_batchwise/model.onnx index 8d50456cb680a3b4818655f242baad2ed5d72796..6e8a50d56f382acfcf99fbadbcc85182b54e015b 100644 GIT binary patch delta 12 TcmaFO_?nT4gKHww3q~;j8iNCW delta 12 TcmaFO_?nT4gMA{?3r0Qw8fgP` diff --git a/onnx/backend/test/data/node/test_gru_defaults/model.onnx b/onnx/backend/test/data/node/test_gru_defaults/model.onnx index 36fcba152af486f12f6ebd4e9c51b81d9967f1c6..07689ef41373700a811dfb04e454685aaca239ec 100644 GIT binary patch delta 12 TcmdnXxR;TMgKHwwE=Dl`76k(J delta 12 TcmdnXxR;TMgMA{?E=E2873%`( diff --git a/onnx/backend/test/data/node/test_gru_seq_length/model.onnx b/onnx/backend/test/data/node/test_gru_seq_length/model.onnx index 2c9c2489c53a7ce8a68d4635cb511c72492d3e84..5f0369e753023d1b17c40b1f88f0a3afb2003128 100644 GIT binary patch delta 12 Tcmcc4c%6}ngKHww6-F@t7>@%( delta 12 Tcmcc4c%6}ngMA{?6-GV)7|$i%;F`$P&L{=|5efoa delta 12 TcmeBT>|$i%V4ld-&d3G;5YPfe diff --git a/onnx/backend/test/data/node/test_hardswish/model.onnx b/onnx/backend/test/data/node/test_hardswish/model.onnx index f72506caa0fcd1cfbe9b6a2c0777800e0e828e02..0ed0b32120822955a78d58ed1031acca80892ebd 100644 GIT binary patch delta 10 Rcmd1JW#ZtP$dtt>1^^7$0s{a5 delta 10 Rcmd1JW#V9;$dtv%2LKGd0r&s_ diff --git a/onnx/backend/test/data/node/test_hardswish_expanded/model.onnx b/onnx/backend/test/data/node/test_hardswish_expanded/model.onnx index ecfe4f31ba5f246b384fd399288a14ffc9fd052e..abe72af6be28a474e841f295b16879274122d3a4 100644 GIT binary patch delta 13 UcmeBT>SAKz;M&N<&d4YR01_wx{{R30 delta 13 UcmeBT>SAKzVBg5Z&dA6I01^uU^Z)<= diff --git a/onnx/backend/test/data/node/test_image_decoder_decode_jpeg2k_rgb/test_data_set_0/input_0.pb b/onnx/backend/test/data/node/test_image_decoder_decode_jpeg2k_rgb/test_data_set_0/input_0.pb index 66db10c971f7bc76eaf32994c299b2dd45aa8f93..5f4cb90f28a29a8bdea0b08b4c067fdb9f086b8b 100644 GIT binary patch delta 12 TcmaFM_m*$MeMX~=4|>@EC!Ynq delta 12 TcmaFM_m*$MeMW@ECzS=e diff --git a/onnx/backend/test/data/node/test_instancenorm_epsilon/model.onnx b/onnx/backend/test/data/node/test_instancenorm_epsilon/model.onnx index d6ac084c9754749da613a2d1f5f879246b843521..9cf84c252d0601ce7ed48fa66d246c4420fef0cb 100644 GIT binary patch delta 12 TcmX@dc#e^YgKHwwX+|*s7p?;+ delta 12 TcmX@dc#e^YgLxv;X+|~x7jy#= diff --git a/onnx/backend/test/data/node/test_instancenorm_example/model.onnx b/onnx/backend/test/data/node/test_instancenorm_example/model.onnx index 37a901970a2fc37397bebf60140a3ad4ef1aca92..ae190ddd6546ff0099768725e7b2658fcb717f62 100644 GIT binary patch delta 12 TcmdnZxSNrQgKHww4n{Em71ILm delta 12 TcmdnZxSNrQgLxv;4n{Tr6`2Cq diff --git a/onnx/backend/test/data/node/test_lppool_1d_default/model.onnx b/onnx/backend/test/data/node/test_lppool_1d_default/model.onnx index 8734aa23c9c2056224aa04b1372b5a84efa0b398..d3d882afbed24b11a6ed25a6b1c5f9d54afdded4 100644 GIT binary patch delta 12 TcmZ3)xQLO7gKHwwd`2+<6Ji3S delta 12 TcmZ3)xQLO7gJUAod`2Mv6H)@6 diff --git a/onnx/backend/test/data/node/test_lppool_2d_default/model.onnx b/onnx/backend/test/data/node/test_lppool_2d_default/model.onnx index 6d8e9eef7f9b7bee73a2566c335c09c01da37cc1..0cd55f03c51f0c76abd53f18492a91e8a4b1bf8f 100644 GIT binary patch delta 12 TcmbQkIERsmgKHwwOhz#P63haU delta 12 TcmbQkIERsmgJUAoOhzF961)P8 diff --git a/onnx/backend/test/data/node/test_lppool_2d_dilations/model.onnx b/onnx/backend/test/data/node/test_lppool_2d_dilations/model.onnx index 503ccff12b944fe818451eb8c24ecad9e65c3497..7970480a7dff811fcdd20fb620f5f7772ae96d98 100644 GIT binary patch delta 12 TcmX@Yc!ZIOgKHwwK}InE7PJEj delta 12 TcmX@Yc!ZIOgJUAoK}I0}7Ni3N diff --git a/onnx/backend/test/data/node/test_lppool_2d_pads/model.onnx b/onnx/backend/test/data/node/test_lppool_2d_pads/model.onnx index 73121feab9ba97acd22c6a5c5d0c855d75e1edb1..4d01b667e63fa2a8820678d468de55c3d4f26033 100644 GIT binary patch delta 12 TcmZ3(xQ3C5gKHwwN=7jN6kGzr delta 12 TcmZ3(xQ3C5gJUAoN=6|76ifoV diff --git a/onnx/backend/test/data/node/test_lppool_2d_same_lower/model.onnx b/onnx/backend/test/data/node/test_lppool_2d_same_lower/model.onnx index dbc14bf1a9bde9686e242f418e2753973cb87974..00afca88cc1c8b48d3f7114f56fbda1269cff5a6 100644 GIT binary patch delta 12 TcmdnRxQmgAgKHwwc1AG(6}kfK delta 12 TcmdnRxQmgAgJUAoc19rp6{-T} diff --git a/onnx/backend/test/data/node/test_lppool_2d_same_upper/model.onnx b/onnx/backend/test/data/node/test_lppool_2d_same_upper/model.onnx index 3216a2a29369b1114b7763de3a3cd7f78f8349e8..108b05ae157859e54026cf1534468808f1505b59 100644 GIT binary patch delta 12 TcmdnRxQmgAgKHwwc1AG(6}kfK delta 12 TcmdnRxQmgAgJUAoc19rp6{-T} diff --git a/onnx/backend/test/data/node/test_lppool_2d_strides/model.onnx b/onnx/backend/test/data/node/test_lppool_2d_strides/model.onnx index fa7064f299b99e6f0db6e37f26ae1fbe3ccaccb6..0ddc7b602cb368be841c99924a600d3e42881e43 100644 GIT binary patch delta 12 TcmZ3-xQ>yDgKHwwYDO^t6pjMO delta 12 TcmZ3-xQ>yDgJUAoYDOUd6n+B2 diff --git a/onnx/backend/test/data/node/test_lppool_3d_default/model.onnx b/onnx/backend/test/data/node/test_lppool_3d_default/model.onnx index e8e653d283820d0d6f4458563d7a253e31005d5c..becb512e64df1e7848442bbb4592a5f0b821f0fe 100644 GIT binary patch delta 12 TcmZ3+xQvmBgKHwwVn#6l6UG9t delta 12 TcmZ3+xQvmBgJUAoVn!hV6Se}X diff --git a/onnx/backend/test/data/node/test_lstm_batchwise/model.onnx b/onnx/backend/test/data/node/test_lstm_batchwise/model.onnx index a10fa1840dfa9be61e685c2600ea5c416107ae1d..29284301f7858d44374663886b815f2848047005 100644 GIT binary patch delta 12 TcmaFM_?D50gKHwwD@HK@8npw3 delta 12 TcmaFM_?D50gMA{?D@Hy58k+-p diff --git a/onnx/backend/test/data/node/test_lstm_defaults/model.onnx b/onnx/backend/test/data/node/test_lstm_defaults/model.onnx index 7e6a4af6806a7fbfbbf131170abd09ba2edb6a2b..a7bcc594141364ef42414183ef2a4d2f3d854874 100644 GIT binary patch delta 12 TcmdnbxSx@UgKHww9!4<$7B>R> delta 12 TcmdnbxSx@UgMA{?9!5R@799fc diff --git a/onnx/backend/test/data/node/test_lstm_with_initial_bias/model.onnx b/onnx/backend/test/data/node/test_lstm_with_initial_bias/model.onnx index 1574652ffda8e583f527326a781efff5b7cf58ea..caba9ced475860dc6341faf354ee69f16c431138 100644 GIT binary patch delta 12 TcmaFB_<)g#gKHwwT}Ckg8E^w$ delta 12 TcmaFB_<)g#gMA{?T}D0t8CC;R diff --git a/onnx/backend/test/data/node/test_lstm_with_peepholes/model.onnx b/onnx/backend/test/data/node/test_lstm_with_peepholes/model.onnx index c5e3f974c4f3ead374272fd35ea0f1dce7dbaa5d..21a905342a2a958d60f1bcc69e7f241201449e33 100644 GIT binary patch delta 13 Ucmey#^plB+gKHyG86%?@03J*OOaK4? delta 13 Ucmey#^plB+gMA}Y86zVf03I&`K>z>% diff --git a/onnx/backend/test/data/node/test_maxpool_1d_default/model.onnx b/onnx/backend/test/data/node/test_maxpool_1d_default/model.onnx index d72de35c8e71383a8ade56038ec16b43dfb45081..dba3be8456f30c41afc1c1066144e029043926da 100644 GIT binary patch delta 12 TcmeBV>||u(;F`$P#wZ2=5b*+8 delta 12 TcmeBV>||u(V4uj;#>fKz5Y+-q diff --git a/onnx/backend/test/data/node/test_maxpool_2d_ceil/model.onnx b/onnx/backend/test/data/node/test_maxpool_2d_ceil/model.onnx index 7515f602fcb260a49ef9e4f7fe5085185ca10742..4bb1e32b06df63667916f7c6d3603ec7ebfaa3df 100644 GIT binary patch delta 12 TcmdnWxRsHKgKHwwCPpy;6+Hso delta 12 TcmdnWxRsHKgMA{?CPp3r6(Iu9 diff --git a/onnx/backend/test/data/node/test_maxpool_2d_ceil_output_size_reduce_by_one/model.onnx b/onnx/backend/test/data/node/test_maxpool_2d_ceil_output_size_reduce_by_one/model.onnx index 0c136bf91b9d39a970c6373cedc77b43c754f4e7..c0b1842bfed08aff9cca2fedd053e3311a5db569 100644 GIT binary patch delta 12 TcmX@lc%G4ogKHww8AdSx7smrD delta 12 TcmX@lc%G4ogMA{?8Acue7pnsv diff --git a/onnx/backend/test/data/node/test_maxpool_2d_default/model.onnx b/onnx/backend/test/data/node/test_maxpool_2d_default/model.onnx index 820d4fdc4c40683c3cda9ec75f74038fc2a82e27..64c4aff71717c19ff8be4a2ecfa5f45a0e9e89ec 100644 GIT binary patch delta 12 TcmbQtIGK@&gKHww1V%9c5$ghX delta 12 TcmbQtIGK@&gMA{?1V$bJ5zhi@ diff --git a/onnx/backend/test/data/node/test_maxpool_2d_dilations/model.onnx b/onnx/backend/test/data/node/test_maxpool_2d_dilations/model.onnx index 19140d87016d1753d928ae42a9d850768f9978cb..3c304ff4aa4d6a4308cb70a8f09ac1f9f136f09e 100644 GIT binary patch delta 12 TcmdnPxQCI6gKHwwPDU{R73>1? delta 12 TcmdnPxQCI6gMA{?PDUO870?3Z diff --git a/onnx/backend/test/data/node/test_maxpool_2d_pads/model.onnx b/onnx/backend/test/data/node/test_maxpool_2d_pads/model.onnx index a917b6a9094a070d19cdf572c4b9f2acc708695f..98cbdbe0cc2b12572e3c739345fe09b1eb86785a 100644 GIT binary patch delta 12 TcmZ3&xP+03gKHwwLPjwF6O;m~ delta 12 TcmZ3&xP+03gMA{?LPj0{6Lc!80LgKHwwSw=Ac7vKXf delta 12 Tcmcb>c!80LgMA{?Sw@%( delta 12 Tcmcc4c%6}ngMA{?6-FKa7;^(Q diff --git a/onnx/backend/test/data/node/test_maxpool_3d_dilations_use_ref_impl_large/model.onnx b/onnx/backend/test/data/node/test_maxpool_3d_dilations_use_ref_impl_large/model.onnx index 3f27feed75163ab8cc6d48d00f9e42ab9315caa5..9509ad6e4a96beb60baf5172a28b9d673b43747e 100644 GIT binary patch delta 12 TcmaFQ_@0r8gKHww8%8kz8s`Ix delta 12 TcmaFQ_@0r8gMA{?8%7=g8p{KI diff --git a/onnx/backend/test/data/node/test_maxpool_with_argmax_2d_precomputed_pads/model.onnx b/onnx/backend/test/data/node/test_maxpool_with_argmax_2d_precomputed_pads/model.onnx index 352bd92939a8d9c644a4cbaf18ae292bbde022e2..3abdc840c54bd0838009402a6770b5e0b995b423 100644 GIT binary patch delta 12 Tcmcb^c!!aRgKHwwO-3;Q84Lqb delta 12 Tcmcb^c!!aRgMA{?O-3F781Mr{ diff --git a/onnx/backend/test/data/node/test_maxpool_with_argmax_2d_precomputed_strides/model.onnx b/onnx/backend/test/data/node/test_maxpool_with_argmax_2d_precomputed_strides/model.onnx index 2d1d01124b6abf6150fda339e372ef32873ce6de..a67af2fbf6bc1ac205f1101406c54c6ab1599ffd 100644 GIT binary patch delta 12 Tcmeyu_=S;)gKHwwM@BIK8)O5T delta 12 Tcmeyu_=S;)gMA{?M@Ak18%P6< diff --git a/onnx/backend/test/data/node/test_maxunpool_export_with_output_shape/model.onnx b/onnx/backend/test/data/node/test_maxunpool_export_with_output_shape/model.onnx index 117892ddba7a946deae906357a5f298058d033b9..04673fcc00ee06c392162e58d5102ae8c265450d 100644 GIT binary patch delta 13 UcmZo;YGY#J;M&N<%*ZGP01>zW^8f$< delta 13 UcmZo;YGY#JVB5&V%*epF delta 13 UcmX@leV&_%gMA~@8CFJK032uoSO5S3 diff --git a/onnx/backend/test/data/node/test_nllloss_NCd1/model.onnx b/onnx/backend/test/data/node/test_nllloss_NCd1/model.onnx index 470693beb696843a28f8b7c71831803bf965bc30..189dc6c3c00f4d1016cd76be56c94951b872ec74 100644 GIT binary patch delta 12 TcmdnZxSNrQgKHww4n{Em71ILm delta 12 TcmdnZxSNrQgMA{?4n|%86}ST9 diff --git a/onnx/backend/test/data/node/test_nllloss_NCd1_expanded/model.onnx b/onnx/backend/test/data/node/test_nllloss_NCd1_expanded/model.onnx index 20d2ead61dde197de53cde9e8133bee634ba413f..d63471102cdfca75be84ed97c8096988e34b3803 100644 GIT binary patch delta 13 UcmZ3+yNs8KgKHzxVm3xG02ny}?f?J) delta 13 UcmZ3+yNs8KgMA~@Vm3xz02mtr;s5{u diff --git a/onnx/backend/test/data/node/test_nllloss_NCd1_ii/model.onnx b/onnx/backend/test/data/node/test_nllloss_NCd1_ii/model.onnx index c855c5a81b352a16f9394e573c4528de269dedb2..b823ccbb2fbb19ed9ad6bd66ff6378ca2425568b 100644 GIT binary patch delta 12 Tcmcc2c$txjgKHww1x7Id7%Kxe delta 12 Tcmcc2c$txjgMA{?1x8)~7!U(1 diff --git a/onnx/backend/test/data/node/test_nllloss_NCd1_ii_expanded/model.onnx b/onnx/backend/test/data/node/test_nllloss_NCd1_ii_expanded/model.onnx index 34ee1d47465da7445c6f0141b02e42abd7a4503a..c75e4ea1f7880b050bda228674b1d1ce6b28f9a4 100644 GIT binary patch delta 13 Ucmdn5x?h!vgKHzx9wA0C039gSto&;M&NSto&VBg5Z!^p@B01}o00ssI2 diff --git a/onnx/backend/test/data/node/test_nllloss_NCd1_mean_weight_negative_ii_expanded/model.onnx b/onnx/backend/test/data/node/test_nllloss_NCd1_mean_weight_negative_ii_expanded/model.onnx index b1693806e2040d27e09236da77716b4831ec1b08..6f6a3f21ff2df36131d293a54b051ece4e957ff4 100644 GIT binary patch delta 13 UcmZ3fzfzxxgKHzxGI2&R02{0WOaK4? delta 13 UcmZ3fzfzxxgMA~@GI2&;02_`2KmY&$ diff --git a/onnx/backend/test/data/node/test_nllloss_NCd1_weight/model.onnx b/onnx/backend/test/data/node/test_nllloss_NCd1_weight/model.onnx index 360bc70a91cfeeec3572a14c87a9a5d329e0a5cb..902f9a0d0b05f85a659392b8cd9b6ef4c1690272 100644 GIT binary patch delta 12 TcmaFB_<)g#gKHwwT}Ckg8E^w$ delta 12 TcmaFB_<)g#gMA{?T}EC28C3&P diff --git a/onnx/backend/test/data/node/test_nllloss_NCd1_weight_expanded/model.onnx b/onnx/backend/test/data/node/test_nllloss_NCd1_weight_expanded/model.onnx index 11bcc65caf9c0f12ac221cf582636b026f25513f..2ec9919837f04a171fcfcd1489f60fed52648664 100644 GIT binary patch delta 13 UcmeAW?GR<+;M&O4%Ec%K02QqQr~m)} delta 13 UcmeAW?GR<+VBg5p%EibF02Pk{oB#j- diff --git a/onnx/backend/test/data/node/test_nllloss_NCd1_weight_ii/model.onnx b/onnx/backend/test/data/node/test_nllloss_NCd1_weight_ii/model.onnx index 086297336b6100ca4b29b7a1a795eec103ca0373..425f977a7850fd17bd21ab7bb64b5506fc9d022b 100644 GIT binary patch delta 12 Tcmeyt_=Ay&gKHwwS4J@a8^{Bu delta 12 Tcmeyt_=Ay&gMA{?S4Lg{8?6JH diff --git a/onnx/backend/test/data/node/test_nllloss_NCd1_weight_ii_expanded/model.onnx b/onnx/backend/test/data/node/test_nllloss_NCd1_weight_ii_expanded/model.onnx index 49017ae31583bd3e09ed5fdb311db13643161826..4f85c65e976aeda260ac8d70eeac620b3b94e80e 100644 GIT binary patch delta 13 UcmZ3Xxk8hPgKHzxQV~Wm02>1XIsgCw delta 13 UcmZ3Xxk8hPgMA~@QV~X802<{3E&u=k diff --git a/onnx/backend/test/data/node/test_nllloss_NCd1d2/model.onnx b/onnx/backend/test/data/node/test_nllloss_NCd1d2/model.onnx index 76f4cfaa31e02f60c1f73a4e4150678c582808ae..b91f1dfac1a7929a3d75b848348ca519592d3786 100644 GIT binary patch delta 12 Tcmcb}c#)BbgKHwwIYu!67x@D* delta 12 Tcmcb}c#)BbgMA{?IYwRp7v2LU diff --git a/onnx/backend/test/data/node/test_nllloss_NCd1d2_expanded/model.onnx b/onnx/backend/test/data/node/test_nllloss_NCd1d2_expanded/model.onnx index 72777a5c1f134b121dbd97d2a8eebbfd81c4b28f..e07381d064d3204418c3a3928e5e890487260280 100644 GIT binary patch delta 13 UcmZ3@vzmvAgKHy`1{GZ?gKHwwXGSpq8GZ?gMA{?XGUHC8+!wk diff --git a/onnx/backend/test/data/node/test_nllloss_NCd1d2_no_weight_reduction_mean_ii_expanded/model.onnx b/onnx/backend/test/data/node/test_nllloss_NCd1d2_no_weight_reduction_mean_ii_expanded/model.onnx index b07bb7d978d2f4edb12d2d85d6916669cccc85b6..59ee8e5d8a7da7ed1b5a1208ba149d4778151036 100644 GIT binary patch delta 13 UcmaE2@WgQi~s-t diff --git a/onnx/backend/test/data/node/test_nllloss_NCd1d2_with_weight/model.onnx b/onnx/backend/test/data/node/test_nllloss_NCd1d2_with_weight/model.onnx index afeef04cc45d2c66964eca8f8740727e4e0aea72..1fbc64e773b0582848b37ef873b8d4818b092365 100644 GIT binary patch delta 12 Tcmey(_?wZ5gKHww4@NNn91{bt delta 12 Tcmey(_?wZ5gMA{?4@O=98~6jG diff --git a/onnx/backend/test/data/node/test_nllloss_NCd1d2_with_weight_expanded/model.onnx b/onnx/backend/test/data/node/test_nllloss_NCd1d2_with_weight_expanded/model.onnx index bb187cea67ddb0490bb8a1052e7e378724290e61..5b9611af54a29102409a3cbf8041fb73cf7876ad 100644 GIT binary patch delta 13 UcmZ21xLA;hgKHzx0uDwo02o68?*IS* delta 13 UcmZ21xLA;hgMA~@0uDxA02n0#;{X5v diff --git a/onnx/backend/test/data/node/test_nllloss_NCd1d2_with_weight_reduction_mean/model.onnx b/onnx/backend/test/data/node/test_nllloss_NCd1d2_with_weight_reduction_mean/model.onnx index 19ae33e1f2ebe90c76fc5402063b21547a389289..5e928bfc0e5ebbd080d83174e56bf03e6ae8293f 100644 GIT binary patch delta 12 Tcmeyz_>Yl^gKHwwZ$>cy99{#s delta 12 Tcmeyz_>Yl^gMA{?Z$@4K976-F diff --git a/onnx/backend/test/data/node/test_nllloss_NCd1d2_with_weight_reduction_mean_expanded/model.onnx b/onnx/backend/test/data/node/test_nllloss_NCd1d2_with_weight_reduction_mean_expanded/model.onnx index 50f66085ace2d73e9bc549e24d6b21c0ce6edfea..d8bd66f76a2a8f99e6e1695e275e19a54127bb3f 100644 GIT binary patch delta 13 Ucmew(`A3q8gKHzxPaZ}w03y2t4gdfE delta 13 Ucmew(`A3q8gMA~@PaZ~I03w|P0ssI2 diff --git a/onnx/backend/test/data/node/test_nllloss_NCd1d2_with_weight_reduction_sum/model.onnx b/onnx/backend/test/data/node/test_nllloss_NCd1d2_with_weight_reduction_sum/model.onnx index fcc48702c96a24148f7c383057cf986656172741..50d52ec64b82f8eb7423c72d598299f14cae9d3a 100644 GIT binary patch delta 12 Tcmeyv_=k~+gKHwwPew5S94rH} delta 12 Tcmeyv_=k~+gMA{?Pext<91#Pi diff --git a/onnx/backend/test/data/node/test_nllloss_NCd1d2_with_weight_reduction_sum_expanded/model.onnx b/onnx/backend/test/data/node/test_nllloss_NCd1d2_with_weight_reduction_sum_expanded/model.onnx index 06e5b65e6d0fe75c3989cc4c343af6c1c41eec5d..4dd5a25b1fc942e853678cd2933a7cb4964b1a86 100644 GIT binary patch delta 13 UcmZ1_x=NIZgKHzxaxO+O02yTi4gdfE delta 13 UcmZ1_x=NIZgMA~@axO+*02xOE0ssI2 diff --git a/onnx/backend/test/data/node/test_nllloss_NCd1d2_with_weight_reduction_sum_ii/model.onnx b/onnx/backend/test/data/node/test_nllloss_NCd1d2_with_weight_reduction_sum_ii/model.onnx index 30e926e943b9c01ae6c367e856b2d10de2ece6c6..5fb3c75bfe3ddc47fbc09b1c12e2a8475512feff 100644 GIT binary patch delta 13 UcmbQjG=+(YgKHy`AS0s~024q09RL6T delta 13 UcmbQjG=+(YgMA~DAR{9$023kt5dZ)H diff --git a/onnx/backend/test/data/node/test_nllloss_NCd1d2_with_weight_reduction_sum_ii_expanded/model.onnx b/onnx/backend/test/data/node/test_nllloss_NCd1d2_with_weight_reduction_sum_ii_expanded/model.onnx index acc84e0bef14f9cabe6742673c2cfa5f399307c7..31c93d17e97ac8ebb9fe6689fc45351e3ea5ab77 100644 GIT binary patch delta 13 Ucmcbodry~%gKHzxZ81hM03k^O<^TWy delta 13 Ucmcbodry~%gMA~@Z81h(03j;_+5i9m diff --git a/onnx/backend/test/data/node/test_nllloss_NCd1d2d3_none_no_weight_negative_ii/model.onnx b/onnx/backend/test/data/node/test_nllloss_NCd1d2d3_none_no_weight_negative_ii/model.onnx index f1022a4bd9f0853499298c224996bded53ff4644..f7f4ff93df418c3f262c3b379c35429a7d49e53e 100644 GIT binary patch delta 13 UcmbQiG=qtWgKHy`C?lg7028nRDF6Tf delta 13 UcmbQiG=qtWgMA~DC?g{;027h|9RL6T diff --git a/onnx/backend/test/data/node/test_nllloss_NCd1d2d3_none_no_weight_negative_ii_expanded/model.onnx b/onnx/backend/test/data/node/test_nllloss_NCd1d2d3_none_no_weight_negative_ii_expanded/model.onnx index 4f236df7a8c08ed04536697ba794c77e71c2fc07..0416417bfd779d02725b32999377b2defe71968b 100644 GIT binary patch delta 13 UcmZqEZqsJs;M&O4EXpVb02g`!*#H0l delta 13 UcmZqEZqsJsVBg5pEXv3W02f>W%>V!Z diff --git a/onnx/backend/test/data/node/test_nllloss_NCd1d2d3_sum_weight_high_ii/model.onnx b/onnx/backend/test/data/node/test_nllloss_NCd1d2d3_sum_weight_high_ii/model.onnx index 8bb7c542065fb19f51483d98419280f0ca34ec00..eebc8c5b7f1dc1cdcf222c1bbaca5439402e3083 100644 GIT binary patch delta 12 Tcmeyv_=k~+gKHwwPew5S94rH} delta 12 Tcmeyv_=k~+gMA{?Pext<91#Pi diff --git a/onnx/backend/test/data/node/test_nllloss_NCd1d2d3_sum_weight_high_ii_expanded/model.onnx b/onnx/backend/test/data/node/test_nllloss_NCd1d2d3_sum_weight_high_ii_expanded/model.onnx index ea7d7177f20dccb464e53f16d290d3c80cb5f13e..4d8c1c76e33d241ed7b3a5954a60c687ba99c11c 100644 GIT binary patch delta 13 UcmX@AbySOqgKHy`lPIGY031jI6aWAK delta 13 UcmX@AbySOqgMA~DlPDuE030d<2mk;8 diff --git a/onnx/backend/test/data/node/test_nllloss_NCd1d2d3d4d5_mean_weight/model.onnx b/onnx/backend/test/data/node/test_nllloss_NCd1d2d3d4d5_mean_weight/model.onnx index 248908917d760c75f8dce7842c8eac18aeece645..178faf552df192ddd5ecdf249c28aab7fa6f1011 100644 GIT binary patch delta 13 UcmeBW>Sbc$;M&N<#mFcI01|ux2mk;8 delta 13 UcmeBW>Sbc$VBg5Z#mLAD01{pS`~Uy| diff --git a/onnx/backend/test/data/node/test_nllloss_NCd1d2d3d4d5_mean_weight_expanded/model.onnx b/onnx/backend/test/data/node/test_nllloss_NCd1d2d3d4d5_mean_weight_expanded/model.onnx index db7aea4c097c76e7c18a847a0349231a91d20de0..ede9e00357a258b441016459e628f51ffeee48f9 100644 GIT binary patch delta 13 UcmbOtF-3xjgKHy`AP=J$02M_7Q~&?~ delta 13 UcmbOtF-3xjgMA~DAP*xi02LSAKz;M&N<&d4YR01_wx{{R30 delta 13 UcmeBT>SAKzVBg5Z&dA6M01^rT^8f$< diff --git a/onnx/backend/test/data/node/test_nllloss_NCd1d2d3d4d5_none_no_weight_expanded/model.onnx b/onnx/backend/test/data/node/test_nllloss_NCd1d2d3d4d5_none_no_weight_expanded/model.onnx index e919d1d37c2ddcc08efee66962054477fbdd2057..89543e5650ca6677d8252f938d1847fa272c1978 100644 GIT binary patch delta 13 UcmdnSzm1=XgKHzxW_Cs~02(L*BLDyZ delta 13 UcmdnSzm1=XgMA~@W_Cti02&Gd7XSbN diff --git a/onnx/backend/test/data/node/test_reduce_log_sum_exp_do_not_keepdims_random/test_data_set_0/output_0.pb b/onnx/backend/test/data/node/test_reduce_log_sum_exp_do_not_keepdims_random/test_data_set_0/output_0.pb index d84c5d549e8..10171914572 100644 --- a/onnx/backend/test/data/node/test_reduce_log_sum_exp_do_not_keepdims_random/test_data_set_0/output_0.pb +++ b/onnx/backend/test/data/node/test_reduce_log_sum_exp_do_not_keepdims_random/test_data_set_0/output_0.pb @@ -1,2 +1,2 @@ - BreducedJ0«eMIzÈ@¥&~X@}îäUŠéå¿Žc;éù^@n6œýœ"@ˆß + BreducedJ0«eMIzÈ@¥&~X@{îäUŠéå¿Žc;éù^@n6œýœ"@‰ß 1ä? \ No newline at end of file diff --git a/onnx/backend/test/data/node/test_reduce_log_sum_exp_do_not_keepdims_random_expanded/test_data_set_0/output_0.pb b/onnx/backend/test/data/node/test_reduce_log_sum_exp_do_not_keepdims_random_expanded/test_data_set_0/output_0.pb index d84c5d549e8..10171914572 100644 --- a/onnx/backend/test/data/node/test_reduce_log_sum_exp_do_not_keepdims_random_expanded/test_data_set_0/output_0.pb +++ b/onnx/backend/test/data/node/test_reduce_log_sum_exp_do_not_keepdims_random_expanded/test_data_set_0/output_0.pb @@ -1,2 +1,2 @@ - BreducedJ0«eMIzÈ@¥&~X@}îäUŠéå¿Žc;éù^@n6œýœ"@ˆß + BreducedJ0«eMIzÈ@¥&~X@{îäUŠéå¿Žc;éù^@n6œýœ"@‰ß 1ä? \ No newline at end of file diff --git a/onnx/backend/test/data/node/test_reduce_log_sum_exp_keepdims_random/test_data_set_0/output_0.pb b/onnx/backend/test/data/node/test_reduce_log_sum_exp_keepdims_random/test_data_set_0/output_0.pb index e54345fc40d..f35be21b4bb 100644 --- a/onnx/backend/test/data/node/test_reduce_log_sum_exp_keepdims_random/test_data_set_0/output_0.pb +++ b/onnx/backend/test/data/node/test_reduce_log_sum_exp_keepdims_random/test_data_set_0/output_0.pb @@ -1,2 +1,2 @@ - BreducedJ0«eMIzÈ@¥&~X@}îäUŠéå¿Žc;éù^@n6œýœ"@ˆß + BreducedJ0«eMIzÈ@¥&~X@{îäUŠéå¿Žc;éù^@n6œýœ"@‰ß 1ä? \ No newline at end of file diff --git a/onnx/backend/test/data/node/test_reduce_log_sum_exp_keepdims_random_expanded/test_data_set_0/output_0.pb b/onnx/backend/test/data/node/test_reduce_log_sum_exp_keepdims_random_expanded/test_data_set_0/output_0.pb index e54345fc40d..f35be21b4bb 100644 --- a/onnx/backend/test/data/node/test_reduce_log_sum_exp_keepdims_random_expanded/test_data_set_0/output_0.pb +++ b/onnx/backend/test/data/node/test_reduce_log_sum_exp_keepdims_random_expanded/test_data_set_0/output_0.pb @@ -1,2 +1,2 @@ - BreducedJ0«eMIzÈ@¥&~X@}îäUŠéå¿Žc;éù^@n6œýœ"@ˆß + BreducedJ0«eMIzÈ@¥&~X@{îäUŠéå¿Žc;éù^@n6œýœ"@‰ß 1ä? \ No newline at end of file diff --git a/onnx/backend/test/data/node/test_reduce_log_sum_exp_negative_axes_keepdims_random/test_data_set_0/output_0.pb b/onnx/backend/test/data/node/test_reduce_log_sum_exp_negative_axes_keepdims_random/test_data_set_0/output_0.pb index e54345fc40d..f35be21b4bb 100644 --- a/onnx/backend/test/data/node/test_reduce_log_sum_exp_negative_axes_keepdims_random/test_data_set_0/output_0.pb +++ b/onnx/backend/test/data/node/test_reduce_log_sum_exp_negative_axes_keepdims_random/test_data_set_0/output_0.pb @@ -1,2 +1,2 @@ - BreducedJ0«eMIzÈ@¥&~X@}îäUŠéå¿Žc;éù^@n6œýœ"@ˆß + BreducedJ0«eMIzÈ@¥&~X@{îäUŠéå¿Žc;éù^@n6œýœ"@‰ß 1ä? \ No newline at end of file diff --git a/onnx/backend/test/data/node/test_reduce_log_sum_exp_negative_axes_keepdims_random_expanded/test_data_set_0/output_0.pb b/onnx/backend/test/data/node/test_reduce_log_sum_exp_negative_axes_keepdims_random_expanded/test_data_set_0/output_0.pb index e54345fc40d..f35be21b4bb 100644 --- a/onnx/backend/test/data/node/test_reduce_log_sum_exp_negative_axes_keepdims_random_expanded/test_data_set_0/output_0.pb +++ b/onnx/backend/test/data/node/test_reduce_log_sum_exp_negative_axes_keepdims_random_expanded/test_data_set_0/output_0.pb @@ -1,2 +1,2 @@ - BreducedJ0«eMIzÈ@¥&~X@}îäUŠéå¿Žc;éù^@n6œýœ"@ˆß + BreducedJ0«eMIzÈ@¥&~X@{îäUŠéå¿Žc;éù^@n6œýœ"@‰ß 1ä? \ No newline at end of file diff --git a/onnx/backend/test/data/node/test_rnn_seq_length/model.onnx b/onnx/backend/test/data/node/test_rnn_seq_length/model.onnx index e8273e546cd9bca066cee16606372e56a1c65a86..7a025009f9be2f6e8fad09bc2f79d90922936cb9 100644 GIT binary patch delta 12 Tcmcc4c%6}ngKHww6-F@t7>@%( delta 12 Tcmcc4c%6}ngMA{?6-GV)7Px# delta 13 Ucmcb?bc2bBgJUC8C?lf)02-VE;Q#;t diff --git a/onnx/backend/test/data/node/test_roialign_mode_max/model.onnx b/onnx/backend/test/data/node/test_roialign_mode_max/model.onnx index c49bcbcebded3cc87c10cf39ea8538d269a6ab95..c27207af408f59bc302c445ed1ee0c5a66fdae8b 100644 GIT binary patch delta 13 UcmaFO^qPr@gKHyG1|y>w035^vA^-pY delta 13 UcmaFO^qPr@gJUC81|y>Y035Ib8UO$Q diff --git a/onnx/backend/test/data/node/test_round/model.onnx b/onnx/backend/test/data/node/test_round/model.onnx index 5551b49085dc0d914a950f0864b3e675cdb40c98..385814c703d6f5038164b5f56746dd0480a768ce 100644 GIT binary patch delta 10 RcmWFyW#ZtP$P~mV1^^1k0lNSI delta 10 RcmWFyW#V9)$P~oL4FC$I0jvN3 diff --git a/onnx/backend/test/data/node/test_selu/model.onnx b/onnx/backend/test/data/node/test_selu/model.onnx index 969a340a7416704eedb0ad9418aea36cb05b5bd8..364ae8436137b1b20f4f6a7fdd420be0e7fef4e2 100644 GIT binary patch delta 12 TcmZo=Y-MEP;F`$P#3%*;5RC#& delta 12 TcmZo=Y-MEPV4ld-#K;B!5K{s+ diff --git a/onnx/backend/test/data/node/test_selu_default/model.onnx b/onnx/backend/test/data/node/test_selu_default/model.onnx index 72e2bd3f48a8aeca1c4bbff00c7bec0214b07721..32f7c62f4cd4b325d4b8f6b303ed203e5d1b428a 100644 GIT binary patch delta 10 Rcmd1KX5!$Q$dth-1^^7K0sQ~~ delta 10 Rcmd1KX5wI;$dtjz1^^6l0p_@}gKHwwBStX*8SMjY delta 12 TcmaFL_>_@}gMA{?BSt;|8Pfw| diff --git a/onnx/backend/test/data/node/test_sin/model.onnx b/onnx/backend/test/data/node/test_sin/model.onnx index 724fc74d610f215ab69815bf04283d976a682021..23fdf09faf51fbc8b0370375d71673f398f112e2 100644 GIT binary patch delta 10 RcmYdHWa8kO$P~vY1^^4t0p9=s delta 10 RcmYdHWa40+$P~xO4gd?60m%RW diff --git a/onnx/backend/test/data/node/test_sin_example/model.onnx b/onnx/backend/test/data/node/test_sin_example/model.onnx index abdb5ae6e3e107894e337b530de9da824c0d8dd6..a2678a541819ad96ec621aaa615e73bc62c3ff24 100644 GIT binary patch delta 10 Rcma!yWa8kO$P~sX1^^2n0mlFU delta 10 Rcma!yWa40+$P~uN4gd=00kHr8 diff --git a/onnx/backend/test/data/node/test_sinh/model.onnx b/onnx/backend/test/data/node/test_sinh/model.onnx index 496db2d0821322653865ca6d91ea3b8322b032fc..54cb1d7cdc3f1e60ff9c7e49fedc321208cdf6b2 100644 GIT binary patch delta 10 RcmYdJX5!$Q$dte+1^^5E0p$Py delta 10 RcmYdJX5wI($dtgy2>=Vr0nz{f diff --git a/onnx/backend/test/data/node/test_sinh_example/model.onnx b/onnx/backend/test/data/node/test_sinh_example/model.onnx index 640cf0a01e85561d369c410c96cec3c82694dc1e..b47d538826c0bf0eba5bcb6dfdba52e120031691 100644 GIT binary patch delta 10 Rcma!!X5!$Q$P~dS1^^380nGpa delta 10 Rcma!!X5wI($P~fI2>=Tl0lEMH diff --git a/onnx/backend/test/data/node/test_softplus/model.onnx b/onnx/backend/test/data/node/test_softplus/model.onnx index 8134a2da809644fa32a6da511605cbf706b97793..4c2f549a2589324e9aaf2ee413715a988fe29c0a 100644 GIT binary patch delta 10 Rcmd1KX5!$Q$dth-1^^7K0sQ~~ delta 10 Rcmd1KX5wI;$dtjz2mlOi0pS1u diff --git a/onnx/backend/test/data/node/test_softplus_example/model.onnx b/onnx/backend/test/data/node/test_softplus_example/model.onnx index 71e49dca20460145267b61fcdf1be7259255d382..ce4dbff63485c97c9e7f0a0b8d5525d697b96ce2 100644 GIT binary patch delta 10 RcmYdJX5!$Q$dte+1^^5E0p$Py delta 10 RcmYdJX5wI;$dtgy2mlMc0m%RW diff --git a/onnx/backend/test/data/node/test_softsign/model.onnx b/onnx/backend/test/data/node/test_softsign/model.onnx index 8da75bcf950f6bdf845edc2b4e0679b6fb6a9c09..08a665a020bab33ad504efcf389c87677f9900cb 100644 GIT binary patch delta 10 Rcmd1KX5!$Q$dth-1^^7K0sQ~~ delta 10 Rcmd1KX5wI;$dtjz2mlOi0pS1u diff --git a/onnx/backend/test/data/node/test_softsign_example/model.onnx b/onnx/backend/test/data/node/test_softsign_example/model.onnx index 215aa383289b3040852e9cd2f1983fe8c0ed628b..08202cbeeb32cb3af899c1a0b4062dbbef573c7b 100644 GIT binary patch delta 10 RcmYdJX5!$Q$dte+1^^5E0p$Py delta 10 RcmYdJX5wI;$dtgy2mlMc0m%RW diff --git a/onnx/backend/test/data/node/test_tan/model.onnx b/onnx/backend/test/data/node/test_tan/model.onnx index 33166fd26cea6cde9e00b0cea49d36ab997cb0eb..3d0edfc0314a9b50d6f634f5cf24c2cb323fb307 100644 GIT binary patch delta 10 RcmYdHWa8kO$P~vY1^^4t0p9=s delta 10 RcmYdHWa40+$P~xO4gd?60m%RW diff --git a/onnx/backend/test/data/node/test_tan_example/model.onnx b/onnx/backend/test/data/node/test_tan_example/model.onnx index 36bb4a7a285e4007089de23b0254499c35cde5e7..f03792d990bc42d9ff6fea70e179178924058662 100644 GIT binary patch delta 10 Rcma!yWa8kO$P~sX1^^2n0mlFU delta 10 Rcma!yWa40+$P~uN4gd=00kHr8 diff --git a/onnx/backend/test/data/node/test_thresholdedrelu/model.onnx b/onnx/backend/test/data/node/test_thresholdedrelu/model.onnx index 2e7eaf545e20be1a87402f545e0a2efbad724326..32d9a52c9b900fad6e183b74017ef9d8e02f21b5 100644 GIT binary patch delta 12 TcmeBT>|$i%;F`$P&L{=|5efoa delta 12 TcmeBT>|$i%V4cX+&d3D-5a0q! diff --git a/onnx/backend/test/data/node/test_thresholdedrelu_default/model.onnx b/onnx/backend/test/data/node/test_thresholdedrelu_default/model.onnx index 73ecc6235facf6a70951d7f70042cee6e9bfb414..bc486141ff9e6352f0813c4b31252d6ba6ba3572 100644 GIT binary patch delta 12 TcmZo5Gevd delta 12 TcmZo(TensorProto::FLOAT)) .Attr("shape", "The shape of the output tensor.", AttributeProto::INTS) .Output(0, "output", "Output tensor of random values drawn from uniform distribution", "T") - .TypeConstraint( - "T", - {"tensor(float16)", "tensor(float)", "tensor(double)"}, - "Constrain output types to float tensors.") + .TypeConstraint("T", OpSchema::all_float_types_ir4(), "Constrain output types to float tensors.") .TypeAndShapeInferenceFunction([](InferenceContext& ctx) { propagateElemTypeFromAttributeToOutput(ctx, "dtype", 0, TensorProto::FLOAT); propagateShapeFromAttributeToOutput(ctx, "shape", 0); })); -static const char* RandomNormal_ver1_doc = R"DOC( +static const char* RandomNormal_ver22_doc = R"DOC( Generate a tensor with random values drawn from a normal distribution. The shape of the tensor is specified by the `shape` argument and the parameter of the normal distribution specified by `mean` and `scale`. @@ -251,9 +226,9 @@ TensorProto message. ONNX_OPERATOR_SET_SCHEMA( RandomNormal, - 1, + 22, OpSchema() - .SetDoc(RandomNormal_ver1_doc) + .SetDoc(RandomNormal_ver22_doc) .Attr("mean", "The mean of the normal distribution.", AttributeProto::FLOAT, 0.0f) .Attr("scale", "The standard deviation of the normal distribution.", AttributeProto::FLOAT, 1.0f) .Attr( @@ -268,16 +243,13 @@ ONNX_OPERATOR_SET_SCHEMA( static_cast(TensorProto::FLOAT)) .Attr("shape", "The shape of the output tensor.", AttributeProto::INTS) .Output(0, "output", "Output tensor of random values drawn from normal distribution", "T") - .TypeConstraint( - "T", - {"tensor(float16)", "tensor(float)", "tensor(double)"}, - "Constrain output types to float tensors.") + .TypeConstraint("T", OpSchema::all_float_types_ir4(), "Constrain output types to float tensors.") .TypeAndShapeInferenceFunction([](InferenceContext& ctx) { propagateElemTypeFromAttributeToOutput(ctx, "dtype", 0, TensorProto::FLOAT); propagateShapeFromAttributeToOutput(ctx, "shape", 0); })); -static const char* RandomUniformLike_ver1_doc = R"DOC( +static const char* RandomUniformLike_ver22_doc = R"DOC( Generate a tensor with random values drawn from a uniform distribution. The shape of the output tensor is copied from the shape of the input tensor, and the parameters of the uniform distribution are specified by `low` and `high`. @@ -289,9 +261,9 @@ TensorProto message and be valid as an output type. ONNX_OPERATOR_SET_SCHEMA( RandomUniformLike, - 1, + 22, OpSchema() - .SetDoc(RandomUniformLike_ver1_doc) + .SetDoc(RandomUniformLike_ver22_doc) .Attr("low", "Lower boundary of the output values.", AttributeProto::FLOAT, 0.0f) .Attr("high", "Upper boundary of the output values.", AttributeProto::FLOAT, 1.0f) .Attr( @@ -309,12 +281,9 @@ ONNX_OPERATOR_SET_SCHEMA( .Output(0, "output", "Output tensor of random values drawn from uniform distribution", "T2") .TypeConstraint( "T1", - OpSchema::all_tensor_types(), + OpSchema::all_tensor_types_ir4(), "Constrain to any tensor type. If the dtype attribute is not provided this must be a valid output type.") - .TypeConstraint( - "T2", - {"tensor(float16)", "tensor(float)", "tensor(double)"}, - "Constrain output types to float tensors.") + .TypeConstraint("T2", OpSchema::all_float_types_ir4(), "Constrain output types to float tensors.") .TypeAndShapeInferenceFunction([](InferenceContext& ctx) { if (ctx.getAttribute("dtype") != nullptr) propagateElemTypeFromAttributeToOutput(ctx, "dtype", 0); @@ -326,7 +295,7 @@ ONNX_OPERATOR_SET_SCHEMA( propagateShapeFromInputToOutput(ctx, 0, 0); })); -static const char* RandomNormalLike_ver1_doc = R"DOC( +static const char* RandomNormalLike_ver22_doc = R"DOC( Generate a tensor with random values drawn from a normal distribution. The shape of the output tensor is copied from the shape of the input tensor, and the parameters of the normal distribution are specified by `mean` and `scale`. @@ -338,9 +307,9 @@ TensorProto message, and be valid as an output type. ONNX_OPERATOR_SET_SCHEMA( RandomNormalLike, - 1, + 22, OpSchema() - .SetDoc(RandomNormalLike_ver1_doc) + .SetDoc(RandomNormalLike_ver22_doc) .Attr("mean", "The mean of the normal distribution.", AttributeProto::FLOAT, 0.0f) .Attr("scale", "The standard deviation of the normal distribution.", AttributeProto::FLOAT, 1.0f) .Attr( @@ -358,12 +327,9 @@ ONNX_OPERATOR_SET_SCHEMA( .Output(0, "output", "Output tensor of random values drawn from normal distribution", "T2") .TypeConstraint( "T1", - OpSchema::all_tensor_types(), + OpSchema::all_tensor_types_ir4(), "Constrain to any tensor type. If the dtype attribute is not provided this must be a valid output type.") - .TypeConstraint( - "T2", - {"tensor(float16)", "tensor(float)", "tensor(double)"}, - "Constrain output types to float tensors.") + .TypeConstraint("T2", OpSchema::all_float_types_ir4(), "Constrain output types to float tensors.") .TypeAndShapeInferenceFunction([](InferenceContext& ctx) { if (ctx.getAttribute("dtype") != nullptr) propagateElemTypeFromAttributeToOutput(ctx, "dtype", 0); @@ -375,16 +341,16 @@ ONNX_OPERATOR_SET_SCHEMA( propagateShapeFromInputToOutput(ctx, 0, 0); })); -static const char* Multinomial_ver7_doc = R"DOC( +static const char* Multinomial_ver22_doc = R"DOC( Generate a tensor of samples from a multinomial distribution according to the probabilities of each of the possible outcomes. )DOC"; ONNX_OPERATOR_SET_SCHEMA( Multinomial, - 7, + 22, OpSchema() - .SetDoc(Multinomial_ver7_doc) + .SetDoc(Multinomial_ver22_doc) .Attr("sample_size", "Number of times to sample.", AttributeProto::INT, static_cast(1)) .Attr( "seed", @@ -406,10 +372,7 @@ ONNX_OPERATOR_SET_SCHEMA( "output", "Output tensor with shape [batch_size, sample_size], where sample_size is the number of times to sample. Each value along the axis zero represents the outcome of the corresponding sample in a batch.", "T2") - .TypeConstraint( - "T1", - {"tensor(float16)", "tensor(float)", "tensor(double)"}, - "Constrain input types to float tensors.") + .TypeConstraint("T1", OpSchema::all_float_types_ir4(), "Constrain input types to float tensors.") .TypeConstraint("T2", {"tensor(int32)", "tensor(int64)"}, "Constrain output types to integral tensors.") .TypeAndShapeInferenceFunction([](InferenceContext& ctx) { auto dtype = ctx.getAttribute("dtype"); @@ -562,7 +525,7 @@ ONNX_OPERATOR_SET_SCHEMA( } })); -static const char* Bernoulli_ver15_doc = R"DOC( +static const char* Bernoulli_ver22_doc = R"DOC( Draws binary random numbers (0 or 1) from a Bernoulli distribution. The input tensor should be a tensor containing probabilities p (a value in the range [0,1]) to be used for drawing the binary random number, where an output of 1 is produced with probability p and an output of 0 is produced with probability (1-p). @@ -573,9 +536,9 @@ implementations (even if a seed is specified). ONNX_OPERATOR_SET_SCHEMA( Bernoulli, - 15, + 22, OpSchema() - .SetDoc(Bernoulli_ver15_doc) + .SetDoc(Bernoulli_ver22_doc) .Attr( "seed", "(Optional) Seed to the random generator, if not specified we will auto generate one.", @@ -589,25 +552,10 @@ ONNX_OPERATOR_SET_SCHEMA( OPTIONAL_VALUE) .Input(0, "input", "All values in input have to be in the range:[0, 1].", "T1") .Output(0, "output", "The returned output tensor only has values 0 or 1, same shape as input tensor.", "T2") - .TypeConstraint( - "T1", - {"tensor(float16)", "tensor(float)", "tensor(double)"}, - "Constrain input types to float tensors.") + .TypeConstraint("T1", OpSchema::all_float_types_ir4(), "Constrain input types to float tensors.") .TypeConstraint( "T2", - {"tensor(float16)", - "tensor(float)", - "tensor(double)", - "tensor(bfloat16)", - "tensor(uint8)", - "tensor(uint16)", - "tensor(uint32)", - "tensor(uint64)", - "tensor(int8)", - "tensor(int16)", - "tensor(int32)", - "tensor(int64)", - "tensor(bool)"}, + OpSchema::all_non_complex_numeric_types_plus_bool_ir4(), "Constrain output types to all numeric tensors and bool tensors.") .TypeAndShapeInferenceFunction([](ONNX_NAMESPACE::InferenceContext& ctx) { if (ctx.getAttribute("dtype") != nullptr) diff --git a/onnx/defs/generator/old.cc b/onnx/defs/generator/old.cc index a0cf5b0a22c..88b7c6fc388 100644 --- a/onnx/defs/generator/old.cc +++ b/onnx/defs/generator/old.cc @@ -5,11 +5,400 @@ #include #include +#include "onnx/defs/function.h" #include "onnx/defs/generator/utils.h" #include "onnx/defs/schema.h" namespace ONNX_NAMESPACE { +static const char* Bernoulli_ver15_doc = R"DOC( +Draws binary random numbers (0 or 1) from a Bernoulli distribution. The input tensor should be a tensor +containing probabilities p (a value in the range [0,1]) to be used for drawing the binary random number, +where an output of 1 is produced with probability p and an output of 0 is produced with probability (1-p). + +This operator is non-deterministic and may not produce the same values in different +implementations (even if a seed is specified). +)DOC"; + +ONNX_OPERATOR_SET_SCHEMA( + Bernoulli, + 15, + OpSchema() + .SetDoc(Bernoulli_ver15_doc) + .Attr( + "seed", + "(Optional) Seed to the random generator, if not specified we will auto generate one.", + AttributeProto::FLOAT, + OPTIONAL_VALUE) + .Attr( + "dtype", + "The data type for the elements of the output tensor. if not specified, we will use " + "the data type of the input tensor.", + AttributeProto::INT, + OPTIONAL_VALUE) + .Input(0, "input", "All values in input have to be in the range:[0, 1].", "T1") + .Output(0, "output", "The returned output tensor only has values 0 or 1, same shape as input tensor.", "T2") + .TypeConstraint( + "T1", + {"tensor(float16)", "tensor(float)", "tensor(double)"}, + "Constrain input types to float tensors.") + .TypeConstraint( + "T2", + {"tensor(float16)", + "tensor(float)", + "tensor(double)", + "tensor(bfloat16)", + "tensor(uint8)", + "tensor(uint16)", + "tensor(uint32)", + "tensor(uint64)", + "tensor(int8)", + "tensor(int16)", + "tensor(int32)", + "tensor(int64)", + "tensor(bool)"}, + "Constrain output types to all numeric tensors and bool tensors.") + .TypeAndShapeInferenceFunction([](ONNX_NAMESPACE::InferenceContext& ctx) { + if (ctx.getAttribute("dtype") != nullptr) + propagateElemTypeFromAttributeToOutput(ctx, "dtype", 0); + else + propagateElemTypeFromInputToOutput(ctx, 0, 0); + if (!hasNInputShapes(ctx, 1)) { + return; + } + propagateShapeFromInputToOutput(ctx, 0, 0); + }) + .SetContextDependentFunctionBodyBuilder( + [](const FunctionBodyBuildContext& ctx, const OpSchema& schema, FunctionProto& functionProto) -> bool { + if (ctx.getInputType(0) == nullptr) { + // we cannot create a correct function body without knowing the input type + return false; + } + auto input_type = ctx.getInputType(0)->tensor_type().elem_type(); + auto dtype = ctx.getAttribute("dtype") != nullptr + ? static_cast(ctx.getAttribute("dtype")->i()) + : input_type; + FunctionBuilder builder(functionProto); + builder + .Add( + "X_random = RandomUniformLike (input)", + "dtype", + int64_t(input_type)) + .Add("X_greater = Greater (X_random, input)") + .Add("output = Cast (X_greater)", "to", int64_t(dtype)); + schema.BuildFunction(functionProto); + return true; + })); + +static const char* Multinomial_ver7_doc = R"DOC( +Generate a tensor of samples from a multinomial distribution according to the probabilities +of each of the possible outcomes. +)DOC"; + +ONNX_OPERATOR_SET_SCHEMA( + Multinomial, + 7, + OpSchema() + .SetDoc(Multinomial_ver7_doc) + .Attr("sample_size", "Number of times to sample.", AttributeProto::INT, static_cast(1)) + .Attr( + "seed", + "(Optional) Seed to the random generator, if not specified we will auto generate one.", + AttributeProto::FLOAT, + OPTIONAL_VALUE) + .Attr( + "dtype", + "(Optional) The data type for the elements of the output tensor, if not specified, we will use int32.", + AttributeProto::INT, + static_cast(TensorProto::INT32)) + .Input( + 0, + "input", + "Input tensor with shape [batch_size, class_size], where class_size is the number of all possible outcomes. Each value along the axis zero represents the unnormalized log-probability of each corresponding outcome in a batch.", + "T1") + .Output( + 0, + "output", + "Output tensor with shape [batch_size, sample_size], where sample_size is the number of times to sample. Each value along the axis zero represents the outcome of the corresponding sample in a batch.", + "T2") + .TypeConstraint( + "T1", + {"tensor(float16)", "tensor(float)", "tensor(double)"}, + "Constrain input types to float tensors.") + .TypeConstraint("T2", {"tensor(int32)", "tensor(int64)"}, "Constrain output types to integral tensors.") + .TypeAndShapeInferenceFunction([](InferenceContext& ctx) { + auto dtype = ctx.getAttribute("dtype"); + auto dataType = TensorProto_DataType::TensorProto_DataType_INT32; + if (dtype != nullptr) { + dataType = static_cast(dtype->i()); + if (dataType != TensorProto_DataType::TensorProto_DataType_INT32 && + dataType != TensorProto_DataType::TensorProto_DataType_INT64) { + fail_type_inference("Output type must be int32 or int64"); + } + } + updateOutputElemType(ctx, 0, dataType); + + TensorShapeProto::Dimension batch_size, sample_size; + if (hasInputShape(ctx, 0)) { + auto& input_shape = getInputShape(ctx, 0); + if (input_shape.dim_size() != 2) { + fail_shape_inference("Input tensor must have rank 2"); + } + batch_size = input_shape.dim(0); + } // else statically-unknown batch-size + sample_size.set_dim_value(getAttribute(ctx, "sample_size", 1)); + updateOutputShape(ctx, 0, {batch_size, sample_size}); + })); + +static const char* RandomNormalLike_ver1_doc = R"DOC( +Generate a tensor with random values drawn from a normal distribution. +The shape of the output tensor is copied from the shape of the input tensor, +and the parameters of the normal distribution are specified by `mean` and `scale`. + +The data type is specified by the 'dtype' argument, or copied from the input tensor if not provided. +The 'dtype' argument must be one of the data types specified in the 'DataType' enum field in the +TensorProto message, and be valid as an output type. +)DOC"; + +ONNX_OPERATOR_SET_SCHEMA( + RandomNormalLike, + 1, + OpSchema() + .SetDoc(RandomNormalLike_ver1_doc) + .Attr("mean", "The mean of the normal distribution.", AttributeProto::FLOAT, 0.0f) + .Attr("scale", "The standard deviation of the normal distribution.", AttributeProto::FLOAT, 1.0f) + .Attr( + "seed", + "(Optional) Seed to the random generator, if not specified we will auto generate one.", + AttributeProto::FLOAT, + OPTIONAL_VALUE) + .Attr( + "dtype", + "(Optional) The data type for the elements of the output tensor, if not specified, we will use " + "the data type of the input tensor.", + AttributeProto::INT, + OPTIONAL_VALUE) + .Input(0, "input", "Input tensor to copy shape and optionally type information from.", "T1") + .Output(0, "output", "Output tensor of random values drawn from normal distribution", "T2") + .TypeConstraint( + "T1", + OpSchema::all_tensor_types(), + "Constrain to any tensor type. If the dtype attribute is not provided this must be a valid output type.") + .TypeConstraint( + "T2", + {"tensor(float16)", "tensor(float)", "tensor(double)"}, + "Constrain output types to float tensors.") + .TypeAndShapeInferenceFunction([](InferenceContext& ctx) { + if (ctx.getAttribute("dtype") != nullptr) + propagateElemTypeFromAttributeToOutput(ctx, "dtype", 0); + else + propagateElemTypeFromInputToOutput(ctx, 0, 0); + if (!hasNInputShapes(ctx, 1)) { + return; + } + propagateShapeFromInputToOutput(ctx, 0, 0); + })); + +static const char* RandomUniformLike_ver1_doc = R"DOC( +Generate a tensor with random values drawn from a uniform distribution. +The shape of the output tensor is copied from the shape of the input tensor, +and the parameters of the uniform distribution are specified by `low` and `high`. + +The data type is specified by the 'dtype' argument, or copied from the input tensor if not provided. +The 'dtype' argument must be one of the data types specified in the 'DataType' enum field in the +TensorProto message and be valid as an output type. +)DOC"; + +ONNX_OPERATOR_SET_SCHEMA( + RandomUniformLike, + 1, + OpSchema() + .SetDoc(RandomUniformLike_ver1_doc) + .Attr("low", "Lower boundary of the output values.", AttributeProto::FLOAT, 0.0f) + .Attr("high", "Upper boundary of the output values.", AttributeProto::FLOAT, 1.0f) + .Attr( + "seed", + "(Optional) Seed to the random generator, if not specified we will auto generate one.", + AttributeProto::FLOAT, + OPTIONAL_VALUE) + .Attr( + "dtype", + "(Optional) The data type for the elements of the output tensor, if not specified, we will use " + "the data type of the input tensor.", + AttributeProto::INT, + OPTIONAL_VALUE) + .Input(0, "input", "Input tensor to copy shape and optionally type information from.", "T1") + .Output(0, "output", "Output tensor of random values drawn from uniform distribution", "T2") + .TypeConstraint( + "T1", + OpSchema::all_tensor_types(), + "Constrain to any tensor type. If the dtype attribute is not provided this must be a valid output type.") + .TypeConstraint( + "T2", + {"tensor(float16)", "tensor(float)", "tensor(double)"}, + "Constrain output types to float tensors.") + .TypeAndShapeInferenceFunction([](InferenceContext& ctx) { + if (ctx.getAttribute("dtype") != nullptr) + propagateElemTypeFromAttributeToOutput(ctx, "dtype", 0); + else + propagateElemTypeFromInputToOutput(ctx, 0, 0); + if (!hasNInputShapes(ctx, 1)) { + return; + } + propagateShapeFromInputToOutput(ctx, 0, 0); + })); + +static const char* RandomNormal_ver1_doc = R"DOC( +Generate a tensor with random values drawn from a normal distribution. The shape +of the tensor is specified by the `shape` argument and the parameter of the normal distribution +specified by `mean` and `scale`. + +The data type is specified by the 'dtype' argument. The 'dtype' argument must +be one of the data types specified in the 'DataType' enum field in the +TensorProto message. +)DOC"; + +ONNX_OPERATOR_SET_SCHEMA( + RandomNormal, + 1, + OpSchema() + .SetDoc(RandomNormal_ver1_doc) + .Attr("mean", "The mean of the normal distribution.", AttributeProto::FLOAT, 0.0f) + .Attr("scale", "The standard deviation of the normal distribution.", AttributeProto::FLOAT, 1.0f) + .Attr( + "seed", + "(Optional) Seed to the random generator, if not specified we will auto generate one.", + AttributeProto::FLOAT, + OPTIONAL_VALUE) + .Attr( + "dtype", + "The data type for the elements of the output tensor. Default is TensorProto::FLOAT.", + AttributeProto::INT, + static_cast(TensorProto::FLOAT)) + .Attr("shape", "The shape of the output tensor.", AttributeProto::INTS) + .Output(0, "output", "Output tensor of random values drawn from normal distribution", "T") + .TypeConstraint( + "T", + {"tensor(float16)", "tensor(float)", "tensor(double)"}, + "Constrain output types to float tensors.") + .TypeAndShapeInferenceFunction([](InferenceContext& ctx) { + propagateElemTypeFromAttributeToOutput(ctx, "dtype", 0, TensorProto::FLOAT); + propagateShapeFromAttributeToOutput(ctx, "shape", 0); + })); + +static const char* RandomUniform_ver1_doc = R"DOC( +Generate a tensor with random values drawn from a uniform distribution. The shape +of the tensor is specified by the `shape` argument and the range by `low` and `high`. + +The data type is specified by the 'dtype' argument. The 'dtype' argument must +be one of the data types specified in the 'DataType' enum field in the +TensorProto message. +)DOC"; + +ONNX_OPERATOR_SET_SCHEMA( + RandomUniform, + 1, + OpSchema() + .SetDoc(RandomUniform_ver1_doc) + .Attr("low", "Lower boundary of the output values.", AttributeProto::FLOAT, 0.0f) + .Attr("high", "Upper boundary of the output values.", AttributeProto::FLOAT, 1.0f) + .Attr( + "seed", + "(Optional) Seed to the random generator, if not specified we will auto generate one.", + AttributeProto::FLOAT, + OPTIONAL_VALUE) + .Attr( + "dtype", + "The data type for the elements of the output tensor. If not specified, default is TensorProto::FLOAT.", + AttributeProto::INT, + static_cast(TensorProto::FLOAT)) + .Attr("shape", "The shape of the output tensor.", AttributeProto::INTS) + .Output(0, "output", "Output tensor of random values drawn from uniform distribution", "T") + .TypeConstraint( + "T", + {"tensor(float16)", "tensor(float)", "tensor(double)"}, + "Constrain output types to float tensors.") + .TypeAndShapeInferenceFunction([](InferenceContext& ctx) { + propagateElemTypeFromAttributeToOutput(ctx, "dtype", 0, TensorProto::FLOAT); + propagateShapeFromAttributeToOutput(ctx, "shape", 0); + })); + +static const char* EyeLike_ver9_doc = R"DOC( +Generate a 2D tensor (matrix) with ones on the diagonal and zeros everywhere else. Only 2D +tensors are supported, i.e. input T1 must be of rank 2. The shape of the output tensor is the +same as the input tensor. The data type can be specified by the 'dtype' argument. If +'dtype' is not specified, then the type of input tensor is used. By default, the main diagonal +is populated with ones, but attribute 'k' can be used to populate upper or lower diagonals. +The 'dtype' argument must be one of the data types specified in the 'DataType' enum field in the +TensorProto message and be valid as an output type. +)DOC"; + +ONNX_OPERATOR_SET_SCHEMA( + EyeLike, + 9, + OpSchema() + .SetDoc(EyeLike_ver9_doc) + .Attr( + "k", + "(Optional) Index of the diagonal to be populated with ones. Default is 0." + " If T2 is the output, this op sets T2[i, i+k] = 1. k = 0 populates the main diagonal, " + "k > 0 populates an upper diagonal, and k < 0 populates a lower diagonal.", + AttributeProto::INT, + static_cast(0)) + .Attr( + "dtype", + "(Optional) The data type for the elements of the output tensor. If not specified," + "the data type of the input tensor T1 is used. If input tensor T1 is also not" + "specified, then type defaults to 'float'.", + AttributeProto::INT, + OPTIONAL_VALUE) + .Input(0, "input", "2D input tensor to copy shape, and optionally, type information from.", "T1") + .Output(0, "output", "Output tensor, same shape as input tensor T1.", "T2") + .TypeConstraint( + "T1", + {"tensor(float16)", + "tensor(float)", + "tensor(double)", + "tensor(int8)", + "tensor(int16)", + "tensor(int32)", + "tensor(int64)", + "tensor(uint8)", + "tensor(uint16)", + "tensor(uint32)", + "tensor(uint64)", + "tensor(bool)"}, + "Constrain input types. Strings and complex are not supported.") + .TypeConstraint( + "T2", + {"tensor(float16)", + "tensor(float)", + "tensor(double)", + "tensor(int8)", + "tensor(int16)", + "tensor(int32)", + "tensor(int64)", + "tensor(uint8)", + "tensor(uint16)", + "tensor(uint32)", + "tensor(uint64)", + "tensor(bool)"}, + "Constrain output types. Strings and complex are not supported.") + .TypeAndShapeInferenceFunction([](InferenceContext& ctx) { + if (ctx.getAttribute("dtype") != nullptr) { + propagateElemTypeFromAttributeToOutput(ctx, "dtype", 0); + } else { + propagateElemTypeFromInputToOutput(ctx, 0, 0); + } + if (hasInputShape(ctx, 0)) { + auto& input_shape = getInputShape(ctx, 0); + if (input_shape.dim_size() != 2) { + fail_shape_inference("Input tensor must be 2-dimensional"); + } + } + propagateShapeFromInputToOutput(ctx, 0, 0); + })); + static const char* Constant_ver19_doc = R"DOC( This operator produces a constant tensor. Exactly one of the provided attributes, either value, sparse_value, or value_* must be specified. diff --git a/onnx/defs/math/defs.cc b/onnx/defs/math/defs.cc index b7dfe3c86ff..c315a2a7b7f 100644 --- a/onnx/defs/math/defs.cc +++ b/onnx/defs/math/defs.cc @@ -14,17 +14,6 @@ namespace ONNX_NAMESPACE { -inline int MathOpTwoIntegers(std::string op_type, int a, int b) { - if (op_type == "Add") { - return a + b; - } else if (op_type == "Sub") { - return a - b; - } else if (op_type == "Mul") { - return a * b; - } - fail_shape_inference("Wrong op_type name for running propagation: ", op_type); -} - inline void MathOpDataPropagator(DataPropagationContext& ctx, std::string op_type) { const auto input_0 = ctx.getInputData(0); const auto input_1 = ctx.getInputData(1); @@ -43,7 +32,7 @@ inline void MathOpDataPropagator(DataPropagationContext& ctx, std::string op_typ auto& input_dim_1 = input_1->dim(size_1 == 1 ? 0 : i); if (input_dim_0.has_dim_value() && input_dim_1.has_dim_value()) { tsp.mutable_dim()->Add()->set_dim_value( - MathOpTwoIntegers(op_type, input_dim_0.dim_value(), input_dim_1.dim_value())); + defs::math::utils::MathOpTwoIntegers(op_type, input_dim_0.dim_value(), input_dim_1.dim_value())); } else { // Cannot compute the value; simply add an empty dim without value and param tsp.mutable_dim()->Add(); @@ -341,7 +330,7 @@ ONNX_OPERATOR_SET_SCHEMA( } )ONNX")); -static const char* ThresholdedRelu_ver10_doc = R"DOC( +static const char* ThresholdedRelu_ver22_doc = R"DOC( ThresholdedRelu takes one input data (Tensor) and produces one output data (Tensor) where the rectified linear function, y = x for x > alpha, y = 0 otherwise, is applied to the tensor elementwise. @@ -349,16 +338,13 @@ is applied to the tensor elementwise. ONNX_OPERATOR_SET_SCHEMA( ThresholdedRelu, - 10, + 22, OpSchema() - .SetDoc(ThresholdedRelu_ver10_doc) + .SetDoc(ThresholdedRelu_ver22_doc) .Attr("alpha", "Threshold value", AttributeProto::FLOAT, 1.0f) .Input(0, "X", "Input tensor", "T", OpSchema::Single, true, 1, OpSchema::Differentiable) .Output(0, "Y", "Output tensor", "T", OpSchema::Single, true, 1, OpSchema::Differentiable) - .TypeConstraint( - "T", - {"tensor(float16)", "tensor(float)", "tensor(double)"}, - "Constrain input and output types to float tensors.") + .TypeConstraint("T", OpSchema::all_float_types_ir4(), "Constrain input and output types to float tensors.") .TypeAndShapeInferenceFunction(propagateShapeAndTypeFromFirstInput) .FunctionBody( R"ONNX( @@ -373,7 +359,7 @@ ONNX_OPERATOR_SET_SCHEMA( )ONNX", 18)); -static const char* Selu_ver6_doc = R"DOC( +static const char* Selu_ver22_doc = R"DOC( Selu takes one input data (Tensor) and produces one output data (Tensor) where the scaled exponential linear unit function, `y = gamma * (alpha * e^x - alpha) for x <= 0`, `y = gamma * x for x > 0`, @@ -382,7 +368,7 @@ is applied to the tensor elementwise. ONNX_OPERATOR_SET_SCHEMA( Selu, - 6, + 22, OpSchema() .Attr( "alpha", @@ -396,13 +382,10 @@ ONNX_OPERATOR_SET_SCHEMA( "(i.e., float32 approximation of 1.0507009873554804934193349852946).", AttributeProto::FLOAT, 1.05070102214813232421875f) - .SetDoc(Selu_ver6_doc) + .SetDoc(Selu_ver22_doc) .Input(0, "X", "Input tensor", "T", OpSchema::Single, true, 1, OpSchema::Differentiable) .Output(0, "Y", "Output tensor", "T", OpSchema::Single, true, 1, OpSchema::Differentiable) - .TypeConstraint( - "T", - {"tensor(float16)", "tensor(float)", "tensor(double)"}, - "Constrain input and output types to float tensors.") + .TypeConstraint("T", OpSchema::all_float_types_ir4(), "Constrain input and output types to float tensors.") .TypeAndShapeInferenceFunction(propagateShapeAndTypeFromFirstInput) .FunctionBody( R"ONNX( @@ -424,7 +407,7 @@ ONNX_OPERATOR_SET_SCHEMA( )ONNX", 18)); -static const char* Elu_ver6_doc = R"DOC( +static const char* Elu_ver22_doc = R"DOC( Elu takes one input data (Tensor) and produces one output data (Tensor) where the function `f(x) = alpha * (exp(x) - 1.) for x < 0`, `f(x) = x for x >= 0`., is applied to the tensor elementwise. @@ -433,16 +416,13 @@ Elu takes one input data (Tensor) and produces one output data ONNX_OPERATOR_SET_SCHEMA( Elu, - 6, + 22, OpSchema() .Attr("alpha", "Coefficient of ELU.", AttributeProto::FLOAT, 1.0f) - .SetDoc(Elu_ver6_doc) + .SetDoc(Elu_ver22_doc) .Input(0, "X", "1D input tensor", "T", OpSchema::Single, true, 1, OpSchema::Differentiable) .Output(0, "Y", "1D output tensor", "T", OpSchema::Single, true, 1, OpSchema::Differentiable) - .TypeConstraint( - "T", - {"tensor(float16)", "tensor(float)", "tensor(double)"}, - "Constrain input and output types to float tensors.") + .TypeConstraint("T", OpSchema::all_float_types_ir4(), "Constrain input and output types to float tensors.") .TypeAndShapeInferenceFunction(propagateShapeAndTypeFromFirstInput) .FunctionBody( R"ONNX( @@ -462,7 +442,7 @@ ONNX_OPERATOR_SET_SCHEMA( )ONNX", 18)); -static const char* mish_ver18_doc = R"DOC( +static const char* mish_ver22_doc = R"DOC( Mish: A Self Regularized Non-Monotonic Neural Activation Function. Perform the linear unit element-wise on the input tensor X using formula: @@ -474,15 +454,12 @@ mish(x) = x * tanh(softplus(x)) = x * tanh(ln(1 + e^{x})) ONNX_OPERATOR_SET_SCHEMA( Mish, - 18, + 22, OpSchema() - .SetDoc(mish_ver18_doc) + .SetDoc(mish_ver22_doc) .Input(0, "X", "Input tensor", "T", OpSchema::Single, true, 1, OpSchema::Differentiable) .Output(0, "Y", "Output tensor", "T", OpSchema::Single, true, 1, OpSchema::Differentiable) - .TypeConstraint( - "T", - {"tensor(float16)", "tensor(float)", "tensor(double)"}, - "Constrain input X and output types to float tensors.") + .TypeConstraint("T", OpSchema::all_float_types_ir4(), "Constrain input X and output types to float tensors.") .FunctionBody(R"ONNX( { Softplus_X = Softplus (X) @@ -664,10 +641,7 @@ ONNX_OPERATOR_SET_SCHEMA( true, 1, OpSchema::Differentiable) - .TypeConstraint( - "T", - {"tensor(float16)", "tensor(float)", "tensor(double)", "tensor(bfloat16)"}, - "Constrain input and output types to float tensors.") + .TypeConstraint("T", OpSchema::all_float_types_ir4(), "Constrain input and output types to float tensors.") .TypeAndShapeInferenceFunction(propagateShapeAndTypeFromFirstInput)); static const char* Log_ver13_doc = R"DOC( @@ -716,10 +690,7 @@ ONNX_OPERATOR_SET_SCHEMA( true, 1, OpSchema::Differentiable) - .TypeConstraint( - "T", - {"tensor(float16)", "tensor(float)", "tensor(double)", "tensor(bfloat16)"}, - "Constrain input and output types to float tensors.") + .TypeConstraint("T", OpSchema::all_float_types_ir4(), "Constrain input and output types to float tensors.") .TypeAndShapeInferenceFunction(propagateShapeAndTypeFromFirstInput)); static const char* Pow_ver15_doc = R"DOC( @@ -842,7 +813,7 @@ ONNX_OPERATOR_SET_SCHEMA( "Constrain input and output types to float tensors.") .TypeAndShapeInferenceFunction(propagateShapeAndTypeFromFirstInput)); -static const char* HardSigmoid_ver6_doc = R"DOC( +static const char* HardSigmoid_ver22_doc = R"DOC( HardSigmoid takes one input data (Tensor) and produces one output data (Tensor) where the HardSigmoid function, y = max(0, min(1, alpha * x + beta)), is applied to the tensor elementwise. @@ -850,17 +821,14 @@ is applied to the tensor elementwise. ONNX_OPERATOR_SET_SCHEMA( HardSigmoid, - 6, + 22, OpSchema() .Attr("alpha", "Value of alpha.", AttributeProto::FLOAT, 0.2f) .Attr("beta", "Value of beta.", AttributeProto::FLOAT, 0.5f) - .SetDoc(HardSigmoid_ver6_doc) + .SetDoc(HardSigmoid_ver22_doc) .Input(0, "X", "Input tensor", "T", OpSchema::Single, true, 1, OpSchema::Differentiable) .Output(0, "Y", "Output tensor", "T", OpSchema::Single, true, 1, OpSchema::Differentiable) - .TypeConstraint( - "T", - {"tensor(float16)", "tensor(float)", "tensor(double)"}, - "Constrain input and output types to float tensors.") + .TypeConstraint("T", OpSchema::all_float_types_ir4(), "Constrain input and output types to float tensors.") .TypeAndShapeInferenceFunction(propagateShapeAndTypeFromFirstInput) .FunctionBody( R"ONNX( @@ -881,7 +849,7 @@ ONNX_OPERATOR_SET_SCHEMA( )ONNX", 18)); -static const char* HardSwish_ver14_doc = R"DOC( +static const char* HardSwish_ver22_doc = R"DOC( HardSwish takes one input data (Tensor) and produces one output data (Tensor) where the HardSwish function, y = x * max(0, min(1, alpha * x + beta)) = x * HardSigmoid(x), where alpha = 1/6 and beta = 0.5, is applied to the tensor elementwise. @@ -889,15 +857,12 @@ where alpha = 1/6 and beta = 0.5, is applied to the tensor elementwise. ONNX_OPERATOR_SET_SCHEMA( HardSwish, - 14, + 22, OpSchema() - .SetDoc(HardSwish_ver14_doc) + .SetDoc(HardSwish_ver22_doc) .Input(0, "X", "Input tensor", "T", OpSchema::Single, true, 1, OpSchema::Differentiable) .Output(0, "Y", "Output tensor", "T", OpSchema::Single, true, 1, OpSchema::Differentiable) - .TypeConstraint( - "T", - {"tensor(float16)", "tensor(float)", "tensor(double)"}, - "Constrain input and output types to float tensors.") + .TypeConstraint("T", OpSchema::all_float_types_ir4(), "Constrain input and output types to float tensors.") .TypeAndShapeInferenceFunction(propagateShapeAndTypeFromFirstInput) .FunctionBody(R"ONNX( { @@ -1232,15 +1197,15 @@ ONNX_OPERATOR_SET_SCHEMA( "hardmax", "Hardmax(element in input, axis) = 1 if the element is the first maximum value along the specified axis, 0 otherwise"))); -static const char* Softsign_ver1_doc = R"DOC( +static const char* Softsign_ver22_doc = R"DOC( Calculates the softsign (x/(1+|x|)) of the given input tensor element-wise. )DOC"; ONNX_OPERATOR_SET_SCHEMA( Softsign, - 1, + 22, OpSchema() - .SetDoc(Softsign_ver1_doc) + .SetDoc(Softsign_ver22_doc) .Input(0, "input", "Input tensor", "T", OpSchema::Single, true, 1, OpSchema::Differentiable) .Output( 0, @@ -1251,10 +1216,7 @@ ONNX_OPERATOR_SET_SCHEMA( true, 1, OpSchema::Differentiable) - .TypeConstraint( - "T", - {"tensor(float16)", "tensor(float)", "tensor(double)"}, - "Constrain input and output types to float tensors.") + .TypeConstraint("T", OpSchema::all_float_types_ir4(), "Constrain input and output types to float tensors.") .TypeAndShapeInferenceFunction(propagateShapeAndTypeFromFirstInput) .FunctionBody( R"ONNX( @@ -1268,7 +1230,7 @@ ONNX_OPERATOR_SET_SCHEMA( )ONNX", 18)); -static const char* Softplus_ver1_doc = R"DOC( +static const char* Softplus_ver22_doc = R"DOC( Softplus takes one input data (Tensor) and produces one output data (Tensor) where the softplus function, y = ln(exp(x) + 1), is applied to the tensor elementwise. @@ -1276,15 +1238,12 @@ the tensor elementwise. ONNX_OPERATOR_SET_SCHEMA( Softplus, - 1, + 22, OpSchema() - .SetDoc(Softplus_ver1_doc) + .SetDoc(Softplus_ver22_doc) .Input(0, "X", "1D input tensor", "T", OpSchema::Single, true, 1, OpSchema::Differentiable) .Output(0, "Y", "1D input tensor", "T", OpSchema::Single, true, 1, OpSchema::Differentiable) - .TypeConstraint( - "T", - {"tensor(float16)", "tensor(float)", "tensor(double)"}, - "Constrain input and output types to float tensors.") + .TypeConstraint("T", OpSchema::all_float_types_ir4(), "Constrain input and output types to float tensors.") .TypeAndShapeInferenceFunction(propagateShapeAndTypeFromFirstInput) .FunctionBody( R"ONNX( @@ -1549,15 +1508,15 @@ ONNX_OPERATOR_SET_SCHEMA( return; })); -static const char* Sin_ver7_doc = R"DOC( +static const char* Sin_ver22_doc = R"DOC( Calculates the sine of the given input tensor, element-wise. )DOC"; ONNX_OPERATOR_SET_SCHEMA( Sin, - 7, + 22, OpSchema() - .SetDoc(Sin_ver7_doc) + .SetDoc(Sin_ver22_doc) .Input(0, "input", "Input tensor", "T", OpSchema::Single, true, 1, OpSchema::Differentiable) .Output( 0, @@ -1569,21 +1528,18 @@ ONNX_OPERATOR_SET_SCHEMA( true, 1, OpSchema::Differentiable) - .TypeConstraint( - "T", - {"tensor(float16)", "tensor(float)", "tensor(double)"}, - "Constrain input and output types to float tensors.") + .TypeConstraint("T", OpSchema::all_float_types_ir4(), "Constrain input and output types to float tensors.") .TypeAndShapeInferenceFunction(propagateShapeAndTypeFromFirstInput)); -static const char* Cos_ver7_doc = R"DOC( +static const char* Cos_ver22_doc = R"DOC( Calculates the cosine of the given input tensor, element-wise. )DOC"; ONNX_OPERATOR_SET_SCHEMA( Cos, - 7, + 22, OpSchema() - .SetDoc(Cos_ver7_doc) + .SetDoc(Cos_ver22_doc) .Input(0, "input", "Input tensor", "T", OpSchema::Single, true, 1, OpSchema::Differentiable) .Output( 0, @@ -1595,21 +1551,18 @@ ONNX_OPERATOR_SET_SCHEMA( true, 1, OpSchema::Differentiable) - .TypeConstraint( - "T", - {"tensor(float16)", "tensor(float)", "tensor(double)"}, - "Constrain input and output types to float tensors.") + .TypeConstraint("T", OpSchema::all_float_types_ir4(), "Constrain input and output types to float tensors.") .TypeAndShapeInferenceFunction(propagateShapeAndTypeFromFirstInput)); -static const char* Tan_ver7_doc = R"DOC( +static const char* Tan_ver22_doc = R"DOC( Calculates the tangent of the given input tensor, element-wise. )DOC"; ONNX_OPERATOR_SET_SCHEMA( Tan, - 7, + 22, OpSchema() - .SetDoc(Tan_ver7_doc) + .SetDoc(Tan_ver22_doc) .Input(0, "input", "Input tensor", "T", OpSchema::Single, true, 1, OpSchema::Differentiable) .Output( 0, @@ -1621,21 +1574,18 @@ ONNX_OPERATOR_SET_SCHEMA( true, 1, OpSchema::Differentiable) - .TypeConstraint( - "T", - {"tensor(float16)", "tensor(float)", "tensor(double)"}, - "Constrain input and output types to float tensors.") + .TypeConstraint("T", OpSchema::all_float_types_ir4(), "Constrain input and output types to float tensors.") .TypeAndShapeInferenceFunction(propagateShapeAndTypeFromFirstInput)); -static const char* Asin_ver7_doc = R"DOC( +static const char* Asin_ver22_doc = R"DOC( Calculates the arcsine (inverse of sine) of the given input tensor, element-wise. )DOC"; ONNX_OPERATOR_SET_SCHEMA( Asin, - 7, + 22, OpSchema() - .SetDoc(Asin_ver7_doc) + .SetDoc(Asin_ver22_doc) .Input(0, "input", "Input tensor", "T", OpSchema::Single, true, 1, OpSchema::Differentiable) .Output( 0, @@ -1647,21 +1597,18 @@ ONNX_OPERATOR_SET_SCHEMA( true, 1, OpSchema::Differentiable) - .TypeConstraint( - "T", - {"tensor(float16)", "tensor(float)", "tensor(double)"}, - "Constrain input and output types to float tensors.") + .TypeConstraint("T", OpSchema::all_float_types_ir4(), "Constrain input and output types to float tensors.") .TypeAndShapeInferenceFunction(propagateShapeAndTypeFromFirstInput)); -static const char* Acos_ver7_doc = R"DOC( +static const char* Acos_ver22_doc = R"DOC( Calculates the arccosine (inverse of cosine) of the given input tensor, element-wise. )DOC"; ONNX_OPERATOR_SET_SCHEMA( Acos, - 7, + 22, OpSchema() - .SetDoc(Acos_ver7_doc) + .SetDoc(Acos_ver22_doc) .Input(0, "input", "Input tensor", "T", OpSchema::Single, true, 1, OpSchema::Differentiable) .Output( 0, @@ -1673,21 +1620,18 @@ ONNX_OPERATOR_SET_SCHEMA( true, 1, OpSchema::Differentiable) - .TypeConstraint( - "T", - {"tensor(float16)", "tensor(float)", "tensor(double)"}, - "Constrain input and output types to float tensors.") + .TypeConstraint("T", OpSchema::all_float_types_ir4(), "Constrain input and output types to float tensors.") .TypeAndShapeInferenceFunction(propagateShapeAndTypeFromFirstInput)); -static const char* Atan_ver7_doc = R"DOC( +static const char* Atan_ver22_doc = R"DOC( Calculates the arctangent (inverse of tangent) of the given input tensor, element-wise. )DOC"; ONNX_OPERATOR_SET_SCHEMA( Atan, - 7, + 22, OpSchema() - .SetDoc(Atan_ver7_doc) + .SetDoc(Atan_ver22_doc) .Input(0, "input", "Input tensor", "T", OpSchema::Single, true, 1, OpSchema::Differentiable) .Output( 0, @@ -1699,10 +1643,7 @@ ONNX_OPERATOR_SET_SCHEMA( true, 1, OpSchema::Differentiable) - .TypeConstraint( - "T", - {"tensor(float16)", "tensor(float)", "tensor(double)"}, - "Constrain input and output types to float tensors.") + .TypeConstraint("T", OpSchema::all_float_types_ir4(), "Constrain input and output types to float tensors.") .TypeAndShapeInferenceFunction(propagateShapeAndTypeFromFirstInput)); static const char* Expand_ver13_doc = R"DOC( @@ -1749,15 +1690,15 @@ ONNX_OPERATOR_SET_SCHEMA( } })); -static const char* Sinh_ver9_doc = R"DOC( +static const char* Sinh_ver22_doc = R"DOC( Calculates the hyperbolic sine of the given input tensor element-wise. )DOC"; ONNX_OPERATOR_SET_SCHEMA( Sinh, - 9, + 22, OpSchema() - .SetDoc(Sinh_ver9_doc) + .SetDoc(Sinh_ver22_doc) .Input(0, "input", "Input tensor", "T", OpSchema::Single, true, 1, OpSchema::Differentiable) .Output( 0, @@ -1769,21 +1710,18 @@ ONNX_OPERATOR_SET_SCHEMA( true, 1, OpSchema::Differentiable) - .TypeConstraint( - "T", - {"tensor(float16)", "tensor(float)", "tensor(double)"}, - "Constrain input and output types to float tensors.") + .TypeConstraint("T", OpSchema::all_float_types_ir4(), "Constrain input and output types to float tensors.") .TypeAndShapeInferenceFunction(propagateShapeAndTypeFromFirstInput)); -static const char* Cosh_ver9_doc = R"DOC( +static const char* Cosh_ver22_doc = R"DOC( Calculates the hyperbolic cosine of the given input tensor element-wise. )DOC"; ONNX_OPERATOR_SET_SCHEMA( Cosh, - 9, + 22, OpSchema() - .SetDoc(Cosh_ver9_doc) + .SetDoc(Cosh_ver22_doc) .Input(0, "input", "Input tensor", "T", OpSchema::Single, true, 1, OpSchema::Differentiable) .Output( 0, @@ -1795,21 +1733,18 @@ ONNX_OPERATOR_SET_SCHEMA( true, 1, OpSchema::Differentiable) - .TypeConstraint( - "T", - {"tensor(float16)", "tensor(float)", "tensor(double)"}, - "Constrain input and output types to float tensors.") + .TypeConstraint("T", OpSchema::all_float_types_ir4(), "Constrain input and output types to float tensors.") .TypeAndShapeInferenceFunction(propagateShapeAndTypeFromFirstInput)); -static const char* Asinh_ver9_doc = R"DOC( +static const char* Asinh_ver22_doc = R"DOC( Calculates the hyperbolic arcsine of the given input tensor element-wise. )DOC"; ONNX_OPERATOR_SET_SCHEMA( Asinh, - 9, + 22, OpSchema() - .SetDoc(Asinh_ver9_doc) + .SetDoc(Asinh_ver22_doc) .Input(0, "input", "Input tensor", "T", OpSchema::Single, true, 1, OpSchema::Differentiable) .Output( 0, @@ -1821,21 +1756,18 @@ ONNX_OPERATOR_SET_SCHEMA( true, 1, OpSchema::Differentiable) - .TypeConstraint( - "T", - {"tensor(float16)", "tensor(float)", "tensor(double)"}, - "Constrain input and output types to float tensors.") + .TypeConstraint("T", OpSchema::all_float_types_ir4(), "Constrain input and output types to float tensors.") .TypeAndShapeInferenceFunction(propagateShapeAndTypeFromFirstInput)); -static const char* Acosh_ver9_doc = R"DOC( +static const char* Acosh_ver22_doc = R"DOC( Calculates the hyperbolic arccosine of the given input tensor element-wise. )DOC"; ONNX_OPERATOR_SET_SCHEMA( Acosh, - 9, + 22, OpSchema() - .SetDoc(Acosh_ver9_doc) + .SetDoc(Acosh_ver22_doc) .Input(0, "input", "Input tensor", "T", OpSchema::Single, true, 1, OpSchema::Differentiable) .Output( 0, @@ -1847,21 +1779,18 @@ ONNX_OPERATOR_SET_SCHEMA( true, 1, OpSchema::Differentiable) - .TypeConstraint( - "T", - {"tensor(float16)", "tensor(float)", "tensor(double)"}, - "Constrain input and output types to float tensors.") + .TypeConstraint("T", OpSchema::all_float_types_ir4(), "Constrain input and output types to float tensors.") .TypeAndShapeInferenceFunction(propagateShapeAndTypeFromFirstInput)); -static const char* Atanh_ver9_doc = R"DOC( +static const char* Atanh_ver22_doc = R"DOC( Calculates the hyperbolic arctangent of the given input tensor element-wise. )DOC"; ONNX_OPERATOR_SET_SCHEMA( Atanh, - 9, + 22, OpSchema() - .SetDoc(Atanh_ver9_doc) + .SetDoc(Atanh_ver22_doc) .Input(0, "input", "Input tensor", "T", OpSchema::Single, true, 1, OpSchema::Differentiable) .Output( 0, @@ -1873,10 +1802,7 @@ ONNX_OPERATOR_SET_SCHEMA( true, 1, OpSchema::Differentiable) - .TypeConstraint( - "T", - {"tensor(float16)", "tensor(float)", "tensor(double)"}, - "Constrain input and output types to float tensors.") + .TypeConstraint("T", OpSchema::all_float_types_ir4(), "Constrain input and output types to float tensors.") .TypeAndShapeInferenceFunction(propagateShapeAndTypeFromFirstInput)); static const char* Sign_ver13_doc = R"DOC( @@ -2154,7 +2080,7 @@ ONNX_OPERATOR_SET_SCHEMA( .TypeConstraint("T2", {"tensor(int32)", "tensor(int64)"}, "axis tensor can be int32 or int64 only") .TypeAndShapeInferenceFunction(ONNX_NAMESPACE::propagateShapeAndTypeFromFirstInput)); -static const char* Round_ver11_doc = R"DOC( +static const char* Round_ver22_doc = R"DOC( Round takes one input Tensor and rounds the values, element-wise, meaning it finds the nearest integer for each value. In case of halves, the rule is to round them to the nearest even integer. @@ -2173,18 +2099,15 @@ round([-4.5]) = [-4.0] ONNX_OPERATOR_SET_SCHEMA( Round, - 11, + 22, OpSchema() - .SetDoc(Round_ver11_doc) + .SetDoc(Round_ver22_doc) .Input(0, "X", "Input tensor", "T", OpSchema::Single, true, 1, OpSchema::NonDifferentiable) .Output(0, "Y", "Output tensor", "T", OpSchema::Single, true, 1, OpSchema::NonDifferentiable) - .TypeConstraint( - "T", - {"tensor(float16)", "tensor(float)", "tensor(double)"}, - "Constrain input and output types to float tensors.") + .TypeConstraint("T", OpSchema::all_float_types_ir4(), "Constrain input and output types to float tensors.") .TypeAndShapeInferenceFunction(propagateShapeAndTypeFromFirstInput)); -static const char* Det_ver11_doc = R"DOC( +static const char* Det_ver22_doc = R"DOC( Det calculates determinant of a square matrix or batches of square matrices. Det takes one input tensor of shape `[*, M, M]`, where `*` is zero or more batch dimensions, and the inner-most 2 dimensions form square matrices. @@ -2194,14 +2117,14 @@ e.g., When the input is 2-D, the output is a scalar(shape is empty: `[]`). ONNX_OPERATOR_SET_SCHEMA( Det, - 11, + 22, OpSchema() - .SetDoc(Det_ver11_doc) + .SetDoc(Det_ver22_doc) .Input(0, "X", "Input tensor", "T", OpSchema::Single, true, 1, OpSchema::Differentiable) .Output(0, "Y", "Output tensor", "T", OpSchema::Single, true, 1, OpSchema::Differentiable) .TypeConstraint( "T", - {"tensor(float16)", "tensor(float)", "tensor(double)"}, + OpSchema::all_float_types_ir4(), "Constrain input and output types to floating-point tensors.") .TypeAndShapeInferenceFunction([](InferenceContext& ctx) { // Type inference @@ -2235,110 +2158,6 @@ ONNX_OPERATOR_SET_SCHEMA( } })); -static const char* NegativeLogLikelihoodLoss_ver13_doc = R"DOC( -A NegativeLogLikelihoodLoss operator computes (weighted) negative log likelihood loss. -Its "input" tensor has the shape of (N, C, d1, d2, ..., dk) where k >= 0. -The "input" tensor contains log-probabilities for input[n, :, d_1, d_2,..., d_k] being in a class of [0, C). -The operator's "target" input tensor has the shape of (N, d1, d2, ..., dk). It encodes class labels (one of C classes) -or it may contain a special value (indicated by an attribute ignore_index) for N x d1 x d2 x ... x dk samples. -The loss value for input[n, :, d_1, d_2,...d_k] being classified as class c = target[n][d_1][d_2]...[d_k] is computed as: - -``` -loss[n][d_1][d_2]...[d_k] = -input[n][c][d_1][d_2]...[d_k]. -``` - -When an optional "weight" is provided, the sample loss is calculated as: - -``` -loss[n][d_1][d_2]...[d_k] = -input[n][c][d_1][d_2]...[d_k] * weight[c]. -``` - -loss is zero for the case when target-value equals ignore_index. - -``` -loss[n][d_1][d_2]...[d_k] = 0, when target[n][d_1][d_2]...[d_k] = ignore_index -``` - -If "reduction" attribute is set to "none", the operator's output will be the above loss with shape (N, d1, d2, ..., dk). -If "reduction" attribute is set to "mean" (the default attribute value), the output loss is (weight) averaged: - -``` -mean(loss), if "weight" is not provided, -``` - -or if weight is provided, - -``` -sum(loss) / sum(weight[target[n][d_1][d_2]...[d_k]]]), for all samples. -``` - -If "reduction" attribute is set to "sum", the output is a scalar: `sum(loss)`. - -See also https://pytorch.org/docs/stable/nn.html#torch.nn.NLLLoss. - -Example 1: - -``` -// negative log likelihood loss, "none" reduction -N, C, d1 = 2, 3, 2 -input = [[[1.0, 2.0], [2.0, 2.0], [3.0, 2.0]], - [[0.0, 1.0], [2.0, 2.0], [1.0, 2]]] -target = [[2, 1], [0, 2]] - -loss = np.zeros((N, d1)) -for n in range(N): - for d_1 in range(d1): - c = target[n][d_1] - loss[n][d_1] = -input[n][c][d_1] - -// print(loss) -// [[-3. -2.] -// [-0. -2.]] -``` - -Example 2: - -``` -// weighted negative log likelihood loss, sum reduction -N, C, d1 = 2, 3, 2 -input = [[[1.0, 2.0], [2.0, 2.0], [3.0, 2.0]], - [[0.0, 1.0], [2.0, 2.0], [1.0, 2]]] -target = [[2, 1], [0, 2]] -weight = [0.2, 0.3, 0.1] -loss = np.zeros((N, d1)) -for n in range(N): - for d_1 in range(d1): - c = target[n][d_1] - loss[n][d_1] = -input[n][c][d_1] * weight[c] - -loss = np.sum(loss) -// print(loss) -// -1.1 -``` - -Example 3: - -``` -// weighted negative log likelihood loss, mean reduction -N, C, d1 = 2, 3, 2 -input = [[[1.0, 2.0], [2.0, 2.0], [3.0, 2.0]], - [[0.0, 1.0], [2.0, 2.0], [1.0, 2]]] -target = [[2, 1], [0, 2]] -weight = [0.2, 0.3, 0.1] -loss = np.zeros((N, d1)) -weight_total = 0 -for n in range(N): - for d_1 in range(d1): - c = target[n][d_1] - loss[n][d_1] = -input[n][c][d_1] * weight[c] - weight_total = weight_total + weight[c] - -loss = np.sum(loss) / weight_total -// print(loss) -// -1.57 -``` -)DOC"; - bool BuildContextDependentFunctionBody( const FunctionBodyBuildContext& ctx, const OpSchema& schema, @@ -2451,11 +2270,115 @@ bool BuildContextDependentFunctionBody( return true; } +static const char* NegativeLogLikelihoodLoss_ver22_doc = R"DOC( +A NegativeLogLikelihoodLoss operator computes (weighted) negative log likelihood loss. +Its "input" tensor has the shape of (N, C, d1, d2, ..., dk) where k >= 0. +The "input" tensor contains log-probabilities for input[n, :, d_1, d_2,..., d_k] being in a class of [0, C). +The operator's "target" input tensor has the shape of (N, d1, d2, ..., dk). It encodes class labels (one of C classes) +or it may contain a special value (indicated by an attribute ignore_index) for N x d1 x d2 x ... x dk samples. +The loss value for input[n, :, d_1, d_2,...d_k] being classified as class c = target[n][d_1][d_2]...[d_k] is computed as: + +``` +loss[n][d_1][d_2]...[d_k] = -input[n][c][d_1][d_2]...[d_k]. +``` + +When an optional "weight" is provided, the sample loss is calculated as: + +``` +loss[n][d_1][d_2]...[d_k] = -input[n][c][d_1][d_2]...[d_k] * weight[c]. +``` + +loss is zero for the case when target-value equals ignore_index. + +``` +loss[n][d_1][d_2]...[d_k] = 0, when target[n][d_1][d_2]...[d_k] = ignore_index +``` + +If "reduction" attribute is set to "none", the operator's output will be the above loss with shape (N, d1, d2, ..., dk). +If "reduction" attribute is set to "mean" (the default attribute value), the output loss is (weight) averaged: + +``` +mean(loss), if "weight" is not provided, +``` + +or if weight is provided, + +``` +sum(loss) / sum(weight[target[n][d_1][d_2]...[d_k]]]), for all samples. +``` + +If "reduction" attribute is set to "sum", the output is a scalar: `sum(loss)`. + +See also https://pytorch.org/docs/stable/nn.html#torch.nn.NLLLoss. + +Example 1: + +``` +// negative log likelihood loss, "none" reduction +N, C, d1 = 2, 3, 2 +input = [[[1.0, 2.0], [2.0, 2.0], [3.0, 2.0]], + [[0.0, 1.0], [2.0, 2.0], [1.0, 2]]] +target = [[2, 1], [0, 2]] + +loss = np.zeros((N, d1)) +for n in range(N): + for d_1 in range(d1): + c = target[n][d_1] + loss[n][d_1] = -input[n][c][d_1] + +// print(loss) +// [[-3. -2.] +// [-0. -2.]] +``` + +Example 2: + +``` +// weighted negative log likelihood loss, sum reduction +N, C, d1 = 2, 3, 2 +input = [[[1.0, 2.0], [2.0, 2.0], [3.0, 2.0]], + [[0.0, 1.0], [2.0, 2.0], [1.0, 2]]] +target = [[2, 1], [0, 2]] +weight = [0.2, 0.3, 0.1] +loss = np.zeros((N, d1)) +for n in range(N): + for d_1 in range(d1): + c = target[n][d_1] + loss[n][d_1] = -input[n][c][d_1] * weight[c] + +loss = np.sum(loss) +// print(loss) +// -1.1 +``` + +Example 3: + +``` +// weighted negative log likelihood loss, mean reduction +N, C, d1 = 2, 3, 2 +input = [[[1.0, 2.0], [2.0, 2.0], [3.0, 2.0]], + [[0.0, 1.0], [2.0, 2.0], [1.0, 2]]] +target = [[2, 1], [0, 2]] +weight = [0.2, 0.3, 0.1] +loss = np.zeros((N, d1)) +weight_total = 0 +for n in range(N): + for d_1 in range(d1): + c = target[n][d_1] + loss[n][d_1] = -input[n][c][d_1] * weight[c] + weight_total = weight_total + weight[c] + +loss = np.sum(loss) / weight_total +// print(loss) +// -1.57 +``` +)DOC"; + ONNX_OPERATOR_SET_SCHEMA( NegativeLogLikelihoodLoss, - 13, + 22, OpSchema() - .SetDoc(NegativeLogLikelihoodLoss_ver13_doc) + .SetDoc(NegativeLogLikelihoodLoss_ver22_doc) .Input( 0, "input", @@ -2502,7 +2425,7 @@ ONNX_OPERATOR_SET_SCHEMA( false) .TypeConstraint( "T", - {"tensor(float16)", "tensor(float)", "tensor(double)"}, + OpSchema::all_float_types_ir4(), "Constrain input, weight, and output types to floating-point tensors.") .TypeConstraint("Tind", {"tensor(int32)", "tensor(int64)"}, "Constrain target to integer types") .SetContextDependentFunctionBodyBuilder(BuildContextDependentFunctionBody) diff --git a/onnx/defs/math/old.cc b/onnx/defs/math/old.cc index 00048188888..c16e0419e2e 100644 --- a/onnx/defs/math/old.cc +++ b/onnx/defs/math/old.cc @@ -4,6 +4,7 @@ #include +#include "onnx/defs/data_type_utils.h" #include "onnx/defs/function.h" #include "onnx/defs/math/utils.h" #include "onnx/defs/schema.h" @@ -11,6 +12,978 @@ namespace ONNX_NAMESPACE { +bool BuildContextDependentFunctionBody_opset13( + const FunctionBodyBuildContext& ctx, + const OpSchema& schema, + FunctionProto& functionProto) { + if (ctx.getInputType(0) == nullptr) { + // we cannot create a correct function body without knowing the input type + return false; + } + auto input_type = ctx.getInputType(0)->tensor_type().elem_type(); + bool float_input = input_type == TensorProto_DataType_FLOAT; + auto reduction_attr_proto = ctx.getAttribute("reduction"); + std::string reduction_attr = + reduction_attr_proto != nullptr && reduction_attr_proto->has_s() ? reduction_attr_proto->s() : "mean"; + + FunctionBuilder builder(functionProto); + builder.Const1D("const_zero", int64_t(0)) + .Const1D("const_one", int64_t(1)) + .Const1D("axes", int64_t(1)) + .Add("expanded_target = Unsqueeze (target, axes)"); + + if (ctx.getAttribute("ignore_index") == nullptr) { + builder.Add(R"( + input_gather_element = GatherElements (input, expanded_target) + loss_NCdd = Neg (input_gather_element) + loss_N1dd = Slice (loss_NCdd, const_zero, const_one, const_one) + )"); + + if (!ctx.hasInput(2)) { + if (reduction_attr == "none") { + builder.Add("loss = Squeeze (loss_N1dd, axes)"); + } else { + builder.Add("loss_Ndd = Squeeze (loss_N1dd, axes)"); + if (reduction_attr == "mean") { + builder.Add("loss = ReduceMean (loss_Ndd)"); + } else { + builder.Add("loss = ReduceSum (loss_Ndd)"); + } + } + } else { + builder.Add("weight_gather = Gather (weight, target)"); + builder.Add("loss_unweighted = Squeeze (loss_N1dd, axes)"); + if (reduction_attr == "none") { + builder.Add("loss = Mul (loss_unweighted, weight_gather)"); + } else { + builder.Add("loss_Ndd = Mul (loss_unweighted, weight_gather)"); + if (reduction_attr == "mean") { + builder.Add(R"( + loss_sum = ReduceSum (loss_Ndd) + weight_gather_sum = ReduceSum (weight_gather) + loss = Div (loss_sum, weight_gather_sum) + )"); + } else { + builder.Add("loss = ReduceSum (loss_Ndd)"); + } + } + } + } else { + builder.Const1D("const_ignore_index", ctx.getAttribute("ignore_index")->i()); + builder.Add(R"( + const_zero_target_typed = Sub (expanded_target, expanded_target) + expanded_target_int64 = Cast (expanded_target) + mask = Equal (expanded_target_int64, const_ignore_index) + transform_targets = Where (mask, const_zero_target_typed, expanded_target) + )"); + builder.Add("input_gather_element = GatherElements (input, transform_targets)"); + builder.Const1D("const_zero_float", 0.0f); + if (!float_input) { + builder.Add("const_zero_casted = Cast (const_zero_float)", "to", static_cast(input_type)) + .Add("input_gather_element_transform = Where (mask, const_zero_casted, input_gather_element)"); + } else + builder.Add("input_gather_element_transform = Where (mask, const_zero_float, input_gather_element)"); + builder.Add("loss_NCdd = Neg (input_gather_element_transform)"); + builder.Add("loss_N1dd = Slice (loss_NCdd, const_zero, const_one, const_one)"); + + if (!ctx.hasInput(2)) { + builder.Add("squeeze_mask = Squeeze (mask, axes)"); + builder.Const1D("const_one_float", 1.0f); + if (!float_input) { + builder.Add("const_one_casted = Cast (const_one_float)", "to", static_cast(input_type)) + .Add("weight_gather = Where (squeeze_mask, const_zero_casted, const_one_casted)"); + } else + builder.Add("weight_gather = Where (squeeze_mask, const_zero_float, const_one_float)"); + + } else { + builder.Add("weight_gather_temp = Gather (weight, transform_targets)"); + builder.Add( + float_input ? "weight_gather_temp_1 = Where (mask, const_zero_float, weight_gather_temp)" + : "weight_gather_temp_1 = Where (mask, const_zero_casted, weight_gather_temp)"); + builder.Add("weight_gather = Squeeze (weight_gather_temp_1, axes)"); + } + + builder.Add("loss_unweighted = Squeeze (loss_N1dd, axes)"); + if (reduction_attr == "none") { + builder.Add("loss = Mul (loss_unweighted, weight_gather)"); + } else { + builder.Add("loss_Ndd = Mul (loss_unweighted, weight_gather)"); + if (reduction_attr == "mean") { + builder.Add(R"( + loss_sum = ReduceSum (loss_Ndd) + weight_gather_sum = ReduceSum (weight_gather) + loss = Div (loss_sum, weight_gather_sum) + )"); + } else { + builder.Add("loss = ReduceSum (loss_Ndd)"); + } + } + } + + schema.BuildFunction(functionProto); + return true; +} + +static const char* NegativeLogLikelihoodLoss_ver13_doc = R"DOC( +A NegativeLogLikelihoodLoss operator computes (weighted) negative log likelihood loss. +Its "input" tensor has the shape of (N, C, d1, d2, ..., dk) where k >= 0. +The "input" tensor contains log-probabilities for input[n, :, d_1, d_2,..., d_k] being in a class of [0, C). +The operator's "target" input tensor has the shape of (N, d1, d2, ..., dk). It encodes class labels (one of C classes) +or it may contain a special value (indicated by an attribute ignore_index) for N x d1 x d2 x ... x dk samples. +The loss value for input[n, :, d_1, d_2,...d_k] being classified as class c = target[n][d_1][d_2]...[d_k] is computed as: + +``` +loss[n][d_1][d_2]...[d_k] = -input[n][c][d_1][d_2]...[d_k]. +``` + +When an optional "weight" is provided, the sample loss is calculated as: + +``` +loss[n][d_1][d_2]...[d_k] = -input[n][c][d_1][d_2]...[d_k] * weight[c]. +``` + +loss is zero for the case when target-value equals ignore_index. + +``` +loss[n][d_1][d_2]...[d_k] = 0, when target[n][d_1][d_2]...[d_k] = ignore_index +``` + +If "reduction" attribute is set to "none", the operator's output will be the above loss with shape (N, d1, d2, ..., dk). +If "reduction" attribute is set to "mean" (the default attribute value), the output loss is (weight) averaged: + +``` +mean(loss), if "weight" is not provided, +``` + +or if weight is provided, + +``` +sum(loss) / sum(weight[target[n][d_1][d_2]...[d_k]]]), for all samples. +``` + +If "reduction" attribute is set to "sum", the output is a scalar: `sum(loss)`. + +See also https://pytorch.org/docs/stable/nn.html#torch.nn.NLLLoss. + +Example 1: + +``` +// negative log likelihood loss, "none" reduction +N, C, d1 = 2, 3, 2 +input = [[[1.0, 2.0], [2.0, 2.0], [3.0, 2.0]], + [[0.0, 1.0], [2.0, 2.0], [1.0, 2]]] +target = [[2, 1], [0, 2]] + +loss = np.zeros((N, d1)) +for n in range(N): + for d_1 in range(d1): + c = target[n][d_1] + loss[n][d_1] = -input[n][c][d_1] + +// print(loss) +// [[-3. -2.] +// [-0. -2.]] +``` + +Example 2: + +``` +// weighted negative log likelihood loss, sum reduction +N, C, d1 = 2, 3, 2 +input = [[[1.0, 2.0], [2.0, 2.0], [3.0, 2.0]], + [[0.0, 1.0], [2.0, 2.0], [1.0, 2]]] +target = [[2, 1], [0, 2]] +weight = [0.2, 0.3, 0.1] +loss = np.zeros((N, d1)) +for n in range(N): + for d_1 in range(d1): + c = target[n][d_1] + loss[n][d_1] = -input[n][c][d_1] * weight[c] + +loss = np.sum(loss) +// print(loss) +// -1.1 +``` + +Example 3: + +``` +// weighted negative log likelihood loss, mean reduction +N, C, d1 = 2, 3, 2 +input = [[[1.0, 2.0], [2.0, 2.0], [3.0, 2.0]], + [[0.0, 1.0], [2.0, 2.0], [1.0, 2]]] +target = [[2, 1], [0, 2]] +weight = [0.2, 0.3, 0.1] +loss = np.zeros((N, d1)) +weight_total = 0 +for n in range(N): + for d_1 in range(d1): + c = target[n][d_1] + loss[n][d_1] = -input[n][c][d_1] * weight[c] + weight_total = weight_total + weight[c] + +loss = np.sum(loss) / weight_total +// print(loss) +// -1.57 +``` +)DOC"; + +ONNX_OPERATOR_SET_SCHEMA( + NegativeLogLikelihoodLoss, + 13, + OpSchema() + .SetDoc(NegativeLogLikelihoodLoss_ver13_doc) + .Input( + 0, + "input", + "Input tensor of shape (N, C) or (N, C, d1, d2, ..., dk).", + "T", + OpSchema::Single, + true, + 1, + OpSchema::Differentiable) + .Input( + 1, + "target", + "Target tensor of shape (N) or (N, d1, d2, ..., dk). Target element value shall be in range of [0, C). " + "If ignore_index is specified, it may have a value outside [0, C) and the target values should either be " + "in the range [0, C) or have the value ignore_index.", + "Tind", + OpSchema::Single, + true, + 1, + OpSchema::NonDifferentiable) + .Input( + 2, + "weight", + "Optional rescaling weight tensor. " + "If given, it has to be a tensor of size C. Otherwise, it is treated as if having all ones.", + "T", + OpSchema::Optional, + true, + 1, + OpSchema::NonDifferentiable) + .Output(0, "loss", "The negative log likelihood loss", "T", OpSchema::Single, true, 1, OpSchema::Differentiable) + .Attr( + "reduction", + "Type of reduction to apply to loss: none, sum, mean (default). " + "'none': the output is the loss for each sample. " + "'sum': the output will be summed. " + "'mean': the sum of the output will be divided by the sum of applied weights.", + AttributeProto::STRING, + std::string("mean")) + .Attr( + "ignore_index", + "Specifies a target value that is ignored and does not contribute to the input gradient. It's an optional value.", + AttributeProto::INT, + false) + .TypeConstraint( + "T", + {"tensor(float16)", "tensor(float)", "tensor(double)"}, + "Constrain input, weight, and output types to floating-point tensors.") + .TypeConstraint("Tind", {"tensor(int32)", "tensor(int64)"}, "Constrain target to integer types") + .SetContextDependentFunctionBodyBuilder(BuildContextDependentFunctionBody_opset13) + .TypeAndShapeInferenceFunction([](InferenceContext& ctx) { + // Type inference + propagateElemTypeFromInputToOutput(ctx, 0, 0); + + // Shape inference + if (hasNInputShapes(ctx, 2)) { + const TensorShapeProto& input_shape = ctx.getInputType(0)->tensor_type().shape(); + const TensorShapeProto& target_shape = ctx.getInputType(1)->tensor_type().shape(); + + const int input_rank = static_cast(input_shape.dim_size()); + const int target_rank = static_cast(target_shape.dim_size()); + + if (input_rank < 2) { + fail_shape_inference("Input rank must be >= 2.") + } + if (target_rank != input_rank - 1) { + fail_shape_inference("Target rank must be 1 less than the input rank."); + } + + // match input dimensions (N, C, d1, ..., dk) with target + // dimensions of (C, d1, ..., dk) + for (int dim = 0; dim < target_rank; dim++) { + const auto input_dim = dim == 0 ? input_shape.dim(dim) : input_shape.dim(dim + 1); + const auto target_dim = target_shape.dim(dim); + if (input_dim.has_dim_value() && target_dim.has_dim_value() && + input_dim.dim_value() != target_dim.dim_value()) + fail_shape_inference("Input and target dimension value mismatch."); + } + + if (ctx.getNumInputs() == 3 && hasInputShape(ctx, 2)) { + const TensorShapeProto& weight_shape = ctx.getInputType(2)->tensor_type().shape(); + if (weight_shape.dim_size() != 1) { + fail_shape_inference("Weight rank must be 1."); + } + } + + TensorShapeProto* output_shape = ctx.getOutputType(0)->mutable_tensor_type()->mutable_shape(); + + if (getAttribute(ctx, "reduction", "mean") == "none") { + // output tensor is of shape (N, d1, d2, ..., dk) if + // reduction attribute is "none". + for (int i = 0; i < input_rank - 1; i++) { + auto* dim = output_shape->add_dim(); + if (i == 0) + *dim = input_shape.dim(i); + else + *dim = input_shape.dim(i + 1); + } + } + // otherwise output is a scalar. + } + })); + +static const char* Det_ver11_doc = R"DOC( +Det calculates determinant of a square matrix or batches of square matrices. +Det takes one input tensor of shape `[*, M, M]`, where `*` is zero or more batch dimensions, +and the inner-most 2 dimensions form square matrices. +The output is a tensor of shape `[*]`, containing the determinants of all input submatrices. +e.g., When the input is 2-D, the output is a scalar(shape is empty: `[]`). +)DOC"; + +ONNX_OPERATOR_SET_SCHEMA( + Det, + 11, + OpSchema() + .SetDoc(Det_ver11_doc) + .Input(0, "X", "Input tensor", "T", OpSchema::Single, true, 1, OpSchema::Differentiable) + .Output(0, "Y", "Output tensor", "T", OpSchema::Single, true, 1, OpSchema::Differentiable) + .TypeConstraint( + "T", + {"tensor(float16)", "tensor(float)", "tensor(double)"}, + "Constrain input and output types to floating-point tensors.") + .TypeAndShapeInferenceFunction([](InferenceContext& ctx) { + // Type inference + propagateElemTypeFromInputToOutput(ctx, 0, 0); + + // Shape inference + if (hasInputShape(ctx, 0)) { + const TensorShapeProto& input_shape = ctx.getInputType(0)->tensor_type().shape(); + TensorShapeProto* output_shape = ctx.getOutputType(0)->mutable_tensor_type()->mutable_shape(); + const int rank = static_cast(input_shape.dim_size()); + + if (rank < 2) { + fail_shape_inference("Input rank must be >= 2."); + } + + const auto mat_w = input_shape.dim(rank - 1); + const auto mat_h = input_shape.dim(rank - 2); + if (mat_w.has_dim_value() && mat_h.has_dim_value() && (mat_w.dim_value() != mat_h.dim_value())) { + fail_shape_inference( + "The inner-most 2 dimensions must have the same size (mat_w:", + mat_w.dim_value(), + " != mat_h:", + mat_h.dim_value(), + ")."); + } + + for (int i = 0; i < rank - 2; ++i) { + auto* dim = output_shape->add_dim(); + *dim = input_shape.dim(i); + } + } + })); + +static const char* Round_ver11_doc = R"DOC( +Round takes one input Tensor and rounds the values, element-wise, meaning +it finds the nearest integer for each value. +In case of halves, the rule is to round them to the nearest even integer. +If input x is integral, +0, -0, NaN, or infinite, x itself is returned. +The output tensor has the same shape and type as the input. + +Examples: +``` +round([0.9]) = [1.0] +round([2.5]) = [2.0] +round([2.3]) = [2.0] +round([1.5]) = [2.0] +round([-4.5]) = [-4.0] +``` +)DOC"; + +ONNX_OPERATOR_SET_SCHEMA( + Round, + 11, + OpSchema() + .SetDoc(Round_ver11_doc) + .Input(0, "X", "Input tensor", "T", OpSchema::Single, true, 1, OpSchema::NonDifferentiable) + .Output(0, "Y", "Output tensor", "T", OpSchema::Single, true, 1, OpSchema::NonDifferentiable) + .TypeConstraint( + "T", + {"tensor(float16)", "tensor(float)", "tensor(double)"}, + "Constrain input and output types to float tensors.") + .TypeAndShapeInferenceFunction(propagateShapeAndTypeFromFirstInput)); + +static const char* Atanh_ver9_doc = R"DOC( +Calculates the hyperbolic arctangent of the given input tensor element-wise. +)DOC"; + +ONNX_OPERATOR_SET_SCHEMA( + Atanh, + 9, + OpSchema() + .SetDoc(Atanh_ver9_doc) + .Input(0, "input", "Input tensor", "T", OpSchema::Single, true, 1, OpSchema::Differentiable) + .Output( + 0, + "output", + "The hyperbolic arctangent values of the input tensor " + "computed element-wise", + "T", + OpSchema::Single, + true, + 1, + OpSchema::Differentiable) + .TypeConstraint( + "T", + {"tensor(float16)", "tensor(float)", "tensor(double)"}, + "Constrain input and output types to float tensors.") + .TypeAndShapeInferenceFunction(propagateShapeAndTypeFromFirstInput)); + +static const char* Acosh_ver9_doc = R"DOC( +Calculates the hyperbolic arccosine of the given input tensor element-wise. +)DOC"; + +ONNX_OPERATOR_SET_SCHEMA( + Acosh, + 9, + OpSchema() + .SetDoc(Acosh_ver9_doc) + .Input(0, "input", "Input tensor", "T", OpSchema::Single, true, 1, OpSchema::Differentiable) + .Output( + 0, + "output", + "The hyperbolic arccosine values of the input tensor " + "computed element-wise", + "T", + OpSchema::Single, + true, + 1, + OpSchema::Differentiable) + .TypeConstraint( + "T", + {"tensor(float16)", "tensor(float)", "tensor(double)"}, + "Constrain input and output types to float tensors.") + .TypeAndShapeInferenceFunction(propagateShapeAndTypeFromFirstInput)); + +static const char* Asinh_ver9_doc = R"DOC( +Calculates the hyperbolic arcsine of the given input tensor element-wise. +)DOC"; + +ONNX_OPERATOR_SET_SCHEMA( + Asinh, + 9, + OpSchema() + .SetDoc(Asinh_ver9_doc) + .Input(0, "input", "Input tensor", "T", OpSchema::Single, true, 1, OpSchema::Differentiable) + .Output( + 0, + "output", + "The hyperbolic arcsine values of the input tensor " + "computed element-wise", + "T", + OpSchema::Single, + true, + 1, + OpSchema::Differentiable) + .TypeConstraint( + "T", + {"tensor(float16)", "tensor(float)", "tensor(double)"}, + "Constrain input and output types to float tensors.") + .TypeAndShapeInferenceFunction(propagateShapeAndTypeFromFirstInput)); + +static const char* Cosh_ver9_doc = R"DOC( +Calculates the hyperbolic cosine of the given input tensor element-wise. +)DOC"; + +ONNX_OPERATOR_SET_SCHEMA( + Cosh, + 9, + OpSchema() + .SetDoc(Cosh_ver9_doc) + .Input(0, "input", "Input tensor", "T", OpSchema::Single, true, 1, OpSchema::Differentiable) + .Output( + 0, + "output", + "The hyperbolic cosine values of the input tensor " + "computed element-wise", + "T", + OpSchema::Single, + true, + 1, + OpSchema::Differentiable) + .TypeConstraint( + "T", + {"tensor(float16)", "tensor(float)", "tensor(double)"}, + "Constrain input and output types to float tensors.") + .TypeAndShapeInferenceFunction(propagateShapeAndTypeFromFirstInput)); + +static const char* Sinh_ver9_doc = R"DOC( +Calculates the hyperbolic sine of the given input tensor element-wise. +)DOC"; + +ONNX_OPERATOR_SET_SCHEMA( + Sinh, + 9, + OpSchema() + .SetDoc(Sinh_ver9_doc) + .Input(0, "input", "Input tensor", "T", OpSchema::Single, true, 1, OpSchema::Differentiable) + .Output( + 0, + "output", + "The hyperbolic sine values of the input tensor " + "computed element-wise", + "T", + OpSchema::Single, + true, + 1, + OpSchema::Differentiable) + .TypeConstraint( + "T", + {"tensor(float16)", "tensor(float)", "tensor(double)"}, + "Constrain input and output types to float tensors.") + .TypeAndShapeInferenceFunction(propagateShapeAndTypeFromFirstInput)); + +static const char* Atan_ver7_doc = R"DOC( +Calculates the arctangent (inverse of tangent) of the given input tensor, element-wise. +)DOC"; + +ONNX_OPERATOR_SET_SCHEMA( + Atan, + 7, + OpSchema() + .SetDoc(Atan_ver7_doc) + .Input(0, "input", "Input tensor", "T", OpSchema::Single, true, 1, OpSchema::Differentiable) + .Output( + 0, + "output", + "The arctangent of the input tensor computed " + "element-wise", + "T", + OpSchema::Single, + true, + 1, + OpSchema::Differentiable) + .TypeConstraint( + "T", + {"tensor(float16)", "tensor(float)", "tensor(double)"}, + "Constrain input and output types to float tensors.") + .TypeAndShapeInferenceFunction(propagateShapeAndTypeFromFirstInput)); + +static const char* Acos_ver7_doc = R"DOC( +Calculates the arccosine (inverse of cosine) of the given input tensor, element-wise. +)DOC"; + +ONNX_OPERATOR_SET_SCHEMA( + Acos, + 7, + OpSchema() + .SetDoc(Acos_ver7_doc) + .Input(0, "input", "Input tensor", "T", OpSchema::Single, true, 1, OpSchema::Differentiable) + .Output( + 0, + "output", + "The arccosine of the input tensor computed " + "element-wise", + "T", + OpSchema::Single, + true, + 1, + OpSchema::Differentiable) + .TypeConstraint( + "T", + {"tensor(float16)", "tensor(float)", "tensor(double)"}, + "Constrain input and output types to float tensors.") + .TypeAndShapeInferenceFunction(propagateShapeAndTypeFromFirstInput)); + +static const char* Asin_ver7_doc = R"DOC( +Calculates the arcsine (inverse of sine) of the given input tensor, element-wise. +)DOC"; + +ONNX_OPERATOR_SET_SCHEMA( + Asin, + 7, + OpSchema() + .SetDoc(Asin_ver7_doc) + .Input(0, "input", "Input tensor", "T", OpSchema::Single, true, 1, OpSchema::Differentiable) + .Output( + 0, + "output", + "The arcsine of the input tensor computed " + "element-wise", + "T", + OpSchema::Single, + true, + 1, + OpSchema::Differentiable) + .TypeConstraint( + "T", + {"tensor(float16)", "tensor(float)", "tensor(double)"}, + "Constrain input and output types to float tensors.") + .TypeAndShapeInferenceFunction(propagateShapeAndTypeFromFirstInput)); + +static const char* Tan_ver7_doc = R"DOC( +Calculates the tangent of the given input tensor, element-wise. +)DOC"; + +ONNX_OPERATOR_SET_SCHEMA( + Tan, + 7, + OpSchema() + .SetDoc(Tan_ver7_doc) + .Input(0, "input", "Input tensor", "T", OpSchema::Single, true, 1, OpSchema::Differentiable) + .Output( + 0, + "output", + "The tangent of the input tensor computed " + "element-wise", + "T", + OpSchema::Single, + true, + 1, + OpSchema::Differentiable) + .TypeConstraint( + "T", + {"tensor(float16)", "tensor(float)", "tensor(double)"}, + "Constrain input and output types to float tensors.") + .TypeAndShapeInferenceFunction(propagateShapeAndTypeFromFirstInput)); + +static const char* Cos_ver7_doc = R"DOC( +Calculates the cosine of the given input tensor, element-wise. +)DOC"; + +ONNX_OPERATOR_SET_SCHEMA( + Cos, + 7, + OpSchema() + .SetDoc(Cos_ver7_doc) + .Input(0, "input", "Input tensor", "T", OpSchema::Single, true, 1, OpSchema::Differentiable) + .Output( + 0, + "output", + "The cosine of the input tensor computed " + "element-wise", + "T", + OpSchema::Single, + true, + 1, + OpSchema::Differentiable) + .TypeConstraint( + "T", + {"tensor(float16)", "tensor(float)", "tensor(double)"}, + "Constrain input and output types to float tensors.") + .TypeAndShapeInferenceFunction(propagateShapeAndTypeFromFirstInput)); + +static const char* Sin_ver7_doc = R"DOC( +Calculates the sine of the given input tensor, element-wise. +)DOC"; + +ONNX_OPERATOR_SET_SCHEMA( + Sin, + 7, + OpSchema() + .SetDoc(Sin_ver7_doc) + .Input(0, "input", "Input tensor", "T", OpSchema::Single, true, 1, OpSchema::Differentiable) + .Output( + 0, + "output", + "The sine of the input tensor computed " + "element-wise", + "T", + OpSchema::Single, + true, + 1, + OpSchema::Differentiable) + .TypeConstraint( + "T", + {"tensor(float16)", "tensor(float)", "tensor(double)"}, + "Constrain input and output types to float tensors.") + .TypeAndShapeInferenceFunction(propagateShapeAndTypeFromFirstInput)); + +static const char* Softplus_ver1_doc = R"DOC( +Softplus takes one input data (Tensor) and produces one output data +(Tensor) where the softplus function, y = ln(exp(x) + 1), is applied to +the tensor elementwise. +)DOC"; + +ONNX_OPERATOR_SET_SCHEMA( + Softplus, + 1, + OpSchema() + .SetDoc(Softplus_ver1_doc) + .Input(0, "X", "1D input tensor", "T", OpSchema::Single, true, 1, OpSchema::Differentiable) + .Output(0, "Y", "1D input tensor", "T", OpSchema::Single, true, 1, OpSchema::Differentiable) + .TypeConstraint( + "T", + {"tensor(float16)", "tensor(float)", "tensor(double)"}, + "Constrain input and output types to float tensors.") + .TypeAndShapeInferenceFunction(propagateShapeAndTypeFromFirstInput) + .FunctionBody( + R"ONNX( + { + exp_x = Exp (X) + one = Constant () + one_cast = CastLike (one, X) + exp_x_add_one = Add (exp_x, one_cast) + Y = Log (exp_x_add_one) + } + )ONNX", + 18)); + +static const char* Softsign_ver1_doc = R"DOC( +Calculates the softsign (x/(1+|x|)) of the given input tensor element-wise. +)DOC"; + +ONNX_OPERATOR_SET_SCHEMA( + Softsign, + 1, + OpSchema() + .SetDoc(Softsign_ver1_doc) + .Input(0, "input", "Input tensor", "T", OpSchema::Single, true, 1, OpSchema::Differentiable) + .Output( + 0, + "output", + "The softsign (x/(1+|x|)) values of the input tensor computed element-wise", + "T", + OpSchema::Single, + true, + 1, + OpSchema::Differentiable) + .TypeConstraint( + "T", + {"tensor(float16)", "tensor(float)", "tensor(double)"}, + "Constrain input and output types to float tensors.") + .TypeAndShapeInferenceFunction(propagateShapeAndTypeFromFirstInput) + .FunctionBody( + R"ONNX( + { + One = Constant () + OneCast = CastLike (One, input) + AbsInput = Abs(input) + OneAddAbsInput = Add (OneCast, AbsInput) + output = Div(input, OneAddAbsInput) + } + )ONNX", + 18)); + +static const char* HardSwish_ver14_doc = R"DOC( +HardSwish takes one input data (Tensor) and produces one output data (Tensor) where +the HardSwish function, y = x * max(0, min(1, alpha * x + beta)) = x * HardSigmoid(x), +where alpha = 1/6 and beta = 0.5, is applied to the tensor elementwise. +)DOC"; + +ONNX_OPERATOR_SET_SCHEMA( + HardSwish, + 14, + OpSchema() + .SetDoc(HardSwish_ver14_doc) + .Input(0, "X", "Input tensor", "T", OpSchema::Single, true, 1, OpSchema::Differentiable) + .Output(0, "Y", "Output tensor", "T", OpSchema::Single, true, 1, OpSchema::Differentiable) + .TypeConstraint( + "T", + {"tensor(float16)", "tensor(float)", "tensor(double)"}, + "Constrain input and output types to float tensors.") + .TypeAndShapeInferenceFunction(propagateShapeAndTypeFromFirstInput) + .FunctionBody(R"ONNX( + { + HS_X = HardSigmoid(X) + Y = Mul (X, HS_X) + } + )ONNX")); + +static const char* HardSigmoid_ver6_doc = R"DOC( +HardSigmoid takes one input data (Tensor) and produces one output data +(Tensor) where the HardSigmoid function, y = max(0, min(1, alpha * x + beta)), +is applied to the tensor elementwise. +)DOC"; + +ONNX_OPERATOR_SET_SCHEMA( + HardSigmoid, + 6, + OpSchema() + .Attr("alpha", "Value of alpha.", AttributeProto::FLOAT, 0.2f) + .Attr("beta", "Value of beta.", AttributeProto::FLOAT, 0.5f) + .SetDoc(HardSigmoid_ver6_doc) + .Input(0, "X", "Input tensor", "T", OpSchema::Single, true, 1, OpSchema::Differentiable) + .Output(0, "Y", "Output tensor", "T", OpSchema::Single, true, 1, OpSchema::Differentiable) + .TypeConstraint( + "T", + {"tensor(float16)", "tensor(float)", "tensor(double)"}, + "Constrain input and output types to float tensors.") + .TypeAndShapeInferenceFunction(propagateShapeAndTypeFromFirstInput) + .FunctionBody( + R"ONNX( + { + Alpha = Constant () + AlphaCast = CastLike (Alpha, X) + Beta = Constant () + BetaCast = CastLike (Beta, X) + Zero = Constant () + ZeroCast = CastLike (Zero, X) + One = Constant () + OneCast = CastLike (One, X) + AlphaMulX = Mul (X, AlphaCast) + AlphaMulXAddBeta = Add (AlphaMulX, BetaCast) + MinOneOrAlphaMulXAddBeta = Min (AlphaMulXAddBeta, OneCast) + Y = Max(MinOneOrAlphaMulXAddBeta, ZeroCast) + } + )ONNX", + 18)); + +static const char* mish_ver18_doc = R"DOC( +Mish: A Self Regularized Non-Monotonic Neural Activation Function. + +Perform the linear unit element-wise on the input tensor X using formula: + +``` +mish(x) = x * tanh(softplus(x)) = x * tanh(ln(1 + e^{x})) +``` +)DOC"; + +ONNX_OPERATOR_SET_SCHEMA( + Mish, + 18, + OpSchema() + .SetDoc(mish_ver18_doc) + .Input(0, "X", "Input tensor", "T", OpSchema::Single, true, 1, OpSchema::Differentiable) + .Output(0, "Y", "Output tensor", "T", OpSchema::Single, true, 1, OpSchema::Differentiable) + .TypeConstraint( + "T", + {"tensor(float16)", "tensor(float)", "tensor(double)"}, + "Constrain input X and output types to float tensors.") + .FunctionBody(R"ONNX( + { + Softplus_X = Softplus (X) + TanHSoftplusX = Tanh (Softplus_X) + Y = Mul (X, TanHSoftplusX) + } + )ONNX") + .TypeAndShapeInferenceFunction(propagateShapeAndTypeFromFirstInput)); + +static const char* Elu_ver6_doc = R"DOC( +Elu takes one input data (Tensor) and produces one output data +(Tensor) where the function `f(x) = alpha * (exp(x) - 1.) for x < +0`, `f(x) = x for x >= 0`., is applied to the tensor elementwise. + +)DOC"; + +ONNX_OPERATOR_SET_SCHEMA( + Elu, + 6, + OpSchema() + .Attr("alpha", "Coefficient of ELU.", AttributeProto::FLOAT, 1.0f) + .SetDoc(Elu_ver6_doc) + .Input(0, "X", "1D input tensor", "T", OpSchema::Single, true, 1, OpSchema::Differentiable) + .Output(0, "Y", "1D output tensor", "T", OpSchema::Single, true, 1, OpSchema::Differentiable) + .TypeConstraint( + "T", + {"tensor(float16)", "tensor(float)", "tensor(double)"}, + "Constrain input and output types to float tensors.") + .TypeAndShapeInferenceFunction(propagateShapeAndTypeFromFirstInput) + .FunctionBody( + R"ONNX( + { + Alpha = Constant () + AlphaCast = CastLike (Alpha, X) + Zero = Constant () + ZeroCast = CastLike (Zero, X) + One = Constant () + OneCast = CastLike (One, X) + XLessThanZero = Less (X, ZeroCast) + ExpX = Exp (X) + ExpXSubOne = Sub (ExpX, OneCast) + AlphaMulExpXSubOne = Mul (AlphaCast, ExpXSubOne) + Y = Where(XLessThanZero, AlphaMulExpXSubOne, X) + } + )ONNX", + 18)); + +static const char* Selu_ver6_doc = R"DOC( +Selu takes one input data (Tensor) and produces one output data +(Tensor) where the scaled exponential linear unit function, +`y = gamma * (alpha * e^x - alpha) for x <= 0`, `y = gamma * x for x > 0`, +is applied to the tensor elementwise. +)DOC"; + +ONNX_OPERATOR_SET_SCHEMA( + Selu, + 6, + OpSchema() + .Attr( + "alpha", + "Coefficient of SELU default to 1.67326319217681884765625 " + "(i.e., float32 approximation of 1.6732632423543772848170429916717).", + AttributeProto::FLOAT, + 1.67326319217681884765625f) + .Attr( + "gamma", + "Coefficient of SELU default to 1.05070102214813232421875 " + "(i.e., float32 approximation of 1.0507009873554804934193349852946).", + AttributeProto::FLOAT, + 1.05070102214813232421875f) + .SetDoc(Selu_ver6_doc) + .Input(0, "X", "Input tensor", "T", OpSchema::Single, true, 1, OpSchema::Differentiable) + .Output(0, "Y", "Output tensor", "T", OpSchema::Single, true, 1, OpSchema::Differentiable) + .TypeConstraint( + "T", + {"tensor(float16)", "tensor(float)", "tensor(double)"}, + "Constrain input and output types to float tensors.") + .TypeAndShapeInferenceFunction(propagateShapeAndTypeFromFirstInput) + .FunctionBody( + R"ONNX( + { + Alpha = Constant () + AlphaCast = CastLike (Alpha, X) + Gamma = Constant () + GammaCast = CastLike (Gamma, X) + Zero = Constant () + ZeroCast = CastLike (Zero, X) + ExpX = Exp (X) + AlphaMulExpX = Mul(AlphaCast, ExpX) + AlphaMulExpXSubAlpha = Sub (AlphaMulExpX, AlphaCast) + Neg = Mul (GammaCast, AlphaMulExpXSubAlpha) + Pos = Mul (GammaCast, X) + XLessThanZero = Less (X, ZeroCast) + Y = Where(XLessThanZero, Neg, Pos) + } + )ONNX", + 18)); + +static const char* ThresholdedRelu_ver10_doc = R"DOC( +ThresholdedRelu takes one input data (Tensor) and produces one output data +(Tensor) where the rectified linear function, y = x for x > alpha, y = 0 otherwise, +is applied to the tensor elementwise. +)DOC"; + +ONNX_OPERATOR_SET_SCHEMA( + ThresholdedRelu, + 10, + OpSchema() + .SetDoc(ThresholdedRelu_ver10_doc) + .Attr("alpha", "Threshold value", AttributeProto::FLOAT, 1.0f) + .Input(0, "X", "Input tensor", "T", OpSchema::Single, true, 1, OpSchema::Differentiable) + .Output(0, "Y", "Output tensor", "T", OpSchema::Single, true, 1, OpSchema::Differentiable) + .TypeConstraint( + "T", + {"tensor(float16)", "tensor(float)", "tensor(double)"}, + "Constrain input and output types to float tensors.") + .TypeAndShapeInferenceFunction(propagateShapeAndTypeFromFirstInput) + .FunctionBody( + R"ONNX( + { + Alpha = Constant () + AlphaCast = CastLike (Alpha, X) + Zero = Constant () + ZeroCast = CastLike (Zero, X) + AlphaLessThanX = Less(AlphaCast, X) + Y = Where(AlphaLessThanX, X, ZeroCast) + } + )ONNX", + 18)); + std::function MathDocGenerator_opset13(const char* name) { return [=](OpSchema& schema) { std::string doc; diff --git a/onnx/defs/math/utils.cc b/onnx/defs/math/utils.cc index e2c6b809673..6b96bace164 100644 --- a/onnx/defs/math/utils.cc +++ b/onnx/defs/math/utils.cc @@ -11,6 +11,17 @@ namespace defs { namespace math { namespace utils { +int MathOpTwoIntegers(std::string op_type, int a, int b) { + if (op_type == "Add") { + return a + b; + } else if (op_type == "Sub") { + return a - b; + } else if (op_type == "Mul") { + return a * b; + } + fail_shape_inference("Wrong op_type name for running propagation: ", op_type); +} + void MatMulShapeInference(ONNX_NAMESPACE::InferenceContext& ctx, int input1Idx, int input2Idx) { if (!hasInputShape(ctx, input1Idx) || !hasInputShape(ctx, input2Idx)) { return; diff --git a/onnx/defs/math/utils.h b/onnx/defs/math/utils.h index 9bbb66be7c6..1151c55ef24 100644 --- a/onnx/defs/math/utils.h +++ b/onnx/defs/math/utils.h @@ -40,6 +40,8 @@ void QLinearMatMulShapeInference(ONNX_NAMESPACE::InferenceContext& ctx); const char* QLinearMatMulDoc(); +int MathOpTwoIntegers(std::string op_type, int a, int b); + } // namespace utils } // namespace math } // namespace defs diff --git a/onnx/defs/nn/defs.cc b/onnx/defs/nn/defs.cc index 9757edb3a69..be6a851dc25 100644 --- a/onnx/defs/nn/defs.cc +++ b/onnx/defs/nn/defs.cc @@ -192,9 +192,9 @@ void convPoolShapeInference( std::vector GetSupportedDataTypesForPoolingOps(bool supports8bit) { if (supports8bit) { - return {"tensor(float16)", "tensor(float)", "tensor(double)", "tensor(int8)", "tensor(uint8)"}; + return OpSchema::all_float_types_plus_Xint8_ir4(); } - return {"tensor(float16)", "tensor(float)", "tensor(double)"}; + return OpSchema::all_float_types_ir4(); } std::function PoolOpSchemaGenerator( @@ -313,7 +313,7 @@ std::function PoolOpSchemaGenerator( ONNX_OPERATOR_SET_SCHEMA( AveragePool, - 19, + 22, OpSchema() .FillUsing(PoolOpSchemaGenerator( "AveragePool", @@ -334,7 +334,7 @@ ONNX_OPERATOR_SET_SCHEMA( ONNX_OPERATOR_SET_SCHEMA( MaxPool, - 12, + 22, OpSchema() .FillUsing(PoolOpSchemaGenerator( "MaxPool", @@ -454,7 +454,7 @@ void maxUnpoolShapeInference(InferenceContext& ctx) { } } -static const char* MaxUnpool_ver11_doc = R"DOC( +static const char* MaxUnpool_ver22_doc = R"DOC( MaxUnpool essentially computes the partial inverse of the MaxPool op. The input information to this op is typically the output information from a MaxPool op. The first input tensor X is the tensor that needs to be unpooled, which is typically the pooled tensor (first output) @@ -477,9 +477,9 @@ In addition to the inputs, MaxUnpool takes three attributes, namely kernel_shape ONNX_OPERATOR_SET_SCHEMA( MaxUnpool, - 11, + 22, OpSchema() - .SetDoc(MaxUnpool_ver11_doc) + .SetDoc(MaxUnpool_ver22_doc) .Attr("kernel_shape", "The size of the kernel along each axis.", AttributeProto::INTS) .Attr( "strides", @@ -541,10 +541,7 @@ ONNX_OPERATOR_SET_SCHEMA( true, 1, OpSchema::Differentiable) - .TypeConstraint( - "T1", - {"tensor(float16)", "tensor(float)", "tensor(double)"}, - "Constrain input and output types to float tensors.") + .TypeConstraint("T1", OpSchema::all_float_types_ir4(), "Constrain input and output types to float tensors.") .TypeConstraint("T2", {"tensor(int64)"}, "Constrain index tensor to int64") .TypeAndShapeInferenceFunction([](InferenceContext& ctx) { maxUnpoolShapeInference(ctx); })); @@ -624,10 +621,7 @@ std::function LpPoolOpSchemaGenerator(const char* name) { true, 1, OpSchema::Differentiable); - schema.TypeConstraint( - "T", - {"tensor(float16)", "tensor(float)", "tensor(double)"}, - "Constrain input and output types to float tensors."); + schema.TypeConstraint("T", OpSchema::all_float_types_ir4(), "Constrain input and output types to float tensors."); schema.TypeAndShapeInferenceFunction([](InferenceContext& ctx) { propagateElemTypeFromInputToOutput(ctx, 0, 0); convPoolShapeInference(ctx, true, true, 0, 1); @@ -635,7 +629,7 @@ std::function LpPoolOpSchemaGenerator(const char* name) { }; } -ONNX_OPERATOR_SET_SCHEMA(LpPool, 18, OpSchema().FillUsing(LpPoolOpSchemaGenerator("LpPool"))); +ONNX_OPERATOR_SET_SCHEMA(LpPool, 22, OpSchema().FillUsing(LpPoolOpSchemaGenerator("LpPool"))); // For ROI pool operations. void roiPoolTypeShapeInference(InferenceContext& ctx) { @@ -725,15 +719,12 @@ std::function RoiPoolOpSchemaGenerator(const char* name) { true, 1, OpSchema::Differentiable); - schema.TypeConstraint( - "T", - {"tensor(float16)", "tensor(float)", "tensor(double)"}, - "Constrain input and output types to float tensors."); + schema.TypeConstraint("T", OpSchema::all_float_types_ir4(), "Constrain input and output types to float tensors."); schema.TypeAndShapeInferenceFunction([](InferenceContext& ctx) { roiPoolTypeShapeInference(ctx); }); }; } -ONNX_OPERATOR_SET_SCHEMA(MaxRoiPool, 1, OpSchema().FillUsing(RoiPoolOpSchemaGenerator("max"))); +ONNX_OPERATOR_SET_SCHEMA(MaxRoiPool, 22, OpSchema().FillUsing(RoiPoolOpSchemaGenerator("max"))); std::function ConvOpSchemaGenerator(const char* filter_desc) { return [=](OpSchema& schema) { @@ -806,10 +797,7 @@ computes the output.)DOC"; true, 1, OpSchema::Differentiable); - schema.TypeConstraint( - "T", - {"tensor(float16)", "tensor(float)", "tensor(double)"}, - "Constrain input and output types to float tensors."); + schema.TypeConstraint("T", OpSchema::all_float_types_ir4(), "Constrain input and output types to float tensors."); schema.Attr( "kernel_shape", "The shape of the convolution kernel. If not present, should be inferred from input W.", @@ -839,7 +827,7 @@ computes the output.)DOC"; }; } -ONNX_OPERATOR_SET_SCHEMA(Conv, 11, OpSchema().FillUsing(ConvOpSchemaGenerator("a filter"))); +ONNX_OPERATOR_SET_SCHEMA(Conv, 22, OpSchema().FillUsing(ConvOpSchemaGenerator("a filter"))); static const char* QLinearConv_ver10_doc = R"DOC( The convolution operator consumes a quantized input tensor, its scale and zero point, @@ -1322,10 +1310,7 @@ output_shape can also be explicitly specified in which case pads values are auto true, 1, OpSchema::Differentiable); - schema.TypeConstraint( - "T", - {"tensor(float16)", "tensor(float)", "tensor(double)"}, - "Constrain input and output types to float tensors."); + schema.TypeConstraint("T", OpSchema::all_float_types_ir4(), "Constrain input and output types to float tensors."); schema.Attr( "kernel_shape", "The shape of the convolution kernel. If not present, should be inferred from input W.", @@ -1373,18 +1358,18 @@ output_shape can also be explicitly specified in which case pads values are auto }; } -ONNX_OPERATOR_SET_SCHEMA(ConvTranspose, 11, OpSchema().FillUsing(ConvTransposeOpSchemaGenerator("a filter"))); +ONNX_OPERATOR_SET_SCHEMA(ConvTranspose, 22, OpSchema().FillUsing(ConvTransposeOpSchemaGenerator("a filter"))); -static const char* DeformConv_ver19_doc = R"DOC( +static const char* DeformConv_ver22_doc = R"DOC( Performs deformable convolution as described in https://arxiv.org/abs/1703.06211 and https://arxiv.org/abs/1811.11168. This operator specification supports the general N-D case. Note that most common use cases have 2D or 3D data. )DOC"; ONNX_OPERATOR_SET_SCHEMA( DeformConv, - 19, + 22, OpSchema() - .SetDoc(DeformConv_ver19_doc) + .SetDoc(DeformConv_ver22_doc) .Input( 0, "X", @@ -1429,10 +1414,7 @@ ONNX_OPERATOR_SET_SCHEMA( "Output data tensor that contains the result of convolution. It has shape (N, oC, oH, oW) " "for 2D data or (N, oC, o1, o2, ..., on) for nD data", "T") - .TypeConstraint( - "T", - {"tensor(float16)", "tensor(float)", "tensor(double)"}, - "Constrain input and output types to float tensors.") + .TypeConstraint("T", OpSchema::all_float_types_ir4(), "Constrain input and output types to float tensors.") .Attr( "dilations", "Dilation value along each spatial axis of the kernel. Default is 1 along each axis.", @@ -1537,18 +1519,15 @@ std::function GlobalPoolingOpSchemaGenerator(const char* op_typ true, 1, OpSchema::Differentiable); - schema.TypeConstraint( - "T", - {"tensor(float16)", "tensor(float)", "tensor(double)"}, - "Constrain input and output types to float tensors."); + schema.TypeConstraint("T", OpSchema::all_float_types_ir4(), "Constrain input and output types to float tensors."); schema.TypeAndShapeInferenceFunction([](InferenceContext& ctx) { globalPoolTypeShapeInference(ctx); }); }; } ONNX_OPERATOR_SET_SCHEMA( GlobalAveragePool, - 1, + 22, OpSchema().FillUsing(GlobalPoolingOpSchemaGenerator("AveragePool", "average"))); -ONNX_OPERATOR_SET_SCHEMA(GlobalMaxPool, 1, OpSchema().FillUsing(GlobalPoolingOpSchemaGenerator("MaxPool", "max"))); +ONNX_OPERATOR_SET_SCHEMA(GlobalMaxPool, 22, OpSchema().FillUsing(GlobalPoolingOpSchemaGenerator("MaxPool", "max"))); std::function GlobalLpPoolingOpSchemaGenerator(const char* op_type, const char* op) { return [=](OpSchema& schema) { @@ -1597,7 +1576,7 @@ std::function GlobalLpPoolingOpSchemaGenerator(const char* op_t }; } -ONNX_OPERATOR_SET_SCHEMA(GlobalLpPool, 2, OpSchema().FillUsing(GlobalLpPoolingOpSchemaGenerator("LpPool", "lp pool"))); +ONNX_OPERATOR_SET_SCHEMA(GlobalLpPool, 22, OpSchema().FillUsing(GlobalLpPoolingOpSchemaGenerator("LpPool", "lp pool"))); static const char* BatchNormalization_ver15_doc = R"DOC( Carries out batch normalization as described in the paper @@ -1779,7 +1758,7 @@ ONNX_OPERATOR_SET_SCHEMA( } })); -static const char* InstanceNormalization_ver6_doc = R"DOC( +static const char* InstanceNormalization_ver22_doc = R"DOC( Carries out instance normalization as described in the paper https://arxiv.org/abs/1607.08022. @@ -1790,9 +1769,9 @@ where mean and variance are computed per instance per channel. ONNX_OPERATOR_SET_SCHEMA( InstanceNormalization, - 6, + 22, OpSchema() - .SetDoc(InstanceNormalization_ver6_doc) + .SetDoc(InstanceNormalization_ver22_doc) .Attr("epsilon", "The epsilon value to use to avoid division by zero.", AttributeProto::FLOAT, 1e-5f) .Input( 0, @@ -1837,27 +1816,21 @@ ONNX_OPERATOR_SET_SCHEMA( true, 1, OpSchema::Differentiable) - .TypeConstraint( - "T", - {"tensor(float16)", "tensor(float)", "tensor(double)"}, - "Constrain input and output types to float tensors.") + .TypeConstraint("T", OpSchema::all_float_types_ir4(), "Constrain input and output types to float tensors.") .TypeAndShapeInferenceFunction([](InferenceContext& ctx) { propagateShapeAndTypeFromFirstInput(ctx); })); -static const char* LpNormalization_ver1_doc = R"DOC( +static const char* LpNormalization_ver22_doc = R"DOC( Given a matrix, apply Lp-normalization along the provided axis. )DOC"; ONNX_OPERATOR_SET_SCHEMA( LpNormalization, - 1, + 22, OpSchema() .Input(0, "input", "Input matrix", "T", OpSchema::Single, true, 1, OpSchema::Differentiable) .Output(0, "output", "Matrix after normalization", "T", OpSchema::Single, true, 1, OpSchema::Differentiable) - .TypeConstraint( - "T", - {"tensor(float16)", "tensor(float)", "tensor(double)"}, - "Constrain input and output types to float tensors.") - .SetDoc(LpNormalization_ver1_doc) + .TypeConstraint("T", OpSchema::all_float_types_ir4(), "Constrain input and output types to float tensors.") + .SetDoc(LpNormalization_ver22_doc) .Attr( "axis", "The axis on which to apply normalization, -1 mean last axis.", @@ -1870,7 +1843,7 @@ ONNX_OPERATOR_SET_SCHEMA( static_cast(2)) .TypeAndShapeInferenceFunction([](InferenceContext& ctx) { propagateShapeAndTypeFromFirstInput(ctx); })); -static const char* Dropout_ver13_doc = R"DOC( +static const char* Dropout_ver22_doc = R"DOC( Dropout takes an input floating-point tensor, an optional input ratio (floating-point scalar) and an optional input training_mode (boolean scalar). It produces two tensor outputs, output (floating-point tensor) and mask (optional `Tensor`). If `training_mode` is true then the output Y will be a random dropout; Note that this Dropout scales the masked input data by the following equation, so to convert the trained model into inference mode, @@ -1886,9 +1859,9 @@ scale = 1. / (1. - ratio). ONNX_OPERATOR_SET_SCHEMA( Dropout, - 13, + 22, OpSchema() - .SetDoc(GET_OP_DOC_STR(std::string(Dropout_ver13_doc) + GenerateOptionalArgumentsDoc())) + .SetDoc(GET_OP_DOC_STR(std::string(Dropout_ver22_doc) + GenerateOptionalArgumentsDoc())) .Attr( "seed", "(Optional) Seed to the random generator, if not specified we will auto generate one.", @@ -1920,14 +1893,8 @@ ONNX_OPERATOR_SET_SCHEMA( OpSchema::NonDifferentiable) .Output(0, "output", "The output.", "T", OpSchema::Single, true, 1, OpSchema::Differentiable) .Output(1, "mask", "The output mask.", "T2", OpSchema::Optional, true, 1, OpSchema::NonDifferentiable) - .TypeConstraint( - "T", - {"tensor(float16)", "tensor(float)", "tensor(double)", "tensor(bfloat16)"}, - "Constrain input and output types to float tensors.") - .TypeConstraint( - "T1", - {"tensor(float16)", "tensor(float)", "tensor(double)"}, - "Constrain input 'ratio' types to float tensors.") + .TypeConstraint("T", OpSchema::all_float_types_ir10(), "Constrain input and output types to float tensors.") + .TypeConstraint("T1", OpSchema::all_float_types_ir10(), "Constrain input 'ratio' types to float tensors.") .TypeConstraint("T2", {"tensor(bool)"}, "Constrain output 'mask' types to boolean tensors.") .TypeAndShapeInferenceFunction([](InferenceContext& ctx) { propagateElemTypeFromInputToOutput(ctx, 0, 0); diff --git a/onnx/defs/nn/old.cc b/onnx/defs/nn/old.cc index 4c12dc94b23..57f8e2a4fdf 100644 --- a/onnx/defs/nn/old.cc +++ b/onnx/defs/nn/old.cc @@ -9,6 +9,1537 @@ namespace ONNX_NAMESPACE { +// For GlobalPool operations. +void globalPoolTypeShapeInference_opset2(InferenceContext& ctx) { + propagateElemTypeFromInputToOutput(ctx, 0, 0); + + // needs at least one input with shape. + if (!hasNInputShapes(ctx, 1)) { + return; + } + + auto input_shape = ctx.getInputType(0)->tensor_type().shape(); + if (input_shape.dim_size() < 2) { + return; + } + + // first dim is the batch axis and the next is the number of channels. + size_t n_input_dims = static_cast(input_shape.dim_size() - 2); + + // (N, C, 1, 1, ..., 1) + auto output_shape = ctx.getOutputType(0)->mutable_tensor_type()->mutable_shape(); + *output_shape->add_dim() = input_shape.dim(0); + *output_shape->add_dim() = input_shape.dim(1); + + for (size_t i = 0; i < n_input_dims; ++i) { + output_shape->add_dim()->set_dim_value(1); + } +} + +std::function GlobalLpPoolingOpSchemaGenerator_opset2(const char* op_type, const char* op) { + return [=](OpSchema& schema) { + std::string doc; + POPULATE_OP_DOC_STR(doc = R"DOC( + Global{op_type} consumes an input tensor X and applies {op} pooling across + the values in the same channel. This is equivalent to {op_type} with kernel size + equal to the spatial dimension of input tensor.)DOC"; + ReplaceAll(doc, "{op_type}", op_type); + ReplaceAll(doc, "{op}", op);); + schema.SetDoc(doc); + schema.Attr( + "p", "p value of the Lp norm used to pool over the input data.", AttributeProto::INT, static_cast(2)); + schema.Input( + 0, + "X", + "Input data tensor from the previous operator; " + "dimensions for image case are (N x C x H x W), " + "where N is the batch size, C is the number of " + "channels, and H and W are the height and the width " + "of the data. For non image case, the dimensions are " + "in the form of (N x C x D1 x D2 ... Dn), " + "where N is the batch size.", + "T", + OpSchema::Single, + true, + 1, + OpSchema::Differentiable); + schema.Output( + 0, + "Y", + "Output data tensor from pooling across the input " + "tensor. The output tensor has the same rank as the input. " + "The first two dimensions of output shape are the same as " + "the input (N x C), while the other dimensions are all 1.", + "T", + OpSchema::Single, + true, + 1, + OpSchema::Differentiable); + schema.TypeConstraint("T", OpSchema::all_float_types_ir4(), "Constrain input and output types to float tensors."); + schema.TypeAndShapeInferenceFunction([](InferenceContext& ctx) { globalPoolTypeShapeInference_opset2(ctx); }); + }; +} + +ONNX_OPERATOR_SET_SCHEMA( + GlobalLpPool, + 2, + OpSchema().FillUsing(GlobalLpPoolingOpSchemaGenerator_opset2("LpPool", "lp pool"))); + +const char* pads_doc_opset11 = + "Padding for the beginning and ending along each spatial axis, it can take any value greater " + "than or equal to 0. The value represent the number of pixels added to the beginning " + "and end part of the corresponding axis. `pads` format should be as follow " + "[x1_begin, x2_begin...x1_end, x2_end,...], where xi_begin the number of pixels " + "added at the beginning of axis `i` and xi_end, the number of pixels added at " + "the end of axis `i`. This attribute cannot be used simultaneously with " + "auto_pad attribute. If not present, the padding defaults to 0 along start and end of each spatial axis."; +const char* conv_auto_pad_doc_opset19 = + "auto_pad must be either NOTSET, SAME_UPPER, SAME_LOWER or VALID. Where " + "default value is NOTSET, which means explicit padding is used. " + "SAME_UPPER or SAME_LOWER mean pad the input so that " + "`output_shape[i] = ceil(input_shape[i] / strides[i])` for each axis `i`. " + "The padding is split between the two sides equally or almost equally (depending " + "on whether it is even or odd). In case the padding is an odd number, the extra " + "padding is added at the end for SAME_UPPER and at the beginning for SAME_LOWER."; +const char* conv_transpose_auto_pad_doc_opset19 = + "auto_pad must be either NOTSET, SAME_UPPER, SAME_LOWER or VALID. Where " + "default value is NOTSET, which means explicit padding is used. " + "SAME_UPPER or SAME_LOWER mean pad the input so that " + "`output_shape[i] = input_shape[i] * strides[i]` for each axis `i`. " + "The padding is split between the two sides equally or almost equally (depending " + "on whether it is even or odd). In case the padding is an odd number, the extra " + "padding is added at the end for SAME_UPPER and at the beginning for SAME_LOWER."; + +void convPoolShapeInference_opset19( + InferenceContext& ctx, + bool use_dilation, + bool require_kernel_shape, + int input1Idx, + int input2Idx) { + // we need the first input shape for this inference. + if (!hasInputShape(ctx, input1Idx)) { + return; + } + + // if kernel shape is an input (and not attribute) + // we need the shape of the second input. + if (!require_kernel_shape && !hasInputShape(ctx, input2Idx)) { + return; + } + + auto input_shape = ctx.getInputType(input1Idx)->tensor_type().shape(); + if (input_shape.dim_size() < 2) { + fail_shape_inference("Input tensor must have at least 2 dimensions"); + } + + // first dim is the batch axis and the next is the number of channels. + size_t n_input_dims = static_cast(input_shape.dim_size() - 2); + + // Only MaxPool and Conv support dilation. For + // simplicity of the code, we just treat the rest of them as having all-1s + // dilation. + std::vector dilations; + if (use_dilation && getRepeatedAttribute(ctx, "dilations", dilations)) { + if (dilations.size() != n_input_dims) { + fail_shape_inference("Attribute dilations has incorrect size"); + } + } else { + dilations.assign(n_input_dims, 1); + } + + std::vector strides; + if (getRepeatedAttribute(ctx, "strides", strides)) { + if (strides.size() != n_input_dims) { + fail_shape_inference("Attribute strides has incorrect size"); + } + } else { + strides.assign(n_input_dims, 1); + } + + std::vector kernel_shape; + if (getRepeatedAttribute(ctx, "kernel_shape", kernel_shape)) { + if (kernel_shape.size() != n_input_dims) { + fail_shape_inference("Attribute kernel_shape has incorrect size"); + } + } else if (require_kernel_shape) { + fail_shape_inference("Attribute kernel_shape must be specified"); + } else { + auto second_input_shape = ctx.getInputType(input2Idx)->tensor_type().shape(); + for (int i = 2; i < second_input_shape.dim_size(); ++i) { + if (!second_input_shape.dim(i).has_dim_value()) { + return; + } + kernel_shape.push_back(second_input_shape.dim(i).dim_value()); + } + } + + std::vector effective_kernel_shape = kernel_shape; + for (int i = 0; i < static_cast(kernel_shape.size()); i++) { + // accounting for dilation, how big is the kernel in this dimension + effective_kernel_shape[i] = (effective_kernel_shape[i] - 1) * dilations[i] + 1; + } + + std::vector pads; + if (getRepeatedAttribute(ctx, "pads", pads)) { + if (pads.size() != n_input_dims * 2) { + fail_shape_inference("Attribute pads has incorrect size"); + } + } else { + pads.assign(n_input_dims * 2, 0); + const auto* auto_pad_attr = ctx.getAttribute("auto_pad"); + if ((nullptr != auto_pad_attr) && (auto_pad_attr->s() != "VALID")) { + int input_dims_size = static_cast(n_input_dims); + for (int i = 0; i < input_dims_size; ++i) { + int64_t residual = 0; + int64_t stride = strides[i]; + if (stride > 1) { + if (!input_shape.dim(2 + i).has_dim_value()) { + continue; + } + residual = input_shape.dim(2 + i).dim_value(); + while (residual >= stride) { + residual -= stride; + } + } + int64_t total_pad = residual == 0 ? effective_kernel_shape[i] - stride : effective_kernel_shape[i] - residual; + if (total_pad < 0) + total_pad = 0; + int64_t half_pad_small = total_pad >> 1; + int64_t half_pad_big = total_pad - half_pad_small; + if (auto_pad_attr->s() == "SAME_UPPER") { + pads[i] = half_pad_small; + pads[i + input_dims_size] = half_pad_big; + } else if (auto_pad_attr->s() == "SAME_LOWER") { + pads[i] = half_pad_big; + pads[i + input_dims_size] = half_pad_small; + } + } + } + } + + auto output_shape = ctx.getOutputType(0)->mutable_tensor_type()->mutable_shape(); + + if (require_kernel_shape) { + // add the first two dimensions from the input. + *output_shape->add_dim() = input_shape.dim(0); + *output_shape->add_dim() = input_shape.dim(1); + } else { + *output_shape->add_dim() = input_shape.dim(0); + auto& second_input_shape = getInputShape(ctx, input2Idx); + if (second_input_shape.dim_size() < 1) { + fail_shape_inference("Second input tensor has wrong dimension"); + } + *output_shape->add_dim() = second_input_shape.dim(0); + } + + int kernel_shape_size = static_cast(kernel_shape.size()); + for (int i = 0; i < kernel_shape_size; ++i) { + auto newdim = output_shape->add_dim(); + if (!input_shape.dim(2 + i).has_dim_value()) { + continue; + } + // how big is the input, including padding + int64_t effective_input_size = input_shape.dim(2 + i).dim_value(); + effective_input_size += pads[i]; + effective_input_size += pads[i + kernel_shape_size]; + + // default is floor mode .i.e. ceil_mode is set to 0 + auto ceil_mode = getAttribute(ctx, "ceil_mode", 0); + + // how many times we can move the kernel from it's initial position, based + // on the stride + int64_t strided_kernel_positions; + + if (ceil_mode == 1) + strided_kernel_positions = + (int64_t)(std::ceil((effective_input_size - effective_kernel_shape[i]) / float(strides[i]))); + else + strided_kernel_positions = (effective_input_size - effective_kernel_shape[i]) / strides[i]; + + // add in the initial position + newdim->set_dim_value(1 + strided_kernel_positions); + } + + if (ctx.getNumOutputs() > 1) { + // MaxPool with two outputs case. + auto second_output_shape = ctx.getOutputType(1)->mutable_tensor_type()->mutable_shape(); + second_output_shape->CopyFrom(*output_shape); + } +} + +static const char* Dropout_ver13_doc = R"DOC( +Dropout takes an input floating-point tensor, an optional input ratio (floating-point scalar) and an optional input training_mode (boolean scalar). It produces two tensor outputs, +output (floating-point tensor) and mask (optional `Tensor`). If `training_mode` is true then the output Y will be a random dropout; +Note that this Dropout scales the masked input data by the following equation, so to convert the trained model into inference mode, +the user can simply not pass `training_mode` input or set it to false. +``` +output = scale * data * mask, +``` +where +``` +scale = 1. / (1. - ratio). +``` +)DOC"; + +ONNX_OPERATOR_SET_SCHEMA( + Dropout, + 13, + OpSchema() + .SetDoc(GET_OP_DOC_STR(std::string(Dropout_ver13_doc) + GenerateOptionalArgumentsDoc())) + .Attr( + "seed", + "(Optional) Seed to the random generator, if not specified we will auto generate one.", + AttributeProto::INT, + OPTIONAL_VALUE) + .Input(0, "data", "The input data as Tensor.", "T", OpSchema::Single, true, 1, OpSchema::Differentiable) + .Input( + 1, + "ratio", + "The ratio of random dropout, with value in [0, 1). If this input was not set, " + "or if it was set to 0, the output would be a simple copy of the input. " + "If it's non-zero, output will be a random dropout of the scaled input, which is typically " + "the case during training. It is an optional value, if not specified it will default to 0.5.", + "T1", + OpSchema::Optional, + true, + 1, + OpSchema::NonDifferentiable) + .Input( + 2, + "training_mode", + "If set to true then it indicates dropout is being used for training. It is an optional value hence unless " + "specified explicitly, it is false. If it is false, ratio is ignored and the operation mimics inference mode where " + "nothing will be dropped from the input data and if mask is requested as output it will contain all ones.", + "T2", + OpSchema::Optional, + true, + 1, + OpSchema::NonDifferentiable) + .Output(0, "output", "The output.", "T", OpSchema::Single, true, 1, OpSchema::Differentiable) + .Output(1, "mask", "The output mask.", "T2", OpSchema::Optional, true, 1, OpSchema::NonDifferentiable) + .TypeConstraint( + "T", + {"tensor(float16)", "tensor(float)", "tensor(double)", "tensor(bfloat16)"}, + "Constrain input and output types to float tensors.") + .TypeConstraint( + "T1", + {"tensor(float16)", "tensor(float)", "tensor(double)"}, + "Constrain input 'ratio' types to float tensors.") + .TypeConstraint("T2", {"tensor(bool)"}, "Constrain output 'mask' types to boolean tensors.") + .TypeAndShapeInferenceFunction([](InferenceContext& ctx) { + propagateElemTypeFromInputToOutput(ctx, 0, 0); + if (hasInputShape(ctx, 0)) { + propagateShapeFromInputToOutput(ctx, 0, 0); + } + + if (ctx.getNumInputs() > 1 && hasInputShape(ctx, 1)) { + auto& ratio_input_shape = getInputShape(ctx, 1); + if (static_cast(ratio_input_shape.dim_size()) != 0) { + fail_shape_inference("Ratio of Dropout must be a scalar."); + } + } + + if (ctx.getNumInputs() > 2 && hasInputShape(ctx, 2)) { + auto& training_mode_input_shape = getInputShape(ctx, 2); + if (static_cast(training_mode_input_shape.dim_size()) != 0) { + fail_shape_inference("training_mode of Dropout must be a scalar."); + } + } + + if (ctx.getNumOutputs() == 2) { + updateOutputElemType(ctx, 1, TensorProto::BOOL); + if (hasNInputShapes(ctx, 1)) { + propagateShapeFromInputToOutput(ctx, 0, 1); + } + } + })); + +static const char* LpNormalization_ver1_doc = R"DOC( +Given a matrix, apply Lp-normalization along the provided axis. +)DOC"; + +ONNX_OPERATOR_SET_SCHEMA( + LpNormalization, + 1, + OpSchema() + .Input(0, "input", "Input matrix", "T", OpSchema::Single, true, 1, OpSchema::Differentiable) + .Output(0, "output", "Matrix after normalization", "T", OpSchema::Single, true, 1, OpSchema::Differentiable) + .TypeConstraint( + "T", + {"tensor(float16)", "tensor(float)", "tensor(double)"}, + "Constrain input and output types to float tensors.") + .SetDoc(LpNormalization_ver1_doc) + .Attr( + "axis", + "The axis on which to apply normalization, -1 mean last axis.", + AttributeProto::INT, + static_cast(-1)) + .Attr( + "p", + "The order of the normalization, only 1 or 2 are supported.", + AttributeProto::INT, + static_cast(2)) + .TypeAndShapeInferenceFunction([](InferenceContext& ctx) { propagateShapeAndTypeFromFirstInput(ctx); })); + +static const char* InstanceNormalization_ver6_doc = R"DOC( +Carries out instance normalization as described in the paper +https://arxiv.org/abs/1607.08022. + +y = scale * (x - mean) / sqrt(variance + epsilon) + B, +where mean and variance are computed per instance per channel. + +)DOC"; + +ONNX_OPERATOR_SET_SCHEMA( + InstanceNormalization, + 6, + OpSchema() + .SetDoc(InstanceNormalization_ver6_doc) + .Attr("epsilon", "The epsilon value to use to avoid division by zero.", AttributeProto::FLOAT, 1e-5f) + .Input( + 0, + "input", + "Input data tensor from the previous operator; " + "dimensions for image case are (N x C x H x W), " + "where N is the batch size, C is the number of " + "channels, and H and W are the height and the " + "width of the data. For non image case, the " + "dimensions are in the form of " + "(N x C x D1 x D2 ... Dn), where N is the batch " + "size.", + "T", + OpSchema::Single, + true, + 1, + OpSchema::Differentiable) + .Input( + 1, + "scale", + "The input 1-dimensional scale tensor of size C.", + "T", + OpSchema::Single, + true, + 1, + OpSchema::Differentiable) + .Input( + 2, + "B", + "The input 1-dimensional bias tensor of size C.", + "T", + OpSchema::Single, + true, + 1, + OpSchema::Differentiable) + .Output( + 0, + "output", + "The output tensor of the same shape as input.", + "T", + OpSchema::Single, + true, + 1, + OpSchema::Differentiable) + .TypeConstraint( + "T", + {"tensor(float16)", "tensor(float)", "tensor(double)"}, + "Constrain input and output types to float tensors.") + .TypeAndShapeInferenceFunction([](InferenceContext& ctx) { propagateShapeAndTypeFromFirstInput(ctx); })); + +void maxUnpoolShapeInference_opset11(InferenceContext& ctx) { + // we need at least two inputs to have a shape for this inference. + if (ctx.getNumInputs() != 2 && ctx.getNumInputs() != 3) { + fail_type_inference("MaxUnpool op must have either two or three inputs."); + } + propagateElemTypeFromInputToOutput(ctx, 0, 0); + if (!hasInputShape(ctx, 0)) { + return; // If first input does not have shape, we cannot infer much. + } + auto input_shape = ctx.getInputType(0)->tensor_type().shape(); + if (input_shape.dim_size() < 2) { + fail_shape_inference("Input tensor X must have at least 2 dimensions."); + } + + // first dim is the batch axis and the next is the number of channels. + size_t n_input_dims = static_cast(input_shape.dim_size() - 2); + + std::vector pads; + if (getRepeatedAttribute(ctx, "pads", pads)) { + if (pads.size() != n_input_dims * 2) { + fail_shape_inference("Attribute pads has incorrect size."); + } + } else { + pads.assign(n_input_dims * 2, 0); + } + + std::vector strides; + if (getRepeatedAttribute(ctx, "strides", strides)) { + if (strides.size() != n_input_dims) { + fail_shape_inference("Attribute strides has incorrect size."); + } + } else { + strides.assign(n_input_dims, 1); + } + + std::vector kernel_shape; + if (getRepeatedAttribute(ctx, "kernel_shape", kernel_shape)) { + if (kernel_shape.size() != n_input_dims) { + fail_shape_inference("Attribute kernel_shape has incorrect size."); + } + } else { + fail_shape_inference("Attribute kernel_shape must be specified."); + } + + if (ctx.getNumInputs() == 3) { + // If the third input, output_size, is specified, then use that instead + // of inferring shape from inputs. + if (hasInputShape(ctx, 2)) { + auto& output_shape = getInputShape(ctx, 2); + if (output_shape.dim_size() != 1) { + fail_type_inference("'output_shape' must be rank 1 tensor."); + } + if (output_shape.dim(static_cast(0)).has_dim_value() && + static_cast(output_shape.dim(static_cast(0)).dim_value()) != input_shape.dim_size()) { + fail_shape_inference("'output_shape' must have same number of elements as the shape of input tensor X."); + } + } + return; // 'output_shape' is specified as input. Actual shape will be + // determined at runtime. + } + + auto final_output_shape = ctx.getOutputType(0)->mutable_tensor_type()->mutable_shape(); + + *final_output_shape->add_dim() = input_shape.dim(0); + *final_output_shape->add_dim() = + ctx.getInputType(1)->tensor_type().shape().dim(1); // channels should be the second dim of second input. + + int kernel_shape_size = static_cast(kernel_shape.size()); + for (int i = 0; i < kernel_shape_size; ++i) { + auto newdim = final_output_shape->add_dim(); + if (!input_shape.dim(2 + i).has_dim_value()) { + continue; + } + + int64_t newdim_value = strides[i] * (input_shape.dim(2 + i).dim_value() - 1); + newdim_value += kernel_shape[i]; + newdim_value -= pads[i]; + newdim_value -= pads[i + kernel_shape_size]; + + // add in the initial position + newdim->set_dim_value(newdim_value); + } +} + +// For GlobalPool operations. +void globalPoolTypeShapeInference_opset1(InferenceContext& ctx) { + propagateElemTypeFromInputToOutput(ctx, 0, 0); + + // needs at least one input with shape. + if (!hasNInputShapes(ctx, 1)) { + return; + } + + auto input_shape = ctx.getInputType(0)->tensor_type().shape(); + if (input_shape.dim_size() < 2) { + return; + } + + // first dim is the batch axis and the next is the number of channels. + size_t n_input_dims = static_cast(input_shape.dim_size() - 2); + + // (N, C, 1, 1, ..., 1) + auto output_shape = ctx.getOutputType(0)->mutable_tensor_type()->mutable_shape(); + *output_shape->add_dim() = input_shape.dim(0); + *output_shape->add_dim() = input_shape.dim(1); + + for (size_t i = 0; i < n_input_dims; ++i) { + output_shape->add_dim()->set_dim_value(1); + } +} + +std::function GlobalPoolingOpSchemaGenerator_opset1(const char* op_type, const char* op) { + return [=](OpSchema& schema) { + std::string doc; + POPULATE_OP_DOC_STR(doc = R"DOC( + Global{op_type} consumes an input tensor X and applies {op} pooling across + the values in the same channel. This is equivalent to {op_type} with kernel size + equal to the spatial dimension of input tensor.)DOC"; + ReplaceAll(doc, "{op_type}", op_type); + ReplaceAll(doc, "{op}", op);); + schema.SetDoc(doc); + schema.Input( + 0, + "X", + "Input data tensor from the previous operator; " + "dimensions for image case are (N x C x H x W), " + "where N is the batch size, C is the number of " + "channels, and H and W are the height and the width " + "of the data. For non image case, the dimensions are " + "in the form of (N x C x D1 x D2 ... Dn), " + "where N is the batch size.", + "T", + OpSchema::Single, + true, + 1, + OpSchema::Differentiable); + schema.Output( + 0, + "Y", + "Output data tensor from pooling across the input " + "tensor. The output tensor has the same rank as the input. " + "The first two dimensions of output shape are the same as " + "the input (N x C), while the other dimensions are all 1.", + "T", + OpSchema::Single, + true, + 1, + OpSchema::Differentiable); + schema.TypeConstraint( + "T", + {"tensor(float16)", "tensor(float)", "tensor(double)"}, + "Constrain input and output types to float tensors."); + schema.TypeAndShapeInferenceFunction([](InferenceContext& ctx) { globalPoolTypeShapeInference_opset1(ctx); }); + }; +} +ONNX_OPERATOR_SET_SCHEMA( + GlobalAveragePool, + 1, + OpSchema().FillUsing(GlobalPoolingOpSchemaGenerator_opset1("AveragePool", "average"))); +ONNX_OPERATOR_SET_SCHEMA( + GlobalMaxPool, + 1, + OpSchema().FillUsing(GlobalPoolingOpSchemaGenerator_opset1("MaxPool", "max"))); + +void convTransposeShapeInference_opset11(InferenceContext& ctx) { + propagateElemTypeFromInputToOutput(ctx, 0, 0); + + // we need at least two inputs to have a shape for this inference. + if (!hasNInputShapes(ctx, 2)) { + return; + } + + int64_t group = getAttribute(ctx, "group", 1); + + auto input_shape = ctx.getInputType(0)->tensor_type().shape(); + if (input_shape.dim_size() < 2) { + return; // Input tensor should have at least two dimensions. + } + + // first dim is the batch axis and the next is the number of channels. + size_t n_input_dims = static_cast(input_shape.dim_size() - 2); + + std::vector dilations; + if (getRepeatedAttribute(ctx, "dilations", dilations)) { + if (dilations.size() != n_input_dims) { + return; + } + } else { + dilations.assign(n_input_dims, 1); + } + + std::vector strides; + if (getRepeatedAttribute(ctx, "strides", strides)) { + if (strides.size() != n_input_dims) { + return; + } + } else { + strides.assign(n_input_dims, 1); + } + + std::vector kernel_shape; + if (getRepeatedAttribute(ctx, "kernel_shape", kernel_shape)) { + if (kernel_shape.size() != n_input_dims) { + return; + } + } else { + auto second_input_shape = ctx.getInputType(1)->tensor_type().shape(); + for (int i = 2; i < second_input_shape.dim_size(); ++i) { + if (!second_input_shape.dim(i).has_dim_value()) { + return; + } + kernel_shape.push_back(second_input_shape.dim(i).dim_value()); + } + } + + std::vector effective_kernel_shape = kernel_shape; + for (int i = 0; i < static_cast(kernel_shape.size()); i++) { + // accounting for dilation, how big is the kernel in this dimension + effective_kernel_shape[i] = (effective_kernel_shape[i] - 1) * dilations[i] + 1; + } + + std::vector pads; + if (getRepeatedAttribute(ctx, "pads", pads)) { + if (pads.size() != n_input_dims * 2) { + fail_shape_inference("Attribute pads has incorrect size"); + } + const auto* auto_pad_attr = ctx.getAttribute("auto_pad"); + if (nullptr != auto_pad_attr && auto_pad_attr->s() != "NOTSET") { + fail_shape_inference("The pads attribute cannot be used simultaneously with auto_pad attribute"); + } + } else { + pads.assign(n_input_dims * 2, 0); + const auto* auto_pad_attr = ctx.getAttribute("auto_pad"); + if ((nullptr != auto_pad_attr) && (auto_pad_attr->s() != "VALID")) { + int input_dims_size = static_cast(n_input_dims); + for (int i = 0; i < input_dims_size; ++i) { + int64_t total_pad = effective_kernel_shape[i] - strides[i]; + if (total_pad < 0) + total_pad = 0; + int64_t half_pad_small = total_pad >> 1; + int64_t half_pad_big = total_pad - half_pad_small; + if (auto_pad_attr->s() == "SAME_UPPER") { + pads[i] = half_pad_small; + pads[i + input_dims_size] = half_pad_big; + } else if (auto_pad_attr->s() == "SAME_LOWER") { + pads[i] = half_pad_big; + pads[i + input_dims_size] = half_pad_small; + } + } + } + } + + std::vector output_shape; + bool output_shape_presented = true; + if (getRepeatedAttribute(ctx, "output_shape", output_shape)) { + if (output_shape.size() != n_input_dims) { + return; + } + } else { + output_shape_presented = false; + } + + std::vector output_padding; + if (getRepeatedAttribute(ctx, "output_padding", output_padding)) { + if (output_padding.size() != n_input_dims) { // Added only to one side. + return; + } + } else { + output_padding.assign(n_input_dims, 0); + } + + auto final_output_shape = ctx.getOutputType(0)->mutable_tensor_type()->mutable_shape(); + + *final_output_shape->add_dim() = input_shape.dim(0); + *final_output_shape->add_dim() = + ctx.getInputType(1)->tensor_type().shape().dim(1) * group; // channels should be the second dim of second input + // multiply group. + + int size_of_output; + if (output_shape_presented) { + size_of_output = static_cast(output_shape.size()); + for (int i = 0; i < size_of_output; ++i) { + if (input_shape.dim(i + 2).has_dim_value()) { + if (output_shape[i] < input_shape.dim(i + 2).dim_value()) { + // TODO: throw exception? + return; // output shape value cannot be smaller than the input shape + // value + } + } + final_output_shape->add_dim()->set_dim_value(output_shape[i]); + } + return; + } else { + size_of_output = input_shape.dim_size() - 2; + for (int i = 0; i < size_of_output; ++i) { + if (input_shape.dim(i + 2).has_dim_value()) { + int64_t output_shape_dim = strides[i] * (input_shape.dim(i + 2).dim_value() - 1) + output_padding[i] + + effective_kernel_shape[i] - pads[i] - pads[i + n_input_dims]; + final_output_shape->add_dim()->set_dim_value(output_shape_dim); + } else { + final_output_shape->add_dim(); + } + } + return; + } +} + +static const char* DeformConv_ver19_doc = R"DOC( +Performs deformable convolution as described in https://arxiv.org/abs/1703.06211 and https://arxiv.org/abs/1811.11168. +This operator specification supports the general N-D case. Note that most common use cases have 2D or 3D data. +)DOC"; + +ONNX_OPERATOR_SET_SCHEMA( + DeformConv, + 19, + OpSchema() + .SetDoc(DeformConv_ver19_doc) + .Input( + 0, + "X", + "Input data tensor. For 2D image data, it has shape (N, C, H, W) where N is the batch size, " + "C is the number of input channels, and H and W are the height and width. " + "In general, the shape is (N, C, D1, D2, ... , Dn) for n-dimensional data, where " + "D1 to Dn are the spatial dimension sizes. Most common use cases have n = 2 or 3.", + "T") + .Input( + 1, + "W", + "Weight tensor that will be used in the convolutions. It has shape (oC, C/group, kH, kW), " + "where oC is the number of output channels and kH and kW are the kernel height and width. " + "For more than 2 dimensions, it has shape (oC, C/group, k1, k2, ... , kn).", + "T") + .Input( + 2, + "offset", + "Offset tensor denoting the offset for the sampling locations in the convolution kernel. " + "It has shape (N, offset_group * kH * kW * 2, oH, oW) for 2D data or " + "(N, offset_group * k1 * k2 * ... * kn * n, o1, o2, ... , on) for nD data. Use linear interpolation" + "for fractional offset values. Sampling locations outside of the padded input tensor gives zero.", + "T") + .Input( + 3, + "B", + "Optional 1D bias of length oC to be added to the convolution. Default is a tensor of zeros.", + "T", + OpSchema::Optional) + .Input( + 4, + "mask", + "The mask tensor to be applied to each position in the convolution kernel. " + "It has shape (N, offset_group * kH * kW, oH, oW) for 2D data or " + "(N, offset_group * k1 * k2 * ... * kn * n, o1, o2, ... , on) for nD data. Default is a " + "tensor of ones.", + "T", + OpSchema::Optional) + .Output( + 0, + "Y", + "Output data tensor that contains the result of convolution. It has shape (N, oC, oH, oW) " + "for 2D data or (N, oC, o1, o2, ..., on) for nD data", + "T") + .TypeConstraint( + "T", + {"tensor(float16)", "tensor(float)", "tensor(double)"}, + "Constrain input and output types to float tensors.") + .Attr( + "dilations", + "Dilation value along each spatial axis of the kernel. Default is 1 along each axis.", + AttributeProto::INTS, + OPTIONAL_VALUE) + .Attr( + "group", + "Number of groups the input and output channels, C and oC, are divided into. C and oC must both " + "be divisible by group. Default is 1.", + AttributeProto::INT, + static_cast(1)) + .Attr( + "kernel_shape", + "Shape of the convolution kernel. If not present, it is inferred from the shape of input W.", + AttributeProto::INTS, + OPTIONAL_VALUE) + .Attr( + "offset_group", + "Number of groups of offset. C must be divisible by offset_group. Default is 1.", + AttributeProto::INT, + static_cast(1)) + .Attr( + "pads", + "Padding for the beginning and end along each spatial axis. The values represent the number of pixels " + "added to the beginning and end of the corresponding axis and can take any nonnegative value. " + "The format should be as follows: [x1_begin, x2_begin, ..., x1_end, x2_end, ...], where xi_begin " + "is the number of pixels added at the beginning of axis `i` and xi_end is the number of pixels " + "added at the end of axis `i`. Default is 0 along each axis.", + AttributeProto::INTS, + OPTIONAL_VALUE) + .Attr( + "strides", + "Stride along each spatial axis. Default is 1 along each axis.", + AttributeProto::INTS, + OPTIONAL_VALUE) + .TypeAndShapeInferenceFunction([](InferenceContext& ctx) { + propagateElemTypeFromInputToOutput(ctx, 0, 0); + convPoolShapeInference_opset19(ctx, true, false, 0, 1); + })); + +std::function ConvTransposeOpSchemaGenerator_opset11(const char* filter_desc) { + return [=](OpSchema& schema) { + std::string doc; + POPULATE_OP_DOC_STR(doc = R"DOC( +The convolution transpose operator consumes an input tensor and {filter_desc}, +and computes the output. + +If the pads parameter is provided the shape of the output is calculated via the following equation: + + output_shape[i] = stride[i] * (input_size[i] - 1) + output_padding[i] + ((kernel_shape[i] - 1) * dilations[i] + 1) - pads[start_i] - pads[end_i] + +output_shape can also be explicitly specified in which case pads values are auto generated using these equations: + + total_padding[i] = stride[i] * (input_size[i] - 1) + output_padding[i] + ((kernel_shape[i] - 1) * dilations[i] + 1) - output_shape[i] + If (auto_pads == SAME_UPPER): pads[start_i] = total_padding[i]/2; pads[end_i] = total_padding[i] - (total_padding[i]/2) + Else: pads[start_i] = total_padding[i] - (total_padding[i]/2); pads[end_i] = (total_padding[i]/2). + + )DOC"; + ReplaceAll(doc, "{filter_desc}", filter_desc);); + schema.SetDoc(doc); + schema.Input( + 0, + "X", + "Input data tensor from previous layer; has size (N x C x H x W)" + ", where N is the batch size, C is the number of channels, and" + " H and W are the height and width. Note that this is for the 2D image. " + "Otherwise the size is (N x C x D1 x D2 ... x Dn)", + "T", + OpSchema::Single, + true, + 1, + OpSchema::Differentiable); + schema.Input( + 1, + "W", + "The weight tensor that will be used in the " + "convolutions; has size (C x M/group x kH x kW), where C " + "is the number of channels, and kH and kW are the " + "height and width of the kernel, and M is the number " + "of feature maps. For more than 2 dimensions, the " + "weight shape will be (C x M/group x k1 x k2 x ... x kn), " + "where (k1 x k2 x ... x kn) is the dimension of the kernel. " + "The number of channels in the output should be equal to W.shape[1] * group " + "(assuming zero based indices of the shape array)", + "T", + OpSchema::Single, + true, + 1, + OpSchema::Differentiable); + schema.Input( + 2, + "B", + "Optional 1D bias to be added to the convolution, has size of M.", + "T", + OpSchema::Optional, + true, + 1, + OpSchema::Differentiable); + schema.Output( + 0, + "Y", + "Output data tensor that contains the result of the convolution. The " + "output dimensions are functions of the kernel size, stride size, " + "pad lengths and group count. " + "The number of channels in the output should be equal to W.shape[1] * group " + "(assuming zero based indices of the shape array)", + "T", + OpSchema::Single, + true, + 1, + OpSchema::Differentiable); + schema.TypeConstraint( + "T", + {"tensor(float16)", "tensor(float)", "tensor(double)"}, + "Constrain input and output types to float tensors."); + schema.Attr( + "kernel_shape", + "The shape of the convolution kernel. If not present, should be inferred from input W.", + AttributeProto::INTS, + OPTIONAL_VALUE); + schema.Attr( + "output_shape", + "The shape of the output can be explicitly set which will cause pads values to be auto generated. If output_shape is specified " + "pads values are ignored. See doc for details for equations to generate pads. Note that the output_shape attribute value " + "should not include dimensions for batch size and channels, which are automatically inferred.", + AttributeProto::INTS, + OPTIONAL_VALUE); + schema.Attr( + "output_padding", + "Additional elements added to the side with higher coordinate indices in the output. " + "Each padding value in \"output_padding\" must be less than the corresponding stride/dilation dimension. " + "By default, this attribute is a zero vector. " + "Note that this attribute doesn't directly affect the computed output values. " + "It only controls the selection of the computed values, " + "so changing this attribute only adds or removes output elements. " + "If \"output_shape\" is explicitly provided, " + "\"output_padding\" does not contribute additional size to \"output_shape\" but " + "participates in the computation of the needed padding amount. " + "This is also called adjs or adjustment in some frameworks.", + AttributeProto::INTS, + OPTIONAL_VALUE); + schema.Attr( + "dilations", + "dilation value along each spatial axis of the filter. If not present, the dilation defaults to 1 along each spatial axis.", + AttributeProto::INTS, + OPTIONAL_VALUE); + schema.Attr( + "strides", + "Stride along each spatial axis. If not present, the stride defaults to 1 along each spatial axis.", + AttributeProto::INTS, + OPTIONAL_VALUE); + schema.Attr("auto_pad", conv_transpose_auto_pad_doc_opset19, AttributeProto::STRING, std::string("NOTSET")); + schema.Attr("pads", pads_doc_opset11, AttributeProto::INTS, OPTIONAL_VALUE); + schema.Attr( + "group", + "number of groups input channels and output channels are divided into.", + AttributeProto::INT, + static_cast(1)); + schema.TypeAndShapeInferenceFunction([](InferenceContext& ctx) { convTransposeShapeInference_opset11(ctx); }); + }; +} + +ONNX_OPERATOR_SET_SCHEMA(ConvTranspose, 11, OpSchema().FillUsing(ConvTransposeOpSchemaGenerator_opset11("a filter"))); + +std::function ConvOpSchemaGenerator_opset11(const char* filter_desc) { + return [=](OpSchema& schema) { + std::string doc; + POPULATE_OP_DOC_STR(doc = R"DOC( +The convolution operator consumes an input tensor and {filter_desc}, and +computes the output.)DOC"; + ReplaceAll(doc, "{filter_desc}", filter_desc);); + schema.SetDoc(doc); + schema.Input( + 0, + "X", + "Input data tensor from previous layer; " + "has size (N x C x H x W), where N is the batch size, " + "C is the number of channels, and H and W are the " + "height and width. Note that this is for the 2D image. " + "Otherwise the size is (N x C x D1 x D2 ... x Dn). " + "Optionally, if dimension denotation is " + "in effect, the operation expects input data tensor " + "to arrive with the dimension denotation of [DATA_BATCH, " + "DATA_CHANNEL, DATA_FEATURE, DATA_FEATURE ...].", + "T", + OpSchema::Single, + true, + 1, + OpSchema::Differentiable); + schema.Input( + 1, + "W", + "The weight tensor that will be used in the " + "convolutions; has size (M x C/group x kH x kW), where C " + "is the number of channels, and kH and kW are the " + "height and width of the kernel, and M is the number " + "of feature maps. For more than 2 dimensions, the " + "kernel shape will be (M x C/group x k1 x k2 x ... x kn), " + "where (k1 x k2 x ... kn) is the dimension of the kernel. " + "Optionally, if dimension denotation is in effect, " + "the operation expects the weight tensor to arrive " + "with the dimension denotation of [FILTER_OUT_CHANNEL, " + "FILTER_IN_CHANNEL, FILTER_SPATIAL, FILTER_SPATIAL ...]. " + "Assuming zero based indices for the shape array, " + "X.shape[1] == (W.shape[1] * group) == C and " + "W.shape[0] mod G == 0. Or in other words " + "FILTER_IN_CHANNEL multiplied by the number of groups " + "should be equal to DATA_CHANNEL and the number of " + "feature maps M should be a multiple of the number of " + "groups G.", + "T", + OpSchema::Single, + true, + 1, + OpSchema::Differentiable); + schema.Input( + 2, + "B", + "Optional 1D bias to be added to the convolution, has size of M.", + "T", + OpSchema::Optional, + true, + 1, + OpSchema::Differentiable); + schema.Output( + 0, + "Y", + "Output data tensor that contains the result of the " + "convolution. The output dimensions are functions " + "of the kernel size, stride size, and pad lengths.", + "T", + OpSchema::Single, + true, + 1, + OpSchema::Differentiable); + schema.TypeConstraint( + "T", + {"tensor(float16)", "tensor(float16)", "tensor(float)", "tensor(double)"}, + "Constrain input and output types to float tensors."); + schema.Attr( + "kernel_shape", + "The shape of the convolution kernel. If not present, should be inferred from input W.", + AttributeProto::INTS, + OPTIONAL_VALUE); + schema.Attr( + "dilations", + "dilation value along each spatial axis of the filter. If not present, the dilation defaults is 1 along each spatial axis.", + AttributeProto::INTS, + OPTIONAL_VALUE); + schema.Attr( + "strides", + "Stride along each spatial axis. If not present, the stride defaults is 1 along each spatial axis.", + AttributeProto::INTS, + OPTIONAL_VALUE); + schema.Attr("auto_pad", conv_auto_pad_doc_opset19, AttributeProto::STRING, std::string("NOTSET")); + schema.Attr("pads", pads_doc_opset11, AttributeProto::INTS, OPTIONAL_VALUE); + schema.Attr( + "group", + "number of groups input channels and output channels are divided into.", + AttributeProto::INT, + static_cast(1)); + schema.TypeAndShapeInferenceFunction([](InferenceContext& ctx) { + propagateElemTypeFromInputToOutput(ctx, 0, 0); + convPoolShapeInference_opset19(ctx, true, false, 0, 1); + }); + }; +} + +ONNX_OPERATOR_SET_SCHEMA(Conv, 11, OpSchema().FillUsing(ConvOpSchemaGenerator_opset11("a filter"))); + +void roiPoolTypeShapeInference_opset1(InferenceContext& ctx) { + propagateElemTypeFromInputToOutput(ctx, 0, 0); + + // rois is the second input. + if (!hasNInputShapes(ctx, 2)) { + return; + } + + auto input_shape = ctx.getInputType(0)->tensor_type().shape(); + auto rios_shape = ctx.getInputType(1)->tensor_type().shape(); + + if (input_shape.dim_size() < 2) { + fail_shape_inference("Input tensor must have at least 2 dimensions"); + } + if (rios_shape.dim_size() != 2) { + fail_shape_inference("RoIs tensor must have 2 dimensions"); + } + + // first dim is the batch axis and the next is the number of channels. + size_t n_input_dims = static_cast(input_shape.dim_size() - 2); + + std::vector pooled_shape; + if (getRepeatedAttribute(ctx, "pooled_shape", pooled_shape)) { + if (pooled_shape.size() != n_input_dims) { + fail_shape_inference("Attribute pooled_shape has incorrect length"); + } + } else { + fail_shape_inference("Attribute pooled_shape must be specified"); + } + + // (num_rois, channels, pooled_shape[0], pooled_shape[1]) + auto output_shape = ctx.getOutputType(0)->mutable_tensor_type()->mutable_shape(); + + *output_shape->add_dim() = rios_shape.dim(0); + *output_shape->add_dim() = input_shape.dim(1); + output_shape->add_dim()->set_dim_value(pooled_shape[0]); + output_shape->add_dim()->set_dim_value(pooled_shape[1]); +} + +std::function RoiPoolOpSchemaGenerator_opset1(const char* name) { + return [=](OpSchema& schema) { + std::string doc; + POPULATE_OP_DOC_STR(doc = R"DOC( + ROI {name} pool consumes an input tensor X and region of interests (RoIs) to + apply {name} pooling across each RoI, to produce output 4-D tensor of shape + (num_rois, channels, pooled_shape[0], pooled_shape[1]).)DOC"; + ReplaceAll(doc, "{name}", name);); + schema.SetDoc(doc); + schema.Attr("pooled_shape", "ROI pool output shape (height, width).", AttributeProto::INTS); + schema.Attr( + "spatial_scale", + "Multiplicative spatial scale factor to translate ROI coordinates from their input scale to the scale used when pooling.", + AttributeProto::FLOAT, + 1.f); + schema.Input( + 0, + "X", + "Input data tensor from the previous operator; " + "dimensions for image case are (N x C x H x W), " + "where N is the batch size, C is the number of " + "channels, and H and W are the height and the " + "width of the data.", + "T", + OpSchema::Single, + true, + 1, + OpSchema::Differentiable); + schema.Input( + 1, + "rois", + "RoIs (Regions of Interest) to pool over. Should " + "be a 2-D tensor of shape (num_rois, 5) given as " + "[[batch_id, x1, y1, x2, y2], ...].", + "T", + OpSchema::Single, + true, + 1, + OpSchema::NonDifferentiable); + schema.Output( + 0, + "Y", + "RoI pooled output 4-D tensor of shape (num_rois, channels, pooled_shape[0], pooled_shape[1]).", + "T", + OpSchema::Single, + true, + 1, + OpSchema::Differentiable); + schema.TypeConstraint( + "T", + {"tensor(float16)", "tensor(float)", "tensor(double)"}, + "Constrain input and output types to float tensors."); + schema.TypeAndShapeInferenceFunction([](InferenceContext& ctx) { roiPoolTypeShapeInference_opset1(ctx); }); + }; +} + +ONNX_OPERATOR_SET_SCHEMA(MaxRoiPool, 1, OpSchema().FillUsing(RoiPoolOpSchemaGenerator_opset1("max"))); + +std::function LpPoolOpSchemaGenerator_opset18(const char* name) { + return [=](OpSchema& schema) { + std::string doc; + POPULATE_OP_DOC_STR(doc = R"DOC( + {name} consumes an input tensor X and applies Lp pooling across + the tensor according to kernel sizes, stride sizes, and pad lengths. + Lp pooling consisting of computing the Lp norm on all values of a subset + of the input tensor according to the kernel size and downsampling the + data into the output tensor Y for further processing. The output spatial shape will be following: + ``` + output_spatial_shape[i] = floor((input_spatial_shape[i] + pad_shape[i] - {kernelSpatialShape}) / strides_spatial_shape[i] + 1) + ``` + or + ``` + output_spatial_shape[i] = ceil((input_spatial_shape[i] + pad_shape[i] - {kernelSpatialShape}) / strides_spatial_shape[i] + 1) + ``` + if ceil_mode is enabled `pad_shape[i]` is the sum of pads along axis `i`. + + `auto_pad` is a DEPRECATED attribute. If you are using them currently, the output spatial shape will be following: + ``` + VALID: output_spatial_shape[i] = ceil((input_spatial_shape[i] - {kernelSpatialShape} + 1) / strides_spatial_shape[i]) + SAME_UPPER or SAME_LOWER: output_spatial_shape[i] = ceil(input_spatial_shape[i] / strides_spatial_shape[i]) + ``` + And pad shape will be following if `SAME_UPPER` or `SAME_LOWER`: + ``` + pad_shape[i] = (output_spatial_shape[i] - 1) * strides_spatial_shape[i] + {kernelSpatialShape} - input_spatial_shape[i] + ```)DOC"; + ReplaceAll(doc, "{name}", name);); + schema.SetDoc(doc); + schema.Attr("kernel_shape", "The size of the kernel along each axis.", AttributeProto::INTS); + schema.Attr( + "strides", + "Stride along each spatial axis. If not present, the stride defaults to 1 along each spatial axis.", + AttributeProto::INTS, + OPTIONAL_VALUE); + schema.Attr( + "dilations", + "dilation value along each spatial axis of the filter. If not present, the dilation defaults is 1 along each spatial axis.", + AttributeProto::INTS, + OPTIONAL_VALUE); + schema.Attr("auto_pad", conv_auto_pad_doc_opset19, AttributeProto::STRING, std::string("NOTSET")); + schema.Attr("pads", pads_doc_opset11, AttributeProto::INTS, OPTIONAL_VALUE); + schema.Attr( + "p", "p value of the Lp norm used to pool over the input data.", AttributeProto::INT, static_cast(2)); + schema.Attr( + "ceil_mode", + "Whether to use ceil or floor (default) to compute the output shape.", + AttributeProto::INT, + static_cast(0)); + schema.Input( + 0, + "X", + "Input data tensor from the previous operator; " + "dimensions for image case are (N x C x H x W), " + "where N is the batch size, C is the number of " + "channels, and H and W are the height and the " + "width of the data. For non image case, the " + "dimensions are in the form of " + "(N x C x D1 x D2 ... Dn), where N is the " + "batch size.", + "T", + OpSchema::Single, + true, + 1, + OpSchema::Differentiable); + schema.Output( + 0, + "Y", + "Output data tensor from Lp pooling across the input " + "tensor. Dimensions will vary based on various kernel, stride, and pad " + "sizes.", + "T", + OpSchema::Single, + true, + 1, + OpSchema::Differentiable); + schema.TypeConstraint( + "T", + {"tensor(float16)", "tensor(float)", "tensor(double)"}, + "Constrain input and output types to float tensors."); + schema.TypeAndShapeInferenceFunction([](InferenceContext& ctx) { + propagateElemTypeFromInputToOutput(ctx, 0, 0); + convPoolShapeInference_opset19(ctx, true, true, 0, 1); + }); + }; +} + +ONNX_OPERATOR_SET_SCHEMA(LpPool, 18, OpSchema().FillUsing(LpPoolOpSchemaGenerator_opset18("LpPool"))); + +static const char* MaxUnpool_ver11_doc = R"DOC( +MaxUnpool essentially computes the partial inverse of the MaxPool op. + The input information to this op is typically the output information from a MaxPool op. The first + input tensor X is the tensor that needs to be unpooled, which is typically the pooled tensor (first output) + from MaxPool. The second input tensor, I, contains the indices to the (locally maximal) elements corresponding + to the elements in the first input tensor X. Input tensor I is typically the second output of the MaxPool op. + The third (optional) input is a tensor that specifies the output size of the unpooling operation. + +MaxUnpool is intended to do 'partial' inverse of the MaxPool op. 'Partial' because all the non-maximal + values from the original input to MaxPool are set to zero in the output of the MaxUnpool op. Pooling + the result of an unpooling operation should give back the original input to the unpooling op. + +MaxUnpool can produce the same output size for several input sizes, which makes unpooling op ambiguous. + The third input argument, output_size, is meant to disambiguate the op and produce output tensor of + known/predictable size. + +In addition to the inputs, MaxUnpool takes three attributes, namely kernel_shape, strides, and pads, + which define the exact unpooling op. The attributes typically have the same values as the corresponding + pooling op that the unpooling op is trying to invert. +)DOC"; + +ONNX_OPERATOR_SET_SCHEMA( + MaxUnpool, + 11, + OpSchema() + .SetDoc(MaxUnpool_ver11_doc) + .Attr("kernel_shape", "The size of the kernel along each axis.", AttributeProto::INTS) + .Attr( + "strides", + "Stride along each spatial axis. If not present, the stride defaults to 1 along each spatial axis.", + AttributeProto::INTS, + OPTIONAL_VALUE) + .Attr("pads", pads_doc_opset11, AttributeProto::INTS, OPTIONAL_VALUE) + .Input( + 0, + "X", + "Input data tensor that has to be unpooled. " + "This tensor is typically the first output of the MaxPool op." + "Dimensions for image case are (N x C x H x W), " + "where N is the batch size, C is the number of " + "channels, and H and W are the height and the " + "width of the data. For non-image case, the " + "dimensions are in the form of " + "(N x C x D1 x D2 ... Dn), where N is the batch " + "size. Optionally, if dimension denotation is " + "in effect, the operation expects the input " + "data tensor to arrive with the dimension denotation " + "of [DATA_BATCH, DATA_CHANNEL, DATA_FEATURE, DATA_FEATURE ...].", + "T1", + OpSchema::Single, + true, + 1, + OpSchema::Differentiable) + .Input( + 1, + "I", + "Input data tensor containing the indices corresponding to " + "elements in the first input tensor X." + "This tensor is typically the second output of the MaxPool op." + "Dimensions must be the same as input tensor X. " + "The indices are linear, i.e. computed considering the tensor as flattened 1-D tensor, " + "assuming row-major storage. Also, the linear indices should not consider padding. " + "So the values in indices are in the range [0, N x C x D1 x ... x Dn).", + "T2", + OpSchema::Single, + true, + 1, + OpSchema::NonDifferentiable) + .Input( + 2, + "output_shape", + "The shape of the output can be explicitly set which will cause pads values to be auto generated. If 'output_shape' is specified, " + "'pads' values are ignored.", + "T2", + OpSchema::Optional, + true, + 1, + OpSchema::NonDifferentiable) + .Output( + 0, + "output", + "Output data tensor that contains the result of the unpooling.", + "T1", + OpSchema::Single, + true, + 1, + OpSchema::Differentiable) + .TypeConstraint( + "T1", + {"tensor(float16)", "tensor(float)", "tensor(double)"}, + "Constrain input and output types to float tensors.") + .TypeConstraint("T2", {"tensor(int64)"}, "Constrain index tensor to int64") + .TypeAndShapeInferenceFunction([](InferenceContext& ctx) { maxUnpoolShapeInference_opset11(ctx); })); + +std::vector GetSupportedDataTypesForPoolingOps_opset19(bool supports8bit) { + if (supports8bit) { + return {"tensor(float16)", "tensor(float)", "tensor(double)", "tensor(int8)", "tensor(uint8)"}; + } + return {"tensor(float16)", "tensor(float)", "tensor(double)"}; +} + +std::function PoolOpSchemaGenerator_opset19( + const char* name, + const char* opName, + const char* additionalDescription, + bool use_dilation, + bool supports8bit = false) { + return [=](OpSchema& schema) { + std::string doc; + POPULATE_OP_DOC_STR( + doc = R"DOC( + {name} consumes an input tensor X and applies {opName} pooling across + the tensor according to kernel sizes, stride sizes, and pad lengths. + {opName} pooling consisting of computing the {opName} on all values of a + subset of the input tensor according to the kernel size and downsampling the + data into the output tensor Y for further processing. The output spatial shape is calculated differently + depending on whether explicit padding is used, where pads is employed, or auto padding is used, where auto_pad is utilized. + With explicit padding (https://pytorch.org/docs/stable/generated/torch.nn.MaxPool2d.html?highlight=maxpool#torch.nn.MaxPool2d): + ``` + output_spatial_shape[i] = floor((input_spatial_shape[i] + pad_shape[i] - dilation[i] * (kernel_shape[i] - 1) - 1) / strides_spatial_shape[i] + 1) + ``` + or + ``` + output_spatial_shape[i] = ceil((input_spatial_shape[i] + pad_shape[i] - dilation[i] * (kernel_shape[i] - 1) - 1) / strides_spatial_shape[i] + 1) + ``` + if ceil_mode is enabled. `pad_shape[i]` is the sum of pads along axis `i`. + + `auto_pad` is a DEPRECATED attribute. If you are using them currently, the output spatial shape will be following when ceil_mode is enabled: + ``` + VALID: output_spatial_shape[i] = ceil((input_spatial_shape[i] - {kernelSpatialShape} + 1) / strides_spatial_shape[i]) + SAME_UPPER or SAME_LOWER: output_spatial_shape[i] = ceil(input_spatial_shape[i] / strides_spatial_shape[i]) + ``` + or when ceil_mode is disabled (https://www.tensorflow.org/api_docs/python/tf/keras/layers/AveragePooling2D): + ``` + VALID: output_spatial_shape[i] = floor((input_spatial_shape[i] - {kernelSpatialShape}) / strides_spatial_shape[i]) + 1 + SAME_UPPER or SAME_LOWER: output_spatial_shape[i] = floor((input_spatial_shape[i] - 1) / strides_spatial_shape[i]) + 1 + ``` + And pad shape will be following if `SAME_UPPER` or `SAME_LOWER`: + ``` + pad_shape[i] = (output_spatial_shape[i] - 1) * strides_spatial_shape[i] + {kernelSpatialShape} - input_spatial_shape[i] + ``` + {additionalDescription} + )DOC"; + ReplaceAll(doc, "{name}", name); + ReplaceAll(doc, "{opName}", opName); + ReplaceAll(doc, "{additionalDescription}", additionalDescription); + ReplaceAll( + doc, + "{kernelSpatialShape}", + use_dilation ? "((kernel_spatial_shape[i] - 1) * dilations[i] + 1)" : "kernel_spatial_shape[i]");); + schema.SetDoc(doc); + schema.Attr("kernel_shape", "The size of the kernel along each axis.", AttributeProto::INTS); + schema.Attr( + "strides", + "Stride along each spatial axis. If not present, the stride defaults to 1 along each spatial axis.", + AttributeProto::INTS, + OPTIONAL_VALUE); + schema.Attr("auto_pad", conv_auto_pad_doc_opset19, AttributeProto::STRING, std::string("NOTSET")); + schema.Attr("pads", pads_doc_opset11, AttributeProto::INTS, OPTIONAL_VALUE); + schema.Attr( + "ceil_mode", + "Whether to use ceil or floor (default) to compute the output shape.", + AttributeProto::INT, + static_cast(0)); + schema.Input( + 0, + "X", + "Input data tensor from the previous operator; " + "dimensions for image case are (N x C x H x W), " + "where N is the batch size, C is the number of " + "channels, and H and W are the height and the " + "width of the data. For non image case, the " + "dimensions are in the form of " + "(N x C x D1 x D2 ... Dn), where N is the batch " + "size. Optionally, if dimension denotation is " + "in effect, the operation expects the input " + "data tensor to arrive with the dimension denotation " + "of [DATA_BATCH, DATA_CHANNEL, DATA_FEATURE, DATA_FEATURE ...].", + "T", + OpSchema::Single, + true, + 1, + OpSchema::Differentiable); + schema.Output( + 0, + "Y", + "Output data tensor from average or max pooling across " + "the input tensor. Dimensions will vary based " + "on various kernel, stride, and pad sizes. Floor value of " + "the dimension is used", + "T", + OpSchema::Single, + true, + 1, + OpSchema::Differentiable); + schema.TypeConstraint( + "T", + GetSupportedDataTypesForPoolingOps_opset19(supports8bit), + supports8bit ? "Constrain input and output types to float and 8 bit tensors." + : "Constrain input and output types to float tensors."); + schema.TypeAndShapeInferenceFunction([use_dilation](InferenceContext& ctx) { + propagateElemTypeFromInputToOutput(ctx, 0, 0); + if (ctx.getNumOutputs() > 1) { + // MaxPool with two outputs case. + auto output_type = ctx.getOutputType(1); + if (output_type->value_case() == TypeProto::kTensorType || + output_type->value_case() == TypeProto::VALUE_NOT_SET) { + output_type->mutable_tensor_type()->set_elem_type(TensorProto::INT64); + } + } + convPoolShapeInference_opset19(ctx, use_dilation, true, 0, 1); + }); + }; +} + +ONNX_OPERATOR_SET_SCHEMA( + AveragePool, + 19, + OpSchema() + .FillUsing(PoolOpSchemaGenerator_opset19( + "AveragePool", + "average", + "The output of each pooling window is divided by the number of elements (exclude pad when attribute count_include_pad is zero).", + true, /* use_dilation: dilations attribute has been added in opset 19. */ + false /* supports8bit: does not support 8bit. */)) + .Attr( + "dilations", + "Dilation value along each spatial axis of filter. If not present, the dilation defaults to 1 along each spatial axis.", + AttributeProto::INTS, + OPTIONAL_VALUE) + .Attr( + "count_include_pad", + "Whether include pad pixels when calculating values for the edges. Default is 0, doesn't count include pad.", + AttributeProto::INT, + static_cast(0))); + +ONNX_OPERATOR_SET_SCHEMA( + MaxPool, + 12, + OpSchema() + .FillUsing(PoolOpSchemaGenerator_opset19( + "MaxPool", + "max", + "The output of each pooling window is maximum number of elements exclude pad. ", + true, + true)) + .Attr( + "storage_order", + "The storage order of the tensor. 0 is row major, and 1 is column major. " + "This attribute is used only to convert an n-tuple index value into " + "a single integer value for producing the second output. ", + AttributeProto::INT, + static_cast(0)) + .Attr( + "dilations", + "Dilation value along each spatial axis of filter. If not present, the dilation defaults to 1 along each spatial axis.", + AttributeProto::INTS, + OPTIONAL_VALUE) + .Output( + 1, + "Indices", + "Indices tensor from max pooling across the input tensor. " + "The dimensions of indices are the same as output tensor. " + "The values in indices of are the indices of the selected values during pooling. " + "The indices are computed as flatten 1-D tensor, " + "and the indices do not consider padding. " + "So the values in indices are in [0, N x C x D1 x ... x Dn).", + "I", + OpSchema::Optional, + true, + 1, + OpSchema::NonDifferentiable) + .TypeConstraint("I", {"tensor(int64)"}, "Constrain index tensor to int64")); + static const char* Dropout_ver12_doc = R"DOC( Dropout takes an input floating-point tensor, an optional input ratio (floating-point scalar) and an optional input training_mode (boolean scalar). It produces two tensor outputs, output (floating-point tensor) and mask (optional `Tensor`). If `training_mode` is true then the output Y will be a random dropout; @@ -956,8 +2487,8 @@ void maxUnpoolShapeInference1(InferenceContext& ctx) { if (output_shape.dim_size() != 1) { fail_type_inference("'output_shape' must be rank 1 tensor."); } - if (output_shape.dim((int)0).has_dim_value() && - static_cast(output_shape.dim((int)0).dim_value()) != input_shape.dim_size()) { + if (output_shape.dim(static_cast(0)).has_dim_value() && + static_cast(output_shape.dim(static_cast(0)).dim_value()) != input_shape.dim_size()) { fail_shape_inference("'output_shape' must have same number of elements as the shape of input tensor X."); } } diff --git a/onnx/defs/object_detection/defs.cc b/onnx/defs/object_detection/defs.cc index 82bdf15440b..6a0ea98b832 100644 --- a/onnx/defs/object_detection/defs.cc +++ b/onnx/defs/object_detection/defs.cc @@ -7,7 +7,7 @@ using namespace ONNX_NAMESPACE; namespace ONNX_NAMESPACE { -static const char* RoiAlign_ver16_doc = R"DOC( +static const char* RoiAlign_ver22_doc = R"DOC( Region of Interest (RoI) align operation described in the [Mask R-CNN paper](https://arxiv.org/abs/1703.06870). RoiAlign consumes an input tensor X and region of interests (rois) @@ -23,9 +23,9 @@ through bilinear interpolation. ONNX_OPERATOR_SET_SCHEMA( RoiAlign, - 16, + 22, OpSchema() - .SetDoc(RoiAlign_ver16_doc) + .SetDoc(RoiAlign_ver22_doc) .Attr( "spatial_scale", "Multiplicative spatial scale factor to translate ROI coordinates " @@ -89,10 +89,7 @@ ONNX_OPERATOR_SET_SCHEMA( "(num_rois, C, output_height, output_width). The r-th batch element Y[r-1] " "is a pooled feature map corresponding to the r-th RoI X[r-1].", "T1") - .TypeConstraint( - "T1", - {"tensor(float16)", "tensor(float)", "tensor(double)"}, - "Constrain types to float tensors.") + .TypeConstraint("T1", OpSchema::all_float_types_ir4(), "Constrain types to float tensors.") .TypeConstraint("T2", {"tensor(int64)"}, "Constrain types to int tensors.") .TypeAndShapeInferenceFunction([](InferenceContext& ctx) { propagateElemTypeFromInputToOutput(ctx, 0, 0); diff --git a/onnx/defs/object_detection/old.cc b/onnx/defs/object_detection/old.cc index 28ae0c5009f..65659bb35db 100644 --- a/onnx/defs/object_detection/old.cc +++ b/onnx/defs/object_detection/old.cc @@ -7,6 +7,123 @@ using namespace ONNX_NAMESPACE; namespace ONNX_NAMESPACE { +static const char* RoiAlign_ver16_doc = R"DOC( +Region of Interest (RoI) align operation described in the +[Mask R-CNN paper](https://arxiv.org/abs/1703.06870). +RoiAlign consumes an input tensor X and region of interests (rois) +to apply pooling across each RoI; it produces a 4-D tensor of shape +(num_rois, C, output_height, output_width). + +RoiAlign is proposed to avoid the misalignment by removing +quantizations while converting from original image into feature +map and from feature map into RoI feature; in each ROI bin, +the value of the sampled locations are computed directly +through bilinear interpolation. +)DOC"; + +ONNX_OPERATOR_SET_SCHEMA( + RoiAlign, + 16, + OpSchema() + .SetDoc(RoiAlign_ver16_doc) + .Attr( + "spatial_scale", + "Multiplicative spatial scale factor to translate ROI coordinates " + "from their input spatial scale to the scale used when pooling, " + "i.e., spatial scale of the input feature map X relative to the " + "input image. E.g.; default is 1.0f. ", + AttributeProto::FLOAT, + 1.f) + .Attr("output_height", "default 1; Pooled output Y's height.", AttributeProto::INT, static_cast(1)) + .Attr("output_width", "default 1; Pooled output Y's width.", AttributeProto::INT, static_cast(1)) + .Attr( + "sampling_ratio", + "Number of sampling points in the interpolation grid used to compute " + "the output value of each pooled output bin. If > 0, then exactly " + "sampling_ratio x sampling_ratio grid points are used. If == 0, then " + "an adaptive number of grid points are used (computed as " + "ceil(roi_width / output_width), and likewise for height). Default is 0.", + AttributeProto::INT, + static_cast(0)) + .Attr( + "mode", + "The pooling method. Two modes are supported: 'avg' and 'max'. " + "Default is 'avg'.", + AttributeProto::STRING, + std::string("avg")) + .Attr( + "coordinate_transformation_mode", + "Allowed values are 'half_pixel' and 'output_half_pixel'. " + "Use the value 'half_pixel' to pixel shift the input coordinates by -0.5 (the recommended behavior). " + "Use the value 'output_half_pixel' to omit the pixel shift for the input (use this for a " + "backward-compatible behavior).", + AttributeProto::STRING, + std::string("half_pixel")) + .Input( + 0, + "X", + "Input data tensor from the previous operator; " + "4-D feature map of shape (N, C, H, W), " + "where N is the batch size, C is the number of channels, " + "and H and W are the height and the width of the data.", + "T1") + .Input( + 1, + "rois", + "RoIs (Regions of Interest) to pool over; rois is " + "2-D input of shape (num_rois, 4) given as " + "[[x1, y1, x2, y2], ...]. " + "The RoIs' coordinates are in the coordinate system of the input image. " + "Each coordinate set has a 1:1 correspondence with the 'batch_indices' input.", + "T1") + .Input( + 2, + "batch_indices", + "1-D tensor of shape (num_rois,) with each element denoting " + "the index of the corresponding image in the batch.", + "T2") + .Output( + 0, + "Y", + "RoI pooled output, 4-D tensor of shape " + "(num_rois, C, output_height, output_width). The r-th batch element Y[r-1] " + "is a pooled feature map corresponding to the r-th RoI X[r-1].", + "T1") + .TypeConstraint( + "T1", + {"tensor(float16)", "tensor(float)", "tensor(double)"}, + "Constrain types to float tensors.") + .TypeConstraint("T2", {"tensor(int64)"}, "Constrain types to int tensors.") + .TypeAndShapeInferenceFunction([](InferenceContext& ctx) { + propagateElemTypeFromInputToOutput(ctx, 0, 0); + + size_t input_param = 0, rois_param = 1, batch_index_param = 2; + + checkInputRank(ctx, input_param, 4); + checkInputRank(ctx, rois_param, 2); + checkInputRank(ctx, batch_index_param, 1); + + // Output dimensions, initialized to an unknown-dimension-value + Dim num_rois, C, ht, width; + + // Get value of C from dim 1 of input_param, if available + unifyInputDim(ctx, input_param, 1, C); + + // Get value of num_rois from dim 0 of rois_param, if available + unifyInputDim(ctx, rois_param, 0, num_rois); + // ... or from dim 0 of batch_index_param, if available + unifyInputDim(ctx, batch_index_param, 0, num_rois); + + // Get height from attribute, using default-value of 1 + unifyDim(ht, getAttribute(ctx, "output_height", 1)); + + // Get width from attribute, using default-value of 1 + unifyDim(width, getAttribute(ctx, "output_width", 1)); + + // set output shape: + updateOutputShape(ctx, 0, {num_rois, C, ht, width}); + })); + static const char* RoiAlign_ver10_doc = R"DOC( Region of Interest (RoI) align operation described in the [Mask R-CNN paper](https://arxiv.org/abs/1703.06870). diff --git a/onnx/defs/operator_sets.h b/onnx/defs/operator_sets.h index 552ddce622d..ad2791524e7 100644 --- a/onnx/defs/operator_sets.h +++ b/onnx/defs/operator_sets.h @@ -1186,13 +1186,107 @@ class OpSet_Onnx_ver21 { }; // Forward declarations for ai.onnx version 22 +class ONNX_OPERATOR_SET_SCHEMA_CLASS_NAME(Onnx, 22, EyeLike); +class ONNX_OPERATOR_SET_SCHEMA_CLASS_NAME(Onnx, 22, RandomUniform); +class ONNX_OPERATOR_SET_SCHEMA_CLASS_NAME(Onnx, 22, RandomNormal); +class ONNX_OPERATOR_SET_SCHEMA_CLASS_NAME(Onnx, 22, RandomUniformLike); +class ONNX_OPERATOR_SET_SCHEMA_CLASS_NAME(Onnx, 22, RandomNormalLike); +class ONNX_OPERATOR_SET_SCHEMA_CLASS_NAME(Onnx, 22, Multinomial); +class ONNX_OPERATOR_SET_SCHEMA_CLASS_NAME(Onnx, 22, Bernoulli); +class ONNX_OPERATOR_SET_SCHEMA_CLASS_NAME(Onnx, 22, ThresholdedRelu); +class ONNX_OPERATOR_SET_SCHEMA_CLASS_NAME(Onnx, 22, Selu); +class ONNX_OPERATOR_SET_SCHEMA_CLASS_NAME(Onnx, 22, Elu); +class ONNX_OPERATOR_SET_SCHEMA_CLASS_NAME(Onnx, 22, Mish); +class ONNX_OPERATOR_SET_SCHEMA_CLASS_NAME(Onnx, 22, HardSigmoid); +class ONNX_OPERATOR_SET_SCHEMA_CLASS_NAME(Onnx, 22, HardSwish); +class ONNX_OPERATOR_SET_SCHEMA_CLASS_NAME(Onnx, 22, Softsign); +class ONNX_OPERATOR_SET_SCHEMA_CLASS_NAME(Onnx, 22, Softplus); +class ONNX_OPERATOR_SET_SCHEMA_CLASS_NAME(Onnx, 22, Sin); +class ONNX_OPERATOR_SET_SCHEMA_CLASS_NAME(Onnx, 22, Cos); +class ONNX_OPERATOR_SET_SCHEMA_CLASS_NAME(Onnx, 22, Tan); +class ONNX_OPERATOR_SET_SCHEMA_CLASS_NAME(Onnx, 22, Asin); +class ONNX_OPERATOR_SET_SCHEMA_CLASS_NAME(Onnx, 22, Acos); +class ONNX_OPERATOR_SET_SCHEMA_CLASS_NAME(Onnx, 22, Atan); +class ONNX_OPERATOR_SET_SCHEMA_CLASS_NAME(Onnx, 22, Sinh); +class ONNX_OPERATOR_SET_SCHEMA_CLASS_NAME(Onnx, 22, Cosh); +class ONNX_OPERATOR_SET_SCHEMA_CLASS_NAME(Onnx, 22, Asinh); +class ONNX_OPERATOR_SET_SCHEMA_CLASS_NAME(Onnx, 22, Acosh); +class ONNX_OPERATOR_SET_SCHEMA_CLASS_NAME(Onnx, 22, Atanh); +class ONNX_OPERATOR_SET_SCHEMA_CLASS_NAME(Onnx, 22, Round); +class ONNX_OPERATOR_SET_SCHEMA_CLASS_NAME(Onnx, 22, Det); +class ONNX_OPERATOR_SET_SCHEMA_CLASS_NAME(Onnx, 22, NegativeLogLikelihoodLoss); +class ONNX_OPERATOR_SET_SCHEMA_CLASS_NAME(Onnx, 22, AveragePool); +class ONNX_OPERATOR_SET_SCHEMA_CLASS_NAME(Onnx, 22, MaxPool); +class ONNX_OPERATOR_SET_SCHEMA_CLASS_NAME(Onnx, 22, MaxUnpool); +class ONNX_OPERATOR_SET_SCHEMA_CLASS_NAME(Onnx, 22, LpPool); +class ONNX_OPERATOR_SET_SCHEMA_CLASS_NAME(Onnx, 22, MaxRoiPool); +class ONNX_OPERATOR_SET_SCHEMA_CLASS_NAME(Onnx, 22, Conv); +class ONNX_OPERATOR_SET_SCHEMA_CLASS_NAME(Onnx, 22, ConvTranspose); +class ONNX_OPERATOR_SET_SCHEMA_CLASS_NAME(Onnx, 22, DeformConv); +class ONNX_OPERATOR_SET_SCHEMA_CLASS_NAME(Onnx, 22, GlobalAveragePool); +class ONNX_OPERATOR_SET_SCHEMA_CLASS_NAME(Onnx, 22, GlobalMaxPool); +class ONNX_OPERATOR_SET_SCHEMA_CLASS_NAME(Onnx, 22, GlobalLpPool); +class ONNX_OPERATOR_SET_SCHEMA_CLASS_NAME(Onnx, 22, InstanceNormalization); +class ONNX_OPERATOR_SET_SCHEMA_CLASS_NAME(Onnx, 22, LpNormalization); +class ONNX_OPERATOR_SET_SCHEMA_CLASS_NAME(Onnx, 22, Dropout); +class ONNX_OPERATOR_SET_SCHEMA_CLASS_NAME(Onnx, 22, RoiAlign); +class ONNX_OPERATOR_SET_SCHEMA_CLASS_NAME(Onnx, 22, RNN); +class ONNX_OPERATOR_SET_SCHEMA_CLASS_NAME(Onnx, 22, GRU); +class ONNX_OPERATOR_SET_SCHEMA_CLASS_NAME(Onnx, 22, LSTM); +class ONNX_OPERATOR_SET_SCHEMA_CLASS_NAME(Onnx, 22, GridSample); // Iterate over schema from ai.onnx version 22 class OpSet_Onnx_ver22 { public: static void ForEachSchema(std::function fn) { - // TODO: Remove after introducing the first schema to opset 22 - (void)fn; + fn(GetOpSchema()); + fn(GetOpSchema()); + fn(GetOpSchema()); + fn(GetOpSchema()); + fn(GetOpSchema()); + fn(GetOpSchema()); + fn(GetOpSchema()); + fn(GetOpSchema()); + fn(GetOpSchema()); + fn(GetOpSchema()); + fn(GetOpSchema()); + fn(GetOpSchema()); + fn(GetOpSchema()); + fn(GetOpSchema()); + fn(GetOpSchema()); + fn(GetOpSchema()); + fn(GetOpSchema()); + fn(GetOpSchema()); + fn(GetOpSchema()); + fn(GetOpSchema()); + fn(GetOpSchema()); + fn(GetOpSchema()); + fn(GetOpSchema()); + fn(GetOpSchema()); + fn(GetOpSchema()); + fn(GetOpSchema()); + fn(GetOpSchema()); + fn(GetOpSchema()); + fn(GetOpSchema()); + fn(GetOpSchema()); + fn(GetOpSchema()); + fn(GetOpSchema()); + fn(GetOpSchema()); + fn(GetOpSchema()); + fn(GetOpSchema()); + fn(GetOpSchema()); + fn(GetOpSchema()); + fn(GetOpSchema()); + fn(GetOpSchema()); + fn(GetOpSchema()); + fn(GetOpSchema()); + fn(GetOpSchema()); + fn(GetOpSchema()); + fn(GetOpSchema()); + fn(GetOpSchema()); + fn(GetOpSchema()); + fn(GetOpSchema()); + fn(GetOpSchema()); } }; @@ -1227,7 +1321,7 @@ inline void RegisterOnnxOperatorSetSchema(int target_version, bool fail_duplicat // Update here if opset_version bumps // These calls for schema registration here are required to be in descending order for this to work correctly // - // Version-sepcific registration sees duplicate schema version request as error if fail_duplicate_schema + // Version-specific registration sees duplicate schema version request as error if fail_duplicate_schema RegisterOpSetSchema(target_version, fail_duplicate_schema); RegisterOpSetSchema(target_version, fail_duplicate_schema); RegisterOpSetSchema(target_version, fail_duplicate_schema); diff --git a/onnx/defs/rnn/defs.cc b/onnx/defs/rnn/defs.cc index b5844444ca8..a28f2354b02 100644 --- a/onnx/defs/rnn/defs.cc +++ b/onnx/defs/rnn/defs.cc @@ -167,16 +167,13 @@ std::function RNNDocGenerator(const char* /*name*/) { true, 1, OpSchema::Differentiable); - schema.TypeConstraint( - "T", - {"tensor(float16)", "tensor(float)", "tensor(double)"}, - "Constrain input and output types to float tensors."); + schema.TypeConstraint("T", OpSchema::all_float_types_ir4(), "Constrain input and output types to float tensors."); schema.TypeConstraint("T1", {"tensor(int32)"}, "Constrain seq_lens to integer tensor."); schema.TypeAndShapeInferenceFunction(RNNShapeInference); }; } -static const char* RNN_ver14_doc = R"DOC( +static const char* RNN_ver22_doc = R"DOC( Computes an one-layer simple RNN. This operator is usually supported via some custom implementation such as CuDNN. @@ -220,9 +217,9 @@ Equations (Default: f=Tanh): ONNX_OPERATOR_SET_SCHEMA( RNN, - 14, + 22, OpSchema() - .SetDoc(GET_OP_DOC_STR(std::string(RNN_ver14_doc) + GenerateOptionalArgumentsDoc())) + .SetDoc(GET_OP_DOC_STR(std::string(RNN_ver22_doc) + GenerateOptionalArgumentsDoc())) .Attr( "activations", "One (or two if bidirectional) activation function for " @@ -266,7 +263,7 @@ ONNX_OPERATOR_SET_SCHEMA( OpSchema::Differentiable) .FillUsing(RNNDocGenerator("RNN"))); -static const char* GRU_ver14_doc = R"DOC( +static const char* GRU_ver22_doc = R"DOC( Computes an one-layer GRU. This operator is usually supported via some custom implementation such as CuDNN. @@ -317,9 +314,9 @@ Equations (Default: f=Sigmoid, g=Tanh): ONNX_OPERATOR_SET_SCHEMA( GRU, - 14, + 22, OpSchema() - .SetDoc(GET_OP_DOC_STR(std::string(GRU_ver14_doc) + GenerateOptionalArgumentsDoc())) + .SetDoc(GET_OP_DOC_STR(std::string(GRU_ver22_doc) + GenerateOptionalArgumentsDoc())) .Attr( "activations", "A list of 2 (or 4 if bidirectional) activation functions " @@ -371,7 +368,7 @@ ONNX_OPERATOR_SET_SCHEMA( OpSchema::Differentiable) .FillUsing(RNNDocGenerator("GRU"))); -static const char* LSTM_ver14_doc = R"DOC( +static const char* LSTM_ver22_doc = R"DOC( Computes an one-layer LSTM. This operator is usually supported via some custom implementation such as CuDNN. @@ -425,9 +422,9 @@ Equations (Default: f=Sigmoid, g=Tanh, h=Tanh): ONNX_OPERATOR_SET_SCHEMA( LSTM, - 14, + 22, OpSchema() - .SetDoc(GET_OP_DOC_STR(std::string(LSTM_ver14_doc) + GenerateOptionalArgumentsDoc())) + .SetDoc(GET_OP_DOC_STR(std::string(LSTM_ver22_doc) + GenerateOptionalArgumentsDoc())) .Attr( "activations", "A list of 3 (or 6 if bidirectional) activation functions " diff --git a/onnx/defs/rnn/old.cc b/onnx/defs/rnn/old.cc index 51fe5960f8b..36371ac67b5 100644 --- a/onnx/defs/rnn/old.cc +++ b/onnx/defs/rnn/old.cc @@ -5,6 +5,521 @@ #include "onnx/defs/schema.h" namespace ONNX_NAMESPACE { + +void RNNShapeInference_opset14(InferenceContext& ctx) { + TensorShapeProto::Dimension num_directions, seq_length, batch_size, hidden_size; + + auto direction = getAttribute(ctx, "direction", "forward"); + if ((direction == "forward") || (direction == "reverse")) + num_directions.set_dim_value(1); + else if (direction == "bidirectional") + num_directions.set_dim_value(2); + // else leave num_directions unknown in case of incorrect attribute value + + auto hidden_size_value = getAttribute(ctx, "hidden_size", -1); + if (hidden_size_value > 0) + hidden_size.set_dim_value(hidden_size_value); + + auto layout_value = getAttribute(ctx, "layout", 0); + + if (hasInputShape(ctx, 0)) { + auto& first_input_shape = getInputShape(ctx, 0); + if (first_input_shape.dim_size() != 3) { + fail_shape_inference("First input tensor must have rank 3"); + } + seq_length = first_input_shape.dim((layout_value == 0) ? 0 : 1); + batch_size = first_input_shape.dim((layout_value == 0) ? 1 : 0); + } + + auto num_outputs = ctx.getNumOutputs(); + + if (num_outputs > 0) { + // Y + propagateElemTypeFromInputToOutput(ctx, 0, 0); + + if (layout_value == 0) { + auto dims = {seq_length, num_directions, batch_size, hidden_size}; + updateOutputShape(ctx, 0, dims); + } else { + auto dims = {batch_size, seq_length, num_directions, hidden_size}; + updateOutputShape(ctx, 0, dims); + } + } + + if (num_outputs > 1) { + // Y_h + propagateElemTypeFromInputToOutput(ctx, 0, 1); + + if (layout_value == 0) { + auto dims = {num_directions, batch_size, hidden_size}; + updateOutputShape(ctx, 1, dims); + } else { + auto dims = {batch_size, num_directions, hidden_size}; + updateOutputShape(ctx, 1, dims); + } + } + + if (num_outputs > 2) { + // Y_c : only in the case of LSTM + propagateElemTypeFromInputToOutput(ctx, 0, 2); + + if (layout_value == 0) { + auto dims = {num_directions, batch_size, hidden_size}; + updateOutputShape(ctx, 2, dims); + } else { + auto dims = {batch_size, num_directions, hidden_size}; + updateOutputShape(ctx, 2, dims); + } + } +} +std::function RNNDocGenerator_opset14(const char* /*name*/) { + return [=](OpSchema& schema) { + schema.Attr( + "direction", + "Specify if the RNN is forward, reverse, or bidirectional. " + "Must be one of forward (default), reverse, or bidirectional.", + AttributeProto::STRING, + std::string("forward")); + schema.Attr( + "layout", + "The shape format of inputs X, initial_h and outputs Y, Y_h. " + "If 0, the following shapes are expected: " + "X.shape = [seq_length, batch_size, input_size], " + "Y.shape = [seq_length, num_directions, batch_size, hidden_size], " + "initial_h.shape = Y_h.shape = [num_directions, batch_size, hidden_size]. " + "If 1, the following shapes are expected: " + "X.shape = [batch_size, seq_length, input_size], " + "Y.shape = [batch_size, seq_length, num_directions, hidden_size], " + "initial_h.shape = Y_h.shape = [batch_size, num_directions, hidden_size].", + AttributeProto::INT, + static_cast(0)); + schema.Attr("hidden_size", "Number of neurons in the hidden layer", AttributeProto::INT, OPTIONAL_VALUE); + schema.Attr( + "activation_alpha", + "Optional scaling values used by some activation functions. The values " + "are consumed in the order of activation functions, for example (f, g, h) " + "in LSTM. Default values are the same as of corresponding ONNX operators." + "For example with LeakyRelu, the default alpha is 0.01.", + AttributeProto::FLOATS, + OPTIONAL_VALUE); + schema.Attr( + "activation_beta", + "Optional scaling values used by some activation functions. The values " + "are consumed in the order of activation functions, for example (f, g, h) " + "in LSTM. Default values are the same as of corresponding ONNX operators.", + AttributeProto::FLOATS, + OPTIONAL_VALUE); + schema.Attr( + "clip", + "Cell clip threshold. Clipping bounds the elements of a tensor " + "in the range of [-threshold, +threshold] and is applied to the input " + "of activations. No clip if not specified.", + AttributeProto::FLOAT, + OPTIONAL_VALUE); + schema.Input( + 0, + "X", + "The input sequences packed (and potentially padded) into one 3-D " + "tensor with the shape of `[seq_length, batch_size, input_size]`.", + "T", + OpSchema::Single, + true, + 1, + OpSchema::Differentiable); + schema.Input( + 4, + "sequence_lens", + "Optional tensor specifying lengths of the sequences in a batch. " + "If not specified - assumed all sequences in the batch to have " + "length `seq_length`. It has shape `[batch_size]`.", + "T1", + OpSchema::Optional, + true, + 1, + OpSchema::NonDifferentiable); + schema.Input( + 5, + "initial_h", + "Optional initial value of the hidden. If not specified - assumed " + "to be 0. It has shape `[num_directions, batch_size, hidden_size]`.", + "T", + OpSchema::Optional, + true, + 1, + OpSchema::NonDifferentiable); + schema.Output( + 0, + "Y", + "A tensor that concats all the intermediate output values of the hidden. " + "It has shape `[seq_length, num_directions, batch_size, hidden_size]`. ", + "T", + OpSchema::Optional, + true, + 1, + OpSchema::Differentiable); + schema.Output( + 1, + "Y_h", + "The last output value of the hidden. It has shape " + "`[num_directions, batch_size, hidden_size]`.", + "T", + OpSchema::Optional, + true, + 1, + OpSchema::Differentiable); + schema.TypeConstraint( + "T", + {"tensor(float16)", "tensor(float)", "tensor(double)"}, + "Constrain input and output types to float tensors."); + schema.TypeConstraint("T1", {"tensor(int32)"}, "Constrain seq_lens to integer tensor."); + schema.TypeAndShapeInferenceFunction(RNNShapeInference_opset14); + }; +} + +static const char* GRU_ver14_doc = R"DOC( +Computes an one-layer GRU. This operator is usually supported via some custom +implementation such as CuDNN. + +Notations: + +* `X` - input tensor +* `z` - update gate +* `r` - reset gate +* `h` - hidden gate +* `t` - time step (t-1 means previous time step) +* `W[zrh]` - W parameter weight matrix for update, reset, and hidden gates +* `R[zrh]` - R recurrence weight matrix for update, reset, and hidden gates +* `Wb[zrh]` - W bias vectors for update, reset, and hidden gates +* `Rb[zrh]` - R bias vectors for update, reset, and hidden gates +* `WB[zrh]` - W parameter weight matrix for backward update, reset, and hidden gates +* `RB[zrh]` - R recurrence weight matrix for backward update, reset, and hidden gates +* `WBb[zrh]` - W bias vectors for backward update, reset, and hidden gates +* `RBb[zrh]` - R bias vectors for backward update, reset, and hidden gates +* `H` - Hidden state +* `num_directions` - 2 if direction == bidirectional else 1 + +Activation functions: + +* Relu(x) - max(0, x) +* Tanh(x) - (1 - e^{-2x})/(1 + e^{-2x}) +* Sigmoid(x) - 1/(1 + e^{-x}) + +NOTE: + Below are optional + +* Affine(x) - alpha * x + beta +* LeakyRelu(x) - x if x >= 0 else alpha * x +* ThresholdedRelu(x) - x if x >= alpha else 0 +* ScaledTanh(x) - alpha * Tanh(beta * x) +* HardSigmoid(x) - min(max(alpha * x + beta, 0), 1) +* Elu(x) - x if x >= 0 else alpha * (e^x - 1) +* Softsign(x) - x/(1 + |x|) +* Softplus(x) - log(1 + e^x) + +Equations (Default: f=Sigmoid, g=Tanh): + +* zt = f(Xt*(Wz^T) + Ht-1*(Rz^T) + Wbz + Rbz) +* rt = f(Xt*(Wr^T) + Ht-1*(Rr^T) + Wbr + Rbr) +* ht = g(Xt*(Wh^T) + (rt (.) Ht-1)*(Rh^T) + Rbh + Wbh) # default, when linear_before_reset = 0 +* ht = g(Xt*(Wh^T) + (rt (.) (Ht-1*(Rh^T) + Rbh)) + Wbh) # when linear_before_reset != 0 +* Ht = (1 - zt) (.) ht + zt (.) Ht-1 +)DOC"; + +ONNX_OPERATOR_SET_SCHEMA( + GRU, + 14, + OpSchema() + .SetDoc(GET_OP_DOC_STR(std::string(GRU_ver14_doc) + GenerateOptionalArgumentsDoc())) + .Attr( + "activations", + "A list of 2 (or 4 if bidirectional) activation functions " + "for update, reset, and hidden gates. The activation functions must be one " + "of the activation functions specified above. Optional: See the equations " + "for default if not specified.", + AttributeProto::STRINGS, + OPTIONAL_VALUE) + .Attr( + "linear_before_reset", + "When computing the output of the hidden gate, " + "apply the linear transformation before multiplying by the output of the " + "reset gate.", + AttributeProto::INT, + static_cast(0)) + .Input( + 1, + "W", + "The weight tensor for the gates. Concatenation of `W[zrh]` and `WB[zrh]` " + "(if bidirectional) along dimension 0. This tensor has shape " + "`[num_directions, 3*hidden_size, input_size]`.", + "T", + OpSchema::Single, + true, + 1, + OpSchema::Differentiable) + .Input( + 2, + "R", + "The recurrence weight tensor. Concatenation of `R[zrh]` and `RB[zrh]` " + "(if bidirectional) along dimension 0. This tensor has shape " + "`[num_directions, 3*hidden_size, hidden_size]`.", + "T", + OpSchema::Single, + true, + 1, + OpSchema::Differentiable) + .Input( + 3, + "B", + "The bias tensor for the gates. Concatenation of `[Wb[zrh], Rb[zrh]]` and " + "`[WBb[zrh], RBb[zrh]]` (if bidirectional) along dimension 0. This tensor " + "has shape `[num_directions, 6*hidden_size]`. Optional: If not specified " + "- assumed to be 0", + "T", + OpSchema::Optional, + true, + 1, + OpSchema::Differentiable) + .FillUsing(RNNDocGenerator_opset14("GRU"))); + +static const char* LSTM_ver14_doc = R"DOC( +Computes an one-layer LSTM. This operator is usually supported via some +custom implementation such as CuDNN. + +Notations: + +* `X` - input tensor +* `i` - input gate +* `o` - output gate +* `f` - forget gate +* `c` - cell gate +* `t` - time step (t-1 means previous time step) +* `W[iofc]` - W parameter weight matrix for input, output, forget, and cell gates +* `R[iofc]` - R recurrence weight matrix for input, output, forget, and cell gates +* `Wb[iofc]` - W bias vectors for input, output, forget, and cell gates +* `Rb[iofc]` - R bias vectors for input, output, forget, and cell gates +* `P[iof]` - P peephole weight vector for input, output, and forget gates +* `WB[iofc]` - W parameter weight matrix for backward input, output, forget, and cell gates +* `RB[iofc]` - R recurrence weight matrix for backward input, output, forget, and cell gates +* `WBb[iofc]` - W bias vectors for backward input, output, forget, and cell gates +* `RBb[iofc]` - R bias vectors for backward input, output, forget, and cell gates +* `PB[iof]` - P peephole weight vector for backward input, output, and forget gates +* `H` - Hidden state +* `num_directions` - 2 if direction == bidirectional else 1 + +Activation functions: + +* Relu(x) - max(0, x) +* Tanh(x) - (1 - e^{-2x})/(1 + e^{-2x}) +* Sigmoid(x) - 1/(1 + e^{-x}) + +NOTE: Below are optional + +* Affine(x) - alpha*x + beta +* LeakyRelu(x) - x if x >= 0 else alpha * x +* ThresholdedRelu(x) - x if x >= alpha else 0 +* ScaledTanh(x) - alpha*Tanh(beta*x) +* HardSigmoid(x) - min(max(alpha*x + beta, 0), 1) +* Elu(x) - x if x >= 0 else alpha*(e^x - 1) +* Softsign(x) - x/(1 + |x|) +* Softplus(x) - log(1 + e^x) + +Equations (Default: f=Sigmoid, g=Tanh, h=Tanh): + +* it = f(Xt*(Wi^T) + Ht-1*(Ri^T) + Pi (.) Ct-1 + Wbi + Rbi) +* ft = f(Xt*(Wf^T) + Ht-1*(Rf^T) + Pf (.) Ct-1 + Wbf + Rbf) +* ct = g(Xt*(Wc^T) + Ht-1*(Rc^T) + Wbc + Rbc) +* Ct = ft (.) Ct-1 + it (.) ct +* ot = f(Xt*(Wo^T) + Ht-1*(Ro^T) + Po (.) Ct + Wbo + Rbo) +* Ht = ot (.) h(Ct) +)DOC"; + +ONNX_OPERATOR_SET_SCHEMA( + LSTM, + 14, + OpSchema() + .SetDoc(GET_OP_DOC_STR(std::string(LSTM_ver14_doc) + GenerateOptionalArgumentsDoc())) + .Attr( + "activations", + "A list of 3 (or 6 if bidirectional) activation functions " + "for input, output, forget, cell, and hidden. The activation functions must " + "be one of the activation functions specified above. Optional: See the equations " + "for default if not specified.", + AttributeProto::STRINGS, + OPTIONAL_VALUE) + .Attr( + "layout", + "The shape format of inputs X, initial_h, initial_c and outputs Y, Y_h, Y_c. " + "If 0, the following shapes are expected: " + "X.shape = [seq_length, batch_size, input_size], " + "Y.shape = [seq_length, num_directions, batch_size, hidden_size], " + "initial_h.shape = Y_h.shape = initial_c.shape = Y_c.shape = " + "[num_directions, batch_size, hidden_size]. " + "If 1, the following shapes are expected: " + "X.shape = [batch_size, seq_length, input_size], " + "Y.shape = [batch_size, seq_length, num_directions, hidden_size], " + "initial_h.shape = Y_h.shape = initial_c.shape = Y_c.shape = " + "[batch_size, num_directions, hidden_size].", + AttributeProto::INT, + static_cast(0)) + .Attr("input_forget", "Couple the input and forget gates if 1.", AttributeProto::INT, static_cast(0)) + .Input( + 1, + "W", + "The weight tensor for the gates. Concatenation of `W[iofc]` and " + "`WB[iofc]` (if bidirectional) along dimension 0. The tensor has shape " + "`[num_directions, 4*hidden_size, input_size]`.", + "T", + OpSchema::Single, + true, + 1, + OpSchema::Differentiable) + .Input( + 2, + "R", + "The recurrence weight tensor. Concatenation of `R[iofc]` and " + "`RB[iofc]` (if bidirectional) along dimension 0. This tensor has shape " + "`[num_directions, 4*hidden_size, hidden_size]`.", + "T", + OpSchema::Single, + true, + 1, + OpSchema::Differentiable) + .Input( + 3, + "B", + "The bias tensor for input gate. Concatenation of `[Wb[iofc], Rb[iofc]]`, " + "and `[WBb[iofc], RBb[iofc]]` (if bidirectional) along dimension 0. This " + "tensor has shape `[num_directions, 8*hidden_size]`. Optional: If not " + "specified - assumed to be 0.", + "T", + OpSchema::Optional, + true, + 1, + OpSchema::Differentiable) + .Input( + 6, + "initial_c", + "Optional initial value of the cell. If not specified - assumed " + "to be 0. It has shape `[num_directions, batch_size, hidden_size]`.", + "T", + OpSchema::Optional, + true, + 1, + OpSchema::NonDifferentiable) + .Input( + 7, + "P", + "The weight tensor for peepholes. Concatenation of `P[iof]` and " + "`PB[iof]` (if bidirectional) along dimension 0. It has shape " + "`[num_directions, 3*hidde_size]`. Optional: If not specified - " + "assumed to be 0.", + "T", + OpSchema::Optional, + true, + 1, + OpSchema::Differentiable) + .FillUsing(RNNDocGenerator_opset14("LSTM")) + .Output( + 2, + "Y_c", + "The last output value of the cell. It has shape " + "`[num_directions, batch_size, hidden_size]`.", + "T", + OpSchema::Optional, + true, + 1, + OpSchema::Differentiable)); + +static const char* RNN_ver14_doc = R"DOC( +Computes an one-layer simple RNN. This operator is usually supported +via some custom implementation such as CuDNN. + +Notations: + +* `X` - input tensor +* `i` - input gate +* `t` - time step (t-1 means previous time step) +* `Wi` - W parameter weight matrix for input gate +* `Ri` - R recurrence weight matrix for input gate +* `Wbi` - W parameter bias vector for input gate +* `Rbi` - R parameter bias vector for input gate +* `WBi` - W parameter weight matrix for backward input gate +* `RBi` - R recurrence weight matrix for backward input gate +* `WBbi` - WR bias vectors for backward input gate +* `RBbi` - RR bias vectors for backward input gate +* `H` - Hidden state +* `num_directions` - 2 if direction == bidirectional else 1 + +Activation functions: + +* Relu(x) - max(0, x) +* Tanh(x) - (1 - e^{-2x})/(1 + e^{-2x}) +* Sigmoid(x) - 1/(1 + e^{-x}) + +NOTE: Below are optional + +* Affine(x) - alpha*x + beta +* LeakyRelu(x) - x if x >= 0 else alpha * x +* ThresholdedRelu(x) - x if x >= alpha else 0 +* ScaledTanh(x) - alpha*Tanh(beta*x) +* HardSigmoid(x) - min(max(alpha*x + beta, 0), 1) +* Elu(x) - x if x >= 0 else alpha*(e^x - 1) +* Softsign(x) - x/(1 + |x|) +* Softplus(x) - log(1 + e^x) + +Equations (Default: f=Tanh): + +* Ht = f(Xt*(Wi^T) + Ht-1*(Ri^T) + Wbi + Rbi) +)DOC"; + +ONNX_OPERATOR_SET_SCHEMA( + RNN, + 14, + OpSchema() + .SetDoc(GET_OP_DOC_STR(std::string(RNN_ver14_doc) + GenerateOptionalArgumentsDoc())) + .Attr( + "activations", + "One (or two if bidirectional) activation function for " + "input gate. The activation function must be one of the activation " + "functions specified above. Optional: Default `Tanh` if not specified.", + AttributeProto::STRINGS, + std::vector{"Tanh", "Tanh"}) + .Input( + 1, + "W", + "The weight tensor for input gate. Concatenation of `Wi` and `WBi` " + "(if bidirectional). The tensor has shape " + "`[num_directions, hidden_size, input_size]`.", + "T", + OpSchema::Single, + true, + 1, + OpSchema::Differentiable) + .Input( + 2, + "R", + "The recurrence weight tensor. Concatenation of `Ri` and `RBi` " + "(if bidirectional). The tensor has shape " + "`[num_directions, hidden_size, hidden_size]`.", + "T", + OpSchema::Single, + true, + 1, + OpSchema::Differentiable) + .Input( + 3, + "B", + "The bias tensor for input gate. Concatenation of `[Wbi, Rbi]` " + "and `[WBbi, RBbi]` (if bidirectional). The tensor has shape " + "`[num_directions, 2*hidden_size]`. Optional: If not specified - assumed " + "to be 0.", + "T", + OpSchema::Optional, + true, + 1, + OpSchema::Differentiable) + .FillUsing(RNNDocGenerator_opset14("RNN"))); + std::function RNNDocGeneratorOld(const char* /*name*/) { return [=](OpSchema& schema) { schema.Attr( @@ -243,8 +758,8 @@ void RNNShapeInference1(InferenceContext& ctx) { // Documentation suggests that the output Y is absent in this case // Different tests seem to disagree on whether Y_h and Y_c, if present, // should be in positions 0 & 1 or 1 & 2. updateOutputShape(ctx, 0, - // {num_directions, batch_size, hidden_size}); // Y_h if (num_outputs > 1) - // updateOutputShape(ctx, 1, {num_directions, batch_size, hidden_size}); // + // {num_directions, batch_size, hidden_size}); // Y_h if (num_outputs > 1) + // updateOutputShape(ctx, 1, {num_directions, batch_size, hidden_size}); // // Y_c } } diff --git a/onnx/defs/schema.h b/onnx/defs/schema.h index e786a96b299..20230065ada 100644 --- a/onnx/defs/schema.h +++ b/onnx/defs/schema.h @@ -764,12 +764,36 @@ class OpSchema final { return all_tensor_types_ir4; } + static const std::vector& all_non_complex_numeric_types_plus_bool_ir4() { + static const std::vector all_non_complex_numeric_types_plus_bool_ir4 = { + "tensor(uint8)", + "tensor(uint16)", + "tensor(uint32)", + "tensor(uint64)", + "tensor(int8)", + "tensor(int16)", + "tensor(int32)", + "tensor(int64)", + "tensor(bfloat16)", + "tensor(float16)", + "tensor(float)", + "tensor(double)", + "tensor(bool)"}; + return all_non_complex_numeric_types_plus_bool_ir4; + } + static const std::vector& all_float_types_ir4() { static const std::vector all_float_types_ir4 = { "tensor(bfloat16)", "tensor(float16)", "tensor(float)", "tensor(double)"}; return all_float_types_ir4; } + static const std::vector& all_float_types_plus_Xint8_ir4() { + static const std::vector all_float_types_ir4 = { + "tensor(bfloat16)", "tensor(float16)", "tensor(float)", "tensor(double)", "tensor(int8)", "tensor(uint8)"}; + return all_float_types_ir4; + } + static const std::vector& all_float_types_ir9() { static const std::vector all_float_types_ir9 = { "tensor(bfloat16)", @@ -810,6 +834,16 @@ class OpSchema final { return all_tensor_types_ir10; } + static const std::vector& all_non_complex_tensor_types_ir10() { + static const std::vector all_non_complex_tensor_types_ir10 = { + "tensor(uint8)", "tensor(uint16)", "tensor(uint32)", "tensor(uint64)", + "tensor(int8)", "tensor(int16)", "tensor(int32)", "tensor(int64)", + "tensor(bfloat16)", "tensor(float16)", "tensor(float)", "tensor(double)", + "tensor(string)", "tensor(bool)", "tensor(float8e4m3fn)", "tensor(float8e4m3fnuz)", + "tensor(float8e5m2)", "tensor(float8e5m2fnuz)", "tensor(uint4)", "tensor(int4)"}; + return all_non_complex_tensor_types_ir10; + } + static const std::vector& all_tensor_sequence_types() { static const std::vector all_tensor_sequence_types = { "seq(tensor(uint8))", @@ -1176,7 +1210,7 @@ class OpSchemaRegistry final : public ISchemaRegistry { // operator schema on specific domain. Update the lowest version when it's // determined to remove too old version history. map_[ONNX_DOMAIN] = std::make_pair(1, 22); - map_[AI_ONNX_ML_DOMAIN] = std::make_pair(1, 5); + map_[AI_ONNX_ML_DOMAIN] = std::make_pair(1, 6); map_[AI_ONNX_TRAINING_DOMAIN] = std::make_pair(1, 1); // ONNX's preview domain contains operators subject to change, so // versining is not meaningful and that domain should have only one @@ -1185,8 +1219,8 @@ class OpSchemaRegistry final : public ISchemaRegistry { // Version corresponding last release of ONNX. Update this to match with // the max version above in a *release* version of ONNX. But in other // versions, the max version may be ahead of the last-release-version. - last_release_version_map_[ONNX_DOMAIN] = 21; - last_release_version_map_[AI_ONNX_ML_DOMAIN] = 5; + last_release_version_map_[ONNX_DOMAIN] = 22; + last_release_version_map_[AI_ONNX_ML_DOMAIN] = 6; last_release_version_map_[AI_ONNX_TRAINING_DOMAIN] = 1; last_release_version_map_[AI_ONNX_PREVIEW_TRAINING_DOMAIN] = 1; } diff --git a/onnx/defs/tensor/defs.cc b/onnx/defs/tensor/defs.cc index 5cad024803d..c27620db5ee 100644 --- a/onnx/defs/tensor/defs.cc +++ b/onnx/defs/tensor/defs.cc @@ -136,7 +136,7 @@ ONNX_OPERATOR_SET_SCHEMA( PropagateShapeDataFromInputToOutput(ctx, 0); })); -static const char* CastLike_ver19_doc = R"DOC( +static const char* CastLike_ver21_doc = R"DOC( The operator casts the elements of a given input tensor (the first input) to the same data type as the elements of the second input tensor. See documentation of the Cast operator for further details. @@ -146,7 +146,7 @@ ONNX_OPERATOR_SET_SCHEMA( CastLike, 21, OpSchema() - .SetDoc(CastLike_ver19_doc) + .SetDoc(CastLike_ver21_doc) .Attr( "saturate", "The parameter defines how the conversion behaves if an input value is out of " @@ -176,19 +176,11 @@ ONNX_OPERATOR_SET_SCHEMA( OpSchema::Differentiable) .TypeConstraint( "T1", - {"tensor(float16)", "tensor(float)", "tensor(double)", "tensor(int8)", - "tensor(int16)", "tensor(int32)", "tensor(int64)", "tensor(uint8)", - "tensor(uint16)", "tensor(uint32)", "tensor(uint64)", "tensor(bool)", - "tensor(string)", "tensor(bfloat16)", "tensor(float8e4m3fn)", "tensor(float8e4m3fnuz)", - "tensor(float8e5m2)", "tensor(float8e5m2fnuz)", "tensor(uint4)", "tensor(int4)"}, + OpSchema::all_non_complex_tensor_types_ir10(), "Constrain input types. Casting from complex is not supported.") .TypeConstraint( "T2", - {"tensor(float16)", "tensor(float)", "tensor(double)", "tensor(int8)", - "tensor(int16)", "tensor(int32)", "tensor(int64)", "tensor(uint8)", - "tensor(uint16)", "tensor(uint32)", "tensor(uint64)", "tensor(bool)", - "tensor(string)", "tensor(bfloat16)", "tensor(float8e4m3fn)", "tensor(float8e4m3fnuz)", - "tensor(float8e5m2)", "tensor(float8e5m2fnuz)", "tensor(uint4)", "tensor(int4)"}, + OpSchema::all_non_complex_tensor_types_ir10(), "Constrain output types. Casting to complex is not supported.") .TypeAndShapeInferenceFunction([](InferenceContext& ctx) { propagateElemTypeFromInputToOutput(ctx, 1, 0); @@ -2324,7 +2316,7 @@ ONNX_OPERATOR_SET_SCHEMA( .SetDoc(Resize_ver19_doc) .TypeAndShapeInferenceFunction([](InferenceContext& ctx) { resizeShapeInference_opset18_to_19(ctx); })); -static const char* GridSample_ver20_doc = R"DOC( +static const char* GridSample_ver22_doc = R"DOC( Given an input `X` and a flow-field `grid`, computes the output `Y` using `X` values and pixel locations from the `grid`. For spatial input `X` with shape (N, C, H, W), the `grid` will have shape (N, H_out, W_out, 2), the output `Y` will have shape (N, C, H_out, W_out). For volumetric input `X` with shape (N, C, D, H, W), @@ -2347,7 +2339,7 @@ See also in [torch.nn.functional.grid_sample](https://pytorch.org/docs/stable/ge ONNX_OPERATOR_SET_SCHEMA( GridSample, - 20, + 22, OpSchema() .Attr( "mode", @@ -2413,13 +2405,10 @@ ONNX_OPERATOR_SET_SCHEMA( OpSchema::Differentiable) .TypeConstraint( "T1", - OpSchema::all_tensor_types(), + OpSchema::all_tensor_types_ir4(), "Constrain input `X` and output `Y` types to all tensor types.") - .TypeConstraint( - "T2", - {"tensor(float16)", "tensor(float)", "tensor(double)"}, - "Constrain grid types to float tensors.") - .SetDoc(GridSample_ver20_doc) + .TypeConstraint("T2", OpSchema::all_float_types_ir4(), "Constrain grid types to float tensors.") + .SetDoc(GridSample_ver22_doc) .TypeAndShapeInferenceFunction([](InferenceContext& ctx) { gridSampleShapeInference(ctx); })); static const char* AffineGrid_ver20_doc = R"DOC( diff --git a/onnx/defs/tensor/old.cc b/onnx/defs/tensor/old.cc index b7188b84b46..3dbcc756018 100644 --- a/onnx/defs/tensor/old.cc +++ b/onnx/defs/tensor/old.cc @@ -13,6 +13,104 @@ namespace ONNX_NAMESPACE { +static const char* GridSample_ver20_doc = R"DOC( +Given an input `X` and a flow-field `grid`, computes the output `Y` using `X` values and pixel locations from the `grid`. +For spatial input `X` with shape (N, C, H, W), the `grid` will have shape (N, H_out, W_out, 2), +the output `Y` will have shape (N, C, H_out, W_out). For volumetric input `X` with shape (N, C, D, H, W), +the `grid` will have shape (N, D_out, H_out, W_out, 3), the output `Y` will have shape (N, C, D_out, H_out, W_out). +More generally, for an input `X` of rank r+2 with shape (N, C, d1, d2, ..., dr), +the `grid` will have shape (N, D1_out, D2_out, ..., Dr_out, r), the output `Y` will have shape (N, C, D1_out, D2_out, ..., Dr_out). + +The tensor `X` contains values at centers of square pixels (voxels, etc) locations such as (n, c, d1_in, d2_in, ..., dr_in). +The (n, d1_out, d2_out, ..., dr_out, :) values from the tensor `grid` are the normalized positions for interpolating the values +at the (n, c, d1_out, d2_out, ..., dr_out) locations from the output tensor `Y` using a specified interpolation method (the mode) +and a padding mode (for `grid` positions falling outside the 2-dimensional image). + +For example, the values in `grid[n, h_out, w_out, :]` are size-2 vectors specifying normalized positions in the 2-dimensional space of `X`. +They are used to interpolate output values of `Y[n, c, h_out, w_out]`. + +The GridSample operator is often used in doing grid generator and sampler in the +[Spatial Transformer Networks](https://arxiv.org/abs/1506.02025). +See also in [torch.nn.functional.grid_sample](https://pytorch.org/docs/stable/generated/torch.nn.functional.grid_sample.html). +)DOC"; + +ONNX_OPERATOR_SET_SCHEMA( + GridSample, + 20, + OpSchema() + .Attr( + "mode", + "Three interpolation modes: linear (default), nearest and cubic. " + "The \"linear\" mode includes linear and N-linear interpolation modes depending on the number of spatial dimensions " + "of the input tensor (i.e. linear for 1 spatial dimension, bilinear for 2 spatial dimensions, etc.). " + "The \"cubic\" mode also includes N-cubic interpolation modes following the same rules. The \"nearest\" mode rounds " + "to the nearest even index when the sampling point falls halfway between two indices.", + AttributeProto::STRING, + std::string("linear")) + .Attr( + "padding_mode", + "Support padding modes for outside grid values: `zeros`(default), `border`, `reflection`. " + "zeros: use 0 for out-of-bound grid locations, " + "border: use border values for out-of-bound grid locations, " + "reflection: use values at locations reflected by the border for out-of-bound grid locations. " + "If index 0 represents the margin pixel, the reflected value at index -1 will be the same as the value at index 1. " + "For location far away from the border, it will keep being reflected until becoming in bound. " + "If pixel location x = -3.5 reflects by border -1 and becomes x' = 1.5, then reflects by border 1 and becomes x'' = 0.5.", + AttributeProto::STRING, + std::string("zeros")) + .Attr( + "align_corners", + "If align_corners=1, the extrema (-1 and 1) are considered as referring to the center points of the input's corner pixels (voxels, etc.). " + "If align_corners=0, they are instead considered as referring to the corner points of the input's corner pixels (voxels, etc.), " + "making the sampling more resolution agnostic.", + AttributeProto::INT, + static_cast(0)) + .Input( + 0, + "X", + "Input tensor of rank r+2 that has shape (N, C, D1, D2, ..., Dr), where N is the batch size, " + "C is the number of channels, D1, D2, ..., Dr are the spatial dimensions.", + "T1", + OpSchema::Single, + true, + 1, + OpSchema::Differentiable) + .Input( + 1, + "grid", + "Input offset of shape (N, D1_out, D2_out, ..., Dr_out, r), where D1_out, D2_out, ..., " + "Dr_out are the spatial dimensions of the grid and output, and r is the number of spatial dimensions. " + "Grid specifies the sampling locations normalized by the input spatial dimensions. " + "Therefore, it should have most values in the range of [-1, 1]. If the grid has values outside the range of [-1, 1], " + "the corresponding outputs will be handled as defined by padding_mode. Following computer vision convention, " + "the coordinates in the length-r location vector are listed from the innermost tensor dimension to the outermost, " + "the opposite of regular tensor indexing.", + "T2", + OpSchema::Single, + true, + 1, + OpSchema::NonDifferentiable) + .Output( + 0, + "Y", + "Output tensor of rank r+2 that has shape (N, C, D1_out, D2_out, ..., Dr_out) of the sampled values. " + "For integer input types, intermediate values are computed as floating point and cast to integer at the end.", + "T1", + OpSchema::Single, + true, + 1, + OpSchema::Differentiable) + .TypeConstraint( + "T1", + OpSchema::all_tensor_types(), + "Constrain input `X` and output `Y` types to all tensor types.") + .TypeConstraint( + "T2", + {"tensor(float16)", "tensor(float)", "tensor(double)"}, + "Constrain grid types to float tensors.") + .SetDoc(GridSample_ver20_doc) + .TypeAndShapeInferenceFunction([](InferenceContext& ctx) { gridSampleShapeInference(ctx); })); + static const char* Cast_ver19_doc = R"DOC( The operator casts the elements of a given input tensor to a data type specified by the 'to' argument and returns an output tensor of the same size in diff --git a/onnx/helper.py b/onnx/helper.py index d28df25ca3c..fc824c09907 100644 --- a/onnx/helper.py +++ b/onnx/helper.py @@ -76,6 +76,7 @@ ("1.14.1", 9, 19, 3, 1), ("1.15.0", 9, 20, 4, 1), ("1.16.0", 10, 21, 5, 1), + ("1.17.0", 10, 22, 6, 1), ] VersionMapType = Dict[Tuple[str, int], int] diff --git a/onnx/test/cpp/schema_registration_test.cc b/onnx/test/cpp/schema_registration_test.cc index 5ca90cf85ef..3745cb7c2ab 100644 --- a/onnx/test/cpp/schema_registration_test.cc +++ b/onnx/test/cpp/schema_registration_test.cc @@ -73,11 +73,11 @@ TEST(SchemaRegistrationTest, RegisterAndDeregisterAllOpsetSchemaVersion) { // Acos-7 // Add-1,6,7,13,14 // Trilu-14 - auto schema = OpSchemaRegistry::Schema("Acos"); + auto schema = OpSchemaRegistry::Schema("Acos", 7); EXPECT_NE(nullptr, schema); EXPECT_EQ(schema->SinceVersion(), 7); - schema = OpSchemaRegistry::Schema("Add"); + schema = OpSchemaRegistry::Schema("Add", 14); EXPECT_NE(nullptr, schema); EXPECT_EQ(schema->SinceVersion(), 14); @@ -121,7 +121,7 @@ TEST(SchemaRegistrationTest, RegisterSpecifiedOpsetSchemaVersion) { EXPECT_EQ(nullptr, opSchema); // Acos-7 is the latest Acos before specified 13 - opSchema = OpSchemaRegistry::Schema("Acos"); + opSchema = OpSchemaRegistry::Schema("Acos", 13); EXPECT_NE(nullptr, opSchema); EXPECT_EQ(opSchema->SinceVersion(), 7); #endif diff --git a/onnx/test/test_backend_onnxruntime.py b/onnx/test/test_backend_onnxruntime.py index df701a052de..4fdc5c7d834 100644 --- a/onnx/test/test_backend_onnxruntime.py +++ b/onnx/test/test_backend_onnxruntime.py @@ -185,6 +185,268 @@ def run_node(cls, node, inputs, device=None, outputs_info=None, **kwargs): "|test_transpose_" "|test_unsqueeze_" "|test_wrap_pad_" + "|test_acos_cpu" + "|test_acos_example_cpu" + "|test_acosh_cpu" + "|test_acosh_example_cpu" + "|test_asin_cpu" + "|test_asin_example_cpu" + "|test_asinh_cpu" + "|test_asinh_example_cpu" + "|test_atan_cpu" + "|test_atan_example_cpu" + "|test_atanh_cpu" + "|test_atanh_example_cpu" + "|test_averagepool_1d_default_cpu" + "|test_averagepool_2d_ceil_cpu" + "|test_averagepool_2d_default_cpu" + "|test_averagepool_2d_dilations_cpu" + "|test_averagepool_2d_pads_count_include_pad_cpu" + "|test_averagepool_2d_pads_cpu" + "|test_averagepool_2d_precomputed_pads_count_include_pad_cpu" + "|test_averagepool_2d_precomputed_pads_cpu" + "|test_averagepool_2d_precomputed_same_upper_cpu" + "|test_averagepool_2d_precomputed_strides_cpu" + "|test_averagepool_2d_same_lower_cpu" + "|test_averagepool_2d_same_upper_cpu" + "|test_averagepool_2d_strides_cpu" + "|test_averagepool_3d_default_cpu" + "|test_averagepool_3d_dilations_large_count_include_pad_is_0_ceil_mode_is_False_cpu" + "|test_averagepool_3d_dilations_large_count_include_pad_is_0_ceil_mode_is_True_cpu" + "|test_averagepool_3d_dilations_large_count_include_pad_is_1_ceil_mode_is_False_cpu" + "|test_averagepool_3d_dilations_large_count_include_pad_is_1_ceil_mode_is_True_cpu" + "|test_averagepool_3d_dilations_small_cpu" + "|test_basic_conv_with_padding_cpu" + "|test_basic_conv_without_padding_cpu" + "|test_conv_with_autopad_same_cpu" + "|test_conv_with_strides_and_asymmetric_padding_cpu" + "|test_conv_with_strides_no_padding_cpu" + "|test_conv_with_strides_padding_cpu" + "|test_convtranspose_1d_cpu" + "|test_convtranspose_3d_cpu" + "|test_convtranspose_autopad_same_cpu" + "|test_convtranspose_cpu" + "|test_convtranspose_dilations_cpu" + "|test_convtranspose_kernel_shape_cpu" + "|test_convtranspose_output_shape_cpu" + "|test_convtranspose_pad_cpu" + "|test_convtranspose_pads_cpu" + "|test_cos_cpu" + "|test_cos_example_cpu" + "|test_cosh_cpu" + "|test_cosh_example_cpu" + "|test_det_2d_cpu" + "|test_det_nd_cpu" + "|test_dropout_default_cpu" + "|test_dropout_default_mask_cpu" + "|test_dropout_default_mask_ratio_cpu" + "|test_dropout_default_ratio_cpu" + "|test_elu_cpu" + "|test_elu_default_cpu" + "|test_elu_example_cpu" + "|test_eyelike_populate_off_main_diagonal_cpu" + "|test_eyelike_with_dtype_cpu" + "|test_eyelike_without_dtype_cpu" + "|test_globalaveragepool_cpu" + "|test_globalaveragepool_precomputed_cpu" + "|test_gridsample_aligncorners_true_cpu" + "|test_gridsample_bicubic_align_corners_0_additional_1_cpu" + "|test_gridsample_bicubic_align_corners_1_additional_1_cpu" + "|test_gridsample_bicubic_cpu" + "|test_gridsample_bilinear_align_corners_0_additional_1_cpu" + "|test_gridsample_bilinear_align_corners_1_additional_1_cpu" + "|test_gridsample_bilinear_cpu" + "|test_gridsample_border_padding_cpu" + "|test_gridsample_cpu" + "|test_gridsample_nearest_align_corners_0_additional_1_cpu" + "|test_gridsample_nearest_align_corners_1_additional_1_cpu" + "|test_gridsample_nearest_cpu" + "|test_gridsample_reflection_padding_cpu" + "|test_gridsample_volumetric_bilinear_align_corners_0_cpu" + "|test_gridsample_volumetric_bilinear_align_corners_1_cpu" + "|test_gridsample_volumetric_nearest_align_corners_0_cpu" + "|test_gridsample_volumetric_nearest_align_corners_1_cpu" + "|test_gridsample_zeros_padding_cpu" + "|test_gru_defaults_cpu" + "|test_gru_seq_length_cpu" + "|test_gru_with_initial_bias_cpu" + "|test_hardsigmoid_cpu" + "|test_hardsigmoid_default_cpu" + "|test_hardsigmoid_example_cpu" + "|test_hardswish_cpu" + "|test_hardswish_expanded_cpu" + "|test_lppool_1d_default_cpu" + "|test_lppool_2d_default_cpu" + "|test_lppool_2d_dilations_cpu" + "|test_lppool_2d_pads_cpu" + "|test_lppool_2d_same_lower_cpu" + "|test_lppool_2d_same_upper_cpu" + "|test_lppool_2d_strides_cpu" + "|test_lppool_3d_default_cpu" + "|test_lstm_defaults_cpu" + "|test_lstm_with_initial_bias_cpu" + "|test_lstm_with_peepholes_cpu" + "|test_maxpool_1d_default_cpu" + "|test_maxpool_2d_ceil_cpu" + "|test_maxpool_2d_default_cpu" + "|test_maxpool_2d_dilations_cpu" + "|test_maxpool_2d_pads_cpu" + "|test_maxpool_2d_precomputed_pads_cpu" + "|test_maxpool_2d_precomputed_same_upper_cpu" + "|test_maxpool_2d_precomputed_strides_cpu" + "|test_maxpool_2d_same_lower_cpu" + "|test_maxpool_2d_same_upper_cpu" + "|test_maxpool_2d_strides_cpu" + "|test_maxpool_2d_uint8_cpu" + "|test_maxpool_3d_default_cpu" + "|test_maxpool_3d_dilations_cpu" + "|test_maxpool_3d_dilations_use_ref_impl_cpu" + "|test_maxpool_3d_dilations_use_ref_impl_large_cpu" + "|test_maxpool_with_argmax_2d_precomputed_pads_cpu" + "|test_maxpool_with_argmax_2d_precomputed_strides_cpu" + "|test_maxunpool_export_without_output_shape_cpu" + "|test_mish_cpu" + "|test_mish_expanded_cpu" + "|test_nllloss_NC_cpu" + "|test_nllloss_NC_expanded_cpu" + "|test_nllloss_NCd1_cpu" + "|test_nllloss_NCd1_expanded_cpu" + "|test_nllloss_NCd1_ii_cpu" + "|test_nllloss_NCd1_ii_expanded_cpu" + "|test_nllloss_NCd1_mean_weight_negative_ii_cpu" + "|test_nllloss_NCd1_mean_weight_negative_ii_expanded_cpu" + "|test_nllloss_NCd1_weight_cpu" + "|test_nllloss_NCd1_weight_expanded_cpu" + "|test_nllloss_NCd1_weight_ii_cpu" + "|test_nllloss_NCd1_weight_ii_expanded_cpu" + "|test_nllloss_NCd1d2_cpu" + "|test_nllloss_NCd1d2_expanded_cpu" + "|test_nllloss_NCd1d2_no_weight_reduction_mean_ii_cpu" + "|test_nllloss_NCd1d2_no_weight_reduction_mean_ii_expanded_cpu" + "|test_nllloss_NCd1d2_reduction_mean_cpu" + "|test_nllloss_NCd1d2_reduction_mean_expanded_cpu" + "|test_nllloss_NCd1d2_reduction_sum_cpu" + "|test_nllloss_NCd1d2_reduction_sum_expanded_cpu" + "|test_nllloss_NCd1d2_with_weight_cpu" + "|test_nllloss_NCd1d2_with_weight_expanded_cpu" + "|test_nllloss_NCd1d2_with_weight_reduction_mean_cpu" + "|test_nllloss_NCd1d2_with_weight_reduction_mean_expanded_cpu" + "|test_nllloss_NCd1d2_with_weight_reduction_sum_cpu" + "|test_nllloss_NCd1d2_with_weight_reduction_sum_expanded_cpu" + "|test_nllloss_NCd1d2_with_weight_reduction_sum_ii_cpu" + "|test_nllloss_NCd1d2_with_weight_reduction_sum_ii_expanded_cpu" + "|test_nllloss_NCd1d2d3_none_no_weight_negative_ii_cpu" + "|test_nllloss_NCd1d2d3_none_no_weight_negative_ii_expanded_cpu" + "|test_nllloss_NCd1d2d3_sum_weight_high_ii_cpu" + "|test_nllloss_NCd1d2d3_sum_weight_high_ii_expanded_cpu" + "|test_nllloss_NCd1d2d3d4d5_mean_weight_cpu" + "|test_nllloss_NCd1d2d3d4d5_mean_weight_expanded_cpu" + "|test_nllloss_NCd1d2d3d4d5_none_no_weight_cpu" + "|test_nllloss_NCd1d2d3d4d5_none_no_weight_expanded_cpu" + "|test_rnn_seq_length_cpu" + "|test_roialign_aligned_false_cpu" + "|test_roialign_aligned_true_cpu" + "|test_roialign_mode_max_cpu" + "|test_round_cpu" + "|test_selu_cpu" + "|test_selu_default_cpu" + "|test_selu_example_cpu" + "|test_simple_rnn_defaults_cpu" + "|test_simple_rnn_with_initial_bias_cpu" + "|test_sin_cpu" + "|test_sin_example_cpu" + "|test_sinh_cpu" + "|test_sinh_example_cpu" + "|test_softplus_cpu" + "|test_softplus_example_cpu" + "|test_softsign_cpu" + "|test_softsign_example_cpu" + "|test_tan_cpu" + "|test_tan_example_cpu" + "|test_thresholdedrelu_cpu" + "|test_thresholdedrelu_default_cpu" + "|test_thresholdedrelu_example_cpu" + "|test_resize_downsample_scales_cubic_A_n0p5_exclude_outside_cpu" + "|test_resize_downsample_scales_cubic_antialias_cpu" + "|test_resize_downsample_scales_cubic_cpu" + "|test_resize_downsample_scales_linear_antialias_cpu" + "|test_resize_downsample_scales_linear_cpu" + "|test_resize_downsample_scales_linear_half_pixel_symmetric_cpu" + "|test_resize_downsample_scales_nearest_cpu" + "|test_resize_downsample_sizes_cubic_antialias_cpu" + "|test_resize_downsample_sizes_cubic_cpu" + "|test_resize_downsample_sizes_linear_antialias_cpu" + "|test_resize_downsample_sizes_linear_pytorch_half_pixel_cpu" + "|test_resize_downsample_sizes_nearest_cpu" + "|test_resize_downsample_sizes_nearest_not_larger_cpu" + "|test_resize_downsample_sizes_nearest_not_smaller_cpu" + "|test_resize_tf_crop_and_resize_axes_2_3_cpu" + "|test_resize_tf_crop_and_resize_axes_3_2_cpu" + "|test_resize_tf_crop_and_resize_cpu" + "|test_resize_upsample_scales_cubic_A_n0p5_exclude_outside_cpu" + "|test_resize_upsample_scales_cubic_align_corners_cpu" + "|test_resize_upsample_scales_cubic_asymmetric_cpu" + "|test_resize_upsample_scales_cubic_cpu" + "|test_resize_upsample_scales_linear_align_corners_cpu" + "|test_resize_upsample_scales_linear_cpu" + "|test_resize_upsample_scales_linear_half_pixel_symmetric_cpu" + "|test_resize_upsample_scales_nearest_axes_2_3_cpu" + "|test_resize_upsample_scales_nearest_axes_3_2_cpu" + "|test_resize_upsample_scales_nearest_cpu" + "|test_resize_upsample_sizes_cubic_cpu" + "|test_resize_upsample_sizes_nearest_axes_2_3_cpu" + "|test_resize_upsample_sizes_nearest_axes_3_2_cpu" + "|test_resize_upsample_sizes_nearest_ceil_half_pixel_cpu" + "|test_resize_upsample_sizes_nearest_cpu" + "|test_resize_upsample_sizes_nearest_floor_align_corners_cpu" + "|test_resize_upsample_sizes_nearest_not_larger_cpu" + "|test_resize_upsample_sizes_nearest_round_prefer_ceil_asymmetric_cpu" + "|test_qlinearmatmul_2D_uint8_float32_cuda" + "|test_qlinearmatmul_2D_int8_float32_cpu" + "|test_image_decoder_decode_jpeg_rgb_cpu" + "|test_basic_deform_conv_without_padding_cuda" + "|test_qlinearmatmul_3D_int8_float16_cuda" + "|test_image_decoder_decode_bmp_rgb_cuda" + "|test_qlinearmatmul_2D_uint8_float16_cpu" + "|test_image_decoder_decode_jpeg2k_rgb_cuda" + "|test_image_decoder_decode_jpeg_bgr_cuda" + "|test_qlinearmatmul_3D_uint8_float32_cpu" + "|test_qlinearmatmul_3D_uint8_float16_cuda" + "|test_deform_conv_with_mask_bias_cpu" + "|test_qlinearmatmul_2D_int8_float16_cuda" + "|test_image_decoder_decode_jpeg_grayscale_cpu" + "|test_basic_deform_conv_without_padding_cpu" + "|test_qlinearmatmul_3D_int8_float32_cuda" + "|test_qlinearmatmul_3D_int8_float16_cpu" + "|test_qlinearmatmul_2D_int8_float32_cuda" + "|test_deform_conv_with_mask_bias_cuda" + "|test_image_decoder_decode_tiff_rgb_cuda" + "|test_image_decoder_decode_jpeg2k_rgb_cpu" + "|test_image_decoder_decode_jpeg_rgb_cuda" + "|test_image_decoder_decode_jpeg_grayscale_cuda" + "|test_qlinearmatmul_3D_uint8_float32_cuda" + "|test_image_decoder_decode_png_rgb_cpu" + "|test_image_decoder_decode_png_rgb_cuda" + "|test_image_decoder_decode_bmp_rgb_cpu" + "|test_qlinearmatmul_3D_uint8_float16_cpu" + "|test_deform_conv_with_multiple_offset_groups_cuda" + "|test_image_decoder_decode_webp_rgb_cpu" + "|test_basic_deform_conv_with_padding_cpu" + "|test_qlinearmatmul_2D_uint8_float16_cuda" + "|test_image_decoder_decode_webp_rgb_cuda" + "|test_basic_deform_conv_with_padding_cuda" + "|test_image_decoder_decode_pnm_rgb_cpu" + "|test_qlinearmatmul_3D_int8_float32_cpu" + "|test_image_decoder_decode_jpeg_bgr_cpu" + "|test_qlinearmatmul_2D_int8_float16_cpu" + "|test_image_decoder_decode_pnm_rgb_cuda" + "|test_deform_conv_with_multiple_offset_groups_cpu" + "|test_qlinearmatmul_2D_uint8_float32_cpu" + "|test_image_decoder_decode_tiff_rgb_cpu" + "|test_globalmaxpool_cpu" + "|test_globalmaxpool_precomputed_cpu" + "|test_instancenorm_example_cpu" + "|test_instancenorm_epsilon_cpu" ")" ) diff --git a/onnx/version_converter/convert.h b/onnx/version_converter/convert.h index 189f63d64ac..2d4410d565e 100644 --- a/onnx/version_converter/convert.h +++ b/onnx/version_converter/convert.h @@ -671,6 +671,113 @@ class DefaultVersionConverter : public BaseVersionConverter { registerAdapter(std::make_unique("Squeeze", OpSetID(21), OpSetID(20), ir10_types_not_in_ir4)); registerAdapter(std::make_unique("Transpose", OpSetID(21), OpSetID(20), ir10_types_not_in_ir9)); registerAdapter(std::make_unique("Unsqueeze", OpSetID(21), OpSetID(20), ir10_types_not_in_ir4)); + + /******** 21 -> 22 ********/ + registerAdapter(std::make_unique("EyeLike", OpSetID(21), OpSetID(22))); + registerAdapter(std::make_unique("RandomUniform", OpSetID(21), OpSetID(22))); + registerAdapter(std::make_unique("RandomNormal", OpSetID(21), OpSetID(22))); + registerAdapter(std::make_unique("RandomUniformLike", OpSetID(21), OpSetID(22))); + registerAdapter(std::make_unique("RandomNormalLike", OpSetID(21), OpSetID(22))); + registerAdapter(std::make_unique("Multinomial", OpSetID(21), OpSetID(22))); + registerAdapter(std::make_unique("Bernoulli", OpSetID(21), OpSetID(22))); + registerAdapter(std::make_unique("ThresholdedRelu", OpSetID(21), OpSetID(22))); + registerAdapter(std::make_unique("Selu", OpSetID(21), OpSetID(22))); + registerAdapter(std::make_unique("Elu", OpSetID(21), OpSetID(22))); + registerAdapter(std::make_unique("Mish", OpSetID(21), OpSetID(22))); + registerAdapter(std::make_unique("HardSigmoid", OpSetID(21), OpSetID(22))); + registerAdapter(std::make_unique("HardSwish", OpSetID(21), OpSetID(22))); + registerAdapter(std::make_unique("Softsign", OpSetID(21), OpSetID(22))); + registerAdapter(std::make_unique("Softplus", OpSetID(21), OpSetID(22))); + registerAdapter(std::make_unique("Sin", OpSetID(21), OpSetID(22))); + registerAdapter(std::make_unique("Cos", OpSetID(21), OpSetID(22))); + registerAdapter(std::make_unique("Tan", OpSetID(21), OpSetID(22))); + registerAdapter(std::make_unique("Asin", OpSetID(21), OpSetID(22))); + registerAdapter(std::make_unique("Acos", OpSetID(21), OpSetID(22))); + registerAdapter(std::make_unique("Atan", OpSetID(21), OpSetID(22))); + registerAdapter(std::make_unique("Sinh", OpSetID(21), OpSetID(22))); + registerAdapter(std::make_unique("Cosh", OpSetID(21), OpSetID(22))); + registerAdapter(std::make_unique("Asinh", OpSetID(21), OpSetID(22))); + registerAdapter(std::make_unique("Acosh", OpSetID(21), OpSetID(22))); + registerAdapter(std::make_unique("Atanh", OpSetID(21), OpSetID(22))); + registerAdapter(std::make_unique("Round", OpSetID(21), OpSetID(22))); + registerAdapter(std::make_unique("Det", OpSetID(21), OpSetID(22))); + registerAdapter(std::make_unique("NegativeLogLikelihoodLoss", OpSetID(21), OpSetID(22))); + registerAdapter(std::make_unique("AveragePool", OpSetID(21), OpSetID(22))); + registerAdapter(std::make_unique("MaxPool", OpSetID(21), OpSetID(22))); + registerAdapter(std::make_unique("MaxUnpool", OpSetID(21), OpSetID(22))); + registerAdapter(std::make_unique("LpPool", OpSetID(21), OpSetID(22))); + registerAdapter(std::make_unique("MaxRoiPool", OpSetID(21), OpSetID(22))); + registerAdapter(std::make_unique("Conv", OpSetID(21), OpSetID(22))); + registerAdapter(std::make_unique("ConvTranspose", OpSetID(21), OpSetID(22))); + registerAdapter(std::make_unique("DeformConv", OpSetID(21), OpSetID(22))); + registerAdapter(std::make_unique("GlobalAveragePool", OpSetID(21), OpSetID(22))); + registerAdapter(std::make_unique("GlobalMaxPool", OpSetID(21), OpSetID(22))); + registerAdapter(std::make_unique("GlobalLpPool", OpSetID(21), OpSetID(22))); + registerAdapter(std::make_unique("InstanceNormalization", OpSetID(21), OpSetID(22))); + registerAdapter(std::make_unique("LpNormalization", OpSetID(21), OpSetID(22))); + registerAdapter(std::make_unique("Dropout", OpSetID(21), OpSetID(22))); + registerAdapter(std::make_unique("RoiAlign", OpSetID(21), OpSetID(22))); + registerAdapter(std::make_unique("RNN", OpSetID(21), OpSetID(22))); + registerAdapter(std::make_unique("GRU", OpSetID(21), OpSetID(22))); + registerAdapter(std::make_unique("LSTM", OpSetID(21), OpSetID(22))); + registerAdapter(std::make_unique("GridSample", OpSetID(21), OpSetID(22))); + + /******** 22 -> 21 ********/ + const std::vector bfloat16_not_allowed = {TensorProto_DataType_BFLOAT16}; + registerAdapter(std::make_unique("EyeLike", OpSetID(22), OpSetID(21), bfloat16_not_allowed)); + registerAdapter(std::make_unique("AveragePool", OpSetID(22), OpSetID(21), bfloat16_not_allowed)); + registerAdapter(std::make_unique("MaxPool", OpSetID(22), OpSetID(21), bfloat16_not_allowed)); + registerAdapter(std::make_unique("RandomUniform", OpSetID(22), OpSetID(21), bfloat16_not_allowed)); + registerAdapter(std::make_unique("RandomNormal", OpSetID(22), OpSetID(21), bfloat16_not_allowed)); + registerAdapter( + std::make_unique("RandomNormalLike", OpSetID(22), OpSetID(21), bfloat16_not_allowed)); + registerAdapter( + std::make_unique("RandomUniformLike", OpSetID(22), OpSetID(21), bfloat16_not_allowed)); + registerAdapter(std::make_unique("Multinomial", OpSetID(22), OpSetID(21), bfloat16_not_allowed)); + registerAdapter(std::make_unique("Bernoulli", OpSetID(22), OpSetID(21), bfloat16_not_allowed)); + registerAdapter( + std::make_unique("ThresholdedRelu", OpSetID(22), OpSetID(21), bfloat16_not_allowed)); + registerAdapter(std::make_unique("Selu", OpSetID(22), OpSetID(21), bfloat16_not_allowed)); + registerAdapter(std::make_unique("Elu", OpSetID(22), OpSetID(21), bfloat16_not_allowed)); + registerAdapter(std::make_unique("Mish", OpSetID(22), OpSetID(21), bfloat16_not_allowed)); + registerAdapter(std::make_unique("HardSigmoid", OpSetID(22), OpSetID(21), bfloat16_not_allowed)); + registerAdapter(std::make_unique("HardSwish", OpSetID(22), OpSetID(21), bfloat16_not_allowed)); + registerAdapter(std::make_unique("Softsign", OpSetID(22), OpSetID(21), bfloat16_not_allowed)); + registerAdapter(std::make_unique("Softplus", OpSetID(22), OpSetID(21), bfloat16_not_allowed)); + registerAdapter(std::make_unique("Sin", OpSetID(22), OpSetID(21), bfloat16_not_allowed)); + registerAdapter(std::make_unique("Cos", OpSetID(22), OpSetID(21), bfloat16_not_allowed)); + registerAdapter(std::make_unique("Tan", OpSetID(22), OpSetID(21), bfloat16_not_allowed)); + registerAdapter(std::make_unique("Asin", OpSetID(22), OpSetID(21), bfloat16_not_allowed)); + registerAdapter(std::make_unique("Acos", OpSetID(22), OpSetID(21), bfloat16_not_allowed)); + registerAdapter(std::make_unique("Atan", OpSetID(22), OpSetID(21), bfloat16_not_allowed)); + registerAdapter(std::make_unique("Sinh", OpSetID(22), OpSetID(21), bfloat16_not_allowed)); + registerAdapter(std::make_unique("Cosh", OpSetID(22), OpSetID(21), bfloat16_not_allowed)); + registerAdapter(std::make_unique("Asinh", OpSetID(22), OpSetID(21), bfloat16_not_allowed)); + registerAdapter(std::make_unique("Acosh", OpSetID(22), OpSetID(21), bfloat16_not_allowed)); + registerAdapter(std::make_unique("Atanh", OpSetID(22), OpSetID(21), bfloat16_not_allowed)); + registerAdapter(std::make_unique("Round", OpSetID(22), OpSetID(21), bfloat16_not_allowed)); + registerAdapter(std::make_unique("Det", OpSetID(22), OpSetID(21), bfloat16_not_allowed)); + registerAdapter( + std::make_unique("NegativeLogLikelihoodLoss", OpSetID(22), OpSetID(21), bfloat16_not_allowed)); + registerAdapter(std::make_unique("MaxUnpool", OpSetID(22), OpSetID(21), bfloat16_not_allowed)); + registerAdapter(std::make_unique("LpPool", OpSetID(22), OpSetID(21), bfloat16_not_allowed)); + registerAdapter(std::make_unique("MaxRoiPool", OpSetID(22), OpSetID(21), bfloat16_not_allowed)); + registerAdapter(std::make_unique("Conv", OpSetID(22), OpSetID(21), bfloat16_not_allowed)); + registerAdapter(std::make_unique("ConvTranspose", OpSetID(22), OpSetID(21), bfloat16_not_allowed)); + registerAdapter(std::make_unique("DeformConv", OpSetID(22), OpSetID(21), bfloat16_not_allowed)); + registerAdapter( + std::make_unique("GlobalAveragePool", OpSetID(22), OpSetID(21), bfloat16_not_allowed)); + registerAdapter(std::make_unique("GlobalLpPool", OpSetID(22), OpSetID(21), bfloat16_not_allowed)); + registerAdapter( + std::make_unique("InstanceNormalization", OpSetID(22), OpSetID(21), bfloat16_not_allowed)); + registerAdapter( + std::make_unique("LpNormalization", OpSetID(22), OpSetID(21), bfloat16_not_allowed)); + registerAdapter(std::make_unique("Dropout", OpSetID(22), OpSetID(21), bfloat16_not_allowed)); + registerAdapter(std::make_unique("RoiAlign", OpSetID(22), OpSetID(21), bfloat16_not_allowed)); + registerAdapter(std::make_unique("RNN", OpSetID(22), OpSetID(21), bfloat16_not_allowed)); + registerAdapter(std::make_unique("GRU", OpSetID(22), OpSetID(21), bfloat16_not_allowed)); + registerAdapter(std::make_unique("LSTM", OpSetID(22), OpSetID(21), bfloat16_not_allowed)); + registerAdapter(std::make_unique("GridSample", OpSetID(22), OpSetID(21), bfloat16_not_allowed)); } ModelProto convert_version(const ModelProto& mp_in, const OpSetID& initial_version, const OpSetID& target_version)