From 5033b6c2eb0c8e0bd787b0ed79dd3c5adfa00259 Mon Sep 17 00:00:00 2001 From: yeliang2258 <30516196+yeliang2258@users.noreply.github.com> Date: Fri, 11 Nov 2022 16:27:42 +0800 Subject: [PATCH] Fix slice bugs in MKLDNN when input dims are zeros (#46671) (#47887) * fix slice bugs * fix * update code * fix * update code --- paddle/fluid/operators/slice_op.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) mode change 100644 => 100755 paddle/fluid/operators/slice_op.cc diff --git a/paddle/fluid/operators/slice_op.cc b/paddle/fluid/operators/slice_op.cc old mode 100644 new mode 100755 index 9d9e5816db..c26589677b --- a/paddle/fluid/operators/slice_op.cc +++ b/paddle/fluid/operators/slice_op.cc @@ -155,8 +155,10 @@ class SliceOp : public framework::OperatorWithKernel { #ifdef PADDLE_WITH_MKLDNN auto input_data_type = framework::OperatorWithKernel::IndicateVarDataType(ctx, "Input"); - - if (this->CanMKLDNNBeUsed(ctx, input_data_type)) { + auto vec_dims = phi::vectorize(in_tensor.dims()); + bool all_zero_dims = std::all_of( + vec_dims.cbegin(), vec_dims.cend(), [](int64_t i) { return i == 0; }); + if (!all_zero_dims && this->CanMKLDNNBeUsed(ctx, input_data_type)) { // OneDNN uses blocking format, which cannot be always supported with // reorders, because if blocked dimension is not divisible by 8 or // 16(depending on which blocking format is used) submemory cannot be -- GitLab