From ab610a34ff6b144e9f5ace5b9a81cffa869d23a1 Mon Sep 17 00:00:00 2001 From: Adam <38704900+grygielski@users.noreply.github.com> Date: Mon, 17 Feb 2020 03:44:01 +0100 Subject: [PATCH] transpose_mkldnn code change to meet Paddle standards (#22591) --- paddle/fluid/operators/mkldnn/transpose_mkldnn_op.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/paddle/fluid/operators/mkldnn/transpose_mkldnn_op.cc b/paddle/fluid/operators/mkldnn/transpose_mkldnn_op.cc index 31110428be..9e9b2fb158 100644 --- a/paddle/fluid/operators/mkldnn/transpose_mkldnn_op.cc +++ b/paddle/fluid/operators/mkldnn/transpose_mkldnn_op.cc @@ -40,7 +40,8 @@ class TransposeMKLDNNOpKernel : public paddle::framework::OpKernel { const T* input_data = input->data(); if (ndims == 1) { - output->ShareDataWith(*input); + framework::TensorCopy(*input, input->place(), output); + output->set_format(input->format()); return; } @@ -85,7 +86,8 @@ class TransposeMKLDNNGradOpKernel : public paddle::framework::OpKernel { std::vector reversed_axis(axis); int ndims = axis.size(); if (ndims == 1) { - x_grad->ShareDataWith(*out_grad); + framework::TensorCopy(*out_grad, out_grad->place(), x_grad); + x_grad->set_format(out_grad->format()); return; } -- GitLab