20 struct GuardSparseAlloc
24 LogicalResult matchAndRewrite(bufferization::AllocTensorOp op,
36 return isa<func::ReturnOp, func::CallOp, func::CallIndirectOp>(
51 template <
typename StageWithSortOp>
58 Value tmpBuf =
nullptr;
59 auto itOp = llvm::cast<StageWithSortSparseOp>(op.getOperation());
60 LogicalResult stageResult = itOp.stageWithSort(rewriter, tmpBuf);
64 rewriter.
create<bufferization::DeallocTensorOp>(loc, tmpBuf);
72 patterns.
add<GuardSparseAlloc, StageUnorderedSparseOps<ConvertOp>,
73 StageUnorderedSparseOps<ConcatenateOp>>(patterns.
getContext());
This class defines the main interface for locations in MLIR and acts as a non-nullable wrapper around...
Operation * create(const OperationState &state)
Creates an operation given the fields represented as an OperationState.
void setInsertionPointAfter(Operation *op)
Sets the insertion point to the node after the specified operation, which will cause subsequent inser...
This class represents an operand of an operation.
OpResult getResult(unsigned idx)
Get the 'idx'th result of this operation.
Location getLoc()
The source location the operation was defined or derived from.
use_range getUses()
Returns a range of all uses, which is useful for iterating over all uses.
A special type of RewriterBase that coordinates the application of a rewrite pattern on the current I...
MLIRContext * getContext() const
RewritePatternSet & add(ConstructorArg &&arg, ConstructorArgs &&...args)
Add an instance of each of the pattern types 'Ts' to the pattern list with the given arguments.
void replaceAllUsesExcept(Value from, Value to, Operation *exceptedUser)
Find uses of from and replace them with to except if the user is exceptedUser.
This class represents an instance of an SSA value in the MLIR system, representing a computable value...
Type getType() const
Return the type of this value.
SparseTensorEncodingAttr getSparseTensorEncoding(Type type)
Convenience method to get a sparse encoding attribute from a type.
Include the generated interface declarations.
LogicalResult failure(bool isFailure=true)
Utility function to generate a LogicalResult.
bool succeeded(LogicalResult result)
Utility function that returns true if the provided LogicalResult corresponds to a success value.
LogicalResult success(bool isSuccess=true)
Utility function to generate a LogicalResult.
void populateStageSparseOperationsPatterns(RewritePatternSet &patterns)
Sets up StageSparseOperation rewriting rules.
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...