diff --git a/mlir/docs/Bufferization.md b/mlir/docs/Bufferization.md --- a/mlir/docs/Bufferization.md +++ b/mlir/docs/Bufferization.md @@ -369,9 +369,9 @@ * `bufferRelation`: Return `BufferRelation::Equivalent` if the given OpResult is the exact same memref as the aliasing OpOperand after bufferization (in case of in-place bufferization). Otherwise, (e.g., they overlap but are not - necessarily the exact same memrefs), `BufferRelation::None` should be + necessarily the exact same memrefs), `BufferRelation::Unknown` should be returned. Additional buffer relations will be added in the future, but - `BufferRelation::None` is always safe. + `BufferRelation::Unknown` is always safe. * `bufferize`: Rewrite the op with the given rewriter. Ops should be replaced with `bufferization::replaceOpWithBufferizedValues`. diff --git a/mlir/include/mlir/Dialect/Bufferization/IR/BufferizableOpInterface.h b/mlir/include/mlir/Dialect/Bufferization/IR/BufferizableOpInterface.h --- a/mlir/include/mlir/Dialect/Bufferization/IR/BufferizableOpInterface.h +++ b/mlir/include/mlir/Dialect/Bufferization/IR/BufferizableOpInterface.h @@ -302,7 +302,7 @@ /// Specify fine-grain relationship between buffers to enable more analysis. enum class BufferRelation { - None, + Unknown, // TODO: ResultContainsOperand, // TODO: OperandContainsResult, Equivalent diff --git a/mlir/lib/Dialect/Arith/Transforms/BufferizableOpInterfaceImpl.cpp b/mlir/lib/Dialect/Arith/Transforms/BufferizableOpInterfaceImpl.cpp --- a/mlir/lib/Dialect/Arith/Transforms/BufferizableOpInterfaceImpl.cpp +++ b/mlir/lib/Dialect/Arith/Transforms/BufferizableOpInterfaceImpl.cpp @@ -202,7 +202,7 @@ BufferRelation bufferRelation(Operation *op, OpResult opResult, const AnalysisState &state) const { - return BufferRelation::None; + return BufferRelation::Unknown; } }; diff --git a/mlir/lib/Dialect/Bufferization/Transforms/FuncBufferizableOpInterfaceImpl.cpp b/mlir/lib/Dialect/Bufferization/Transforms/FuncBufferizableOpInterfaceImpl.cpp --- a/mlir/lib/Dialect/Bufferization/Transforms/FuncBufferizableOpInterfaceImpl.cpp +++ b/mlir/lib/Dialect/Bufferization/Transforms/FuncBufferizableOpInterfaceImpl.cpp @@ -236,7 +236,7 @@ if (getFuncOpAnalysisState(state, funcOp) != FuncOpAnalysisState::Analyzed) { // Function not analyzed yet. The conservative answer is "None". - return BufferRelation::None; + return BufferRelation::Unknown; } const FuncAnalysisState &funcState = getFuncAnalysisState(state); @@ -253,7 +253,7 @@ #endif return BufferRelation::Equivalent; } - return BufferRelation::None; + return BufferRelation::Unknown; } /// All function arguments are writable. It is the responsibility of the diff --git a/mlir/lib/Dialect/SCF/Transforms/BufferizableOpInterfaceImpl.cpp b/mlir/lib/Dialect/SCF/Transforms/BufferizableOpInterfaceImpl.cpp --- a/mlir/lib/Dialect/SCF/Transforms/BufferizableOpInterfaceImpl.cpp +++ b/mlir/lib/Dialect/SCF/Transforms/BufferizableOpInterfaceImpl.cpp @@ -312,7 +312,8 @@ assert(yieldValues.size() == 2 && "expected 2 yield values"); bool equivalentYields = state.areEquivalentBufferizedValues( yieldValues[0]->get(), yieldValues[1]->get()); - return equivalentYields ? BufferRelation::Equivalent : BufferRelation::None; + return equivalentYields ? BufferRelation::Equivalent + : BufferRelation::Unknown; } }; @@ -502,7 +503,8 @@ cast(forOp.getLoopBody().front().getTerminator()); bool equivalentYield = state.areEquivalentBufferizedValues( bbArg, yieldOp->getOperand(opResult.getResultNumber())); - return equivalentYield ? BufferRelation::Equivalent : BufferRelation::None; + return equivalentYield ? BufferRelation::Equivalent + : BufferRelation::Unknown; } bool isWritable(Operation *op, Value value, @@ -723,10 +725,10 @@ // The "before" region bbArgs and the OpResults may not match. if (resultNumber >= whileOp.getBeforeArguments().size()) - return BufferRelation::None; + return BufferRelation::Unknown; if (opResult.getType() != whileOp.getBeforeArguments()[resultNumber].getType()) - return BufferRelation::None; + return BufferRelation::Unknown; auto conditionOp = whileOp.getConditionOp(); BlockArgument conditionBbArg = whileOp.getBeforeArguments()[resultNumber]; @@ -741,7 +743,7 @@ state.areEquivalentBufferizedValues(bodyBbArg, yieldOperand); return equivCondition && equivYield ? BufferRelation::Equivalent - : BufferRelation::None; + : BufferRelation::Unknown; } bool isWritable(Operation *op, Value value, diff --git a/mlir/lib/Dialect/Tensor/Transforms/BufferizableOpInterfaceImpl.cpp b/mlir/lib/Dialect/Tensor/Transforms/BufferizableOpInterfaceImpl.cpp --- a/mlir/lib/Dialect/Tensor/Transforms/BufferizableOpInterfaceImpl.cpp +++ b/mlir/lib/Dialect/Tensor/Transforms/BufferizableOpInterfaceImpl.cpp @@ -333,7 +333,7 @@ BufferRelation bufferRelation(Operation *op, OpResult opResult, const AnalysisState &state) const { - return BufferRelation::None; + return BufferRelation::Unknown; } LogicalResult bufferize(Operation *op, RewriterBase &rewriter,