Skip to content

Commit b538f10

Browse files
bottlerfacebook-github-bot
authored andcommitted
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
1 parent 04d318d commit b538f10

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

pytorch3d/renderer/implicit/raymarching.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -177,12 +177,12 @@ def _check_density_bounds(
177177
Checks whether the elements of `rays_densities` range within `bounds`.
178178
If not issues a warning.
179179
"""
180-
# pyre-fixme[16]: `ByteTensor` has no attribute `any`.
181-
if ((rays_densities > bounds[1]) | (rays_densities < bounds[0])).any():
182-
warnings.warn(
183-
"One or more elements of rays_densities are outside of valid"
184-
+ f"range {str(bounds)}"
185-
)
180+
with torch.no_grad():
181+
if (rays_densities.max() > bounds[1]) or (rays_densities.min() < bounds[0]):
182+
warnings.warn(
183+
"One or more elements of rays_densities are outside of valid"
184+
+ f"range {str(bounds)}"
185+
)
186186

187187

188188
def _check_raymarcher_inputs(

0 commit comments

Comments
 (0)