File tree Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments