From 6c2af7bb2d8fc57d4fd11b8411d0e1e11276e280 Mon Sep 17 00:00:00 2001 From: yeliang2258 <30516196+yeliang2258@users.noreply.github.com> Date: Tue, 11 Oct 2022 15:09:28 +0800 Subject: [PATCH] Fix slice bugs in MKLDNN when input dims are zeros (#46671) * 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 44a9bd24032..6609f6e9263 --- 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