From 631c1f3018261c2e52aca97b716d0333afeb858f Mon Sep 17 00:00:00 2001 From: Jacek Czaja Date: Fri, 9 Oct 2020 13:54:24 +0200 Subject: [PATCH] - Fix to 27398 (#27770) test=develop - compilation fix test=develop --- paddle/fluid/framework/data_transform.cc | 3 +++ paddle/fluid/framework/tensor_util.cc | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/paddle/fluid/framework/data_transform.cc b/paddle/fluid/framework/data_transform.cc index 3a40de6988f..70693a5df26 100644 --- a/paddle/fluid/framework/data_transform.cc +++ b/paddle/fluid/framework/data_transform.cc @@ -117,6 +117,9 @@ void SetTensorToVariable(const Variable &in_var, const Tensor &tensor, auto *tran_lod_tensor = out_var->GetMutable(); tran_lod_tensor->set_lod(in_lod_tensor.lod()); tran_lod_tensor->set_layout(in_lod_tensor.layout()); +#ifdef PADDLE_WITH_MKLDNN + tran_lod_tensor->set_format(in_lod_tensor.format()); +#endif tran_lod_tensor->ShareDataWith(tensor); } else if (in_var.IsType()) { auto &in_selected_rows = in_var.Get(); diff --git a/paddle/fluid/framework/tensor_util.cc b/paddle/fluid/framework/tensor_util.cc index a073dbd733f..4fe01aff79e 100644 --- a/paddle/fluid/framework/tensor_util.cc +++ b/paddle/fluid/framework/tensor_util.cc @@ -38,6 +38,9 @@ void TensorCopy(const Tensor& src, const platform::Place& dst_place, dst->Resize(src.dims()); dst->set_layout(src.layout()); +#ifdef PADDLE_WITH_MKLDNN + dst->set_format(src.format()); +#endif auto src_place = src.place(); auto src_ptr = src.data(); auto dst_ptr = dst->mutable_data(dst_place, src.type()); @@ -237,6 +240,9 @@ void TensorCopySync(const Tensor& src, const platform::Place& dst_place, src.check_memory_size(); dst->Resize(src.dims()); dst->set_layout(src.layout()); +#ifdef PADDLE_WITH_MKLDNN + dst->set_format(src.format()); +#endif auto src_place = src.place(); auto src_ptr = src.data(); auto dst_ptr = dst->mutable_data(dst_place, src.type()); -- GitLab