diff --git a/paddle/fluid/operators/slice_op.cc b/paddle/fluid/operators/slice_op.cc old mode 100644 new mode 100755 index 44a9bd24032ab5bd8320c6c6044071283de89422..6609f6e926362fcaac1d7a2dfb2101c1107b6e78 --- 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