From a71cfd8c4116d9cb74b942775e63f321b5c3b9fa Mon Sep 17 00:00:00 2001 From: Li Min <11663212+limin2021@users.noreply.github.com> Date: Wed, 27 Jul 2022 10:32:05 +0800 Subject: [PATCH] fix dygraph bugs in broadcast_to api. (#44612) --- python/paddle/tensor/manipulation.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/python/paddle/tensor/manipulation.py b/python/paddle/tensor/manipulation.py index 05823efc3f1..f3b67cf743d 100755 --- a/python/paddle/tensor/manipulation.py +++ b/python/paddle/tensor/manipulation.py @@ -3000,8 +3000,10 @@ def broadcast_to(x, shape, name=None): print(out) # [[1, 2, 3], [1, 2, 3]] """ - if paddle.in_dynamic_mode(): + if in_dygraph_mode(): return _C_ops.final_state_expand(x, shape) + if _in_legacy_dygraph(): + return _C_ops.expand_v2(x, 'shape', shape) if isinstance(shape, Variable): assert len(shape.shape) == 1, ('shape must be an 1-D Tensor.') -- GitLab