From 97f7a70c01b8995b65cfe69851efa1e95fdb1ab1 Mon Sep 17 00:00:00 2001 From: liym27 <33742067+liym27@users.noreply.github.com> Date: Mon, 8 Feb 2021 11:07:20 +0800 Subject: [PATCH] Add error message for slice op(#30851) --- paddle/fluid/operators/slice_op.cc | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/paddle/fluid/operators/slice_op.cc b/paddle/fluid/operators/slice_op.cc index b49e026b5e..0a41424cfa 100644 --- a/paddle/fluid/operators/slice_op.cc +++ b/paddle/fluid/operators/slice_op.cc @@ -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 " -- GitLab