From ecc5268893ac523e33d06c4fb00ec8f96d7bd319 Mon Sep 17 00:00:00 2001 From: Adam <38704900+grygielski@users.noreply.github.com> Date: Sun, 19 Jan 2020 14:42:57 +0100 Subject: [PATCH] Preserve shape in inplace operators (#22369) --- paddle/fluid/framework/operator.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/paddle/fluid/framework/operator.cc b/paddle/fluid/framework/operator.cc index 42095c7bdc..7073984c64 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); } } -- GitLab