Skip to content

Commit 82391ab

Browse files
committed
CI fix
1 parent 0da71a3 commit 82391ab

4 files changed

Lines changed: 6 additions & 5 deletions

File tree

paddle/fluid/framework/data_layout_transform.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ void TransDataLayoutFromMKLDNN(const OpKernelType& kernel_type_for_var,
143143

144144
void innerTransDataLayoutFromMKLDNN(DataLayout in_layout, DataLayout out_layout,
145145
const Tensor& in, Tensor* out,
146-
platform::Place place) {
146+
platform::Place place, bool always_copy) {
147147
PADDLE_ENFORCE_NE(in.format(), MKLDNNMemoryFormat::undef,
148148
platform::errors::InvalidArgument(
149149
"Input tensor format is invalid. Input tensor should "
@@ -177,7 +177,7 @@ void innerTransDataLayoutFromMKLDNN(DataLayout in_layout, DataLayout out_layout,
177177
// output tensor has the same dims as input. Reorder don't change dims
178178
out->Resize(in.dims());
179179

180-
if (in_format != out_format) {
180+
if ((in_format != out_format) || always_copy) {
181181
void* in_data = GetDataFromTensor(in, in_type);
182182
std::string key =
183183
platform::CreateKey(*dev_ctx, in_tz, in_format, out_format, in_type);

paddle/fluid/framework/data_layout_transform.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@ inline MKLDNNDataType ToMKLDNNDataType(proto::VarType::Type type) {
7878

7979
void innerTransDataLayoutFromMKLDNN(DataLayout in_layout, DataLayout out_layout,
8080
const Tensor& in, Tensor* out,
81-
platform::Place place);
81+
platform::Place place,
82+
bool always_copy = false);
8283

8384
void TransDataLayoutFromMKLDNN(const OpKernelType& kernel_type_for_var,
8485
const OpKernelType& expected_kernel_type,

paddle/fluid/inference/api/details/zero_copy_tensor.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ void Tensor::CopyToCpu(T *data) {
174174
paddle::framework::innerTransDataLayoutFromMKLDNN(
175175
tensor->layout(), paddle::platform::MKLDNNDeviceContext::tls()
176176
.get_cur_paddle_data_layout(),
177-
*tensor, &out, paddle::platform::CPUPlace());
177+
*tensor, &out, paddle::platform::CPUPlace(), true);
178178
else
179179
std::memcpy(static_cast<void *>(data), t_data, ele_num * sizeof(T));
180180
#else

paddle/fluid/operators/scale_op.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ class ScaleGradMaker : public framework::SingleGradOpMaker<T> {
130130
grad_op->SetAttr("scale", this->GetAttr("scale"));
131131
grad_op->SetAttr("bias", 0.0f);
132132
grad_op->SetAttr("bias_after_scale", true);
133-
if(grad_op->HasAttr("use_mkldnn"))
133+
if (grad_op->HasAttr("use_mkldnn"))
134134
grad_op->SetAttr("use_mkldnn", this->GetAttr("use_mkldnn"));
135135
}
136136
};

0 commit comments

Comments
 (0)