未验证 提交 e31bffee 编写于 作者: C chentianyu03 提交者: GitHub

[Yaml]add exp yaml (#41217)

* add exp yaml

* add exp api in test case

* add determinant yaml

* fix exp op unittest

* change test class name

* modify api name

* compacted with raw api

* fix det api

* add python_api

* add test eager for determinant op
上级 c4e54acd
......@@ -50,7 +50,8 @@ class TestActivation(OpTest):
self.op_type = "exp"
self.init_dtype()
self.init_kernel_type()
self.check_eager = False
self.check_eager = True
self.python_api = paddle.exp
np.random.seed(2049)
x = np.random.uniform(0.1, 1, [11, 17]).astype(self.dtype)
......
......@@ -22,21 +22,23 @@ import paddle.nn.functional as F
import paddle.fluid as fluid
import paddle.fluid.core as core
import paddle.tensor as tensor
from paddle.fluid.framework import _test_eager_guard
paddle.enable_static()
class TestDeterminantOp(OpTest):
def setUp(self):
self.python_api = paddle.linalg.det
self.init_data()
self.op_type = "determinant"
self.outputs = {'Out': self.target}
def test_check_output(self):
self.check_output()
self.check_output(check_eager=True)
def test_check_grad(self):
self.check_grad(['Input'], ['Out'])
self.check_grad(['Input'], ['Out'], check_eager=True)
def init_data(self):
np.random.seed(0)
......@@ -89,6 +91,10 @@ class TestDeterminantAPI(unittest.TestCase):
self.assertEqual(np.allclose(out.numpy(), out_ref, rtol=1e-03), True)
paddle.enable_static()
def test_eager(self):
with _test_eager_guard():
self.test_api_dygraph()
class TestSlogDeterminantOp(OpTest):
def setUp(self):
......
......@@ -1580,7 +1580,10 @@ def det(x, name=None):
"""
if paddle.in_dynamic_mode():
if in_dygraph_mode():
return _C_ops.final_state_det(x)
if _in_legacy_dygraph():
return _C_ops.determinant(x)
check_dtype(x.dtype, 'Input', ['float32', 'float64'], 'det')
......
......@@ -443,6 +443,15 @@
func : depthwise_conv2d_transpose
backward : depthwise_conv2d_transpose_grad
- api : det
args : (Tensor x)
output : Tensor
infer_meta :
func : UnchangedInferMeta
kernel :
func : determinant
backward : det_grad
- api : diag
args : (Tensor x, int offset, float padding_value)
output : Tensor
......@@ -587,6 +596,16 @@
func : erfinv
backward : erfinv_grad
# exp
- api : exp
args : (Tensor x)
output : Tensor
infer_meta :
func : UnchangedInferMeta
kernel :
func : exp
backward : exp_grad
# expand_as
- api : expand_as
args : (Tensor x, Tensor y, int[] target_shape)
......
......@@ -310,6 +310,16 @@
kernel :
func : depthwise_conv2d_transpose_grad
- backward_api : det_grad
forward : det (Tensor x) -> Tensor(out)
args : (Tensor x, Tensor out, Tensor out_grad)
output : Tensor(x_grad)
infer_meta :
func : UnchangedInferMeta
param : [x]
kernel :
func : determinant_grad
- backward_api : diagonal_grad
forward : diagonal (Tensor x, int offset, int axis1, int axis2) -> Tensor(out)
args : (Tensor x, Tensor out_grad, int offset = 0, int axis1 = 0, int axis2 = 1)
......@@ -413,6 +423,16 @@
kernel :
func : erfinv_grad
- backward_api : exp_grad
forward : exp (Tensor x) -> Tensor(out)
args : (Tensor out, Tensor out_grad)
output : Tensor(x_grad)
infer_meta :
func : UnchangedInferMeta
param : [out]
kernel :
func : exp_grad
- backward_api : expand_as_grad
forward : expand_as (Tensor x, Tensor y, int[] target_shape) -> Tensor(out)
args : (Tensor x, Tensor out_grad, int[] target_shape)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册