Skip to content

Commit bc156b5

Browse files
author
git apple-llvm automerger
committed
Merge commit '6b30fb765394' from llvm.org/master into apple/main
2 parents 9aea541 + 6b30fb7 commit bc156b5

File tree

5 files changed

+17
-22
lines changed

5 files changed

+17
-22
lines changed

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,12 @@ std::unique_ptr<FunctionPass> createRemoveShapeConstraintsPass();
4343
void populateShapeTypeConversionPatterns(
4444
MLIRContext *ctx, BufferAssignmentTypeConverter &converter,
4545
OwningRewritePatternList &patterns);
46-
// Collects a set of patterns to replace tensors as inputs and outputs to shape
47-
// operations with buffers. This only modifies the shape operations.
48-
std::unique_ptr<FunctionPass> createShapeTensorToMemrefPass();
46+
// Bufferizes shape dialect ops.
47+
//
48+
// Note that most shape dialect ops must be converted to std before
49+
// bufferization happens, as they are intended to be bufferized at the std
50+
// level.
51+
std::unique_ptr<FunctionPass> createShapeBufferizePass();
4952

5053
//===----------------------------------------------------------------------===//
5154
// Registration

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ def ShapeToShapeLowering : FunctionPass<"shape-to-shape-lowering"> {
2222
}
2323

2424
// TODO: Generalize this to allow any type conversions desired.
25-
def ShapeTensorToMemref : FunctionPass<"shape-tensor-to-memref"> {
26-
let summary = "Replace tensors involving shape operations with memrefs";
27-
let constructor = "mlir::createShapeTensorToMemrefPass()";
25+
def ShapeBufferize : FunctionPass<"shape-bufferize"> {
26+
let summary = "Bufferize the shape dialect.";
27+
let constructor = "mlir::createShapeBufferizePass()";
2828
}
2929
#endif // MLIR_DIALECT_SHAPE_TRANSFORMS_PASSES

mlir/lib/Dialect/Shape/Transforms/ShapeTypeConversion.cpp renamed to mlir/lib/Dialect/Shape/Transforms/Bufferize.cpp

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,19 @@
1-
//====----- ShapeTypeConversion.cpp - Shape Type Conversions ----*- C++-*--===//
1+
//====----- Bufferize.cpp - Bufferization of shape ops ---------*- C++-*--===//
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
//===----------------------------------------------------------------------===//
8-
//
9-
// This file defines patterns to convert types of inputs and outputs to shape
10-
// operations to be memrefs instead of tensors.
11-
//
12-
//===----------------------------------------------------------------------===//
138

9+
#include "mlir/Transforms/Bufferize.h"
1410
#include "PassDetail.h"
1511
#include "mlir/Dialect/Shape/IR/Shape.h"
1612
#include "mlir/Dialect/Shape/Transforms/Passes.h"
1713
#include "mlir/Dialect/StandardOps/IR/Ops.h"
1814
#include "mlir/IR/Operation.h"
1915
#include "mlir/IR/StandardTypes.h"
2016
#include "mlir/Pass/Pass.h"
21-
#include "mlir/Transforms/Bufferize.h"
2217

2318
using namespace mlir;
2419
using namespace mlir::shape;
@@ -53,8 +48,7 @@ class TypeConversionAssumingOpConverter
5348
}
5449
};
5550

56-
struct ShapeTensorToMemrefPass
57-
: public ShapeTensorToMemrefBase<ShapeTensorToMemrefPass> {
51+
struct ShapeBufferizePass : public ShapeBufferizeBase<ShapeBufferizePass> {
5852
void runOnFunction() override {
5953
MLIRContext &ctx = getContext();
6054

@@ -87,9 +81,9 @@ void mlir::populateShapeTypeConversionPatterns(
8781
}
8882

8983
//===----------------------------------------------------------------------===//
90-
// ShapeTensorToMemrefPass construction
84+
// ShapeBufferizePass construction
9185
//===----------------------------------------------------------------------===//
9286

93-
std::unique_ptr<FunctionPass> mlir::createShapeTensorToMemrefPass() {
94-
return std::make_unique<ShapeTensorToMemrefPass>();
87+
std::unique_ptr<FunctionPass> mlir::createShapeBufferizePass() {
88+
return std::make_unique<ShapeBufferizePass>();
9589
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
add_mlir_dialect_library(MLIRShapeOpsTransforms
2+
Bufferize.cpp
23
RemoveShapeConstraints.cpp
3-
ShapeTypeConversion.cpp
44
ShapeToShapeLowering.cpp
55

66
ADDITIONAL_HEADER_DIRS

mlir/test/Dialect/Shape/shape-type-conversion.mlir renamed to mlir/test/Dialect/Shape/bufferize.mlir

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: mlir-opt -split-input-file -shape-tensor-to-memref <%s | FileCheck %s
1+
// RUN: mlir-opt -split-input-file -shape-bufferize <%s | FileCheck %s
22

33
// -----
44
// Check that shape.assuming returns a memref.
@@ -14,5 +14,3 @@ func @shape_assuming_returns_memref() {
1414
"test.sink"(%1) : (tensor<2xf16>) -> ()
1515
return
1616
}
17-
18-

0 commit comments

Comments
 (0)