Skip to content

Commit

Permalink
fix trace heap overflow
Browse files Browse the repository at this point in the history
  • Loading branch information
jeff41404 committed Jan 4, 2023
1 parent ac75a9a commit 12549df
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions paddle/phi/infermeta/unary.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4016,13 +4016,22 @@ void TraceInferMeta(
x_dims.size(),
2,
phi::errors::OutOfRange(
"Input's dim is out of range (expected at least 2, but got %ld).",
"Input(x)'s dim is out of range (expected at least 2, but got %ld).",
x_dims.size()));
PADDLE_ENFORCE_LT(
dim1_,
x_dims.size(),
phi::errors::OutOfRange(
"Attr(dim1) is out of range (expected to be in range of [%ld, "
"axis1 is out of range (expected to be in range of [%ld, "
"%ld], but got %ld).",
-(x_dims.size()),
(x_dims.size() - 1),
dim1));
PADDLE_ENFORCE_GE(
dim1_,
0,
phi::errors::OutOfRange(
"axis1 is out of range (expected to be in range of [%ld, "
"%ld], but got %ld).",
-(x_dims.size()),
(x_dims.size() - 1),
Expand All @@ -4031,7 +4040,16 @@ void TraceInferMeta(
dim2_,
x_dims.size(),
phi::errors::OutOfRange(
"Attr(dim2) is out of range (expected to be in range of [%ld, "
"axis2 is out of range (expected to be in range of [%ld, "
"%ld], but got %ld).",
-(x_dims.size()),
(x_dims.size() - 1),
dim2));
PADDLE_ENFORCE_GE(
dim2_,
0,
phi::errors::OutOfRange(
"axis2 is out of range (expected to be in range of [%ld, "
"%ld], but got %ld).",
-(x_dims.size()),
(x_dims.size() - 1),
Expand Down

0 comments on commit 12549df

Please sign in to comment.