[Mlir-commits] [mlir] 8b97b4e - [mlir][MemRef] NFC rename simplify-extract-strided-metadata

Quentin Colombet llvmlistbot at llvm.org
Mon Nov 21 14:49:24 PST 2022


Author: Quentin Colombet
Date: 2022-11-21T22:43:15Z
New Revision: 8b97b4e7ee285539b37a8a88a2d38ae5719c1dfc

URL: https://github.com/llvm/llvm-project/commit/8b97b4e7ee285539b37a8a88a2d38ae5719c1dfc
DIFF: https://github.com/llvm/llvm-project/commit/8b97b4e7ee285539b37a8a88a2d38ae5719c1dfc.diff

LOG: [mlir][MemRef] NFC rename simplify-extract-strided-metadata

This pass has outgrown its original goal and is now going to be used to
expand certain memref operations before lowering.
Reflect that in the name.

The pass is now called expand-strided-metadata.

NFC

Differential Revision: https://reviews.llvm.org/D138448

Added: 
    mlir/lib/Dialect/MemRef/Transforms/ExpandStridedMetadata.cpp
    mlir/test/Dialect/MemRef/expand-strided-metadata.mlir

Modified: 
    mlir/include/mlir/Dialect/MemRef/Transforms/Passes.h
    mlir/include/mlir/Dialect/MemRef/Transforms/Passes.td
    mlir/lib/Dialect/MemRef/Transforms/CMakeLists.txt

Removed: 
    mlir/lib/Dialect/MemRef/Transforms/SimplifyExtractStridedMetadata.cpp
    mlir/test/Dialect/MemRef/simplify-extract-strided-metadata.mlir


################################################################################
diff  --git a/mlir/include/mlir/Dialect/MemRef/Transforms/Passes.h b/mlir/include/mlir/Dialect/MemRef/Transforms/Passes.h
index ee30e6e252dff..8935650eed9c9 100644
--- a/mlir/include/mlir/Dialect/MemRef/Transforms/Passes.h
+++ b/mlir/include/mlir/Dialect/MemRef/Transforms/Passes.h
@@ -59,10 +59,9 @@ void populateResolveRankedShapeTypeResultDimsPatterns(
 /// terms of shapes of its input operands.
 void populateResolveShapedTypeResultDimsPatterns(RewritePatternSet &patterns);
 
-/// Appends patterns for simplifying extract_strided_metadata(other_op) into
-/// easier to analyze constructs.
-void populateSimplifyExtractStridedMetadataOpPatterns(
-    RewritePatternSet &patterns);
+/// Appends patterns for expanding memref operations that modify the metadata
+/// (sizes, offset, strides) of a memref into easier to analyze constructs.
+void populateExpandStridedMetadataPatterns(RewritePatternSet &patterns);
 
 /// Appends patterns for emulating wide integer memref operations with ops over
 /// narrower integer types.
@@ -135,10 +134,9 @@ std::unique_ptr<Pass> createResolveRankedShapeTypeResultDimsPass();
 /// in terms of shapes of its input operands.
 std::unique_ptr<Pass> createResolveShapedTypeResultDimsPass();
 
-/// Creates an operation pass to simplify
-/// `extract_strided_metadata(other_op(memref))` into
-/// `extract_strided_metadata(memref)`.
-std::unique_ptr<Pass> createSimplifyExtractStridedMetadataPass();
+/// Creates an operation pass to expand some memref operation into
+/// easier to reason about operations.
+std::unique_ptr<Pass> createExpandStridedMetadataPass();
 
 //===----------------------------------------------------------------------===//
 // Registration

diff  --git a/mlir/include/mlir/Dialect/MemRef/Transforms/Passes.td b/mlir/include/mlir/Dialect/MemRef/Transforms/Passes.td
index b41676482a889..c0b08ee34ce2c 100644
--- a/mlir/include/mlir/Dialect/MemRef/Transforms/Passes.td
+++ b/mlir/include/mlir/Dialect/MemRef/Transforms/Passes.td
@@ -189,15 +189,16 @@ def ResolveShapedTypeResultDims : Pass<"resolve-shaped-type-result-dims"> {
   ];
 }
 
-def SimplifyExtractStridedMetadata : Pass<"simplify-extract-strided-metadata"> {
-  let summary = "Simplify extract_strided_metadata ops";
+def ExpandStridedMetadata : Pass<"expand-strided-metadata"> {
+  let summary = "Expand memref operations into easier to analyze constructs";
   let description = [{
-    The pass simplifies extract_strided_metadata(other_op(memref)) to
-    extract_strided_metadata(memref) when it is possible to model the effect
-    of other_op directly with affine maps applied to the result of
-    extract_strided_metadata.
+    The pass expands memref operations that modify the metadata of a memref
+    (sizes, offset, strides) into a sequence of easier to analyze constructs.
+    In particular, this pass transforms operations into explicit sequence of
+    operations that model the effect of this operation on the 
diff erent metadata.
+    This pass uses affine constructs to materialize these effects.
   }];
-  let constructor = "mlir::memref::createSimplifyExtractStridedMetadataPass()";
+  let constructor = "mlir::memref::createExpandStridedMetadataPass()";
   let dependentDialects = [
       "AffineDialect", "memref::MemRefDialect"
   ];

diff  --git a/mlir/lib/Dialect/MemRef/Transforms/CMakeLists.txt b/mlir/lib/Dialect/MemRef/Transforms/CMakeLists.txt
index 2e2ffb491fb75..7c65605500787 100644
--- a/mlir/lib/Dialect/MemRef/Transforms/CMakeLists.txt
+++ b/mlir/lib/Dialect/MemRef/Transforms/CMakeLists.txt
@@ -1,12 +1,12 @@
 add_mlir_dialect_library(MLIRMemRefTransforms
   ComposeSubView.cpp
   ExpandOps.cpp
+  ExpandStridedMetadata.cpp
   EmulateWideInt.cpp
   FoldMemRefAliasOps.cpp
   MultiBuffer.cpp
   NormalizeMemRefs.cpp
   ResolveShapedTypeResultDims.cpp
-  SimplifyExtractStridedMetadata.cpp
 
   ADDITIONAL_HEADER_DIRS
   ${MLIR_MAIN_INCLUDE_DIR}/mlir/Dialect/MemRef

diff  --git a/mlir/lib/Dialect/MemRef/Transforms/SimplifyExtractStridedMetadata.cpp b/mlir/lib/Dialect/MemRef/Transforms/ExpandStridedMetadata.cpp
similarity index 97%
rename from mlir/lib/Dialect/MemRef/Transforms/SimplifyExtractStridedMetadata.cpp
rename to mlir/lib/Dialect/MemRef/Transforms/ExpandStridedMetadata.cpp
index 9d2713f0e8225..549108d3b8f4e 100644
--- a/mlir/lib/Dialect/MemRef/Transforms/SimplifyExtractStridedMetadata.cpp
+++ b/mlir/lib/Dialect/MemRef/Transforms/ExpandStridedMetadata.cpp
@@ -1,4 +1,4 @@
-//===- SimplifyExtractStridedMetadata.cpp - Simplify this operation -------===//
+//===- ExpandStridedMetadata.cpp - Simplify this operation -------===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -6,10 +6,11 @@
 //
 //===----------------------------------------------------------------------===//
 //
-/// This pass simplifies extract_strided_metadata(other_op(memref) to
-/// extract_strided_metadata(memref) when it is possible to express the effect
-// of other_op using affine apply on the results of
-// extract_strided_metadata(memref).
+/// The pass expands memref operations that modify the metadata of a memref
+/// (sizes, offset, strides) into a sequence of easier to analyze constructs.
+/// In particular, this pass transforms operations into explicit sequence of
+/// operations that model the effect of this operation on the 
diff erent
+/// metadata. This pass uses affine constructs to materialize these effects.
 //===----------------------------------------------------------------------===//
 
 #include "mlir/Dialect/Affine/IR/AffineOps.h"
@@ -23,7 +24,7 @@
 
 namespace mlir {
 namespace memref {
-#define GEN_PASS_DEF_SIMPLIFYEXTRACTSTRIDEDMETADATA
+#define GEN_PASS_DEF_EXPANDSTRIDEDMETADATA
 #include "mlir/Dialect/MemRef/Transforms/Passes.h.inc"
 } // namespace memref
 } // namespace mlir
@@ -736,7 +737,7 @@ class ExtractStridedMetadataOpExtractStridedMetadataFolder
 };
 } // namespace
 
-void memref::populateSimplifyExtractStridedMetadataOpPatterns(
+void memref::populateExpandStridedMetadataPatterns(
     RewritePatternSet &patterns) {
   patterns.add<SubviewFolder,
                ReshapeFolder<memref::ExpandShapeOp, getExpandedSizes,
@@ -757,21 +758,21 @@ void memref::populateSimplifyExtractStridedMetadataOpPatterns(
 
 namespace {
 
-struct SimplifyExtractStridedMetadataPass final
-    : public memref::impl::SimplifyExtractStridedMetadataBase<
-          SimplifyExtractStridedMetadataPass> {
+struct ExpandStridedMetadataPass final
+    : public memref::impl::ExpandStridedMetadataBase<
+          ExpandStridedMetadataPass> {
   void runOnOperation() override;
 };
 
 } // namespace
 
-void SimplifyExtractStridedMetadataPass::runOnOperation() {
+void ExpandStridedMetadataPass::runOnOperation() {
   RewritePatternSet patterns(&getContext());
-  memref::populateSimplifyExtractStridedMetadataOpPatterns(patterns);
+  memref::populateExpandStridedMetadataPatterns(patterns);
   (void)applyPatternsAndFoldGreedily(getOperation()->getRegions(),
                                      std::move(patterns));
 }
 
-std::unique_ptr<Pass> memref::createSimplifyExtractStridedMetadataPass() {
-  return std::make_unique<SimplifyExtractStridedMetadataPass>();
+std::unique_ptr<Pass> memref::createExpandStridedMetadataPass() {
+  return std::make_unique<ExpandStridedMetadataPass>();
 }

diff  --git a/mlir/test/Dialect/MemRef/simplify-extract-strided-metadata.mlir b/mlir/test/Dialect/MemRef/expand-strided-metadata.mlir
similarity index 99%
rename from mlir/test/Dialect/MemRef/simplify-extract-strided-metadata.mlir
rename to mlir/test/Dialect/MemRef/expand-strided-metadata.mlir
index d7f2dfdb77b31..52e181f10697f 100644
--- a/mlir/test/Dialect/MemRef/simplify-extract-strided-metadata.mlir
+++ b/mlir/test/Dialect/MemRef/expand-strided-metadata.mlir
@@ -1,4 +1,4 @@
-// RUN: mlir-opt --simplify-extract-strided-metadata -split-input-file %s -o - | FileCheck %s
+// RUN: mlir-opt --expand-strided-metadata -split-input-file %s -o - | FileCheck %s
 
 // CHECK-LABEL: func @extract_strided_metadata_constants
 //  CHECK-SAME: (%[[ARG:.*]]: memref<5x4xf32, strided<[4, 1], offset: 2>>)


        


More information about the Mlir-commits mailing list