test_interp_op.py 715 字节
Newer Older
L
Luo Tao 已提交
1 2 3 4 5 6 7 8 9 10 11 12
import unittest
import numpy as np
from op_test import OpTest


class TestInterpOp(OpTest):
    def setUp(self):
        self.op_type = "interp"
        x = np.random.random((2, 3)).astype("float32")
        y = np.random.random((2, 3)).astype("float32")
        w = np.random.random(2).astype("float32")

L
Luo Tao 已提交
13 14
        sub_out = x - y
        mul_out = sub_out * w.reshape(2, 1)
L
Luo Tao 已提交
15 16 17
        out = mul_out + y

        self.inputs = {'X': x, 'Y': y, 'W': w}
L
Luo Tao 已提交
18
        self.outputs = {'Out': out, 'SubOut': sub_out, 'MulOut': mul_out}
L
Luo Tao 已提交
19 20 21 22 23 24 25 26 27 28

    def test_check_output(self):
        self.check_output()

    def test_check_grad_normal(self):
        self.check_grad(['X', 'Y'], 'Out')


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