Skip to content

Output dtype of DequantizeLinear v19 is not aligned with its doc #5704

@LoSealL

Description

@LoSealL

Bug Report

The document description of DequantizeLinear v19 is:
| y (heterogeneous) - T2: N-D full precision output tensor. It has same shape as input ‘x’.
| T2 in ( tensor(bfloat16), tensor(float), tensor(float16) ): ‘x_scale’ determines the output type.

So the dtype of y should be the same as x_scale. However in the code it's fixed to FLOAT:

        .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);
        }));

So if x_scale dtype is float16, onnx.shape_inference.infer_shapes will deduce a wrong output data type.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions