Skip to content

Commit cd8ea57

Browse files
committed
Merge metadata props when fusing
1 parent dcf98c8 commit cd8ea57

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

onnxscript/rewriter/_rewrite_rule.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -531,6 +531,15 @@ def _apply_to_graph_or_function(
531531
f = ir.Function(domain, name, overload, graph=graph, attributes=())
532532
model.functions[f.identifier()] = f
533533

534+
# If we are fusing nodes, update the metadata props of the new node(s)
535+
if delta.match.nodes and delta.new_nodes:
536+
# Concatenate metadata props from all original nodes
537+
fused_metadata_props = "Fused: " + "\t\n".join(
538+
n.metadata_props for n in delta.match.nodes if getattr(n, "metadata_props", None)
539+
)
540+
# Assign to all new nodes (or just the first, depending on your policy)
541+
delta.new_nodes[0].metadata_props += fused_metadata_props
542+
534543
if verbose:
535544
name = f"{rule.name}: " if rule.name else ""
536545
print(f"----{name}Matched Nodes----")

0 commit comments

Comments
 (0)