Skip to content

Commit 8b97b4e

Browse files
committed
[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
1 parent b78d538 commit 8b97b4e

File tree

5 files changed

+31
-31
lines changed

5 files changed

+31
-31
lines changed

mlir/include/mlir/Dialect/MemRef/Transforms/Passes.h

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,9 @@ void populateResolveRankedShapeTypeResultDimsPatterns(
5959
/// terms of shapes of its input operands.
6060
void populateResolveShapedTypeResultDimsPatterns(RewritePatternSet &patterns);
6161

62-
/// Appends patterns for simplifying extract_strided_metadata(other_op) into
63-
/// easier to analyze constructs.
64-
void populateSimplifyExtractStridedMetadataOpPatterns(
65-
RewritePatternSet &patterns);
62+
/// Appends patterns for expanding memref operations that modify the metadata
63+
/// (sizes, offset, strides) of a memref into easier to analyze constructs.
64+
void populateExpandStridedMetadataPatterns(RewritePatternSet &patterns);
6665

6766
/// Appends patterns for emulating wide integer memref operations with ops over
6867
/// narrower integer types.
@@ -135,10 +134,9 @@ std::unique_ptr<Pass> createResolveRankedShapeTypeResultDimsPass();
135134
/// in terms of shapes of its input operands.
136135
std::unique_ptr<Pass> createResolveShapedTypeResultDimsPass();
137136

138-
/// Creates an operation pass to simplify
139-
/// `extract_strided_metadata(other_op(memref))` into
140-
/// `extract_strided_metadata(memref)`.
141-
std::unique_ptr<Pass> createSimplifyExtractStridedMetadataPass();
137+
/// Creates an operation pass to expand some memref operation into
138+
/// easier to reason about operations.
139+
std::unique_ptr<Pass> createExpandStridedMetadataPass();
142140

143141
//===----------------------------------------------------------------------===//
144142
// Registration

mlir/include/mlir/Dialect/MemRef/Transforms/Passes.td

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -189,15 +189,16 @@ def ResolveShapedTypeResultDims : Pass<"resolve-shaped-type-result-dims"> {
189189
];
190190
}
191191

192-
def SimplifyExtractStridedMetadata : Pass<"simplify-extract-strided-metadata"> {
193-
let summary = "Simplify extract_strided_metadata ops";
192+
def ExpandStridedMetadata : Pass<"expand-strided-metadata"> {
193+
let summary = "Expand memref operations into easier to analyze constructs";
194194
let description = [{
195-
The pass simplifies extract_strided_metadata(other_op(memref)) to
196-
extract_strided_metadata(memref) when it is possible to model the effect
197-
of other_op directly with affine maps applied to the result of
198-
extract_strided_metadata.
195+
The pass expands memref operations that modify the metadata of a memref
196+
(sizes, offset, strides) into a sequence of easier to analyze constructs.
197+
In particular, this pass transforms operations into explicit sequence of
198+
operations that model the effect of this operation on the different metadata.
199+
This pass uses affine constructs to materialize these effects.
199200
}];
200-
let constructor = "mlir::memref::createSimplifyExtractStridedMetadataPass()";
201+
let constructor = "mlir::memref::createExpandStridedMetadataPass()";
201202
let dependentDialects = [
202203
"AffineDialect", "memref::MemRefDialect"
203204
];

mlir/lib/Dialect/MemRef/Transforms/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
add_mlir_dialect_library(MLIRMemRefTransforms
22
ComposeSubView.cpp
33
ExpandOps.cpp
4+
ExpandStridedMetadata.cpp
45
EmulateWideInt.cpp
56
FoldMemRefAliasOps.cpp
67
MultiBuffer.cpp
78
NormalizeMemRefs.cpp
89
ResolveShapedTypeResultDims.cpp
9-
SimplifyExtractStridedMetadata.cpp
1010

1111
ADDITIONAL_HEADER_DIRS
1212
${MLIR_MAIN_INCLUDE_DIR}/mlir/Dialect/MemRef

mlir/lib/Dialect/MemRef/Transforms/SimplifyExtractStridedMetadata.cpp renamed to mlir/lib/Dialect/MemRef/Transforms/ExpandStridedMetadata.cpp

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
1-
//===- SimplifyExtractStridedMetadata.cpp - Simplify this operation -------===//
1+
//===- ExpandStridedMetadata.cpp - Simplify this operation -------===//
22
//
33
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
44
// See https://llvm.org/LICENSE.txt for license information.
55
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
66
//
77
//===----------------------------------------------------------------------===//
88
//
9-
/// This pass simplifies extract_strided_metadata(other_op(memref) to
10-
/// extract_strided_metadata(memref) when it is possible to express the effect
11-
// of other_op using affine apply on the results of
12-
// extract_strided_metadata(memref).
9+
/// The pass expands memref operations that modify the metadata of a memref
10+
/// (sizes, offset, strides) into a sequence of easier to analyze constructs.
11+
/// In particular, this pass transforms operations into explicit sequence of
12+
/// operations that model the effect of this operation on the different
13+
/// metadata. This pass uses affine constructs to materialize these effects.
1314
//===----------------------------------------------------------------------===//
1415

1516
#include "mlir/Dialect/Affine/IR/AffineOps.h"
@@ -23,7 +24,7 @@
2324

2425
namespace mlir {
2526
namespace memref {
26-
#define GEN_PASS_DEF_SIMPLIFYEXTRACTSTRIDEDMETADATA
27+
#define GEN_PASS_DEF_EXPANDSTRIDEDMETADATA
2728
#include "mlir/Dialect/MemRef/Transforms/Passes.h.inc"
2829
} // namespace memref
2930
} // namespace mlir
@@ -736,7 +737,7 @@ class ExtractStridedMetadataOpExtractStridedMetadataFolder
736737
};
737738
} // namespace
738739

739-
void memref::populateSimplifyExtractStridedMetadataOpPatterns(
740+
void memref::populateExpandStridedMetadataPatterns(
740741
RewritePatternSet &patterns) {
741742
patterns.add<SubviewFolder,
742743
ReshapeFolder<memref::ExpandShapeOp, getExpandedSizes,
@@ -757,21 +758,21 @@ void memref::populateSimplifyExtractStridedMetadataOpPatterns(
757758

758759
namespace {
759760

760-
struct SimplifyExtractStridedMetadataPass final
761-
: public memref::impl::SimplifyExtractStridedMetadataBase<
762-
SimplifyExtractStridedMetadataPass> {
761+
struct ExpandStridedMetadataPass final
762+
: public memref::impl::ExpandStridedMetadataBase<
763+
ExpandStridedMetadataPass> {
763764
void runOnOperation() override;
764765
};
765766

766767
} // namespace
767768

768-
void SimplifyExtractStridedMetadataPass::runOnOperation() {
769+
void ExpandStridedMetadataPass::runOnOperation() {
769770
RewritePatternSet patterns(&getContext());
770-
memref::populateSimplifyExtractStridedMetadataOpPatterns(patterns);
771+
memref::populateExpandStridedMetadataPatterns(patterns);
771772
(void)applyPatternsAndFoldGreedily(getOperation()->getRegions(),
772773
std::move(patterns));
773774
}
774775

775-
std::unique_ptr<Pass> memref::createSimplifyExtractStridedMetadataPass() {
776-
return std::make_unique<SimplifyExtractStridedMetadataPass>();
776+
std::unique_ptr<Pass> memref::createExpandStridedMetadataPass() {
777+
return std::make_unique<ExpandStridedMetadataPass>();
777778
}

mlir/test/Dialect/MemRef/simplify-extract-strided-metadata.mlir renamed to mlir/test/Dialect/MemRef/expand-strided-metadata.mlir

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: mlir-opt --simplify-extract-strided-metadata -split-input-file %s -o - | FileCheck %s
1+
// RUN: mlir-opt --expand-strided-metadata -split-input-file %s -o - | FileCheck %s
22

33
// CHECK-LABEL: func @extract_strided_metadata_constants
44
// CHECK-SAME: (%[[ARG:.*]]: memref<5x4xf32, strided<[4, 1], offset: 2>>)

0 commit comments

Comments
 (0)