[Mlir-commits] [mlir] [mlir][tosa] Disallow inferable dim in reshape/slice validation (PR #182472)

Sayan Saha llvmlistbot at llvm.org
Sat Feb 28 16:45:54 PST 2026


================
@@ -1214,6 +1215,47 @@ LogicalResult checkErrorIfPad(Operation *op) {
   return success();
 }
 
+LogicalResult checkErrorIfReshape(Operation *op) {
+  auto reshapeOp = dyn_cast<tosa::ReshapeOp>(op);
+  if (!reshapeOp)
+    return success();
+
+  constexpr int64_t kInferableDim = -1;
+  SmallVector<int64_t> shapeValues;
+  if (!tosa::getConstShapeValues(reshapeOp.getShape().getDefiningOp(),
+                                 shapeValues))
+    return success();
+
+  if (llvm::is_contained(shapeValues, kInferableDim))
+    return op->emitOpError("shape input contains inferable dimension (-1) "
----------------
sahas3 wrote:

Is this a recent change in tosa spec? I think tosa.reshape used to handle at least one dynamic dimension which is represented with `-1`. I think this will break some existing model support for us.

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


More information about the Mlir-commits mailing list