From 94249f5e562dd6822167c949ac56df18c2582843 Mon Sep 17 00:00:00 2001 From: zyfncg Date: Tue, 21 Jun 2022 16:14:29 +0800 Subject: [PATCH] fix set_value (#43694) --- 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 e26a6543789..bfe024f45a0 100644 --- a/paddle/phi/kernels/funcs/slice_utils.h +++ b/paddle/phi/kernels/funcs/slice_utils.h @@ -78,6 +78,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