insert a point representing inf at n=0
(self)
| 168 | assert arr.size(1) == n, f'{name}.shape = {arr.shape}, num_points not {n}' |
| 169 | |
| 170 | def insert_point_at_inf(self): |
| 171 | """ |
| 172 | insert a point representing inf at n=0 |
| 173 | """ |
| 174 | if self.included_point_at_inf: |
| 175 | return |
| 176 | |
| 177 | b = self.xyz_w.size(0) |
| 178 | # when using pr to find k points within a fixed distance of ray |
| 179 | # use a far-away point (1e12) to represent that the point is not found |
| 180 | # this far-away point will be replaced by a learned token in the model later on |
| 181 | |
| 182 | for name in self.attr_names: |
| 183 | arr = getattr(self, name, None) |
| 184 | if arr is None: |
| 185 | continue |
| 186 | ndim = arr.shape[2:] |
| 187 | if name == 'xyz_w': |
| 188 | val = INF |
| 189 | elif name == 'valid_mask': |
| 190 | val = 0 |
| 191 | else: |
| 192 | val = 0 |
| 193 | |
| 194 | arr_requires_grad = arr.requires_grad |
| 195 | |
| 196 | arr = torch.cat( |
| 197 | ( |
| 198 | (torch.ones(b, 1, *ndim, dtype=arr.dtype, device=arr.device) * val).to(dtype=arr.dtype), |
| 199 | arr, |
| 200 | ), |
| 201 | dim=1, |
| 202 | ) |
| 203 | arr.requires_grad = arr_requires_grad |
| 204 | setattr(self, name, arr) |
| 205 | |
| 206 | self.included_point_at_inf = True |
| 207 | self.check_dim() |
| 208 | |
| 209 | def reset_point_at_inf(self): |
| 210 | """ |
no test coverage detected