Avoid temporary arrays in _check_density_bounds

Summary: We can check the bounds without using extra memory. This produces a small speedup in NeRF training (like 0.5%).

Reviewed By: nikhilaravi

Differential Revision: D27859691

fbshipit-source-id: d566420c465f51231f4a57438084c98b73253046
This commit is contained in:
Jeremy Reizenstein 2021-04-22 07:08:52 -07:00 committed by Facebook GitHub Bot
parent 04d318d88f
commit b538f10796

View File

@ -177,12 +177,12 @@ def _check_density_bounds(
Checks whether the elements of `rays_densities` range within `bounds`.
If not issues a warning.
"""
# pyre-fixme[16]: `ByteTensor` has no attribute `any`.
if ((rays_densities > bounds[1]) | (rays_densities < bounds[0])).any():
warnings.warn(
"One or more elements of rays_densities are outside of valid"
+ f"range {str(bounds)}"
)
with torch.no_grad():
if (rays_densities.max() > bounds[1]) or (rays_densities.min() < bounds[0]):
warnings.warn(
"One or more elements of rays_densities are outside of valid"
+ f"range {str(bounds)}"
)
def _check_raymarcher_inputs(