From a5cf2e305b744e3ebd2f2210341f88d349d4ec5e Mon Sep 17 00:00:00 2001 From: Jiawei Wang Date: Tue, 30 Nov 2021 11:22:28 +0800 Subject: [PATCH] fix range op (#37486) (#37611) --- 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 abc84be12b3..cc32f2b5156 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