Skip to content

Commit b51a827

Browse files
authored
Merge 5590b2b into 1a067ba
2 parents 1a067ba + 5590b2b commit b51a827

7 files changed

Lines changed: 9 additions & 170 deletions

File tree

onnx/cpp2py_export.cc

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,7 @@ PYBIND11_MODULE(onnx_cpp2py_export, onnx_cpp2py_export) {
4040
"type_constraints", &OpSchema::typeConstraintParams)
4141
.def_static(
4242
"is_infinite",
43-
[](int v) { return v == std::numeric_limits<int>::max(); })
44-
.def("consumed", [](const OpSchema& schema, int i) {
45-
return schema.consumed(i);
46-
});
43+
[](int v) { return v == std::numeric_limits<int>::max(); });
4744

4845
py::class_<OpSchema::Attribute>(op_schema, "Attribute")
4946
.def_readonly("name", &OpSchema::Attribute::name)
@@ -89,11 +86,6 @@ PYBIND11_MODULE(onnx_cpp2py_export, onnx_cpp2py_export) {
8986
.value("COMMON", OpSchema::SupportType::COMMON)
9087
.value("EXPERIMENTAL", OpSchema::SupportType::EXPERIMENTAL);
9188

92-
py::enum_<OpSchema::UseType>(op_schema, "UseType")
93-
.value("DEFAULT", OpSchema::UseType::DEFAULT)
94-
.value("CONSUME_ALLOWED", OpSchema::UseType::CONSUME_ALLOWED)
95-
.value("CONSUME_ENFORCED", OpSchema::UseType::CONSUME_ENFORCED);
96-
9789
defs.def("has_schema", [](const std::string& op_type) -> bool {
9890
return OpSchemaRegistry::Schema(op_type) != nullptr;
9991
});

onnx/defs/experiments/defs.cc

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ is applied to the tensor elementwise.
3535

3636
ONNX_OPERATOR_SCHEMA(ThresholdedRelu)
3737
.SetSupportLevel(SupportType::EXPERIMENTAL)
38-
.AllowConsumed({{0, 0}})
3938
.SetDoc(R"DOC(
4039
ThresholdedRelu takes one input data (Tensor<T>) and produces one output data
4140
(Tensor<T>) where the rectified linear function, y = x for x > alpha, y = 0 otherwise,
@@ -52,7 +51,6 @@ is applied to the tensor elementwise.
5251

5352
ONNX_OPERATOR_SCHEMA(ScaledTanh)
5453
.SetSupportLevel(SupportType::EXPERIMENTAL)
55-
.AllowConsumed({{0, 0}})
5654
.SetDoc(R"DOC(
5755
Calculates the scaled hyperbolic tangent of the given input tensor element-wise,
5856
alpha * tanh(beta * x). This operation can be done in an in-place fashion too,
@@ -68,7 +66,6 @@ by providing the same input and output blobs.
6866

6967
ONNX_OPERATOR_SCHEMA(ParametricSoftplus)
7068
.SetSupportLevel(SupportType::EXPERIMENTAL)
71-
.AllowConsumed({{0, 0}})
7269
.SetDoc(R"DOC(
7370
ParametricSoftplus takes one input data (Tensor<T>) and produces one output data
7471
(Tensor<T>) where the softplus function, y = alpha * ln(exp(beta * x) + 1), is applied to
@@ -83,7 +80,6 @@ the tensor elementwise.
8380

8481
ONNX_OPERATOR_SCHEMA(ConstantFill)
8582
.SetSupportLevel(SupportType::EXPERIMENTAL)
86-
.AllowConsumed({{0, 0}})
8783
.SetDoc(R"DOC(
8884
The operator fills the elements of the output tensor with a constant value
8985
specified by the 'value' attribute.
@@ -156,18 +152,17 @@ NOTE: Currently, it supports data type of float, int32, int64, and bool.
156152
"Constrain output types to float, int32, int64, bool tensors.");
157153

158154
ONNX_OPERATOR_SCHEMA(GivenTensorFill)
159-
.SetSupportLevel(SupportType::EXPERIMENTAL)
160-
.Input(0, "shape", "The shape of filled tensor", "T", OpSchema::Optional)
161-
.Output(0, "X", "The filled tensor", "T")
162-
.TypeConstraint(
163-
"T",
164-
{"tensor(float16)", "tensor(float)", "tensor(double)"},
165-
"Constrain input and output types to float tensors.")
155+
.SetSupportLevel(SupportType::EXPERIMENTAL)
156+
.Input(0, "shape", "The shape of filled tensor", "T", OpSchema::Optional)
157+
.Output(0, "X", "The filled tensor", "T")
158+
.TypeConstraint(
159+
"T",
160+
{ "tensor(float16)", "tensor(float)", "tensor(double)" },
161+
"Constrain input and output types to float tensors.")
166162
.Attr("values", "", AttributeProto::FLOATS, OPTIONAL)
167163
.Attr("shape", "", AttributeProto::INTS, OPTIONAL)
168164
.Attr("input_as_shape", "", AttributeProto::INT, OPTIONAL)
169-
.Attr("extra_shape", "", AttributeProto::INTS, OPTIONAL)
170-
.AllowConsumed({{0, 0}});
165+
.Attr("extra_shape", "", AttributeProto::INTS, OPTIONAL);
171166

172167
ONNX_OPERATOR_SCHEMA(FC)
173168
.SetSupportLevel(SupportType::EXPERIMENTAL)
@@ -231,7 +226,6 @@ ONNX_OPERATOR_SCHEMA(Scale)
231226
"T",
232227
{"tensor(float16)", "tensor(float)", "tensor(double)"},
233228
"Constrain input and output types to float tensors.")
234-
.AllowConsumed({{0, 0}})
235229
.SetDoc(R"DOC(
236230
Scale takes one input data (Tensor<float>) and produces one output data
237231
(Tensor<float>) whose value is the input data tensor scaled element-wise.
@@ -290,7 +284,6 @@ and op)DOC")
290284

291285
ONNX_OPERATOR_SCHEMA(ImageScaler)
292286
.SetSupportLevel(SupportType::EXPERIMENTAL)
293-
.AllowConsumed({{0, 0}})
294287
.SetDoc(R"DOC(Scale and bias the input image. Bias values are stored in
295288
the same ordering as the image pixel format.)DOC")
296289
.Attr("bias", "Bias applied to each channel, same size as C.", AttributeProto::FLOATS, OPTIONAL)
@@ -304,7 +297,6 @@ the same ordering as the image pixel format.)DOC")
304297

305298
ONNX_OPERATOR_SCHEMA(MeanVarianceNormalization)
306299
.SetSupportLevel(SupportType::EXPERIMENTAL)
307-
.AllowConsumed({{0, 0}})
308300
.SetDoc(R"DOC(Perform mean variance normalization.)DOC")
309301
.Attr("across_channels", "If 1, mean and variance are computed across channels. Default is 0.", AttributeProto::INT, static_cast<int64_t>(0))
310302
.Attr("normalize_variance", "If 0, normalize the mean only. Default is 1.", AttributeProto::INT, static_cast<int64_t>(1))
@@ -317,7 +309,6 @@ ONNX_OPERATOR_SCHEMA(MeanVarianceNormalization)
317309

318310
ONNX_OPERATOR_SCHEMA(Crop)
319311
.SetSupportLevel(SupportType::EXPERIMENTAL)
320-
.AllowConsumed({{0, 0}})
321312
.SetDoc(R"DOC(Crop and image to the specified spatial dimensions. If scale is given,
322313
then optionally start the crop offset by the left/top border amounts.
323314
If scale is not provided, crop the borders as provided.)DOC")

onnx/defs/math/defs.cc

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -97,24 +97,19 @@ will throw errors.
9797
}
9898

9999
ONNX_OPERATOR_SCHEMA(Add)
100-
.AllowConsumed({{0, 0}, {1, 0}})
101100
.FillUsing(MathDocGenerator("addition"));
102101

103102
ONNX_OPERATOR_SCHEMA(Sub)
104-
.AllowConsumed({{0, 0}, {1, 0}})
105103
.FillUsing(MathDocGenerator("subtraction"));
106104

107105
ONNX_OPERATOR_SCHEMA(Mul)
108-
.AllowConsumed({{0, 0}, {1, 0}})
109106
.FillUsing(MathDocGenerator("multiplication"));
110107

111108
ONNX_OPERATOR_SCHEMA(Div)
112-
.AllowConsumed({{0, 0}, {1, 0}})
113109
.FillUsing(MathDocGenerator("division"));
114110
} // namespace ONNX_NAMESPACE
115111

116112
ONNX_OPERATOR_SCHEMA(Neg)
117-
.AllowConsumed({{0, 0}})
118113
.SetDoc(R"DOC(
119114
Neg takes one input data (Tensor<T>) and produces one output data
120115
(Tensor<T>) where each element flipped sign, y = -x, is applied to
@@ -126,7 +121,6 @@ the tensor elementwise.
126121
"Constrain input and output types to float tensors.");
127122

128123
ONNX_OPERATOR_SCHEMA(Abs)
129-
.AllowConsumed({{0, 0}})
130124
.SetDoc(R"DOC(
131125
Absolute takes one input data (Tensor<T>) and produces one output data
132126
(Tensor<T>) where the absolute is, y = abs(x), is applied to
@@ -138,7 +132,6 @@ the tensor elementwise.
138132
"Constrain input and output types to float tensors.");
139133

140134
ONNX_OPERATOR_SCHEMA(Reciprocal)
141-
.AllowConsumed({{0, 0}})
142135
.SetDoc(R"DOC(
143136
Reciprocal takes one input data (Tensor<T>) and produces one output data
144137
(Tensor<T>) where the reciprocal is, y = 1/x, is applied to
@@ -150,7 +143,6 @@ the tensor elementwise.
150143
"Constrain input and output types to float tensors.");
151144

152145
ONNX_OPERATOR_SCHEMA(Floor)
153-
.AllowConsumed({{0, 0}})
154146
.SetDoc(R"DOC(
155147
Floor takes one input data (Tensor<T>) and produces one output data
156148
(Tensor<T>) where the floor is, y = floor(x), is applied to
@@ -162,7 +154,6 @@ the tensor elementwise.
162154
"Constrain input and output types to float tensors.");
163155

164156
ONNX_OPERATOR_SCHEMA(Ceil)
165-
.AllowConsumed({{0, 0}})
166157
.SetDoc(R"DOC(
167158
Ceil takes one input data (Tensor<T>) and produces one output data
168159
(Tensor<T>) where the ceil is, y = ceil(x), is applied to
@@ -174,7 +165,6 @@ the tensor elementwise.
174165
"Constrain input and output types to float tensors.");
175166

176167
ONNX_OPERATOR_SCHEMA(Sqrt)
177-
.AllowConsumed({{0, 0}})
178168
.SetDoc(R"DOC(
179169
Square root takes one input data (Tensor<T>) and produces one output data
180170
(Tensor<T>) where the square root is, y = x^0.5, is applied to
@@ -186,7 +176,6 @@ the tensor elementwise. If x is negative, then it will return NaN.
186176
"Constrain input and output types to float tensors.");
187177

188178
ONNX_OPERATOR_SCHEMA(Relu)
189-
.AllowConsumed({{0, 0}})
190179
.SetDoc(R"DOC(
191180
Relu takes one input data (Tensor<T>) and produces one output data
192181
(Tensor<T>) where the rectified linear function, y = max(0, x), is applied to
@@ -202,7 +191,6 @@ ONNX_OPERATOR_SCHEMA(LeakyRelu)
202191
"Coefficient of leakage default to 0.01.",
203192
AttributeProto::FLOAT,
204193
0.01f)
205-
.AllowConsumed({{0, 0}})
206194
.SetDoc(R"DOC(
207195
LeakyRelu takes input data (Tensor<T>) and an argument alpha, and produces one
208196
output data (Tensor<T>) where the function `f(x) = alpha * x for x < 0`,
@@ -214,7 +202,6 @@ output data (Tensor<T>) where the function `f(x) = alpha * x for x < 0`,
214202
"Constrain input and output types to float tensors.");
215203

216204
ONNX_OPERATOR_SCHEMA(Selu)
217-
.AllowConsumed({{0, 0}})
218205
.Attr("alpha",
219206
"Coefficient of SELU default to 1.6732.",
220207
AttributeProto::FLOAT,
@@ -235,7 +222,6 @@ is applied to the tensor elementwise.
235222
"Constrain input and output types to float tensors.");
236223

237224
ONNX_OPERATOR_SCHEMA(Elu)
238-
.AllowConsumed({{0, 0}})
239225
.Attr("alpha",
240226
"Coefficient of ELU default to 1.0.",
241227
AttributeProto::FLOAT,
@@ -252,7 +238,6 @@ Elu takes one input data (Tensor<T>) and produces one output data
252238
"Constrain input and output types to float tensors.");
253239

254240
ONNX_OPERATOR_SCHEMA(Exp)
255-
.AllowConsumed({{0, 0}})
256241
.SetDoc(R"DOC(
257242
Calculates the exponential of the given input tensor, element-wise.
258243
)DOC")
@@ -266,7 +251,6 @@ Calculates the exponential of the given input tensor, element-wise.
266251
"Constrain input and output types to float tensors.");
267252

268253
ONNX_OPERATOR_SCHEMA(Log)
269-
.AllowConsumed({{0, 0}})
270254
.SetDoc(R"DOC(
271255
Calculates the natural log of the given input tensor, element-wise.
272256
)DOC")
@@ -280,7 +264,6 @@ Calculates the natural log of the given input tensor, element-wise.
280264
"Constrain input and output types to float tensors.");
281265

282266
ONNX_OPERATOR_SCHEMA(Tanh)
283-
.AllowConsumed({{0, 0}})
284267
.SetDoc(R"DOC(
285268
Calculates the hyperbolic tangent of the given input tensor element-wise.
286269
)DOC")
@@ -312,7 +295,6 @@ is applied to the data tensor elementwise.
312295
"Constrain input and output types to float tensors.");
313296

314297
ONNX_OPERATOR_SCHEMA(PRelu)
315-
.AllowConsumed({{0, 0}})
316298
.SetDoc(R"DOC(
317299
318300
PRelu takes input data (Tensor<T>) and slope tensor as input, and produces one
@@ -331,7 +313,6 @@ output data (Tensor<T>) where the function `f(x) = slope * x for x < 0`,
331313
"Constrain input and output types to float tensors.");
332314

333315
ONNX_OPERATOR_SCHEMA(Sigmoid)
334-
.AllowConsumed({{0, 0}})
335316
.SetDoc(R"DOC(
336317
Sigmoid takes one input data (Tensor<T>) and produces one output data
337318
(Tensor<T>) where the sigmoid function, y = 1 / (1 + exp(-x)), is applied to the
@@ -343,7 +324,6 @@ tensor elementwise.
343324
"Constrain input and output types to float tensors.");
344325

345326
ONNX_OPERATOR_SCHEMA(HardSigmoid)
346-
.AllowConsumed({{0, 0}})
347327
.Attr("alpha",
348328
"Value of alpha default to 0.2",
349329
AttributeProto::FLOAT,
@@ -363,7 +343,6 @@ is applied to the tensor elementwise.
363343
"Constrain input and output types to float tensors.");
364344

365345
ONNX_OPERATOR_SCHEMA(Max)
366-
.AllowConsumed({{0, 0}})
367346
.SetDoc(R"DOC(
368347
Element-wise max of each of the input tensors. All inputs and outputs must
369348
have the same shape and data type.
@@ -374,7 +353,6 @@ have the same shape and data type.
374353
"Constrain input and output types to float tensors.");
375354

376355
ONNX_OPERATOR_SCHEMA(Min)
377-
.AllowConsumed({{0, 0}})
378356
.SetDoc(R"DOC(
379357
Element-wise min of each of the input tensors. All inputs and outputs must
380358
have the same shape and data type.
@@ -385,7 +363,6 @@ have the same shape and data type.
385363
"Constrain input and output types to float tensors.");
386364

387365
ONNX_OPERATOR_SCHEMA(Sum)
388-
.AllowConsumed({{0, 0}})
389366
.SetDoc(R"DOC(
390367
Element-wise sum of each of the input tensors. All inputs and outputs must
391368
have the same shape and data type.
@@ -396,7 +373,6 @@ have the same shape and data type.
396373
"Constrain input and output types to float tensors.");
397374

398375
ONNX_OPERATOR_SCHEMA(Mean)
399-
.AllowConsumed({{0, 0}})
400376
.SetDoc(R"DOC(
401377
Element-wise mean of each of the input tensors. All inputs and outputs must
402378
have the same shape and data type.
@@ -407,7 +383,6 @@ have the same shape and data type.
407383
"Constrain input and output types to float tensors.");
408384

409385
ONNX_OPERATOR_SCHEMA(Clip)
410-
.AllowConsumed({{0, 0}})
411386
.SetDoc(R"DOC(
412387
Clip operator limits the given input within an interval. The interval is
413388
specified with arguments 'min' and 'max'. They default to
@@ -470,7 +445,6 @@ if attribute transA is non-zero, same for B and transB.
470445
.Input(0, "A", "Input tensor A", "T")
471446
.Input(1, "B", "Input tensor B", "T")
472447
.Input(2, "C", "Input tensor C, can be inplace.", "T")
473-
.AllowConsumed({{2, 0}})
474448
.Output(0, "Y", "Output tensor.", "T")
475449
.TypeConstraint("T", { "tensor(float16)", "tensor(float)", "tensor(double)" },
476450
"Constrain input and output types to float tensors.")

onnx/defs/nn/defs.cc

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,6 @@ namespace ONNX_NAMESPACE {
391391

392392
ONNX_OPERATOR_SCHEMA(BatchNormalization)
393393
.NumOutputs({ 1, 5 })
394-
.EnforceConsumed({ {3, 1}, {4, 2} })
395394
.SetDoc(R"DOC(
396395
Carries out batch normalization as described in the paper
397396
https://arxiv.org/abs/1502.03167. Depending on the mode it is being run,
@@ -459,7 +458,6 @@ Output case #2: Y (test mode)
459458
"Constrain input and output types to float tensors.");
460459

461460
ONNX_OPERATOR_SCHEMA(InstanceNormalization)
462-
.AllowConsumed({{0, 0}})
463461
.SetDoc(R"DOC(
464462
Carries out instance normalization as described in the paper
465463
https://arxiv.org/abs/1607.08022.
@@ -501,7 +499,6 @@ Given a matrix, apply Lp-normalization along the provided axis.
501499
.Attr("p", "(int64, default 2) the order of the normalization, only 1 or 2 are supported.", AttributeProto::INT, static_cast<int64_t>(2));
502500

503501
ONNX_OPERATOR_SCHEMA(Dropout)
504-
.AllowConsumed({{0, 0}})
505502
.SetDoc(R"DOC(
506503
Dropout takes one input data (Tensor<float>) and produces two Tensor outputs,
507504
output (Tensor<float>) and mask (Tensor<bool>). Depending on whether it is in

0 commit comments

Comments
 (0)