ITADN

Constant Folding removes 'axes' initializer form Squeeze layer, resulting in incorrect ONNX model

#2810Openbas-aarts 创建于 2026-02-14
buggood first issuecontribution welcomemodule: optimizer
B
bas-aartscommented
converting the attached ONNX model with the following script: ``` from onnxscript import ir from onnxscript.optimizer import optimize ir_model = ir.load("input.onnx") optimized_model = optimize(ir_model) ir.save(optimized_model, "output.onnx") ``` produces an incorrect ONNX model. axes initializer '17' in Squeeze layer 'If_11_Squeeze_13' is missing. The constant folder is causing this. The If layer in the input model is the default way that a squeeze layer is exported from Torch, making this a common pattern. [input.onnx.zip](https://github.com/user-attachments/files/25318319/input.onnx.zip) versions of relevant packages: ``` ml_dtypes 0.5.4 onnx 1.20.1 onnx-ir 0.1.16 onnxscript 0.6.2 ```
3 条评论