gather the points belonging to each grid cell. Args: grid_idxs: grid index of each point total_cells: total grid cells valid_mask: whether to record the point Returns: list of list of list, (b, total_cells[bidx]) -> n
(
grid_idxs: torch.Tensor, # (b, n), long
total_cells: torch.Tensor, # (b,) long
valid_mask: torch.Tensor = None, # (b, n), bool
)
| 157 | |
| 158 | |
| 159 | def gather_points( |
| 160 | grid_idxs: torch.Tensor, # (b, n), long |
| 161 | total_cells: torch.Tensor, # (b,) long |
| 162 | valid_mask: torch.Tensor = None, # (b, n), bool |
| 163 | ) -> T.List[T.List[T.List[int]]]: |
| 164 | """ |
| 165 | gather the points belonging to each grid cell. |
| 166 | |
| 167 | Args: |
| 168 | grid_idxs: |
| 169 | grid index of each point |
| 170 | total_cells: |
| 171 | total grid cells |
| 172 | valid_mask: |
| 173 | whether to record the point |
| 174 | |
| 175 | Returns: |
| 176 | list of list of list, (b, total_cells[bidx]) -> n_idx of points in the cell |
| 177 | """ |
| 178 | batch_size, n_points = grid_idxs.shape |
| 179 | grid_idxs = grid_idxs.long() |
| 180 | total_cells = total_cells.long() |
| 181 | |
| 182 | all_cell2pidx = [] |
| 183 | for b in range(batch_size): |
| 184 | cell2pidx: T.List[T.List[int]] = [[] for _ in range(total_cells[b])] |
| 185 | for i in range(n_points): |
| 186 | if valid_mask is None or valid_mask[b, i]: |
| 187 | cell2pidx[grid_idxs[b, i]].append(i) |
| 188 | all_cell2pidx.append(cell2pidx) |
| 189 | return all_cell2pidx |
| 190 | |
| 191 | |
| 192 | def grid_ray_intersection( |
no outgoing calls
no test coverage detected