diff --git a/onnxruntime/core/graph/contrib_ops/contrib_defs.cc b/onnxruntime/core/graph/contrib_ops/contrib_defs.cc index 16704c46b4..0644ffdd5e 100644 --- a/onnxruntime/core/graph/contrib_ops/contrib_defs.cc +++ b/onnxruntime/core/graph/contrib_ops/contrib_defs.cc @@ -522,7 +522,16 @@ activation and leaky_relu_alpha.)DOC") .SetDoc(R"DOC( The linear quantization operator. It consumes a full precision data, a scale, a zero point and computes the quantized data. The quantization formula is y = (x / y_scale) + y_zero_point. For (x / y_scale), it computes the nearest integer value to arg (in floating-point format), - rounding halfway cases away from zero. Scale and zero point must have same shape. They must be either scalar (per tensor) or 1-D tensor (per 'axis').)DOC"); + rounding halfway cases away from zero. Scale and zero point must have same shape. They must be either scalar (per tensor) or 1-D tensor (per 'axis').)DOC") + .TypeAndShapeInferenceFunction([](ONNX_NAMESPACE::InferenceContext& ctx) { + propagateElemTypeFromInputToOutput(ctx, 2, 0); + + if (!hasInputShape(ctx, 0)) + return; + + auto& input_shape = getInputShape(ctx, 0); + updateOutputShape(ctx, 0, input_shape); + }); ONNX_CONTRIB_OPERATOR_SCHEMA(DequantizeLinear) .SetDomain(kMSDomain) @@ -543,7 +552,18 @@ The quantization formula is y = (x / y_scale) + y_zero_point. For (x / y_scale), .SetDoc(R"DOC( The linear de-quantization operator. It consumes a quantized data, a scale, a zero point and computes the full precision data. The dequantization formula is y = (x - x_zero_point) * x_scale. - Scale and zero point must have same shape. They must be either scalar (per tensor) or 1-D tensor (per 'axis').)DOC"); +Scale and zero point must have same shape. They must be either scalar (per tensor) or 1-D tensor (per 'axis').)DOC") + .TypeAndShapeInferenceFunction([](ONNX_NAMESPACE::InferenceContext& ctx) { + auto y_type = ctx.getOutputType(0); + // only float is supported + y_type->mutable_tensor_type()->set_elem_type(ONNX_NAMESPACE::TensorProto::FLOAT); + + if (!hasInputShape(ctx, 0)) + return; + + auto& input_shape = getInputShape(ctx, 0); + updateOutputShape(ctx, 0, input_shape); + }); ONNX_CONTRIB_OPERATOR_SCHEMA(QLinearMatMul) .SetDomain(kMSDomain)