-
Notifications
You must be signed in to change notification settings - Fork 19
Open
Open
Copy link
Labels
Description
The feature was initially proposed here: microsoft/onnxscript#2680 (comment), where we saw a silent name collision leading to problematic optimized model.
We should firstly refactor rewrite rules to use the official initializer registration API to avoid silent errors:
https://github.com/microsoft/onnxscript/blob/478acf741471a4764d507d52a4ca6b544a63fc86/onnxscript/rewriter/_rewrite_rule.py#L685-L691
Also, instead of throwing errors, register_initializer can solve this automatically:
Lines 2727 to 2743 in 926397c
| def register_initializer(self, value: Value) -> None: | |
| """Register an initializer to the graph. | |
| This is a convenience method to register an initializer to the graph with | |
| checks. | |
| Args: | |
| value: The :class:`Value` to register as an initializer of the graph. | |
| It must have its ``.const_value`` set. | |
| Raises: | |
| ValueError: If a value of the same name that is not this value | |
| is already registered. | |
| ValueError: If the value does not have a name. | |
| ValueError: If the initializer is produced by a node. | |
| ValueError: If the value does not have its ``.const_value`` set. | |
| """ |
cc @justinchuby @xadupre @gramalingam more thoughts
Reactions are currently unavailable