[Mlir-commits] [mlir] [mlir][tosa] Enable constant operand check by default (PR #150598)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Fri Jul 25 02:41:56 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-mlir-tosa
@llvm/pr-subscribers-mlir
Author: Luke Hutton (lhutton1)
<details>
<summary>Changes</summary>
Previous behaviour was to only run the check for constant operands when the "strict-op-spec-alignment" check was enabled. However, this type of check seems more generally useful without this option enabled. For example, tosa-to-linalg doesn't enable the "strict-op-spec-alignment" option when running the tosa-validate pass, but it does expect operands to be constant.
By enabling this type of checking by default, lowering that don't support non constant operands and don't use the "strict-op-spec-alignment" option will fail early, rather than later in the lowering pipeline.
Should a use-case need to disable this type of checking, `--tosa-validate="extension=dynamic"` can be used.
---
Full diff: https://github.com/llvm/llvm-project/pull/150598.diff
3 Files Affected:
- (modified) mlir/lib/Dialect/Tosa/Transforms/TosaValidation.cpp (+1-1)
- (modified) mlir/test/Dialect/Tosa/dynamic_extension.mlir (+1-1)
- (modified) mlir/test/Dialect/Tosa/level_check.mlir (+1-1)
``````````diff
diff --git a/mlir/lib/Dialect/Tosa/Transforms/TosaValidation.cpp b/mlir/lib/Dialect/Tosa/Transforms/TosaValidation.cpp
index 32b5fb63a6ece..0620b590ed5dd 100644
--- a/mlir/lib/Dialect/Tosa/Transforms/TosaValidation.cpp
+++ b/mlir/lib/Dialect/Tosa/Transforms/TosaValidation.cpp
@@ -1383,7 +1383,7 @@ void TosaValidation::runOnOperation() {
// Some uses of TOSA rely on the constant operands of particular
// operations.
- if (strictOpSpecAlignment && failed(applyConstantOperandCheck(op)))
+ if (failed(applyConstantOperandCheck(op)))
signalPassFailure();
// do level checks
diff --git a/mlir/test/Dialect/Tosa/dynamic_extension.mlir b/mlir/test/Dialect/Tosa/dynamic_extension.mlir
index 8739f979d8d50..e23ce43031a24 100644
--- a/mlir/test/Dialect/Tosa/dynamic_extension.mlir
+++ b/mlir/test/Dialect/Tosa/dynamic_extension.mlir
@@ -2,7 +2,7 @@
// Check operations when the dynamic extension is enabled.
//--------------------------------------------------------
-// RUN: mlir-opt %s -split-input-file -verify-diagnostics -tosa-validate="profile=pro_int,pro_fp extension=dynamic strict-op-spec-alignment allow-invalid-op-datatype-combinations"
+// RUN: mlir-opt %s -split-input-file -verify-diagnostics -tosa-validate="profile=pro_int,pro_fp extension=dynamic allow-invalid-op-datatype-combinations"
// -----
diff --git a/mlir/test/Dialect/Tosa/level_check.mlir b/mlir/test/Dialect/Tosa/level_check.mlir
index 0dddf26fb1f85..afb49ce312de7 100644
--- a/mlir/test/Dialect/Tosa/level_check.mlir
+++ b/mlir/test/Dialect/Tosa/level_check.mlir
@@ -1,4 +1,4 @@
-// RUN: mlir-opt %s -split-input-file -verify-diagnostics --tosa-validate
+// RUN: mlir-opt %s -split-input-file -verify-diagnostics --tosa-validate="extension=dynamic"
func.func @test_argmax_rank_invalid(%arg0: tensor<1x1x1x1x29x29x4xf32>) -> tensor<1x1x1x1x29x4xi32> {
// expected-error at +1 {{'tosa.argmax' op failed level check: operand rank(shape) <= MAX_RANK}}
``````````
</details>
https://github.com/llvm/llvm-project/pull/150598
More information about the Mlir-commits
mailing list