Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace with dygraph op calling method. #44331

Merged
merged 7 commits into from
Jul 21, 2022
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions python/paddle/fluid/dygraph/math_op_patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -376,8 +376,11 @@ def __impl__(self, other_var):
if framework._in_eager_mode_ else
('__rtruediv__',
_binary_creator_('rtruediv__', 'elementwise_div', True, None)),
('__pow__', _binary_creator_('__pow__', 'elementwise_pow', False,
None)),
('__pow__', _binary_creator_('__pow__', 'final_state_elementwise_pow', False, None, True))
if framework._in_eager_mode_ else
('__pow__',
_binary_creator_('__pow__', 'elementwise_pow', False,
None)),
('__rpow__', _binary_creator_('__rpow__', 'elementwise_pow', True,
None)),
('__floordiv__',
Expand Down
8 changes: 6 additions & 2 deletions python/paddle/tensor/creation.py
Original file line number Diff line number Diff line change
Expand Up @@ -663,8 +663,12 @@ def eye(num_rows, num_columns=None, dtype=None, name=None):
num_columns = num_rows

if _non_static_mode():
out = _C_ops.eye('dtype', dtype, 'num_rows', num_rows, 'num_columns',
num_columns)
if in_dygraph_mode():
out = _C_ops.final_state_eye(num_rows, num_columns, dtype,
_current_expected_place())
elif _in_legacy_dygraph():
out = _C_ops.eye('dtype', dtype, 'num_rows', num_rows,
'num_columns', num_columns)

else:
helper = LayerHelper("eye", **locals())
Expand Down
5 changes: 2 additions & 3 deletions python/paddle/tensor/manipulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -2694,8 +2694,7 @@ def scatter_nd_add(x, index, updates, name=None):
# [3, 5, 9, 10]
"""
if in_dygraph_mode():
op = getattr(_C_ops, 'scatter_nd_add')
return op(x, index, updates)
return _C_ops.final_state_scatter_nd_add(x, index, updates)
else:
if _in_legacy_dygraph():
op = getattr(_C_ops, 'scatter_nd_add')
Expand Down Expand Up @@ -2992,7 +2991,7 @@ def broadcast_to(x, shape, name=None):
# [[1, 2, 3], [1, 2, 3]]
"""
if paddle.in_dynamic_mode():
return _C_ops.expand_v2(x, 'shape', shape)
return _C_ops.final_state_expand(x, shape)

if isinstance(shape, Variable):
assert len(shape.shape) == 1, ('shape must be an 1-D Tensor.')
Expand Down