Skip to content

Conversation

@gramalingam
Copy link
Collaborator

Fixes a few different issues. Helps resolve an issue relating to ir-based optimization for the Blender model in the benchmark.

  • Move the utility for evaluating Constant op into the IR, and make const_value automatically perform the related computation.
  • Eliminate the dependence on the reference-implementation for evaluation of Constant op.
  • There are still a couple of issues relating to the use of reference-implementation (eg., when we have tensor-valued attributes in external-data format, and the use of float16) which will need to be addressed separately, but the above bypasses this issue for Constant op (and the Blender model).
  • Make the optimizer robust to external-data-tensors whose files are not available.

@codecov
Copy link

codecov bot commented Oct 8, 2024

❌ 15 Tests Failed:

Tests completed Failed Passed Skipped
12894 15 12879 2643
View the top 3 failed tests by shortest run time
tests.ir.serde_roundtrip_test.SerdeTest test_serialization_deserialization_produces_same_model_0292_test_cast_FLOAT16_to_FLOAT4E2M1_model_onnx
Stack Traces | 0.001s run time
onnxscript/ir/serde.py:97: in wrapper
    return func(*args, **kwargs)
onnxscript/ir/serde.py:711: in deserialize_type_proto_for_type
    return _core.TensorType(_enums.DataType(elem_type), denotation=denotation)
....../Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/enum.py:714: in __call__
    return cls.__new__(cls, value)
....../Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/enum.py:1137: in __new__
    raise ve_exc
E   ValueError: 23 is not a valid DataType

The above exception was the direct cause of the following exception:
onnxscript/ir/serde.py:97: in wrapper
    return func(*args, **kwargs)
onnxscript/ir/serde.py:657: in deserialize_value_info_proto
    value.type = deserialize_type_proto_for_type(proto.type)
onnxscript/ir/serde.py:99: in wrapper
    raise SerdeError(
E   onnxscript.ir.serde.SerdeError: Error calling deserialize_type_proto_for_type with: tensor_type {
E     elem_type: 23
E     shape {
E       dim {
E         dim_value: 3
E       }
E       dim {
E         dim_value: 5
E       }
E     }
E   }

The above exception was the direct cause of the following exception:
onnxscript/ir/serde.py:97: in wrapper
    return func(*args, **kwargs)
onnxscript/ir/serde.py:600: in _deserialize_graph
    outputs = [deserialize_value_info_proto(info, values[info.name]) for info in proto.output]
onnxscript/ir/serde.py:600: in <listcomp>
    outputs = [deserialize_value_info_proto(info, values[info.name]) for info in proto.output]
onnxscript/ir/serde.py:99: in wrapper
    raise SerdeError(
E   onnxscript.ir.serde.SerdeError: Error calling deserialize_value_info_proto with: name: "output"
E   type {
E     tensor_type {
E       elem_type: 23
E       shape {
E         dim {
E           dim_value: 3
E         }
E         dim {
E           dim_value: 5
E         }
E       }
E     }
E   }

The above exception was the direct cause of the following exception:
..../test_onnx_weekly/lib/python3.11.../site-packages/parameterized/parameterized.py:620: in standalone_func
    return func(*(a + p.args), **p.kwargs, **kw)
tests/ir/serde_roundtrip_test.py:38: in test_serialization_deserialization_produces_same_model
    ir_model = ir.serde.deserialize_model(model)
onnxscript/ir/serde.py:459: in deserialize_model
    graph = _deserialize_graph(proto.graph, [])
onnxscript/ir/serde.py:99: in wrapper
    raise SerdeError(
E   onnxscript.ir.serde.SerdeError: Error calling _deserialize_graph with: main_graph
tests.ir.serde_roundtrip_test.SerdeTest test_serialization_deserialization_produces_same_model_0430_test_dequantizelinear_float4e2m1_model_onnx
Stack Traces | 0.001s run time
onnxscript/ir/serde.py:97: in wrapper
    return func(*args, **kwargs)
onnxscript/ir/serde.py:711: in deserialize_type_proto_for_type
    return _core.TensorType(_enums.DataType(elem_type), denotation=denotation)
....../Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/enum.py:714: in __call__
    return cls.__new__(cls, value)
....../Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/enum.py:1137: in __new__
    raise ve_exc
E   ValueError: 23 is not a valid DataType

The above exception was the direct cause of the following exception:
onnxscript/ir/serde.py:97: in wrapper
    return func(*args, **kwargs)
onnxscript/ir/serde.py:657: in deserialize_value_info_proto
    value.type = deserialize_type_proto_for_type(proto.type)
onnxscript/ir/serde.py:99: in wrapper
    raise SerdeError(
E   onnxscript.ir.serde.SerdeError: Error calling deserialize_type_proto_for_type with: tensor_type {
E     elem_type: 23
E     shape {
E       dim {
E         dim_value: 5
E       }
E     }
E   }

The above exception was the direct cause of the following exception:
onnxscript/ir/serde.py:97: in wrapper
    return func(*args, **kwargs)
onnxscript/ir/serde.py:568: in _deserialize_graph
    deserialize_value_info_proto(info, value)
onnxscript/ir/serde.py:99: in wrapper
    raise SerdeError(
E   onnxscript.ir.serde.SerdeError: Error calling deserialize_value_info_proto with: name: "x"
E   type {
E     tensor_type {
E       elem_type: 23
E       shape {
E         dim {
E           dim_value: 5
E         }
E       }
E     }
E   }

The above exception was the direct cause of the following exception:
..../test_onnx_weekly/lib/python3.11.../site-packages/parameterized/parameterized.py:620: in standalone_func
    return func(*(a + p.args), **p.kwargs, **kw)
tests/ir/serde_roundtrip_test.py:38: in test_serialization_deserialization_produces_same_model
    ir_model = ir.serde.deserialize_model(model)
onnxscript/ir/serde.py:459: in deserialize_model
    graph = _deserialize_graph(proto.graph, [])
onnxscript/ir/serde.py:99: in wrapper
    raise SerdeError(
E   onnxscript.ir.serde.SerdeError: Error calling _deserialize_graph with: main_graph
tests.ir.serde_roundtrip_test.SerdeTest test_serialization_deserialization_produces_same_model_0571_test_cast_FLOAT4E2M1_to_FLOAT_model_onnx
Stack Traces | 0.001s run time
onnxscript/ir/serde.py:97: in wrapper
    return func(*args, **kwargs)
onnxscript/ir/serde.py:711: in deserialize_type_proto_for_type
    return _core.TensorType(_enums.DataType(elem_type), denotation=denotation)
.../hostedtoolcache/Python/3.11.10....../x64/lib/python3.11/enum.py:714: in __call__
    return cls.__new__(cls, value)
.../hostedtoolcache/Python/3.11.10....../x64/lib/python3.11/enum.py:1137: in __new__
    raise ve_exc
E   ValueError: 23 is not a valid DataType

The above exception was the direct cause of the following exception:
onnxscript/ir/serde.py:97: in wrapper
    return func(*args, **kwargs)
onnxscript/ir/serde.py:657: in deserialize_value_info_proto
    value.type = deserialize_type_proto_for_type(proto.type)
onnxscript/ir/serde.py:99: in wrapper
    raise SerdeError(
E   onnxscript.ir.serde.SerdeError: Error calling deserialize_type_proto_for_type with: tensor_type {
E     elem_type: 23
E     shape {
E       dim {
E         dim_value: 3
E       }
E       dim {
E         dim_value: 5
E       }
E     }
E   }

The above exception was the direct cause of the following exception:
onnxscript/ir/serde.py:97: in wrapper
    return func(*args, **kwargs)
onnxscript/ir/serde.py:568: in _deserialize_graph
    deserialize_value_info_proto(info, value)
onnxscript/ir/serde.py:99: in wrapper
    raise SerdeError(
E   onnxscript.ir.serde.SerdeError: Error calling deserialize_value_info_proto with: name: "input"
E   type {
E     tensor_type {
E       elem_type: 23
E       shape {
E         dim {
E           dim_value: 3
E         }
E         dim {
E           dim_value: 5
E         }
E       }
E     }
E   }

The above exception was the direct cause of the following exception:
..../test_onnx_weekly/lib/python3.11.../site-packages/parameterized/parameterized.py:620: in standalone_func
    return func(*(a + p.args), **p.kwargs, **kw)
tests/ir/serde_roundtrip_test.py:38: in test_serialization_deserialization_produces_same_model
    ir_model = ir.serde.deserialize_model(model)
onnxscript/ir/serde.py:459: in deserialize_model
    graph = _deserialize_graph(proto.graph, [])
onnxscript/ir/serde.py:99: in wrapper
    raise SerdeError(
E   onnxscript.ir.serde.SerdeError: Error calling _deserialize_graph with: main_graph

To view individual test run time comparison to the main branch, go to the Test Analytics Dashboard

@justinchuby justinchuby added the module: IR Intermediate representation label Oct 10, 2024
Copy link
Collaborator

@justinchuby justinchuby left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm with tests added (and comments on const_value guarantees), thanks!

@gramalingam gramalingam enabled auto-merge (squash) October 11, 2024 14:07
@gramalingam gramalingam merged commit ed28222 into main Oct 11, 2024
22 of 39 checks passed
@gramalingam gramalingam deleted the rama/const-prop branch October 11, 2024 15:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

module: IR Intermediate representation module: optimizer

Projects

Development

Successfully merging this pull request may close these issues.

3 participants