Skip to content

Commit bb179d7

Browse files
authored
Revert the rule that rewrites a quantize-dequantize pair to identity (#2952)
Signed-off-by: Tung D. Le <[email protected]>
1 parent 5c53b7e commit bb179d7

File tree

3 files changed

+1
-28
lines changed

3 files changed

+1
-28
lines changed

src/Dialect/ONNX/ONNXOps/Canonicalize.cpp

+1-3
Original file line numberDiff line numberDiff line change
@@ -1863,6 +1863,4 @@ void ONNXWhereOp::getCanonicalizationPatterns(
18631863

18641864
// on the ONNXDequantizeLinearOp.
18651865
void ONNXDequantizeLinearOp::getCanonicalizationPatterns(
1866-
RewritePatternSet &result, MLIRContext *context) {
1867-
result.insert<QuantizeDequantizePattern>(context);
1868-
}
1866+
RewritePatternSet &result, MLIRContext *context) {}

src/Dialect/ONNX/ONNXOps/Canonicalize.td

-11
Original file line numberDiff line numberDiff line change
@@ -1055,15 +1055,4 @@ def AlwaysFalseWherePattern : Pat<
10551055
[(IsNegativeSplatConstant:$negative_constant), (AreAllDimSizes:$dims)]
10561056
>;
10571057

1058-
//===----------------------------------------------------------------------===//
1059-
// Canonicalization for ONNXDequantizeLinear
1060-
//===----------------------------------------------------------------------===//
1061-
1062-
// Convert QuantizeLinear+DequantizeLinear to Identity.
1063-
def QuantizeDequantizePattern: Pat<
1064-
(ONNXDequantizeLinearOp (ONNXQuantizeLinearOp $x, $x_scale, $x_zeropoint, $x_axis, $x_saturate),
1065-
$y_scale, $y_zeropoint, $y_axis),
1066-
(replaceWithValue $x)
1067-
>;
1068-
10691058
#endif // ONNX_REWRITE

test/mlir/onnx/onnx_canonicalization.mlir

-14
Original file line numberDiff line numberDiff line change
@@ -1826,17 +1826,3 @@ func.func @test_where_with_always_false_3(%arg0: tensor<?x?xi64>) -> tensor<2xi6
18261826
// CHECK: }
18271827
}
18281828

1829-
// -----
1830-
1831-
func.func @test_dequantize_linear(%arg0: tensor<?x?x768xf32>, %arg1: tensor<f32>, %arg2: tensor<i8>) -> (tensor<?x?x768xf32>) {
1832-
%0 = "onnx.QuantizeLinear"(%arg0, %arg1, %arg2) {axis = 1 : si64} : (tensor<?x?x768xf32>, tensor<f32>, tensor<i8>) -> tensor<?x?x768xi8>
1833-
%1 = "onnx.DequantizeLinear"(%0, %arg1, %arg2) {axis = 1 : si64} : (tensor<?x?x768xi8>, tensor<f32>, tensor<i8>) -> tensor<?x?x768xf32>
1834-
return %1: tensor<?x?x768xf32>
1835-
1836-
// CHECK-LABEL: func.func @test_dequantize_linear
1837-
// CHECK-SAME: ([[PARAM_0_:%.+]]: tensor<?x?x768xf32>, [[PARAM_1_:%.+]]: tensor<f32>, [[PARAM_2_:%.+]]: tensor<i8>) -> tensor<?x?x768xf32> {
1838-
// CHECK-NOT: "onnx.QuantizeLinear"
1839-
// CHECK-NOT: "onnx.DequantizeLinear"
1840-
// CHECK: return [[PARAM_0_]] : tensor<?x?x768xf32>
1841-
// CHECK: }
1842-
}

0 commit comments

Comments
 (0)