Args: points: (b, m, k, 3) or (bm, k, 3), m: number of rays, n: number of neighbor points, xyz coord of points additional_features: (b, m, n, dim_point_feature) neighbor_num: (b, m) number of valid neighbors found by pr_cuda. dtype: lo
(
self,
points: torch.Tensor,
additional_features: torch.Tensor = None,
neighbor_num: torch.Tensor = None,
valid_mask: torch.Tensor = None,
printout: bool = False,
max_chunk_size: int = -1,
check_finite: bool = False,
)
| 220 | raise NotImplementedError |
| 221 | |
| 222 | def forward( |
| 223 | self, |
| 224 | points: torch.Tensor, |
| 225 | additional_features: torch.Tensor = None, |
| 226 | neighbor_num: torch.Tensor = None, |
| 227 | valid_mask: torch.Tensor = None, |
| 228 | printout: bool = False, |
| 229 | max_chunk_size: int = -1, |
| 230 | check_finite: bool = False, |
| 231 | ): |
| 232 | """ |
| 233 | Args: |
| 234 | points: (b, m, k, 3) or (bm, k, 3), m: number of rays, n: number of neighbor points, xyz coord of points |
| 235 | additional_features: (b, m, n, dim_point_feature) |
| 236 | neighbor_num: |
| 237 | (b, m) number of valid neighbors found by pr_cuda. dtype: long |
| 238 | pr_cuda returns index (b, m, k), among the k points, only neighbor_num[b, m] is valid, |
| 239 | others are padding with dummy index 0 (mapped to (10^12, 10^12, 10^12)) |
| 240 | valid_mask: |
| 241 | (b, m, k) or (bm, k) whether the point is valid to use |
| 242 | |
| 243 | Returns: |
| 244 | ts: (b, m) |
| 245 | surface_normals: (b, m, 3) |
| 246 | """ |
| 247 | |
| 248 | if max_chunk_size < 0: |
| 249 | max_chunk_size = np.inf |
| 250 | |
| 251 | *b_shape, n, dim = points.shape |
| 252 | device = points.device |
| 253 | |
| 254 | # Note that when we only find neighbors within a fixed distance of ray and the number < n, |
| 255 | # we use a far away dummy point (1e12,1e12,1e12) to the fill the neighbor position |
| 256 | # so pr points may contain a far away one |
| 257 | |
| 258 | points = points.reshape(-1, points.size(-2), points.size(-1)) # (b*m, n, 3) |
| 259 | |
| 260 | if valid_mask is not None: |
| 261 | valid_mask = valid_mask.reshape(-1, points.size(-2)) # (bm, n) |
| 262 | |
| 263 | # pr use neighbor_num to know which points are invalid |
| 264 | if self.use_pr: |
| 265 | assert neighbor_num is not None, "need to include neighbor num when use pr" |
| 266 | |
| 267 | assert torch.isfinite(points).all() |
| 268 | # The position of points can actually be infinite. Since the ray may shoot to opposite direction to all points, |
| 269 | # the t_s will all be negative and thus become inf. |
| 270 | |
| 271 | # get positional encoding |
| 272 | xs = self.pos_embedder(points) # (b*m, n, dim) |
| 273 | |
| 274 | if check_finite and (not torch.isfinite(xs).all() or torch.isnan(xs).any()): |
| 275 | print('positional embedding is wrong!') |
| 276 | |
| 277 | # concat additional feature |
| 278 | if additional_features is not None: |
| 279 | xs = torch.cat( |
nothing calls this directly
no test coverage detected