From 9d12e70c5daab2c59724d0d4b2758b1f1ecdaabc Mon Sep 17 00:00:00 2001 From: zyfncg Date: Thu, 23 Jun 2022 20:37:03 +0800 Subject: [PATCH] fix set_value (#43694) (#43783) --- paddle/phi/kernels/funcs/slice_utils.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/paddle/phi/kernels/funcs/slice_utils.h b/paddle/phi/kernels/funcs/slice_utils.h index 0c956248fd9..c42843f9491 100644 --- a/paddle/phi/kernels/funcs/slice_utils.h +++ b/paddle/phi/kernels/funcs/slice_utils.h @@ -77,6 +77,9 @@ inline void CheckAndUpdateSliceAttrs(const DDim in_dims, // dim_value-1 // "end is -1" means contain the 0-th element of this axis. start = std::min(start, dim_value - 1); + if (end < -1) { + end += dim_value; + } end = std::max(end, static_cast(-1)); PADDLE_ENFORCE_GE( start, -- GitLab