[mlir][MemRef] NFC rename simplify-extract-strided-metadata
authorQuentin Colombet <quentin.colombet@gmail.com>
Mon, 21 Nov 2022 17:37:39 +0000 (17:37 +0000)
committerQuentin Colombet <quentin.colombet@gmail.com>
Mon, 21 Nov 2022 22:43:15 +0000 (22:43 +0000)
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

mlir/include/mlir/Dialect/MemRef/Transforms/Passes.h
mlir/include/mlir/Dialect/MemRef/Transforms/Passes.td
mlir/lib/Dialect/MemRef/Transforms/CMakeLists.txt
mlir/lib/Dialect/MemRef/Transforms/ExpandStridedMetadata.cpp [moved from mlir/lib/Dialect/MemRef/Transforms/SimplifyExtractStridedMetadata.cpp with 97% similarity]
mlir/test/Dialect/MemRef/expand-strided-metadata.mlir [moved from mlir/test/Dialect/MemRef/simplify-extract-strided-metadata.mlir with 99% similarity]

index ee30e6e..8935650 100644 (file)
@@ -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
index b416764..c0b08ee 100644 (file)
@@ -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 different 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"
   ];
index 2e2ffb4..7c65605 100644 (file)
@@ -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
@@ -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 different
+/// 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>();
 }
@@ -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>>)