From ab8db2d3d6d330036895afa1db466e3c81b5300d Mon Sep 17 00:00:00 2001 From: Chen Weihang Date: Wed, 20 Oct 2021 14:22:59 +0000 Subject: [PATCH] readd share tensor impl methods --- paddle/fluid/framework/pten_utils.cc | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/paddle/fluid/framework/pten_utils.cc b/paddle/fluid/framework/pten_utils.cc index 9965085cdbb52..fbe9a4759bbf1 100644 --- a/paddle/fluid/framework/pten_utils.cc +++ b/paddle/fluid/framework/pten_utils.cc @@ -79,6 +79,20 @@ std::shared_ptr MakeTensorImpl( pten::TransToPtDataLayout(tensor.layout())); } +template <> +void ShareTensorImpl(pten::DenseTensor* tensor_impl, + LoDTensor* out) { + out->ResetHolderWithType(tensor_impl->allocation(), + pten::TransToProtoVarType(tensor_impl->data_type())); +} + +template <> +void ShareTensorImpl(pten::DenseTensor* tensor_impl, + Tensor* out) { + out->ResetHolderWithType(tensor_impl->allocation(), + pten::TransToProtoVarType(tensor_impl->data_type())); +} + std::shared_ptr InputVariableToPtTensor( const framework::Variable& variable, const pten::TensorArgDef& arg_def) { auto expected_place = pten::TransToFluidPlace(arg_def.backend);