Skip to content

Commit

Permalink
Add more tolerance to allclose tests in SPC (#497)
Browse files Browse the repository at this point in the history
Signed-off-by: Towaki Takikawa <ttakikawa@nvidia.com>
  • Loading branch information
tovacinni committed Dec 17, 2021
1 parent 0236fbc commit 5422898
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion tests/python/kaolin/ops/spc/test_points.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,4 @@ def test_coords_to_trilinear(self, points):
w[:, 0] * w[:, 1] * (1 - w[:, 2]),
w[:, 0] * w[:, 1] * w[:, 2]
], dim=-1)
assert torch.allclose(coords_to_trilinear(x, points), expected_coeffs)
assert torch.allclose(coords_to_trilinear(x, points), expected_coeffs, atol=1e-5)
10 changes: 5 additions & 5 deletions tests/python/kaolin/render/spc/test_rayops.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def test_sum_reduce_big(self, feats_big, boundaries_big):
fdim = feats_big.shape[-1]
sum_reduce = spc_render.sum_reduce(feats_big.reshape(-1, fdim), boundaries_big)
expected = feats_big.sum(1)
assert torch.allclose(sum_reduce, expected)
assert torch.allclose(sum_reduce, expected, atol=1e-5)

def test_sum_reduce_big_backward(self, feats_big, boundaries_big):

Expand All @@ -97,7 +97,7 @@ def test_sum_reduce_big_backward(self, feats_big, boundaries_big):
loss.backward()
grad1 = feats_big.grad.clone()

assert torch.allclose(grad0, grad1)
assert torch.allclose(grad0, grad1, atol=1e-5)

def test_cumsum(self, feats, boundaries):
cumsum = spc_render.cumsum(feats, boundaries)
Expand All @@ -108,7 +108,7 @@ def test_cumsum_big(self, feats_big, boundaries_big):
fdim = feats_big.shape[-1]
cumsum = spc_render.cumsum(feats_big.reshape(-1, fdim), boundaries_big)
expected = torch.cumsum(feats_big, dim=1).reshape(-1, fdim)
assert torch.allclose(cumsum, expected)
assert torch.allclose(cumsum, expected, atol=1e-5)

def test_cumsum_big_backward(self, feats_big, boundaries_big):

Expand All @@ -131,7 +131,7 @@ def test_cumsum_big_backward(self, feats_big, boundaries_big):
loss.backward()
grad1 = feats_big.grad.clone()

assert torch.allclose(grad0, grad1)
assert torch.allclose(grad0, grad1, atol=1e-4)

def test_cumsum_reverse(self, feats, boundaries):
cumsum = spc_render.cumsum(feats, boundaries, reverse=True)
Expand All @@ -157,7 +157,7 @@ def test_cumprod_big(self, feats_big, boundaries_big):
fdim = feats_big.shape[-1]
cumprod = spc_render.cumprod(feats_big.reshape(-1, fdim), boundaries_big)
expected = torch.cumprod(feats_big, dim=1).reshape(-1, fdim)
assert torch.allclose(cumprod, expected)
assert torch.allclose(cumprod, expected, atol=1e-4)

def test_cumprod_big_backward(self, feats_big, boundaries_big):

Expand Down

0 comments on commit 5422898

Please sign in to comment.