@@ -79,6 +79,7 @@ void addONNXToZHighPasses(
79
79
pm.addNestedPass <func::FuncOp>(onnx_mlir::createShapeInferencePass ());
80
80
// There are more opportunities for const propagation once all zhigh ops were
81
81
// generated.
82
+ pm.addNestedPass <func::FuncOp>(onnx_mlir::createDecomposeONNXToONNXPass ());
82
83
pm.addNestedPass <func::FuncOp>(onnx_mlir::createConstPropONNXToONNXPass ());
83
84
pm.addPass (mlir::createCanonicalizerPass ());
84
85
// Layout propagation at ZHighIR.
@@ -103,13 +104,6 @@ void addONNXToZHighPasses(
103
104
if (nnpaEnableZHighToOnnx)
104
105
pm.addNestedPass <func::FuncOp>(onnx_mlir::createZHighToONNXPass ());
105
106
106
- // Constant propagation at ZHighIR: constant stickify.
107
- // Only support BE machines.
108
- bool isBE = llvm::support::endian::system_endianness () ==
109
- llvm::support::endianness::big;
110
- if (isBE)
111
- pm.addNestedPass <func::FuncOp>(
112
- onnx_mlir::zhigh::createZHighConstPropagationPass ());
113
107
// One more call to ONNX shape inference/canonicalization/... to update shape
114
108
// if possible.
115
109
if (enableONNXHybridPass) {
@@ -121,6 +115,19 @@ void addONNXToZHighPasses(
121
115
pm.addPass (mlir::createCanonicalizerPass ());
122
116
pm.addNestedPass <func::FuncOp>(onnx_mlir::createShapeInferencePass ());
123
117
}
118
+
119
+ // Replace every DisposableElementsAttr with DenseElementsAttr.
120
+ // ZHighConstPropagation currently assumes that DenseElementsAttr is used.
121
+ pm.addPass (createScrubDisposablePass ());
122
+
123
+ // Constant propagation at ZHighIR: constant stickify.
124
+ // Only support BE machines.
125
+ bool isBE = llvm::support::endian::system_endianness () ==
126
+ llvm::support::endianness::big;
127
+ if (isBE)
128
+ pm.addNestedPass <func::FuncOp>(
129
+ onnx_mlir::zhigh::createZHighConstPropagationPass ());
130
+
124
131
// Remove common sub-expressions.
125
132
pm.addPass (mlir::createCSEPass ());
126
133
0 commit comments