[Mlir-commits] [mlir] [mlir][tosa] Add concat_shape Op folder (PR #183293)
Luke Hutton
llvmlistbot at llvm.org
Thu Mar 12 09:31:57 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());
+ if (!vAttr)
+ return {};
+
+ const auto vETy = vAttr.getElementType();
+ (void)vETy;
+ assert(vETy.isIntOrIndex());
----------------
lhutton1 wrote:
Thanks for the update, but I suspect this could result in an unused variable compiler warning. Since `vETy` isn't used anywhere else other than the assert, it's best not to create it
https://github.com/llvm/llvm-project/pull/183293
More information about the Mlir-commits
mailing list