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/ShapeTypeConversion.cpp b/mlir/lib/Dialect/Shape/Transforms/Bufferize.cpp rename from mlir/lib/Dialect/Shape/Transforms/ShapeTypeConversion.cpp rename to mlir/lib/Dialect/Shape/Transforms/Bufferize.cpp --- a/mlir/lib/Dialect/Shape/Transforms/ShapeTypeConversion.cpp +++ b/mlir/lib/Dialect/Shape/Transforms/Bufferize.cpp @@ -1,16 +1,12 @@ -//====----- ShapeTypeConversion.cpp - Shape Type Conversions ----*- C++-*--===// +//====----- Bufferize.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. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// -// -// This file defines patterns to convert types of inputs and outputs to shape -// operations to be memrefs instead of tensors. -// -//===----------------------------------------------------------------------===// +#include "mlir/Transforms/Bufferize.h" #include "PassDetail.h" #include "mlir/Dialect/Shape/IR/Shape.h" #include "mlir/Dialect/Shape/Transforms/Passes.h" @@ -18,7 +14,6 @@ #include "mlir/IR/Operation.h" #include "mlir/IR/StandardTypes.h" #include "mlir/Pass/Pass.h" -#include "mlir/Transforms/Bufferize.h" using namespace mlir; using namespace mlir::shape; @@ -53,8 +48,7 @@ } }; -struct ShapeTensorToMemrefPass - : public ShapeTensorToMemrefBase { +struct ShapeBufferizePass : public ShapeBufferizeBase { void runOnFunction() override { MLIRContext &ctx = getContext(); @@ -87,9 +81,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/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 + Bufferize.cpp RemoveShapeConstraints.cpp - ShapeTypeConversion.cpp ShapeToShapeLowering.cpp ADDITIONAL_HEADER_DIRS 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 } - -