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 (!isa<RankedTensorType>(in->get().getType()))
58 TraversalConfig config;
59 config.followEquivalentOnly = true;
60 config.alwaysIncludeLeaves = false;
61 SetVector<Value> emptyTensors = state.findValueInReverseUseDefChain(
64 return val.getDefiningOp<tensor::EmptyOp>() &&
65 val.getType() == in->get().getType();
68 if (emptyTensors.empty())
77 if (!llvm::all_of(emptyTensors, [&](
Value v) {
84 for (
Value v : emptyTensors) {
85 assert(v.
getDefiningOp<tensor::EmptyOp>() &&
"expected tensor.empty");
95 in->set(emptyTensors.front());
97 assert(outArg.getUses().empty() &&
"expected that out has no uses");
100 assert(!op.payloadUsesValueFromOperand(in) &&
101 "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 replaceAllUsesWith(Value from, Value to)
Find uses of from and replace them with to.
void modifyOpInPlace(Operation *root, CallableT &&callable)
This method is a utility wrapper around an in-place modification of an operation.
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.
const FrozenRewritePatternSet GreedyRewriteConfig config