Fix out of bounds index bug

This commit is contained in:
Matt Tancik authored and Matthew Tancik committed 2022-07-13 10:13:31 -07:00
1 parent 25a1f91dee
commit 7cda0158c7
1 file changed
+2 -2
+2 -2
View File
@@ -317,8 +317,8 @@ class PDFSampler(Sampler):
)
inds = torch.searchsorted(cdf, u, side="right")
below = torch.clamp(inds - 1, 0, num_bins - 1)
above = torch.clamp(inds, 0, num_bins - 1)
below = torch.clamp(inds - 1, 0, existing_bins.shape[-1] - 1)
above = torch.clamp(inds, 0, existing_bins.shape[-1] - 1)
cdf_g0 = torch.gather(cdf, -1, below)
bins_g0 = torch.gather(existing_bins, -1, below)
cdf_g1 = torch.gather(cdf, -1, above)