-
Notifications
You must be signed in to change notification settings - Fork 59
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
[IR] Refactor TensorBase to simplify implementation #2081
base: main
Are you sure you want to change the base?
Conversation
Move name, doc_string, meta and metadata fields to the base class
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR Overview
This PR refactors the TensorBase class to simplify its implementation by consolidating common fields (name, doc_string, metadata, and metadata_props) to the base class. Key changes include:
- Adding an init method and slots in TensorBase to manage common attributes.
- Removing duplicate metadata properties from Tensor, ExternalTensor, and StringTensor.
- Updating TensorProtoTensor in the serde module to call the new TensorBase constructor.
Reviewed Changes
File | Description |
---|---|
onnxscript/ir/_core.py | Refactors TensorBase by adding common initialization and removing metadata duplicates in subclasses. |
onnxscript/ir/serde.py | Updates TensorProtoTensor by removing inlined metadata_props deserialization and adjusting imports. |
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
Comments suppressed due to low confidence (1)
onnxscript/ir/serde.py:246
- The metadata_props deserialization from proto (previously done via deserialize_metadata_props) has been removed in TensorProtoTensor.init. If metadata is expected to be propagated from the proto, consider reintroducing this assignment.
super().__init__()
❌ 42 Tests Failed:
View the top 3 failed test(s) by shortest run time
To view more test analytics, go to the Test Analytics Dashboard |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR Overview
This PR refactors the TensorBase implementation by moving metadata, documentation, and name fields to the base class, thereby simplifying the initialization logic across tensor-related classes.
- Consolidated common field initialization (name, doc_string, metadata_props) into TensorBase.
- Removed duplicate property definitions and assignments from Tensor subclasses.
- Updated import statements to reflect the removal of now-unnecessary dependencies.
Reviewed Changes
File | Description |
---|---|
onnxscript/ir/serde.py | Updated TensorProtoTensor init to delegate metadata_props to the base class. |
onnxscript/ir/_core.py | Added common fields to TensorBase and updated subclass constructors accordingly. |
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
Comments suppressed due to low confidence (3)
onnxscript/ir/serde.py:247
- The refactor moves metadata properties initialization to the base class. Consider adding tests to ensure that metadata_props deserialization from proto remains consistent.
def __init__(self, proto: onnx.TensorProto) -> None:
onnxscript/ir/_core.py:107
- The new init in TensorBase consolidates common fields; please ensure that all subclasses correctly pass these parameters to maintain consistent behavior. Adding unit tests for these changes is recommended.
def __init__(self, name: str | None = None, doc_string: str | None = None, metadata_props: dict[str, str] | None = None) -> None:
onnxscript/ir/_core.py:397
- The removal of redundant assignments (e.g. name, doc_string, metadata_props) in the Tensor subclass appears appropriate; please verify through tests that these fields are correctly initialized via the base class.
super().__init__(name=name, doc_string=doc_string, metadata_props=metadata_props)
Move name, doc_string, meta and metadata fields to the base class