diff --git a/python/paddle/fluid/dygraph/math_op_patch.py b/python/paddle/fluid/dygraph/math_op_patch.py index 1a59d2f95fd4d307410df9b3a10d5adf09e55a75..1f6ce480887c4dcdbde206dcde370d323b5b458e 100644 --- a/python/paddle/fluid/dygraph/math_op_patch.py +++ b/python/paddle/fluid/dygraph/math_op_patch.py @@ -379,8 +379,9 @@ def monkey_patch_math_varbase(): ('__rtruediv__', _binary_creator_('rtruediv__', 'elementwise_div', True, None)), ('__pow__', - _binary_creator_('__pow__', 'final_state_elementwise_pow', False, None, - True)) if framework._in_eager_mode_ else + _binary_creator_('__pow__', 'final_state_elementwise_pow', False, + _C_ops.final_state_pow, True)) + if framework._in_eager_mode_ else ('__pow__', _binary_creator_('__pow__', 'elementwise_pow', False, None)), ('__rpow__', _binary_creator_('__rpow__', 'elementwise_pow', True, diff --git a/python/paddle/tensor/math.py b/python/paddle/tensor/math.py index 6199cd8120f74a0f278da11526175463e96613ac..0ea657d8c7c23519ecd6665b17067db5ec01daac 100644 --- a/python/paddle/tensor/math.py +++ b/python/paddle/tensor/math.py @@ -736,7 +736,9 @@ def floor_divide(x, y, name=None): """ op_type = 'elementwise_floordiv' axis = -1 - if paddle.in_dynamic_mode(): + if in_dygraph_mode(): + return _C_ops.final_state_floor_divide(x, y) + if _in_legacy_dygraph(): return _elementwise_op_in_dygraph( x, y, axis=axis, op_name=op_type) @@ -776,7 +778,9 @@ def remainder(x, y, name=None): """ op_type = 'elementwise_mod' axis = -1 - if paddle.in_dynamic_mode(): + if in_dygraph_mode(): + return _C_ops.final_state_modulo(x, y) + if _in_legacy_dygraph(): return _elementwise_op_in_dygraph( x, y, axis=axis, op_name=op_type) @@ -894,7 +898,9 @@ def maximum(x, y, name=None): op_type = 'elementwise_max' axis = -1 act = None - if paddle.in_dynamic_mode(): + if in_dygraph_mode(): + return _C_ops.final_state_maximum(x, y) + if _in_legacy_dygraph(): return _elementwise_op_in_dygraph( x, y, axis=axis, act=act, op_name=op_type) return _elementwise_op(LayerHelper(op_type, **locals())) @@ -953,7 +959,9 @@ def minimum(x, y, name=None): op_type = 'elementwise_min' axis = -1 act = None - if paddle.in_dynamic_mode(): + if in_dygraph_mode(): + return _C_ops.final_state_minimum(x, y) + if _in_legacy_dygraph(): return _elementwise_op_in_dygraph( x, y, axis=axis, act=act, op_name=op_type) return _elementwise_op(LayerHelper(op_type, **locals()))