test_sum_op.py 614 字节
Newer Older
1 2 3 4 5 6 7 8 9 10 11
import unittest
import numpy as np
from op_test import OpTest


class TestSumOp(OpTest):
    def setUp(self):
        self.op_type = "sum"
        x0 = np.random.random((3, 4)).astype('float32')
        x1 = np.random.random((3, 4)).astype('float32')
        x2 = np.random.random((3, 4)).astype('float32')
12
        self.inputs = {"X": [("x0", x0), ("x1", x1), ("x2", x2)]}
13 14 15 16
        y = x0 + x1 + x2
        self.outputs = {'Out': y}

    def test_check_output(self):
Q
qijun 已提交
17
        self.check_output()
18 19

    def test_check_grad(self):
Q
qijun 已提交
20
        self.check_grad(['x0'], 'Out')
21 22


Q
qijun 已提交
23
if __name__ == "__main__":
24
    unittest.main()