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

Handle Constant op variants in shape inference #3985

Closed
gramalingam opened this issue Feb 2, 2022 · 1 comment
Closed

Handle Constant op variants in shape inference #3985

gramalingam opened this issue Feb 2, 2022 · 1 comment

Comments

@gramalingam
Copy link
Contributor

Bug Report

Describe the bug

Shape-inference does not handle variants of Constant op introduced in opset 12. The opset 12 version introduced the ability to specify constant values using one of multiple attributes (like value_ints, for example) but the implementation handles only the original form (using the attribute value).

Reproduction instructions

  • Describe the code to reproduce the behavior.
from onnx import shape_inference, parser

def infer(x):
    model = parser.parse_model(x)
    inferred_model = shape_inference.infer_shapes(model)
    return { vi.name : vi.type for vi in inferred_model.graph.value_info }

result = infer('''
<
  ir_version: 7,
  opset_import: [ "" : 15 ]
>
toy (int64[?] X) => (int64[] Y)
{
    S = Constant <value_ints = [10, 20]>()
    Z = Reshape (X, S)
    Y = Identity (Z)
}
''')

print(result['Z'])

result2 = infer('''
<
  ir_version: 7,
  opset_import: [ "" : 15 ]
>
toy (int64[?] X) => (int64[] Y)
{
    S = Constant <value = int64[2] {10, 20}>()
    Z = Reshape (X, S)
    Y = Identity (Z)
}
''')

print(result2['Z'])

Expected behavior

Both result and result2 should have same value

Notes

This line needs to be fixed:

if (attr.name() == "value") {

@gramalingam
Copy link
Contributor Author

This was completed by this PR: #4824

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

Successfully merging a pull request may close this issue.

1 participant