未验证 提交 122fff46 编写于 作者: B BiynXu 提交者: GitHub

[PHI]Add yaml and unittest for bmm op (#44625)

Add yaml and unittest for bmm op
上级 d62af8b4
......@@ -326,6 +326,16 @@
kernel :
func : bitwise_xor
# bmm
- api : bmm
args : (Tensor x, Tensor y)
output : Tensor
infer_meta :
func : BmmInferMeta
kernel :
func : bmm
backward : bmm_grad
# box_coder
- api : box_coder
args : (Tensor prior_box, Tensor prior_box_var, Tensor target_box, str code_type, bool box_normalized, int axis, float[] variance)
......
......@@ -260,6 +260,15 @@
kernel :
func : bilinear_tensor_product_grad
- backward_api : bmm_grad
forward : bmm (Tensor x, Tensor y) -> Tensor(out)
args : (Tensor x, Tensor y, Tensor out_grad)
output : Tensor(x_grad), Tensor(y_grad)
infer_meta :
func : BmmGradInferMeta
kernel :
func : bmm_grad
- backward_api : brelu_grad
forward : brelu (Tensor x, float t_min, float t_max) -> Tensor(out)
args : (Tensor x, Tensor out_grad, float t_min, float t_max)
......
......@@ -27,6 +27,7 @@ class TestBmmOp(OpTest):
def setUp(self):
self.op_type = "bmm"
self.python_api = paddle.tensor.bmm
X = np.random.random((10, 3, 4)).astype("float64")
Y = np.random.random((10, 4, 5)).astype("float64")
self.inputs = {'X': X, 'Y': Y}
......@@ -34,10 +35,10 @@ class TestBmmOp(OpTest):
self.outputs = {'Out': Out}
def test_check_output(self):
self.check_output()
self.check_output(check_eager=True)
def test_checkout_grad(self):
self.check_grad(['X', 'Y'], 'Out')
self.check_grad(['X', 'Y'], 'Out', check_eager=True)
class API_TestBmm(unittest.TestCase):
......
......@@ -1521,6 +1521,9 @@ def bmm(x, y, name=None):
"x's batch (shape[0]) must be equal with y's batch (shape[0]). But received x's shape: {}, y's shape: {}"
.format(x_shape, y_shape))
if in_dygraph_mode():
return _C_ops.final_state_bmm(x, y)
if paddle.in_dynamic_mode():
return _C_ops.bmm(x, y)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册