Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Checker misses data type mismatch for Max #4619

Closed
ganler opened this issue Oct 24, 2022 · 1 comment · Fixed by #4622
Closed

[Bug] Checker misses data type mismatch for Max #4619

ganler opened this issue Oct 24, 2022 · 1 comment · Fixed by #4622

Comments

@ganler
Copy link

ganler commented Oct 24, 2022

Bug Report

Is the issue related to model conversion?

Partially. PyTorch generates a wrong ONNX model but still onnx.checker did not check it carefully (I use onnx.checker.check_model(mode, full_check=True) to skip wrong models).

Describe the bug

The minimized model looks like this:

"""
graph par1 (
  %i0[DOUBLE, 2x2x1x1]
  %/mlist.0/Mul_1_output_0[FLOAT, scalar]
) {
  %/Max_output_0 = Max(%i0, %/mlist.0/Mul_1_output_0)
  return %/Max_output_0
}
"""

Basically, it is Max(<double>[2,2,1,1], <float>[scalar]). The checker returns successfully when checking the model. Maybe there is some missed cases/conditions in the checker.

System information

  • ONNX version: 1.12
  • Python version: 3.9
  • OS: Ubuntu 22.04

Reproduction instructions

import onnx

X = onnx.helper.make_tensor_value_info("X", onnx.TensorProto.DOUBLE, (2, 2, 1, 1))
Y = onnx.helper.make_tensor_value_info("Y", onnx.TensorProto.FLOAT, ())
Z = onnx.helper.make_tensor_value_info("Z", onnx.TensorProto.DOUBLE, (2, 2, 1, 1))
model = onnx.helper.make_model(
    onnx.helper.make_graph(
        nodes=[
            onnx.helper.make_node("Max", ["X", "Y"], ["Z"]),
        ],
        name="bar",
        inputs=[X, Y],
        outputs=[Z],
        initializer=[],
        value_info=[],
    ),
    producer_name="foo",
)

model = onnx.shape_inference.infer_shapes(model, strict_mode=True)
onnx.checker.check_model(model, full_check=True)

Expected behavior

Should fail but did not. But later this error occurs when using ONNXRuntime.

cc: @jcwchen Thanks!

@jcwchen
Copy link
Member

jcwchen commented Oct 25, 2022

Hi @ganler,
Thank you for catching this. I can repro this by your example. Yes, I think ideally checker should catch this type mismatch. I will submit a PR to fix this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants