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

Method test_chunk

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

Source from the content-addressed store, hash-verified

85 assert torch.allclose(projections, projs)
86
87 def test_chunk(self):
88 b_shape = [3, 5]
89 n = 10
90 m = 7
91 points = torch.randn(*b_shape, n, 3)
92 ray_origins = torch.randn(*b_shape, m, 3)
93 ray_directions = torch.zeros(*b_shape, m, 3)
94 ray_directions[..., 2] = 1.
95
96 # standard (no chunking)
97 out_dict_gt = utils.compute_point_ray_distance(
98 points=points,
99 ray_origins=ray_origins,
100 ray_directions=ray_directions,
101 )
102
103 # with chunking
104 mn = m * n
105 for max_chunk_size in [int(1e9), mn//2, mn+1]:
106 out_dict = utils.compute_point_ray_distance_in_chunks(
107 points=points,
108 ray_origins=ray_origins,
109 ray_directions=ray_directions,
110 max_chunk_size=max_chunk_size,
111 )
112 for key in out_dict_gt:
113 assert torch.allclose(out_dict_gt[key], out_dict[key]), f'{max_chunk_size}'
114
115
116

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected