non-deterministic rewriter behavior in onnxscript
When running the onnxscript_bug.py multiple times on the attached input model, sometimes it will apply a rewrite rule, other times it won't.
In the below text, 6 out of 20 runs triggered a rewrite.
Non-deterministic behavior should be avoided at all cost, as it complicates matters.
```
$ cat onnxscript_bug.py
from onnxscript import ir
from onnxscript.optimizer import optimize_ir
ir_model = ir.load("input.onnx")
optimize_ir(ir_model, num_iterations = 1)
ir.save(ir_model, "output.onnx")
$ for i in {1..20}; do python onnxscript_bug.py; done
Applied 1 of general pattern rewrite rules.
Applied 1 of general pattern rewrite rules.
Applied 1 of general pattern rewrite rules.
Applied 1 of general pattern rewrite rules.
Applied 1 of general pattern rewrite rules.
Applied 1 of general pattern rewrite rules.
$ pip list | grep onnx
onnx 1.19.1
onnx-ir 0.2.0
onnxscript 0.6.2
sne4onnx 2.0.1
```
[input.onnx.zip](https://github.com/user-attachments/files/26420676/input.onnx.zip)
the resulting graphs show the difference:
<img width="291" height="401" alt="Image" src="https://github.com/user-attachments/assets/bea1a70f-5e84-46e1-b77f-223e47f30cb1" />
<img width="301" height="389" alt="Image" src="https://github.com/user-attachments/assets/b5452a72-e123-4274-882d-022151a5c660" />
1 条评论