microsoft / onnxscript

ONNX Script enables developers to naturally author ONNX functions and models using a subset of Python.
https://onnxscript.ai/
MIT License
270 stars 50 forks source link

Preserve metadata_props in optimizer #1752

Open justinchuby opened 1 month ago

justinchuby commented 1 month ago

cc @gramalingam

gramalingam commented 1 month ago

Can you give examples of metadata_props that we care about? That could help identify some strategies. Unless you are talking about the simpler case of just propagating metadata_props for unmodified nodes etc. The complex case is when a group of nodes is replaced by one or more new nodes. A single strategy might not work for all metadata_props, but we can probably find a few common strategies for the properties we care about. I suppose we could also generalize this from being dictionary-like (unique keys) to list-like (permitting duplicate keys) ... alternatively, we may need to combine multiple values into one

justinchuby commented 1 month ago

One example is the namespace key. For example, two nodes may have namespaces a/b/c and a/b. In which case we can either

(1) take an arbitrary namespace, or (2) take the common stem a/b

Preserving the namespace is important for model explorer to be able to display the graph properly (otherwise it fails to layout big graphs)

For other keys like source location, they are more informational and taking arbitrary keys may work?