[Mlir-commits] [mlir] d72d488 - [mlir][quant] output spec verification check for quant.region
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Fri Jun 24 16:58:33 PDT 2022
Author: lewuathe
Date: 2022-06-25T08:57:44+09:00
New Revision: d72d48803921551604f49db1ee72aa0ae9e57611
URL: https://github.com/llvm/llvm-project/commit/d72d48803921551604f49db1ee72aa0ae9e57611
DIFF: https://github.com/llvm/llvm-project/commit/d72d48803921551604f49db1ee72aa0ae9e57611.diff
LOG: [mlir][quant] output spec verification check for quant.region
We can have validation test for quant.region having incompatible output spec.
Reviewed By: stellaraccident
Differential Revision: https://reviews.llvm.org/D128245
Added:
Modified:
mlir/test/Dialect/Quant/quant_region.mlir
Removed:
################################################################################
diff --git a/mlir/test/Dialect/Quant/quant_region.mlir b/mlir/test/Dialect/Quant/quant_region.mlir
index 8c7d6c40ef40d..437edf8f3e04f 100644
--- a/mlir/test/Dialect/Quant/quant_region.mlir
+++ b/mlir/test/Dialect/Quant/quant_region.mlir
@@ -70,6 +70,36 @@ func.func @unmatched_primitive(%arg0: tensor<4xf32>, %arg1: tensor<4xf32>, %arg2
// -----
+func.func @unmatched_quantize(%arg0: tensor<4xf32>, %arg1: tensor<4xf32>, %arg2: tensor<4xf32>) -> (tensor<4xf32>) {
+ // @expected-error @+1 {{'quant.region' op has incompatible specification !quant.uniform<i32:f16, 4.000000e+00> and output type 'tensor<4xf32>'}}
+ %0 = "quant.region"(%arg0, %arg1, %arg2) ({
+ ^bb0(%10: tensor<4xf32>, %11: tensor<4xf32>, %12: tensor<4xf32>):
+ %13 = "foo"(%10, %11) : (tensor<4xf32>, tensor<4xf32>) -> tensor<4xf32>
+ %14 = "bar"(%13, %12) : (tensor<4xf32>, tensor<4xf32>) -> tensor<4xf32>
+ "quant.return"(%14) : (tensor<4xf32>) -> ()
+ }) {input_specs = [!quant.uniform<i8:f32, 1.0>, !quant.uniform<i8:f32, 2.0>, !quant.uniform<i8:f32, 3.0>],
+ output_specs = [!quant.uniform<i32:f16, 4.0>], logical_kernel = "xyz"}
+ : (tensor<4xf32>, tensor<4xf32>, tensor<4xf32>) -> (tensor<4xf32>)
+ return %0 : tensor<4xf32>
+}
+
+// -----
+
+func.func @unmatched_primitive(%arg0: tensor<4xf32>, %arg1: tensor<4xf32>, %arg2: tensor<4xf32>) -> (tensor<4xf32>) {
+ // @expected-error @+1 {{'quant.region' op has incompatible specification i32 and output type 'tensor<4xf32>'}}
+ %0 = "quant.region"(%arg0, %arg1, %arg2) ({
+ ^bb0(%10: tensor<4xf32>, %11: tensor<4xf32>, %12: tensor<4xf32>):
+ %13 = "foo"(%10, %11) : (tensor<4xf32>, tensor<4xf32>) -> tensor<4xf32>
+ %14 = "bar"(%13, %12) : (tensor<4xf32>, tensor<4xf32>) -> tensor<4xf32>
+ "quant.return"(%14) : (tensor<4xf32>) -> ()
+ }) {input_specs = [!quant.uniform<i8:f32, 1.0>, !quant.uniform<i8:f32, 2.0>, !quant.uniform<i32:f32, 2.0>],
+ output_specs = [i32], logical_kernel = "xyz"}
+ : (tensor<4xf32>, tensor<4xf32>, tensor<4xf32>) -> (tensor<4xf32>)
+ return %0 : tensor<4xf32>
+}
+
+// -----
+
func.func @unmatched_number(%arg0: tensor<4xf32>, %arg1: tensor<4xf32>, %arg2: tensor<4xf32>) -> (tensor<4xf32>) {
// @expected-error @+1 {{'quant.region' op has unmatched operands/results number and spec attributes number}}
%0 = "quant.region"(%arg0, %arg1, %arg2) ({
More information about the Mlir-commits
mailing list