[Mlir-commits] [mlir] [mlir][tosa] Enhance TosaInferShapes pass for simple shape inference (PR #178418)

Luke Hutton llvmlistbot at llvm.org
Mon Feb 23 05:29:35 PST 2026


================
@@ -333,13 +161,252 @@ void validateSameOperandsAndResultRankTrait(Region &region) {
 struct TosaInferShapes
     : public tosa::impl::TosaInferShapesPassBase<TosaInferShapes> {
 public:
+  explicit TosaInferShapes() = default;
+  explicit TosaInferShapes(const TosaInferShapesPassOptions &options)
+      : TosaInferShapes() {
+    this->foldShapeExpressions = options.foldShapeExpressions;
+    this->convertFunctionBoundaries = options.convertFunctionBoundaries;
+  }
+
   void runOnOperation() override {
     func::FuncOp func = getOperation();
     TypeModificationState state;
     propagateShapesInRegion(func.getBody(), state);
     state.commit();
 
     validateSameOperandsAndResultRankTrait(func.getBody());
+
+    if (convertFunctionBoundaries)
+      convertFunctionReturnTypes(func);
----------------
lhutton1 wrote:

Yep it does leave dead const_shape ops around. I thought about adding something like this, but thought a user can just as easily run the `--remove-dead-values` pass after `--tosa-infer-shapes` to clean up. In the latest commit I've added a clean up step as a result of folding.

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


More information about the Mlir-commits mailing list