[Mlir-commits] [mlir] [mlir][tensor][bufferize] `tensor.empty` bufferizes to allocation (PR #68201)

Matthias Springer llvmlistbot at llvm.org
Wed Oct 4 03:43:04 PDT 2023


https://github.com/matthias-springer created https://github.com/llvm/llvm-project/pull/68201

`BufferizableOpInterface::bufferizesToAllocation` is queried when forming equivalence sets during bufferization. It is not really needed for ops like `tensor.empty` which do not have tensor operands, but it should be added for consistency.

This change should have been part of #68080. No test is added because the return value of this function is irrelevant for ops without tensor operands. (However, this function acts as a form documentation, describing the bufferization semantics of the op.)

>From d561c4a2e77c5e4fb9f0972b5ec1ac06a667c56f Mon Sep 17 00:00:00 2001
From: Matthias Springer <me at m-sp.org>
Date: Wed, 4 Oct 2023 12:42:19 +0200
Subject: [PATCH] [mlir][tensor][bufferize] `tensor.empty` bufferizes to
 allocation

`BufferizableOpInterface::bufferizesToAllocation` is queried when forming equivalence sets during bufferization. It is not really needed for ops like `tensor.empty` which do not have tensor operands, but it should be added for consistency.

This change should have been part of #68080. No test is added because the return value of this function is irrelevant for ops without tensor operands. (However, this function acts as a form documentation, describing the bufferization semantics of the op.)
---
 .../Dialect/Tensor/Transforms/BufferizableOpInterfaceImpl.cpp   | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/mlir/lib/Dialect/Tensor/Transforms/BufferizableOpInterfaceImpl.cpp b/mlir/lib/Dialect/Tensor/Transforms/BufferizableOpInterfaceImpl.cpp
index b08283f0070784c..997e442bc9ae241 100644
--- a/mlir/lib/Dialect/Tensor/Transforms/BufferizableOpInterfaceImpl.cpp
+++ b/mlir/lib/Dialect/Tensor/Transforms/BufferizableOpInterfaceImpl.cpp
@@ -260,6 +260,8 @@ struct DimOpInterface
 struct EmptyOpInterface
     : public BufferizableOpInterface::ExternalModel<EmptyOpInterface,
                                                     tensor::EmptyOp> {
+  bool bufferizesToAllocation(Operation *op, Value value) const { return true; }
+
   bool resultBufferizesToMemoryWrite(Operation *op, OpResult opResult,
                                      const AnalysisState &state) const {
     // The returned tensor does not have specified contents.



More information about the Mlir-commits mailing list