Skip to content

Commit 009a3d3

Browse files
bottlerfacebook-github-bot
authored andcommitted
projects/nerf subsampling fix for newish pytorch #1441
Summary: Fix for #1441 where we were indexing with a tensor on the wrong device. Reviewed By: shapovalov Differential Revision: D46276449 fbshipit-source-id: 7750ed45ffecefa5d291fd1eadfe515310c2cf0d
1 parent cd5db07 commit 009a3d3

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

projects/nerf/nerf/raysampler.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -330,9 +330,9 @@ def forward(
330330

331331
if self.training:
332332
# During training we randomly subsample rays.
333-
sel_rays = torch.randperm(n_pixels, device=device)[
334-
: self._mc_raysampler._n_rays_per_image
335-
]
333+
sel_rays = torch.randperm(
334+
n_pixels, device=full_ray_bundle.lengths.device
335+
)[: self._mc_raysampler._n_rays_per_image]
336336
else:
337337
# In case we test, we take only the requested chunk.
338338
if chunksize is None:

0 commit comments

Comments
 (0)