未验证 提交 e0a01461 编写于 作者: Z zyfncg 提交者: GitHub

fix bug of infer shape for slice (#43443)

上级 42754088
...@@ -104,7 +104,11 @@ class SliceOp : public framework::OperatorWithKernel { ...@@ -104,7 +104,11 @@ class SliceOp : public framework::OperatorWithKernel {
platform::errors::InvalidArgument( platform::errors::InvalidArgument(
"The size of ends must be equal to the size of axes.")); "The size of ends must be equal to the size of axes."));
} }
for (auto &axis : axes) {
if (axis < 0) {
axis = std::max(0, axis + in_dims.size());
}
}
phi::funcs::CheckAndUpdateSliceAttrs<int>(in_dims, axes, &starts, &ends, phi::funcs::CheckAndUpdateSliceAttrs<int>(in_dims, axes, &starts, &ends,
nullptr, &infer_flags); nullptr, &infer_flags);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册