[Mlir-commits] [mlir] 9472c5f - [TOSA] Make validation pass isValidElementType check more strict (#119671)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Thu Dec 12 03:34:26 PST 2024
Author: Luke Hutton
Date: 2024-12-12T11:34:22Z
New Revision: 9472c5fcc78a1f7ff48d797f91b55246f7c80b1a
URL: https://github.com/llvm/llvm-project/commit/9472c5fcc78a1f7ff48d797f91b55246f7c80b1a
DIFF: https://github.com/llvm/llvm-project/commit/9472c5fcc78a1f7ff48d797f91b55246f7c80b1a.diff
LOG: [TOSA] Make validation pass isValidElementType check more strict (#119671)
The validation pass is used to check alignment of the IR against the
TOSA specification. This commit updates the `isValidElement` check to
more strictly align with the specifications supported element types.
Signed-off-by: Luke Hutton <luke.hutton at arm.com>
Added:
Modified:
mlir/lib/Dialect/Tosa/Transforms/TosaValidation.cpp
mlir/test/Dialect/Tosa/level_check.mlir
Removed:
################################################################################
diff --git a/mlir/lib/Dialect/Tosa/Transforms/TosaValidation.cpp b/mlir/lib/Dialect/Tosa/Transforms/TosaValidation.cpp
index 93e8cac6b84e9c..893cedefc1ebde 100644
--- a/mlir/lib/Dialect/Tosa/Transforms/TosaValidation.cpp
+++ b/mlir/lib/Dialect/Tosa/Transforms/TosaValidation.cpp
@@ -524,18 +524,8 @@ bool TosaValidation::isValidElementType(Type type) {
if (!isEnabledProfile(TosaProfileEnum::MainInference))
return false;
return type.isF32() || type.isF16() || type.isBF16();
- }
- if (auto intTy = dyn_cast<IntegerType>(type)) {
- if (intTy.isUnsigned()) {
- switch (intTy.getWidth()) {
- case 8:
- case 16:
- return true;
- default:
- return false;
- }
- } else {
- // Signless - treated as signed.
+ } else if (auto intTy = dyn_cast<IntegerType>(type)) {
+ if (intTy.isSignless()) {
switch (intTy.getWidth()) {
case 1:
case 4:
@@ -544,13 +534,10 @@ bool TosaValidation::isValidElementType(Type type) {
case 32:
case 48:
return true;
- default:
- return false;
}
}
- return false;
}
- return true;
+ return false;
}
void TosaValidation::runOnOperation() {
diff --git a/mlir/test/Dialect/Tosa/level_check.mlir b/mlir/test/Dialect/Tosa/level_check.mlir
index e851019362958f..529a16ca48c7eb 100644
--- a/mlir/test/Dialect/Tosa/level_check.mlir
+++ b/mlir/test/Dialect/Tosa/level_check.mlir
@@ -143,6 +143,14 @@ func.func @test_const_f64(%arg0 : tensor<1xf64>) {
// -----
+func.func @test_const_ui8(%arg0 : tensor<1xui8>) {
+ // expected-error at +1 {{'tosa.const' op is not profile-aligned: element type 'ui8' is not legal}}
+ %0 = "tosa.const"() {value = dense<0> : tensor<1xui8>} : () -> tensor<1xui8>
+ return
+}
+
+// -----
+
func.func @test_avgpool2d_kernel_y(%arg0: tensor<1x32x32x8xf32>) -> tensor<1x32x32x8xf32> {
// expected-error at +1 {{'tosa.avg_pool2d' op failed level check: kernel <= MAX_KERNEL}}
%0 = "tosa.avg_pool2d"(%arg0) {kernel = array<i64: 8193, 1>, pad = array<i64: 4, 4, 4, 4>, stride = array<i64: 1, 1>, acc_type = f32} :
More information about the Mlir-commits
mailing list