diff --git a/paddle/phi/kernels/funcs/strided_slice.h b/paddle/phi/kernels/funcs/strided_slice.h index 8eebfc7caa79536f5fe8d74f739da9eb948bece8..c39a9694e18e57ca139d12bd49168f611553ac5e 100644 --- a/paddle/phi/kernels/funcs/strided_slice.h +++ b/paddle/phi/kernels/funcs/strided_slice.h @@ -74,10 +74,14 @@ static void StridedSliceOutDims(const std::vector& starts, if (start_index < 0) { start_index = start_index + axis_size; + start_index = std::max(start_index, 0); } if (end_index < 0) { if (!(end_index == -1 && stride_index < 0)) { // skip None stop condition end_index = end_index + axis_size; + if (end_index < 0) { + end_index = 0; + } } }