[Mlir-commits] [mlir] [DRAFT] Generalize expand_shape to take shape as explicit input (PR #69267)

Gaurav Shukla llvmlistbot at llvm.org
Thu Oct 26 09:55:56 PDT 2023


================
@@ -197,8 +197,21 @@ class ReshapeConverterExpand : public OpConversionPattern<tosa::ReshapeOp> {
       return rewriter.notifyMatchFailure(
           reshape, "tosa.reshape Cannot expand into given shape");
     }
+
+    Value input = adaptor.getInput1();
+    SmallVector<OpFoldResult> inputShape =
+        tensor::getMixedSizes(rewriter, reshape.getLoc(), input);
+    SmallVector<OpFoldResult> outputShape;
+    if (failed(tensor::ExpandShapeOp::inferOutputShape(
----------------
Shukla-Gaurav wrote:

I have added a helper build method which can infer the output shape. But in the cases where we can not infer output shapes, it's assert vs failure. With the helper build method, in case the output shapes can not be inferred, it breaks with assert(let me know if there is better way?). 

If the helper build method seems fine, I will update other parts of the code to use this build method.
cc: @ramiro050 

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


More information about the Mlir-commits mailing list