From d5c51e6291d71f2a7a5734efec9b5685ff309deb Mon Sep 17 00:00:00 2001 From: Jiawei Wang Date: Wed, 24 Nov 2021 19:10:16 +0800 Subject: [PATCH] fix range op (#37486) --- python/paddle/fluid/layers/tensor.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/python/paddle/fluid/layers/tensor.py b/python/paddle/fluid/layers/tensor.py index abc84be12b..cc32f2b515 100644 --- a/python/paddle/fluid/layers/tensor.py +++ b/python/paddle/fluid/layers/tensor.py @@ -1433,7 +1433,9 @@ def range(start, end, step, dtype, name=None): step = cast(step, dtype) if in_dygraph_mode(): - return _C_ops.range(start, end, step) + out = _C_ops.range(start, end, step) + out.stop_gradient = True + return out out_shape = None if not isinstance(start, Variable) and not isinstance( -- GitLab