adjust the quantization ops' definitions (#278)

This commit is contained in:
Ke Zhang 2019-01-04 16:05:29 -08:00 committed by GitHub
parent 8a7b6761de
commit 251d4bbb23
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -18,8 +18,8 @@ void convPoolTypeAndShapeInference(ONNX_NAMESPACE::InferenceContext& ctx, bool u
namespace onnxruntime {
namespace contrib {
using ::ONNX_NAMESPACE::AttributeProto;
using ::ONNX_NAMESPACE::OpSchema;
using ::ONNX_NAMESPACE::OPTIONAL;
using ::ONNX_NAMESPACE::OpSchema;
void RegisterContribSchemas() {
ONNX_CONTRIB_OPERATOR_SCHEMA(SampleOp)
@ -465,12 +465,12 @@ if the input is 8 bits or in 64 bits if the input is 16 bits.)DOC")
"X.shape[1] == (W.shape[1] * group) == C "
"(assuming zero based indices for the shape array). "
"Or in other words FILTER_IN_CHANNEL should be equal to DATA_CHANNEL. ",
"T1")
"T2")
.Input(4, "w_scale", "Scale tensor for input 'w'. It could be a scalar or a 1-D tensor, which means a per-tensor or per-channel quantization. If it's a 1-D tensor, its number of elements should be equal to the number of channels of input 'w'.", "tensor(float)")
.Input(5, "w_zero_point", "Scale tensor for input 'w'. It could be a scalar or a 1-D tensor, which means a per-tensor or per-channel quantization. If it's a 1-D tensor, its number of elements should be equal to the number of channels of input 'w'.", "T1")
.Input(5, "w_zero_point", "Scale tensor for input 'w'. It could be a scalar or a 1-D tensor, which means a per-tensor or per-channel quantization. If it's a 1-D tensor, its number of elements should be equal to the number of channels of input 'w'.", "T2")
.Input(6, "y_scale", "Scale tensor for output 'y'. It could be a scalar or a 1-D tensor, which means a per-tensor or per-channel quantization. If it's a 1-D tensor, its number of elements should be equal to the number of channels of input 'y'.", "tensor(float)")
.Input(7, "y_zero_point", "Scale tensor for output 'y'. It could be a scalar or a 1-D tensor, which means a per-tensor or per-channel quantization. If it's a 1-D tensor, its number of elements should be equal to the number of channels of input 'y'.", "T1")
.Input(8, "B", "Optional 1D bias to be added to the convolution, has size of M.", "T2", OpSchema::Optional)
.Input(7, "y_zero_point", "Scale tensor for output 'y'. It could be a scalar or a 1-D tensor, which means a per-tensor or per-channel quantization. If it's a 1-D tensor, its number of elements should be equal to the number of channels of input 'y'.", "T3")
.Input(8, "B", "Optional 1D bias to be added to the convolution, has size of M.", "T4", OpSchema::Optional)
.Output(
0,
"y",
@ -481,8 +481,16 @@ if the input is 8 bits or in 64 bits if the input is 16 bits.)DOC")
.TypeConstraint(
"T1",
{"tensor(int8)", "tensor(uint8)", "tensor(int16)", "tensor(uint16)"},
"Constrain input, filter, and output types to 8-bit or 16-bit integer tensors.")
.TypeConstraint("T2", {"tensor(int32)", "tensor(uint32)"}, "Constrain bias type to 32-bit integer tensor.")
"Constrain input types to 8-bit or 16-bit integer tensors.")
.TypeConstraint(
"T2",
{"tensor(int8)", "tensor(uint8)", "tensor(int16)", "tensor(uint16)"},
"Constrain filter types to 8-bit or 16-bit integer tensors.")
.TypeConstraint(
"T3",
{"tensor(int8)", "tensor(uint8)", "tensor(int16)", "tensor(uint16)"},
"Constrain output types to 8-bit or 16-bit integer tensors.")
.TypeConstraint("T4", {"tensor(int32)", "tensor(uint32)"}, "Constrain bias type to 32-bit integer tensor.")
.Attr(
"auto_pad",
auto_pad_doc,
@ -552,7 +560,16 @@ The integer convolution operator consumes an input tensor, a filter, and a paddi
"(assuming zero based indices for the shape array). "
"Or in other words FILTER_IN_CHANNEL should be equal to DATA_CHANNEL. ",
"T2")
.Input(2, "z", "Padding value (zero_point normally), it's optional and default value is 0.", "T1", OpSchema::Optional)
.Input(2, "x_zero_point",
"Zero point tensor for input 'x'. It's optional and default value is 0. It could be a scalar or a 1-D tensor, "
"which means a per-tensor or per-channel quantization. If it's a 1-D tensor, its number of elements "
"should be equal to the number of channels of input 'x'.",
"T1", OpSchema::Optional)
.Input(3, "w_zero_point",
"Scale tensor for input 'w'. It's optional and default value is 0. It could be a scalar or a 1-D tensor, "
"which means a per-tensor or per-channel quantization. If it's a 1-D tensor, its number "
"of elements should be equal to the number of channels of input 'w'.",
"T2", OpSchema::Optional)
.Output(
0,
"y",
@ -606,6 +623,16 @@ Matrix product that behaves like numpy.matmul: https://docs.scipy.org/doc/numpy-
The production MUST never overflow. The accumulation may overflow if and only if in 32 bits.)DOC")
.Input(0, "A", "N-dimensional matrix A", "T1")
.Input(1, "B", "N-dimensional matrix B", "T2")
.Input(2, "a_zero_point",
"Zero point tensor for input 'A'. It's optional and default value is 0. It could be a scalar or a 1-D tensor, "
"which means a per-tensor or per-row quantization. If it's a 1-D tensor, its number of elements "
"should be equal to the number of rows of input 'A'.",
"T1", OpSchema::Optional)
.Input(3, "b_zero_point",
"Scale tensor for input 'B'. It's optional and default value is 0. It could be a scalar or a 1-D tensor, "
"which means a per-tensor or per-column quantization. If it's a 1-D tensor, its number "
"of elements should be equal to the number of columns of input 'B'.",
"T2", OpSchema::Optional)
.Output(0, "Y", "Matrix multiply results from A * B", "T3")
.TypeConstraint("T1", {"tensor(int8)", "tensor(uint8)"}, "Constrain input A data types as 8-bit integer tensor")
.TypeConstraint("T2", {"tensor(int8)", "tensor(uint8)"}, "Constrain input B data types as 8-bit integer tensor")