From abc5d0c400d20dfca24cfcd54b8ab06c5853a9c9 Mon Sep 17 00:00:00 2001 From: zyfncg Date: Mon, 13 Jun 2022 10:38:52 +0800 Subject: [PATCH] fix bug of strided_slice (#43388) * fix stride_slice bug * fix bug --- paddle/phi/kernels/funcs/strided_slice.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/paddle/phi/kernels/funcs/strided_slice.h b/paddle/phi/kernels/funcs/strided_slice.h index 8eebfc7caa..c39a9694e1 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; + } } } -- GitLab