Skip to content

Commit

Permalink
Add error message for slice op(PaddlePaddle#30851)
Browse files Browse the repository at this point in the history
  • Loading branch information
liym27 authored Feb 8, 2021
1 parent 87197f8 commit 97f7a70
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions paddle/fluid/operators/slice_op.cc
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,13 @@ class SliceOp : public framework::OperatorWithKernel {
start = std::max(start, 0);
end = std::max(end, 0);
end = std::min(end, dim_value);

PADDLE_ENFORCE_LE(start, dim_value,
platform::errors::InvalidArgument(
"start should be less than or equal to the "
"dimension value, but received "
"start = %d, shape[%d] = %d.",
starts[i], axes[i], out_dims[axes[i]]));
PADDLE_ENFORCE_GT(end, start,
platform::errors::InvalidArgument(
"end should greater than start, but received "
Expand Down

0 comments on commit 97f7a70

Please sign in to comment.