MCPcopy Create free account
hub / github.com/apple/ml-pointersect / test_chunk

Method test_chunk

tests/plib/test_utils.py:179–208  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

177class Test_KNN(unittest.TestCase):
178
179 def test_chunk(self):
180 b_shape = [3, 5]
181 n = 10
182 m = 7
183 k=6
184 points = torch.randn(*b_shape, n, 3)
185 ray_origins = torch.randn(*b_shape, m, 3)
186 ray_directions = torch.zeros(*b_shape, m, 3)
187 ray_directions[..., 2] = 1.
188
189 # standard (no chunking)
190 out_dict_gt = utils.get_k_neighbor_points(
191 points=points,
192 ray_origins=ray_origins,
193 ray_directions=ray_directions,
194 k=k,
195 )
196
197 # with chunking
198 mn = m * n
199 for max_chunk_size in [int(1e9), mn//2, mn+1]:
200 out_dict = utils.get_k_neighbor_points_in_chunks(
201 points=points,
202 ray_origins=ray_origins,
203 ray_directions=ray_directions,
204 k=k,
205 max_chunk_size=max_chunk_size,
206 )
207 for key in out_dict_gt:
208 assert torch.allclose(out_dict_gt[key], out_dict[key]), f'{max_chunk_size}'
209
210
211

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected