From 2182a4f9e9f179d94905c06ec948983bb6f2f1b9 Mon Sep 17 00:00:00 2001 From: Jacek Czaja Date: Mon, 14 Nov 2022 09:53:23 +0100 Subject: [PATCH] - Modified mem_desc() to return reference to Tensor::memory::desc to (#47844) avoid copying --- paddle/phi/core/dense_tensor.inl | 2 +- paddle/phi/core/dense_tensor_impl.cc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/paddle/phi/core/dense_tensor.inl b/paddle/phi/core/dense_tensor.inl index c876ba679b..d631032cae 100644 --- a/paddle/phi/core/dense_tensor.inl +++ b/paddle/phi/core/dense_tensor.inl @@ -116,7 +116,7 @@ following codes there. #ifdef PADDLE_WITH_MKLDNN public: - dnnl::memory::desc mem_desc() const; + const dnnl::memory::desc& mem_desc() const; inline void set_mem_desc(const dnnl::memory::desc& mem_desc) { mem_desc_ = mem_desc; diff --git a/paddle/phi/core/dense_tensor_impl.cc b/paddle/phi/core/dense_tensor_impl.cc index f16b662501..c8998f65ef 100644 --- a/paddle/phi/core/dense_tensor_impl.cc +++ b/paddle/phi/core/dense_tensor_impl.cc @@ -344,7 +344,7 @@ std::vector DenseTensor::Chunk(int64_t chunks, } #ifdef PADDLE_WITH_MKLDNN -dnnl::memory::desc DenseTensor::mem_desc() const { return mem_desc_; } +const dnnl::memory::desc& DenseTensor::mem_desc() const { return mem_desc_; } #endif // NOTE: For historical reasons, this interface has a special behavior, -- GitLab