Use sample_pdf from PyTorch3D in NeRF

Summary:
Use PyTorch3D's new faster sample_pdf function instead of local Python implementation.

Also clarify deps for the Python implementation.

Reviewed By: gkioxari

Differential Revision: D30512109

fbshipit-source-id: 84cfdc00313fada37a6b29837de96f6a4646434f
This commit is contained in:
Jeremy Reizenstein
2021-08-31 10:38:58 -07:00
committed by Facebook GitHub Bot
parent d2bbd0cdb7
commit 1251446383
5 changed files with 5 additions and 70 deletions

View File

@@ -75,14 +75,15 @@ def sample_pdf_python(
This is a pure python implementation of the `sample_pdf` function.
It may be faster than sample_pdf when the number of bins is very large,
because it behaves as O(batchsize * [n_bins + log(n_bins) * n_samples] )
whereas sample_pdf behaves as O(batchsize * n_bins * n_samples).
whereas sample_pdf behaves as O(batchsize * n_bins * n_samples).
For 64 bins sample_pdf is much faster.
Samples probability density functions defined by bin edges `bins` and
the non-negative per-bin probabilities `weights`.
Note: This is a direct conversion of the TensorFlow function from the original
release [1] to PyTorch.
release [1] to PyTorch. It requires PyTorch 1.6 or greater due to the use of
torch.searchsorted.
Args:
bins: Tensor of shape `(..., n_bins+1)` denoting the edges of the sampling bins.