Bug fix for case where aspect ratio is a float

Summary:
- Fix the calculation of the non square NDC range when the H and W are not integer multiples.
- Add test for this case

Reviewed By: gkioxari

Differential Revision: D26613213

fbshipit-source-id: df6763cac602e9f1d516b41b432c4d2cfbaa356d
This commit is contained in:
Nikhila Ravi
2021-02-24 10:05:07 -08:00
committed by Facebook GitHub Bot
parent 0345f860d4
commit 13429640d3
4 changed files with 15 additions and 18 deletions

View File

@@ -314,7 +314,7 @@ class TestRasterizeRectangleImagesMeshes(TestCaseMixin, unittest.TestCase):
# Finally check the gradients of the input vertices for
# the square and non square case
self.assertClose(verts_square.grad, grad_tensor.grad, rtol=2e-4)
self.assertClose(verts_square.grad, grad_tensor.grad, rtol=3e-4)
def test_gpu(self):
"""
@@ -323,8 +323,9 @@ class TestRasterizeRectangleImagesMeshes(TestCaseMixin, unittest.TestCase):
dists, zbuf, bary are all the same for the square
region which is present in both images.
"""
# Test both cases: (W > H), (H > W)
image_sizes = [(64, 128), (128, 64), (128, 256), (256, 128)]
# Test both cases: (W > H), (H > W) as well as the case where
# H and W are not integer multiples of each other (i.e. float aspect ratio)
image_sizes = [(64, 128), (128, 64), (128, 256), (256, 128), (600, 1110)]
devices = ["cuda:0"]
blurs = [0.0, 0.001]
@@ -391,7 +392,7 @@ class TestRasterizeRectangleImagesMeshes(TestCaseMixin, unittest.TestCase):
"""
# Test both when (W > H) and (H > W).
# Using smaller image sizes here as the Python rasterizer is really slow.
image_sizes = [(32, 64), (64, 32)]
image_sizes = [(32, 64), (64, 32), (60, 110)]
devices = ["cpu"]
blurs = [0.0, 0.001]
batch_sizes = [1]
@@ -646,8 +647,9 @@ class TestRasterizeRectangleImagesPointclouds(TestCaseMixin, unittest.TestCase):
dists, zbuf, idx are all the same for the square
region which is present in both images.
"""
# Test both cases: (W > H), (H > W)
image_sizes = [(64, 128), (128, 64), (128, 256), (256, 128)]
# Test both cases: (W > H), (H > W) as well as the case where
# H and W are not integer multiples of each other (i.e. float aspect ratio)
image_sizes = [(64, 128), (128, 64), (128, 256), (256, 128), (600, 1110)]
devices = ["cuda:0"]
blurs = [5e-2]
@@ -713,7 +715,7 @@ class TestRasterizeRectangleImagesPointclouds(TestCaseMixin, unittest.TestCase):
"""
# Test both when (W > H) and (H > W).
# Using smaller image sizes here as the Python rasterizer is really slow.
image_sizes = [(32, 64), (64, 32)]
image_sizes = [(32, 64), (64, 32), (60, 110)]
devices = ["cpu"]
blurs = [5e-2]
batch_sizes = [1]