[Mlir-commits] [mlir] [mlir][tosa] Fold tiled input into binary elementwise operations (PR #203941)

Luke Hutton llvmlistbot at llvm.org
Mon Jun 29 06:57:06 PDT 2026


================
@@ -2216,6 +2218,91 @@ OpFoldResult tosa::SelectOp::fold(FoldAdaptor adaptor) {
   return {};
 }
 
+static LogicalResult verifyTileIsBroadcast(tosa::TileOp tileOp) {
+  const auto inputType =
+      dyn_cast<RankedTensorType>(tileOp.getInput1().getType());
+  const auto outputType = dyn_cast<RankedTensorType>(tileOp.getType());
+  if (!inputType || !outputType)
+    return failure();
+
+  SmallVector<int64_t> multiples;
+  if (failed(tileOp.getConstantMultiples(multiples)))
+    return failure();
+
+  for (const auto [index, multiple] : llvm::enumerate(multiples)) {
+    if (multiple == 1)
+      continue;
+
+    if (inputType.isDynamicDim(index) || outputType.isDynamicDim(index))
+      return failure();
+    const int64_t inputDim = inputType.getDimSize(index);
+    if (inputDim * multiple != outputType.getDimSize(index))
+      return failure();
----------------
lhutton1 wrote:

Actually, I think we can remove it altogether - this should be checked by the verifier

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


More information about the Mlir-commits mailing list