[Mlir-commits] [mlir] be2f384 - [mlir][linalg] Treat quant dialect type as unsupported in named conversion
Kai Sasaki
llvmlistbot at llvm.org
Wed May 24 17:36:23 PDT 2023
Author: Kai Sasaki
Date: 2023-05-25T09:35:23+09:00
New Revision: be2f384f9eee16f9854fe5035581d12085113b01
URL: https://github.com/llvm/llvm-project/commit/be2f384f9eee16f9854fe5035581d12085113b01
DIFF: https://github.com/llvm/llvm-project/commit/be2f384f9eee16f9854fe5035581d12085113b01.diff
LOG: [mlir][linalg] Treat quant dialect type as unsupported in named conversion
Since the tosa-to-linalg conversion does not support the quant dialect type, we can treat it as unsupported instead of crash. Issue was reported https://github.com/llvm/llvm-project/issues/62367
Reviewed By: springerm
Differential Revision: https://reviews.llvm.org/D151296
Added:
mlir/test/Conversion/TosaToLinalg/tosa-to-linalg-invalid.mlir
Modified:
mlir/lib/Conversion/TosaToLinalg/TosaToLinalgNamed.cpp
Removed:
################################################################################
diff --git a/mlir/lib/Conversion/TosaToLinalg/TosaToLinalgNamed.cpp b/mlir/lib/Conversion/TosaToLinalg/TosaToLinalgNamed.cpp
index 4f9ea7c630330..62ec44bf9c1e1 100644
--- a/mlir/lib/Conversion/TosaToLinalg/TosaToLinalgNamed.cpp
+++ b/mlir/lib/Conversion/TosaToLinalg/TosaToLinalgNamed.cpp
@@ -766,6 +766,9 @@ class AvgPool2dConverter : public OpRewritePattern<tosa::AvgPool2dOp> {
llvm::append_range(pad, op.getPad());
pad.resize(pad.size() + 2, 0);
TypedAttr padAttr = rewriter.getZeroAttr(inElementTy);
+ // Unsupported element type
+ if (!padAttr)
+ return failure();
Value paddedInput = applyPad(loc, input, pad, padAttr, rewriter);
auto initialAttr = rewriter.getZeroAttr(accETy);
diff --git a/mlir/test/Conversion/TosaToLinalg/tosa-to-linalg-invalid.mlir b/mlir/test/Conversion/TosaToLinalg/tosa-to-linalg-invalid.mlir
new file mode 100644
index 0000000000000..2310ba986b5dd
--- /dev/null
+++ b/mlir/test/Conversion/TosaToLinalg/tosa-to-linalg-invalid.mlir
@@ -0,0 +1,8 @@
+// RUN: mlir-opt --split-input-file -pass-pipeline="builtin.module(func.func(tosa-to-linalg-named))" %s -verify-diagnostics
+
+// CHECK-LABEL: @avg_pool2d_with_unsupported_quant_type
+func.func @avg_pool2d_with_unsupported_quant_type(%arg0: tensor<1x7x7x9x!quant.uniform<i8:f32, 0.01>>) -> tensor<1x7x7x9x!quant.uniform<i8:f32, 0.01>> {
+ // expected-error at +1 {{failed to legalize operation 'tosa.avg_pool2d'}}
+ %0 = "tosa.avg_pool2d"(%arg0) {acc_type = i32, kernel = array<i64: 2, 2>, pad = array<i64: 0, 1, 0, 1>, stride = array<i64: 1, 1>} : (tensor<1x7x7x9x!quant.uniform<i8:f32, 0.01>>) -> tensor<1x7x7x9x!quant.uniform<i8:f32, 0.01>>
+ return %0 : tensor<1x7x7x9x!quant.uniform<i8:f32, 0.01>>
+}
More information about the Mlir-commits
mailing list