未验证 提交 10563791 编写于 作者: T TeslaZhao 提交者: GitHub

Fix a bug of transpose op, about accessing memory out of bounds of the perm param (#35079)

上级 93d862b0
...@@ -48,6 +48,12 @@ class TransposeOp : public framework::OperatorWithKernel { ...@@ -48,6 +48,12 @@ class TransposeOp : public framework::OperatorWithKernel {
std::vector<int> count(axis_size, 0); std::vector<int> count(axis_size, 0);
for (size_t i = 0; i < axis_size; i++) { for (size_t i = 0; i < axis_size; i++) {
PADDLE_ENFORCE_GE(axis[i], 0,
platform::errors::InvalidArgument(
"The axis should be greater than or equal to 0."
"But received %d of axis[%d]",
axis[i], i));
PADDLE_ENFORCE_EQ( PADDLE_ENFORCE_EQ(
axis[i] < static_cast<int>(axis_size) && ++count[axis[i]] == 1, true, axis[i] < static_cast<int>(axis_size) && ++count[axis[i]] == 1, true,
platform::errors::InvalidArgument( platform::errors::InvalidArgument(
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册