25 for (
OpOperand &operand : op.getDpsInitsMutable()) {
27 if (op.payloadUsesValueFromOperand(&operand))
30 if (operand.get().getType() != in->
get().
getType())
33 if (op.getMatchingIndexingMap(&operand) != op.getMatchingIndexingMap(in))
45 op->
walk([&](LinalgOp op) {
47 if (op.getNumParallelLoops() != op.getNumLoops())
50 for (
OpOperand *in : op.getDpsInputOperands()) {
52 if (!in->get().getType().isa<RankedTensorType>())
58 TraversalConfig config;
59 config.followEquivalentOnly = true;
60 config.alwaysIncludeLeaves = false;
61 SetVector<Value> emptyTensors = state.findValueInReverseUseDefChain(
63 [&](Value val) { return val.getDefiningOp<tensor::EmptyOp>(); },
65 if (emptyTensors.empty())
74 if (!llvm::all_of(emptyTensors, [&](
Value v) {
81 for (
Value v : emptyTensors) {
82 assert(v.
getDefiningOp<tensor::EmptyOp>() &&
"expected tensor.empty");
92 in->set(emptyTensors.front());
94 assert(outArg.getUses().empty() &&
"expected that out has no uses");
97 assert(!op.payloadUsesValueFromOperand(in) &&
98 "expected that the in operand is now unused");
static OpOperand * getUnusedOutOperand(LinalgOp op, OpOperand *in)
Get an output operand that matches the given input operand and can be used to eliminate a tensor....
This class represents an argument of a Block.
A class for computing basic dominance information.
bool properlyDominates(Operation *a, Operation *b, bool enclosingOpOk=true) const
Return true if operation A properly dominates operation B, i.e.
IRValueT get() const
Return the current value being used by this operand.
void set(IRValueT newValue)
Set the current value being used by this operand.
RAII guard to reset the insertion point of the builder when destroyed.
This class represents an operand of an operation.
Operation is the basic unit of execution within MLIR.
std::enable_if_t< llvm::function_traits< std::decay_t< FnT > >::num_args==1, RetT > walk(FnT &&callback)
Walk the operation by calling the callback for each nested operation (including this one),...
This class coordinates the application of a rewrite on a set of IR, providing a way for clients to tr...
void updateRootInPlace(Operation *root, CallableT &&callable)
This method is a utility wrapper around a root update of an operation.
void replaceAllUsesWith(Value from, Value to)
Find uses of from and replace them with to.
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.
Operation * getDefiningOp() const
If this value is the result of an operation, return the operation that defines it.
static WalkResult advance()
State for analysis-enabled bufferization.
LogicalResult linalgOpAnchoredEmptyTensorEliminationStep(RewriterBase &rewriter, Operation *op, bufferization::OneShotAnalysisState &state)
Try to eliminate tensor::EmptyOps inside op that are anchored on a LinalgOp.
Include the generated interface declarations.
LogicalResult success(bool isSuccess=true)
Utility function to generate a LogicalResult.
This class represents an efficient way to signal success or failure.