[Mlir-commits] [mlir] [MLIR][SCF] Fold dim ops of iter_args to respective init_args (PR #109973)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Wed Sep 25 10:41:49 PDT 2024


================
@@ -1478,6 +1478,45 @@ struct DimOfForallOp : public OpRewritePattern<tensor::DimOp> {
   }
 };
 
+/// Fold dim ops of iter_args to dim ops of their respective init args. E.g.:
+///
+/// ```
+/// %0 = ... : tensor<?x?xf32>
+/// scf.forall ... shared_outs(%arg0 = %0) -> (tensor<?x?xf32>) {
+///   %1 = tensor.dim %arg0, %c0 : tensor<?x?xf32>
+///   ...
+/// }
+/// ```
+///
+/// is folded to:
+///
+/// ```
+/// %0 = ... : tensor<?x?xf32>
+/// scf.forall ... shared_outs(%arg0 = %0) -> (tensor<?x?xf32>) {
+///   %1 = tensor.dim %0, %c0 : tensor<?x?xf32>
+///   ...
+/// }
+/// ```
+struct DimOfForallIterArg : public OpRewritePattern<tensor::DimOp> {
----------------
MaheshRavishankar wrote:

Lets not add this to canonicalize. Lets add this to https://github.com/llvm/llvm-project/blob/394f59c203c715d00be4643c20bbe22893397adf/mlir/include/mlir/Dialect/MemRef/Transforms/Transforms.h#L58 and make this work on `LoopLikeOpInterface` instead?

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


More information about the Mlir-commits mailing list