Skip to content

Commit

Permalink
add unittest
Browse files Browse the repository at this point in the history
  • Loading branch information
Liyulingyue committed Aug 28, 2023
1 parent 81770a5 commit d8f8bb5
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions test/legacy_test/test_linear_interp_v2_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,24 @@ def test_case(self):
np.testing.assert_allclose(interp.numpy(), expect, rtol=1e-05)


class TestLinearInterpOpAPI2_0_case2(unittest.TestCase):
def test_case(self):
# dygraph
x_data = np.random.random((1, 3, 128)).astype("float32")
us_1 = paddle.nn.Upsample(
size=[64], mode='linear', align_mode=1, align_corners=False
)
with fluid.dygraph.guard():
x = fluid.dygraph.to_variable(x_data)
interp = us_1(x)

expect = linear_interp_np(
x_data, out_w=64, align_mode=1, align_corners=False
)

np.testing.assert_allclose(interp.numpy(), expect, rtol=1e-05)


class TestLinearInterpOpFP16(TestLinearInterpOp):
def test_check_output(self):
self.check_output(atol=1e-3)
Expand Down

0 comments on commit d8f8bb5

Please sign in to comment.