Farthest point sampling python naive

Summary:
This is a naive python implementation of the iterative farthest point sampling algorithm along with associated simple tests. The C++/CUDA implementations will follow in subsequent diffs.

The algorithm is used to subsample a pointcloud with better coverage of the space of the pointcloud.

The function has not been added to `__init__.py`. I will add this after the full C++/CUDA implementations.

Reviewed By: jcjohnson

Differential Revision: D30285716

fbshipit-source-id: 33f4181041fc652776406bcfd67800a6f0c3dd58
This commit is contained in:
Nikhila Ravi
2021-09-15 13:47:55 -07:00
committed by Facebook GitHub Bot
parent a0d76a7080
commit 3b7d78c7a7
5 changed files with 295 additions and 12 deletions

View File

@@ -76,3 +76,13 @@ class TestOpsUtils(TestCaseMixin, unittest.TestCase):
mean = oputil.wmean(x, dim=(0, 1), weight=weight, keepdim=False)
mean_gt = np.average(x_np, axis=(0, 1), weights=weight_np)
self.assertClose(mean.cpu().data.numpy(), mean_gt)
def test_masked_gather_errors(self):
idx = torch.randint(0, 10, size=(5, 10, 4, 2))
points = torch.randn(size=(5, 10, 3))
with self.assertRaisesRegex(ValueError, "format is not supported"):
oputil.masked_gather(points, idx)
points = torch.randn(size=(2, 10, 3))
with self.assertRaisesRegex(ValueError, "same batch dimension"):
oputil.masked_gather(points, idx)