[Mlir-commits] [mlir] a36f821 - [mlir][linalg] Add test for ReduceOp empty-input verifier; remove dead empty-output check (#189614)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Thu Apr 2 06:57:57 PDT 2026
Author: Mehdi Amini
Date: 2026-04-02T15:57:53+02:00
New Revision: a36f821e7749618e6910b39778911c907dcd2c6f
URL: https://github.com/llvm/llvm-project/commit/a36f821e7749618e6910b39778911c907dcd2c6f
DIFF: https://github.com/llvm/llvm-project/commit/a36f821e7749618e6910b39778911c907dcd2c6f.diff
LOG: [mlir][linalg] Add test for ReduceOp empty-input verifier; remove dead empty-output check (#189614)
Add a FileCheck test covering the 'expected at least one input' error in
ReduceOp::verify(). The companion 'expected at least one output' check
was dead code: SameVariadicOperandSize fires first whenever
inputs.size() \!= inits.size(), and when both are empty the input check
fires first; remove the unreachable branch.
Assisted-by: Claude Code
Added:
Modified:
mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp
mlir/test/Dialect/Linalg/invalid.mlir
Removed:
################################################################################
diff --git a/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp b/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp
index e9698365765e7..f9c8589683ba7 100644
--- a/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp
+++ b/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp
@@ -1897,8 +1897,6 @@ LogicalResult ReduceOp::verify() {
if (getInputs().empty())
return emitOpError() << "expected at least one input";
- if (getInits().empty())
- return emitOpError() << "expected at least one output";
for (int64_t i = 1; i < getNumDpsInputs(); ++i) {
if (llvm::cast<ShapedType>(getInputs()[i].getType()).getShape() !=
diff --git a/mlir/test/Dialect/Linalg/invalid.mlir b/mlir/test/Dialect/Linalg/invalid.mlir
index a70c7ceb19bac..06f3fcb41190b 100644
--- a/mlir/test/Dialect/Linalg/invalid.mlir
+++ b/mlir/test/Dialect/Linalg/invalid.mlir
@@ -2194,3 +2194,15 @@ func.func @reduce_unequal_input_output_count(
%ext = tensor.extract %reduced[] : tensor<i32>
return %ext : i32
}
+
+// -----
+
+func.func @reduce_no_inputs() {
+ // expected-error @+1 {{'linalg.reduce' op expected at least one input}}
+ linalg.reduce
+ dimensions = []
+ () {
+ linalg.yield
+ }
+ func.return
+}
More information about the Mlir-commits
mailing list