From e7a9f6bbb769ec4672a3885b1fb1eccc474787d8 Mon Sep 17 00:00:00 2001 From: Adam <38704900+grygielski@users.noreply.github.com> Date: Sun, 19 Jan 2020 03:25:14 +0100 Subject: [PATCH] [Bugfix] Preserve shape in inpalce operators (#22360) --- 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 72dec87847b..9baf720429d 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