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<FunctionPass> 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<FunctionPass> createShapeBufferizePass();
//===----------------------------------------------------------------------===//
// Registration
}
// 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
-//====----- 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"
#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;
}
};
-struct ShapeTensorToMemrefPass
- : public ShapeTensorToMemrefBase<ShapeTensorToMemrefPass> {
+struct ShapeBufferizePass : public ShapeBufferizeBase<ShapeBufferizePass> {
void runOnFunction() override {
MLIRContext &ctx = getContext();
}
//===----------------------------------------------------------------------===//
-// ShapeTensorToMemrefPass construction
+// ShapeBufferizePass construction
//===----------------------------------------------------------------------===//
-std::unique_ptr<FunctionPass> mlir::createShapeTensorToMemrefPass() {
- return std::make_unique<ShapeTensorToMemrefPass>();
+std::unique_ptr<FunctionPass> mlir::createShapeBufferizePass() {
+ return std::make_unique<ShapeBufferizePass>();
}