[Mlir-commits] [mlir] [MLIR][TOSA] Guard scatter lowering against unranked operand (PR #178188)

Luke Hutton llvmlistbot at llvm.org
Tue Jan 27 05:23:09 PST 2026


================
@@ -101,6 +101,14 @@ class ScatterOpConverter : public OpRewritePattern<tosa::ScatterOp> {
     auto input = scatter.getInput();
     auto loc = scatter.getLoc();
 
+    auto valuesType = dyn_cast<RankedTensorType>(valuesIn.getType());
+    auto indicesType = dyn_cast<RankedTensorType>(indices.getType());
+    auto inputType = dyn_cast<RankedTensorType>(input.getType());
+    if (!valuesType || !indicesType || !inputType ||
+        valuesType.getRank() != 3 || inputType.getRank() != 3 ||
----------------
lhutton1 wrote:

We don't need to check the size of the rank since this is enforced by the tablegen definition of the op. See https://github.com/llvm/llvm-project/blob/f010621809b3fab9f3d64fa39699ea5c0c11e699/mlir/include/mlir/Dialect/Tosa/IR/TosaOps.td#L2347

Given this, we can just check the type `isa<RankedTensorType>()` and avoid the dynamic cast

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


More information about the Mlir-commits mailing list