[Mlir-commits] [mlir] [mlir][linalg] Fix crash in linalg.reduce verifier when inputs \!= inits count (PR #186278)
Jakub Kuderski
llvmlistbot at llvm.org
Mon Mar 23 05:57:10 PDT 2026
================
@@ -1883,6 +1883,23 @@ void ReduceOp::print(OpAsmPrinter &p) {
LogicalResult ReduceOp::verify() {
ArrayRef<int64_t> dimensionsRef = getDimensions();
+ // The ReduceOp uses `SameVariadicOperandSize`, which requires equal numbers
+ // of inputs and inits. Detect a mismatch early: when they differ, the
+ // ODS-generated getInputs()/getInits() accessors compute each group's size
+ // via floordiv of the total operand count, producing incorrect slices that
+ // would cause out-of-bounds accesses below.
+ if (getInputs().size() != (size_t)getNumDpsInputs())
----------------
kuhar wrote:
use c++-style casts: https://llvm.org/docs/CodingStandards.html#prefer-c-style-casts
https://github.com/llvm/llvm-project/pull/186278
More information about the Mlir-commits
mailing list