test_concat_op.py 704 字节
Newer Older
1 2
import unittest
import numpy as np
3
from op_test import OpTest
4 5


6
class TestConcatOp(OpTest):
7
    def setUp(self):
8
        self.op_type = "concat"
9 10
        x0 = np.random.random((2, 1, 4, 5)).astype('float32')
        x1 = np.random.random((2, 2, 4, 5)).astype('float32')
11
        x2 = np.random.random((2, 3, 4, 5)).astype('float32')
12
        axis = 1
13
        self.inputs = {'X': [('x0', x0), ('x1', x1), ('x2', x2)]}
14 15 16
        self.attrs = {'axis': axis}
        self.outputs = {'Out': np.concatenate((x0, x1, x2), axis=axis)}

17 18 19
    def test_check_output(self):
        self.check_output()

20 21 22
    def test_check_grad(self):
        self.check_grad(['x0'], 'Out')

23 24 25

if __name__ == '__main__':
    unittest.main()