test_interp_op.py 723 字节
Newer Older
L
Luo Tao 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
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")

        minus_out = x - y
        mul_out = minus_out * w.reshape(2, 1)
        out = mul_out + y

        self.inputs = {'X': x, 'Y': y, 'W': w}
        self.outputs = {'Out': out, 'MinusOut': minus_out, 'MulOut': mul_out}

    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()