Skip to content

[DRAFT] Merge metadata props when fusing #2375

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

bmehta001
Copy link
Contributor

No description provided.

@bmehta001 bmehta001 force-pushed the merge-docstrings-when-fusing branch from 0ffe2bd to cd8ea57 Compare June 12, 2025 17:49
Comment on lines +537 to +539
fused_metadata_props = "Fused: " + "\t\n".join(
n.metadata_props for n in delta.match.nodes if getattr(n, "metadata_props", None)
)
Copy link
Collaborator

Choose a reason for hiding this comment

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

n will always have metadata_props.

n.metadata_props for n in delta.match.nodes if getattr(n, "metadata_props", None)
)
# Assign to all new nodes (or just the first, depending on your policy)
delta.new_nodes[0].metadata_props += fused_metadata_props
Copy link
Collaborator

Choose a reason for hiding this comment

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

Prefer metadata_props.update()

# If we are fusing nodes, update the metadata props of the new node(s)
if delta.match.nodes and delta.new_nodes:
# Concatenate metadata props from all original nodes
fused_metadata_props = "Fused: " + "\t\n".join(
Copy link
Collaborator

@justinchuby justinchuby Jun 12, 2025

Choose a reason for hiding this comment

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

I would consider creating special reconciliation logic for known fields

Copy link
Collaborator

Choose a reason for hiding this comment

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

+1. I am also confused a bit here. Isn't metadata_props effectively a dict[str, str]? I am not sure how the proto is represented in onnx-ir, but assuming it is a dictionary. We should be merging the dictionaries, using special merging logic for known entries in the dictionary.

This may require us to extend the definition/documentation of specific metadata fields. For example, we may need a way to represent a set of source-locations, instead of a single source-location, for a source-location metadata.

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

Successfully merging this pull request may close these issues.

3 participants