Skip to content

Commit 5033b6c

Browse files
authored
Fix slice bugs in MKLDNN when input dims are zeros (#46671) (#47887)
* fix slice bugs * fix * update code * fix * update code
1 parent 4465ba2 commit 5033b6c

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

paddle/fluid/operators/slice_op.cc

100644100755
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,10 @@ class SliceOp : public framework::OperatorWithKernel {
155155
#ifdef PADDLE_WITH_MKLDNN
156156
auto input_data_type =
157157
framework::OperatorWithKernel::IndicateVarDataType(ctx, "Input");
158-
159-
if (this->CanMKLDNNBeUsed(ctx, input_data_type)) {
158+
auto vec_dims = phi::vectorize(in_tensor.dims());
159+
bool all_zero_dims = std::all_of(
160+
vec_dims.cbegin(), vec_dims.cend(), [](int64_t i) { return i == 0; });
161+
if (!all_zero_dims && this->CanMKLDNNBeUsed(ctx, input_data_type)) {
160162
// OneDNN uses blocking format, which cannot be always supported with
161163
// reorders, because if blocked dimension is not divisible by 8 or
162164
// 16(depending on which blocking format is used) submemory cannot be

0 commit comments

Comments
 (0)