diff --git a/mlir/include/mlir/Dialect/Shape/Transforms/Passes.h b/mlir/include/mlir/Dialect/Shape/Transforms/Passes.h --- a/mlir/include/mlir/Dialect/Shape/Transforms/Passes.h +++ b/mlir/include/mlir/Dialect/Shape/Transforms/Passes.h @@ -43,9 +43,12 @@ void populateShapeTypeConversionPatterns( MLIRContext *ctx, BufferAssignmentTypeConverter &converter, OwningRewritePatternList &patterns); -// Collects a set of patterns to replace tensors as inputs and outputs to shape -// operations with buffers. This only modifies the shape operations. -std::unique_ptr createShapeTensorToMemrefPass(); +// Bufferizes shape dialect ops. +// +// Note that most shape dialect ops must be converted to std before +// bufferization happens, as they are intended to be bufferized at the std +// level. +std::unique_ptr createShapeBufferizePass(); //===----------------------------------------------------------------------===// // Registration diff --git a/mlir/include/mlir/Dialect/Shape/Transforms/Passes.td b/mlir/include/mlir/Dialect/Shape/Transforms/Passes.td --- a/mlir/include/mlir/Dialect/Shape/Transforms/Passes.td +++ b/mlir/include/mlir/Dialect/Shape/Transforms/Passes.td @@ -22,8 +22,8 @@ } // TODO: Generalize this to allow any type conversions desired. -def ShapeTensorToMemref : FunctionPass<"shape-tensor-to-memref"> { - let summary = "Replace tensors involving shape operations with memrefs"; - let constructor = "mlir::createShapeTensorToMemrefPass()"; +def ShapeBufferize : FunctionPass<"shape-bufferize"> { + let summary = "Bufferize the shape dialect."; + let constructor = "mlir::createShapeBufferizePass()"; } #endif // MLIR_DIALECT_SHAPE_TRANSFORMS_PASSES diff --git a/mlir/lib/Dialect/Shape/Transforms/CMakeLists.txt b/mlir/lib/Dialect/Shape/Transforms/CMakeLists.txt --- a/mlir/lib/Dialect/Shape/Transforms/CMakeLists.txt +++ b/mlir/lib/Dialect/Shape/Transforms/CMakeLists.txt @@ -1,6 +1,6 @@ add_mlir_dialect_library(MLIRShapeOpsTransforms RemoveShapeConstraints.cpp - ShapeTypeConversion.cpp + ShapeBufferize.cpp ShapeToShapeLowering.cpp ADDITIONAL_HEADER_DIRS diff --git a/mlir/lib/Dialect/Shape/Transforms/ShapeTypeConversion.cpp b/mlir/lib/Dialect/Shape/Transforms/ShapeBufferize.cpp rename from mlir/lib/Dialect/Shape/Transforms/ShapeTypeConversion.cpp rename to mlir/lib/Dialect/Shape/Transforms/ShapeBufferize.cpp --- a/mlir/lib/Dialect/Shape/Transforms/ShapeTypeConversion.cpp +++ b/mlir/lib/Dialect/Shape/Transforms/ShapeBufferize.cpp @@ -1,4 +1,4 @@ -//====----- ShapeTypeConversion.cpp - Shape Type Conversions ----*- C++-*--===// +//====----- ShapeBufferize.cpp - Bufferization of shape ops ----*- C++-*--===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -6,8 +6,7 @@ // //===----------------------------------------------------------------------===// // -// This file defines patterns to convert types of inputs and outputs to shape -// operations to be memrefs instead of tensors. +// This file defines a bufferization pass for the shape dialect. // //===----------------------------------------------------------------------===// @@ -53,8 +52,7 @@ } }; -struct ShapeTensorToMemrefPass - : public ShapeTensorToMemrefBase { +struct ShapeBufferizePass : public ShapeBufferizeBase { void runOnFunction() override { MLIRContext &ctx = getContext(); @@ -87,9 +85,9 @@ } //===----------------------------------------------------------------------===// -// ShapeTensorToMemrefPass construction +// ShapeBufferizePass construction //===----------------------------------------------------------------------===// -std::unique_ptr mlir::createShapeTensorToMemrefPass() { - return std::make_unique(); +std::unique_ptr mlir::createShapeBufferizePass() { + return std::make_unique(); } diff --git a/mlir/test/Dialect/Shape/shape-type-conversion.mlir b/mlir/test/Dialect/Shape/bufferize.mlir rename from mlir/test/Dialect/Shape/shape-type-conversion.mlir rename to mlir/test/Dialect/Shape/bufferize.mlir --- a/mlir/test/Dialect/Shape/shape-type-conversion.mlir +++ b/mlir/test/Dialect/Shape/bufferize.mlir @@ -1,4 +1,4 @@ -// RUN: mlir-opt -split-input-file -shape-tensor-to-memref <%s | FileCheck %s +// RUN: mlir-opt -split-input-file -shape-bufferize <%s | FileCheck %s // ----- // Check that shape.assuming returns a memref. @@ -14,5 +14,3 @@ "test.sink"(%1) : (tensor<2xf16>) -> () return } - -