未验证 提交 b68f1120 编写于 作者: W Weilong Wu 提交者: GitHub

[Eager] polish scale and pow python interface logic (#45259)

上级 e0f1c9f2
...@@ -176,8 +176,7 @@ def scale(x, scale=1.0, bias=0.0, bias_after_scale=True, act=None, name=None): ...@@ -176,8 +176,7 @@ def scale(x, scale=1.0, bias=0.0, bias_after_scale=True, act=None, name=None):
""" """
if in_dygraph_mode(): if in_dygraph_mode():
out = _C_ops.final_state_scale(x, scale, float(bias), bias_after_scale) return _C_ops.final_state_scale(x, scale, float(bias), bias_after_scale)
return dygraph_utils._append_activation_in_dygraph(out)
if _non_static_mode(): if _non_static_mode():
_scale = scale.numpy().item(0) if isinstance(scale, Variable) else scale _scale = scale.numpy().item(0) if isinstance(scale, Variable) else scale
out = _C_ops.scale(x, 'scale', out = _C_ops.scale(x, 'scale',
...@@ -386,8 +385,7 @@ def pow(x, y, name=None): ...@@ -386,8 +385,7 @@ def pow(x, y, name=None):
if isinstance(y, (int, float)): if isinstance(y, (int, float)):
return _C_ops.final_state_pow(x, y) return _C_ops.final_state_pow(x, y)
elif isinstance(y, (paddle.Tensor, Variable)): elif isinstance(y, (paddle.Tensor, Variable)):
return _elementwise_op_in_dygraph( return _C_ops.final_state_elementwise_pow(x, y)
x, y, axis=-1, act=None, op_name='elementwise_pow')
else: else:
raise TypeError('y must be scalar or tensor type, but received: %s '% (y.dtype)) raise TypeError('y must be scalar or tensor type, but received: %s '% (y.dtype))
if _in_legacy_dygraph(): if _in_legacy_dygraph():
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册