[Mlir-commits] [mlir] [mlir][linalg] Fix crash in linalg.reduce verifier when inputs \!= inits count (PR #186278)

Mehdi Amini llvmlistbot at llvm.org
Mon Mar 23 06:36:06 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())
----------------
joker-eph wrote:

Done

https://github.com/llvm/llvm-project/pull/186278


More information about the Mlir-commits mailing list