Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions paddle/phi/infermeta/unary.cc
Original file line number Diff line number Diff line change
Expand Up @@ -590,21 +590,6 @@ void CumWithIndicesInferMeta(const MetaTensor& x,
phi::errors::InvalidArgument(
"dtype of indices must be DataType::INT32 or DataType::INT64"));

if (dtype == DataType::INT32) {
int _axis = 0;
if (axis < 0) {
_axis = axis + x_dims.size();
} else {
_axis = axis;
}
PADDLE_ENFORCE_LT(
common::vectorize(x_dims)[_axis],
INT32_MAX,
phi::errors::OutOfRange(
"cummax with axis %ld may be overflow, set dtype int64 to continue",
axis));
}

if (x_dims.size() > 0) {
PADDLE_ENFORCE_GE(
axis,
Expand Down Expand Up @@ -633,6 +618,21 @@ void CumWithIndicesInferMeta(const MetaTensor& x,
axis));
}

if (dtype == DataType::INT32) {
int _axis = 0;
if (axis < 0) {
_axis = axis + x_dims.size();
} else {
_axis = axis;
}
PADDLE_ENFORCE_LT(
common::vectorize(x_dims)[_axis],
INT32_MAX,
phi::errors::OutOfRange(
"cummax with axis %ld may be overflow, set dtype int64 to continue",
axis));
}

out->set_dims(x_dims);
out->set_dtype(x.dtype());
out->share_lod(x);
Expand Down