Skip to content

Commit

Permalink
Fix slice bugs in MKLDNN when input dims are zeros (#46671) (#47887)
Browse files Browse the repository at this point in the history
* fix slice bugs

* fix

* update code

* fix

* update code
  • Loading branch information
yeliang2258 committed Nov 11, 2022
1 parent 4465ba2 commit 5033b6c
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions paddle/fluid/operators/slice_op.cc 100644 → 100755
Expand Up @@ -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
Expand Down

0 comments on commit 5033b6c

Please sign in to comment.