18 namespace bufferization {
19 #define GEN_PASS_DEF_EMPTYTENSORTOALLOCTENSOR
20 #include "mlir/Dialect/Bufferization/Transforms/Passes.h.inc"
29 struct EmptyTensorLoweringPattern :
public OpRewritePattern<tensor::EmptyOp> {
35 op, op.getType(), op.getDynamicSizes());
40 struct EmptyTensorToAllocTensor
41 :
public bufferization::impl::EmptyTensorToAllocTensorBase<
42 EmptyTensorToAllocTensor> {
43 EmptyTensorToAllocTensor() =
default;
45 void runOnOperation()
override;
49 .
insert<tensor::TensorDialect, bufferization::BufferizationDialect>();
59 void EmptyTensorToAllocTensor::runOnOperation() {
69 return std::make_unique<EmptyTensorToAllocTensor>();
The DialectRegistry maps a dialect namespace to a constructor for the matching dialect.
Operation is the basic unit of execution within MLIR.
MLIRContext * getContext()
Return the context this operation is associated with.
A special type of RewriterBase that coordinates the application of a rewrite pattern on the current I...
RewritePatternSet & insert(ConstructorArg &&arg, ConstructorArgs &&...args)
Add an instance of each of the pattern types 'Ts' to the pattern list with the given arguments.
MLIRContext * getContext() const
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.
std::unique_ptr< Pass > createEmptyTensorToAllocTensorPass()
Create a pass that rewrites tensor.empty to bufferization.alloc_tensor.
Include the generated interface declarations.
LogicalResult success(bool isSuccess=true)
Utility function to generate a LogicalResult.
LogicalResult applyPatternsAndFoldGreedily(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...
bool failed(LogicalResult result)
Utility function that returns true if the provided LogicalResult corresponds to a failure value.
This class represents an efficient way to signal success or failure.
OpRewritePattern is a wrapper around RewritePattern that allows for matching and rewriting against an...