diff --git a/paddle/fluid/operators/concat_op.h b/paddle/fluid/operators/concat_op.h index 8613b5e3c8d9c5a7c8f00fb195e94ee1b23afb0c..e00d606f644d5c2f5684994bfc5c39aa858b7eb4 100644 --- a/paddle/fluid/operators/concat_op.h +++ b/paddle/fluid/operators/concat_op.h @@ -61,6 +61,11 @@ static inline framework::DDim ComputeAndCheckShape( } static inline int64_t ComputeAxis(int64_t axis, int64_t rank) { + PADDLE_ENFORCE_EQ( + axis >= -rank && axis < rank, true, + platform::errors::InvalidArgument( + "The axis is expected to be in range of [%d, %d), but got %d", -rank, + rank, axis)); if (axis < 0) { axis = axis + rank; }