Skip to content

Commit

Permalink
Add missing shape inference check for DequantizeLinear (#6080)
Browse files Browse the repository at this point in the history
Add missing `hasInputShape` condition in shape-inference for
DequantizeLinear ... strangely missing in last two versions, but present
in earlier version.

Signed-off-by: Ganesan Ramalingam <grama@microsoft.com>
  • Loading branch information
gramalingam committed Apr 23, 2024
1 parent c459890 commit 5ecc0a9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
3 changes: 3 additions & 0 deletions onnx/defs/quantization/defs.cc
Expand Up @@ -200,6 +200,9 @@ ONNX_OPERATOR_SET_SCHEMA(
.SetDoc(DequantizeLinear_ver21_doc)
.TypeAndShapeInferenceFunction([](ONNX_NAMESPACE::InferenceContext& ctx) {
propagateElemTypeFromInputToOutput(ctx, 1, 0);
if (!hasInputShape(ctx, 0)) {
return;
}
auto& input_shape = getInputShape(ctx, 0);
updateOutputShape(ctx, 0, input_shape);
}));
Expand Down
4 changes: 3 additions & 1 deletion onnx/defs/quantization/old.cc
Expand Up @@ -130,6 +130,9 @@ ONNX_OPERATOR_SET_SCHEMA(
.SetDoc(DequantizeLinear_ver19_doc)
.TypeAndShapeInferenceFunction([](ONNX_NAMESPACE::InferenceContext& ctx) {
propagateElemTypeFromInputToOutput(ctx, 1, 0);
if (!hasInputShape(ctx, 0)) {
return;
}
auto& input_shape = getInputShape(ctx, 0);
updateOutputShape(ctx, 0, input_shape);
}));
Expand Down Expand Up @@ -181,7 +184,6 @@ ONNX_OPERATOR_SET_SCHEMA(
if (!hasInputShape(ctx, 0)) {
return;
}

auto& input_shape = getInputShape(ctx, 0);
updateOutputShape(ctx, 0, input_shape);
}));
Expand Down

0 comments on commit 5ecc0a9

Please sign in to comment.