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

Aart Bik llvmlistbot at llvm.org
Mon Apr 8 14:47:50 PDT 2024


================
@@ -952,8 +952,15 @@ struct ReshapeRewriter : public OpRewritePattern<ReshapeOp> {
       auto rtp = getRankedTensorType(op.getResult());
       auto denseTp =
           RankedTensorType::get(rtp.getShape(), rtp.getElementType());
-      auto reshape = rewriter.create<ReshapeOp>(loc, denseTp, op.getSrc(),
-                                                op.getReassociation());
+      ReshapeOp reshape;
+      if constexpr (std::is_same<ReshapeOp, tensor::ExpandShapeOp>::value) {
----------------
aartbik wrote:

can this be hidden inside a templated "create" helper method, so we don't get such a huge if-then-else block?

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


More information about the Mlir-commits mailing list