(
self,
b: int = 1,
n: int = 10000, # number of points
m: int = 80000, # number of rays
k: int = 40, # number of neighboring points
ray_radius: float = 0.1,
grid_size: int = 100,
grid_width: float = 1.,
# pointersect
num_layers: int = 4,
)
| 14 | |
| 15 | class TestSpeed(unittest.TestCase): |
| 16 | def test( |
| 17 | self, |
| 18 | b: int = 1, |
| 19 | n: int = 10000, # number of points |
| 20 | m: int = 80000, # number of rays |
| 21 | k: int = 40, # number of neighboring points |
| 22 | ray_radius: float = 0.1, |
| 23 | grid_size: int = 100, |
| 24 | grid_width: float = 1., |
| 25 | # pointersect |
| 26 | num_layers: int = 4, |
| 27 | |
| 28 | ): |
| 29 | print('very beginning') |
| 30 | torch.cuda.empty_cache() |
| 31 | print(f'cuda memory reserved: {torch.cuda.memory_reserved(0)/1.e6} MB') |
| 32 | print(f'cuda memory allocated: {torch.cuda.memory_allocated(0)/1.e6} MB') |
| 33 | |
| 34 | points = (torch.rand(b, n, 3) - 0.5) * 2 * grid_width |
| 35 | ray_origins = torch.randn(b, m, 3) |
| 36 | ray_directions = torch.nn.functional.normalize(torch.randn(b, m, 3), dim=-1) |
| 37 | ray_radius = torch.ones(b) * ray_radius |
| 38 | grid_size = torch.ones(b, 3, dtype=torch.long) * grid_size |
| 39 | grid_width = torch.ones(b, 3) * grid_width |
| 40 | |
| 41 | # # test cpu |
| 42 | # device = torch.device('cpu') |
| 43 | # points = points.to(device=device) |
| 44 | # ray_origins = ray_origins.to(device=device) |
| 45 | # ray_directions = ray_directions.to(device=device) |
| 46 | # ray_radius = ray_radius.to(device=device) if isinstance(ray_radius, torch.Tensor) else ray_radius |
| 47 | # grid_size = grid_size.to(device=device) if isinstance(grid_size, torch.Tensor) else grid_size |
| 48 | # grid_width = grid_width.to(device=device) if isinstance(grid_width, torch.Tensor) else grid_width |
| 49 | # |
| 50 | # stime = timer() |
| 51 | # all_ray2pidxs = pr_utils.find_neighbor_points_of_rays( |
| 52 | # points=points, |
| 53 | # ray_origins=ray_origins, |
| 54 | # ray_directions=ray_directions, |
| 55 | # ray_radius=ray_radius, |
| 56 | # grid_size=grid_size, |
| 57 | # grid_width=grid_width, |
| 58 | # ) |
| 59 | # time_pr_old = timer() - stime |
| 60 | # print(f'pr_old_cpu: {time_pr_old:.3f} secs') |
| 61 | |
| 62 | |
| 63 | if not torch.cuda.is_available(): |
| 64 | return |
| 65 | |
| 66 | # test gpu |
| 67 | device = torch.device('cuda') |
| 68 | points = points.to(device=device) |
| 69 | ray_origins = ray_origins.to(device=device) |
| 70 | ray_directions = ray_directions.to(device=device) |
| 71 | ray_radius = ray_radius.to(device=device) if isinstance(ray_radius, torch.Tensor) else ray_radius |
| 72 | grid_size = grid_size.to(device=device) if isinstance(grid_size, torch.Tensor) else grid_size |
| 73 | grid_width = grid_width.to(device=device) if isinstance(grid_width, torch.Tensor) else grid_width |
nothing calls this directly
no test coverage detected