diff --git a/paddle/fluid/framework/operator.cc b/paddle/fluid/framework/operator.cc index 42095c7bdc3e26bae2b80436af2f487a79aedb45..7073984c6484e2f35aa107c7cf0abb190a652caf 100644 --- a/paddle/fluid/framework/operator.cc +++ b/paddle/fluid/framework/operator.cc @@ -1086,7 +1086,9 @@ void OperatorWithKernel::TransferInplaceVarsBack( PADDLE_ENFORCE_NOT_NULL(var, "The var[%s] should not be nullptr.", var_name); auto* transformed_tensor = GetLoDTensorOrSelectedRowsValueFromVar(*var); + auto original_dims = original_tensor->dims(); original_tensor->ShareDataWith(*transformed_tensor); + original_tensor->Resize(original_dims); } }