test_reshape_op.py 522 字节
Newer Older
Y
Yibing Liu 已提交
1 2
import unittest
import numpy as np
Y
Yibing Liu 已提交
3
from op_test import OpTest
Y
Yibing Liu 已提交
4 5


Y
Yibing Liu 已提交
6
class TestReshapeOp(OpTest):
Y
Yibing Liu 已提交
7
    def setUp(self):
Y
Yibing Liu 已提交
8 9 10
        self.op_type = "reshape"
        self.inputs = {'X': np.random.random((10, 20)).astype("float32")}
        self.attrs = {'shape': [10 * 20]}
Y
Yibing Liu 已提交
11 12
        self.outputs = {'Out': self.inputs['X'].reshape(self.attrs['shape'])}

Y
Yibing Liu 已提交
13 14
    def test_check_output(self):
        self.check_output()
Y
Yibing Liu 已提交
15

Y
Yibing Liu 已提交
16 17
    def test_check_grad(self):
        self.check_grad(["X"], "Out")
Y
Yibing Liu 已提交
18 19 20 21


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