Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix test_grid_sample.py and test_affine_grid.py threshold #6125

Merged
merged 3 commits into from
Sep 1, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions python/oneflow/test/modules/test_affine_grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ def test_affine_grid_2d(test_case):
)
groundtruth = np.array([[[[0.0, -3.0], [2.0, 5.0]], [[4.0, 7.0], [6.0, 15.0]]]])
test_case.assertTrue(
np.allclose(output.numpy(), groundtruth, rtol=1e-4, atol=1e-8)
np.allclose(output.numpy(), groundtruth, rtol=1e-3, atol=1e-4)
)

output = flow.nn.functional.affine_grid(
input, flow.Size([1, 1, 2, 2]), align_corners=False
)
groundtruth = np.array([[[[1.5, 1.5], [2.5, 5.5]], [[3.5, 6.5], [4.5, 10.5]]]])
test_case.assertTrue(
np.allclose(output.numpy(), groundtruth, rtol=1e-4, atol=1e-8)
np.allclose(output.numpy(), groundtruth, rtol=1e-3, atol=1e-4)
)

def test_affine_grid_3d(test_case):
Expand All @@ -64,7 +64,7 @@ def test_affine_grid_3d(test_case):
]
)
test_case.assertTrue(
np.allclose(output.numpy(), groundtruth, rtol=1e-4, atol=1e-8)
np.allclose(output.numpy(), groundtruth, rtol=1e-3, atol=1e-4)
)

output = flow.nn.functional.affine_grid(
Expand All @@ -85,10 +85,10 @@ def test_affine_grid_3d(test_case):
]
)
test_case.assertTrue(
np.allclose(output.numpy(), groundtruth, rtol=1e-4, atol=1e-8)
np.allclose(output.numpy(), groundtruth, rtol=1e-3, atol=1e-4)
)

@autotest()
@autotest(rtol=1e-03, atol=1e-04)
def test_flow_affine_grid_2d_with_random_data(test_case):
N = randint(1, 8)
C = randint(1, 8)
Expand Down
6 changes: 3 additions & 3 deletions python/oneflow/test/modules/test_grid_sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ def test_grid_sample_4d(test_case):
input, grid, mode="nearest", padding_mode="zeros", align_corners=True
)
test_case.assertTrue(
np.allclose(output.numpy(), groundtruth, rtol=1e-4, atol=1e-8)
np.allclose(output.numpy(), groundtruth, rtol=1e-3, atol=1e-4)
)

@unittest.skipIf(os.getenv("ONEFLOW_TEST_CPU_ONLY"), "only test cpu cases")
@autotest()
@autotest(rtol=1e-03, atol=1e-04)
def test_flow_grid_sample_cudnn_with_random_data(test_case):
# cudnn only support 4D input, with mode = 'bilinear' && padding_mode = 'zeros' && align_corners
N = randint(1, 8)
Expand Down Expand Up @@ -78,7 +78,7 @@ def test_flow_grid_sample_cudnn_with_random_data(test_case):
)
return output

@autotest()
@autotest(rtol=1e-03, atol=1e-04)
def test_flow_grid_sample_4d_with_random_data(test_case):
N = randint(1, 8)
C = randint(1, 8)
Expand Down