18#define GEN_PASS_DEF_EMPTYTENSORTOALLOCTENSORPASS
19#include "mlir/Dialect/Bufferization/Transforms/Passes.h.inc"
28struct EmptyTensorLoweringPattern :
public OpRewritePattern<tensor::EmptyOp> {
29 using OpRewritePattern<tensor::EmptyOp>::OpRewritePattern;
31 LogicalResult matchAndRewrite(tensor::EmptyOp op,
32 PatternRewriter &rewriter)
const override {
34 op, op.getType(), op.getDynamicSizes());
39struct EmptyTensorToAllocTensor
41 EmptyTensorToAllocTensor> {
42 void runOnOperation()
override;
44 void getDependentDialects(DialectRegistry ®istry)
const override {
46 .
insert<tensor::TensorDialect, bufferization::BufferizationDialect>();
56void EmptyTensorToAllocTensor::runOnOperation() {
Operation is the basic unit of execution within MLIR.
MLIRContext * getContext()
Return the context this operation is associated with.
OpTy replaceOpWithNewOp(Operation *op, Args &&...args)
Replace the results of the given (original) op with a new op that is created without verification (re...
void populateEmptyTensorToAllocTensorPattern(RewritePatternSet &patterns)
Populate patterns to lower tensor.empty ops to bufferization.alloc_tensor ops.
Include the generated interface declarations.
LogicalResult applyPatternsGreedily(Region ®ion, const FrozenRewritePatternSet &patterns, GreedyRewriteConfig config=GreedyRewriteConfig(), bool *changed=nullptr)
Rewrite ops in the given region, which must be isolated from above, by repeatedly applying the highes...
const FrozenRewritePatternSet & patterns
OpRewritePattern is a wrapper around RewritePattern that allows for matching and rewriting against an...