[Mlir-commits] [mlir] [mlir][tosa] Add concat_shape Op folder (PR #183293)

Udaya Ranga llvmlistbot at llvm.org
Thu Mar 12 03:31:43 PDT 2026


================
@@ -2020,6 +2020,40 @@ OpFoldResult tosa::DimOp::fold(FoldAdaptor adaptor) {
   return DenseElementsAttr::get(resultAttrTy, dimSize);
 }
 
+OpFoldResult concatShapeFold(tosa::ConcatShapeOp *op) {
+  auto const inputs = op->getInput();
+
+  if (inputs.empty())
+    return {};
+
+  SmallVector<APInt> concatDims;
+  concatDims.reserve(/*max elem*/ 64);
+  for (auto const &v : inputs) {
+    auto vConstShape = dyn_cast<tosa::ConstShapeOp>(v.getDefiningOp());
+    if (!vConstShape)
+      return {};
+
+    const auto vAttr = cast<DenseElementsAttr>(vConstShape.getValues());
----------------
udaya-ranga wrote:

Replaced `if{}` with `assert`. My concern is if the tablegen definitions change, there's no obviously way of knowing without failing.

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


More information about the Mlir-commits mailing list