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

[Phi] heaviside add yaml (#49807)

上级 ad4824e5
......@@ -411,6 +411,16 @@
kernel :
func : einsum_grad
- backward_op : elementwise_heaviside_grad
forward : heaviside (Tensor x, Tensor y) -> Tensor(out)
args : (Tensor x, Tensor y, Tensor out_grad, int axis = -1)
output : Tensor(x_grad), Tensor(y_grad)
infer_meta :
func : GeneralBinaryGradInferMeta
param : [x, y]
kernel :
func : elementwise_heaviside_grad
- backward_op : elementwise_pow_grad
forward : elementwise_pow(Tensor x, Tensor y) -> Tensor(out)
args : (Tensor x, Tensor y, Tensor out_grad, int axis=-1)
......
......@@ -564,6 +564,15 @@
func : einsum
backward : einsum_grad
- op : elementwise_heaviside
args : (Tensor x, Tensor y)
output : Tensor
infer_meta :
func : ElementwiseInferMeta
kernel :
func : elementwise_heaviside
backward : elementwise_heaviside_grad
- op : elementwise_pow
args : (Tensor x, Tensor y)
output : Tensor(out)
......
......@@ -32,20 +32,21 @@ class TestElementwiseOp(OpTest):
self.op_type = "elementwise_heaviside"
x = np.random.random((13, 17)).astype("float64")
y = np.random.random((13, 17)).astype("float64")
self.python_api = paddle.heaviside
self.inputs = {'X': x, 'Y': y}
self.outputs = {'Out': np.heaviside(self.inputs['X'], self.inputs['Y'])}
def test_check_output(self):
self.check_output()
self.check_output(check_eager=True)
def test_check_grad_normal(self):
self.check_grad(['X', 'Y'], 'Out')
self.check_grad(['X', 'Y'], 'Out', check_eager=True)
def test_check_grad_ingore_x(self):
self.check_grad(['Y'], 'Out', no_grad_set=set("X"))
self.check_grad(['Y'], 'Out', no_grad_set=set("X"), check_eager=True)
def test_check_grad_ingore_y(self):
self.check_grad(['X'], 'Out', no_grad_set=set('Y'))
self.check_grad(['X'], 'Out', no_grad_set=set('Y'), check_eager=True)
class TestHeavisideBroadcast(unittest.TestCase):
......
......@@ -4857,14 +4857,10 @@ def heaviside(x, y, name=None):
# [[0. , 0.20000000, 1. ],
# [0. , 1. , 0.30000001]]
"""
op_type = 'elementwise_heaviside'
axis = -1
act = None
if in_dygraph_mode():
return _elementwise_op_in_dygraph(
x, y, axis=axis, act=act, op_name=op_type
)
return _C_ops.elementwise_heaviside(x, y)
else:
op_type = 'elementwise_heaviside'
return _elementwise_op(LayerHelper(op_type, **locals()))
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册