未验证 提交 6c2af7bb 编写于 作者: Y yeliang2258 提交者: GitHub

Fix slice bugs in MKLDNN when input dims are zeros (#46671)

* fix slice bugs

* fix

* update code

* fix

* update code
上级 1f3f02e3
...@@ -155,8 +155,10 @@ class SliceOp : public framework::OperatorWithKernel { ...@@ -155,8 +155,10 @@ class SliceOp : public framework::OperatorWithKernel {
#ifdef PADDLE_WITH_MKLDNN #ifdef PADDLE_WITH_MKLDNN
auto input_data_type = auto input_data_type =
framework::OperatorWithKernel::IndicateVarDataType(ctx, "Input"); framework::OperatorWithKernel::IndicateVarDataType(ctx, "Input");
auto vec_dims = phi::vectorize(in_tensor.dims());
if (this->CanMKLDNNBeUsed(ctx, input_data_type)) { 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 // OneDNN uses blocking format, which cannot be always supported with
// reorders, because if blocked dimension is not divisible by 8 or // reorders, because if blocked dimension is not divisible by 8 or
// 16(depending on which blocking format is used) submemory cannot be // 16(depending on which blocking format is used) submemory cannot be
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册