[Mlir-commits] [mlir] [mlir][tosa] Enable constant operand check by default (PR #150598)
Luke Hutton
llvmlistbot at llvm.org
Fri Jul 25 02:41:25 PDT 2025
https://github.com/lhutton1 created https://github.com/llvm/llvm-project/pull/150598
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.
>From a34fc5c59d81c6339eacf7453ea7697f077bbf99 Mon Sep 17 00:00:00 2001
From: Luke Hutton <luke.hutton at arm.com>
Date: Fri, 25 Jul 2025 08:35:53 +0000
Subject: [PATCH] [mlir][tosa] Enable constant operand check by default
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"
opetion 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.
Change-Id: Ia8893fd3d2293905183d62f8fa82c93fb0048969
---
mlir/lib/Dialect/Tosa/Transforms/TosaValidation.cpp | 2 +-
mlir/test/Dialect/Tosa/dynamic_extension.mlir | 2 +-
mlir/test/Dialect/Tosa/level_check.mlir | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
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}}
More information about the Mlir-commits
mailing list