mirror of
https://github.com/nerfstudio-project/nerfstudio.git
synced 2026-11-13 19:33:46 +08:00
Drop backward compatibility for Torch 1.13 (#1948)
* Drop backward compatibility for Torch 1.13 * Fix lint errors
This commit is contained in:
1 parent
ea3f25d662
commit
08e3a1f1a6
4 files changed
+3
-18
No files matched your search
@@ -25,8 +25,6 @@ from jaxtyping import Float
|
||||
from numpy.typing import NDArray
|
||||
from torch import Tensor
|
||||
|
||||
from nerfstudio.utils.misc import torch_compile
|
||||
|
||||
_EPS = np.finfo(float).eps * 4.0
|
||||
|
||||
|
||||
@@ -407,7 +405,7 @@ def _compute_residual_and_jacobian(
|
||||
return fx, fy, fx_x, fx_y, fy_x, fy_y
|
||||
|
||||
|
||||
@torch_compile(dynamic=True, mode="reduce-overhead", backend="eager")
|
||||
@torch.compile(dynamic=True, mode="reduce-overhead", backend="eager")
|
||||
def radial_and_tangential_undistort(
|
||||
coords: torch.Tensor,
|
||||
distortion_params: torch.Tensor,
|
||||
|
||||
@@ -22,7 +22,6 @@ import torch
|
||||
from jaxtyping import Float
|
||||
from torch import Tensor, nn
|
||||
|
||||
from nerfstudio.utils.misc import torch_compile
|
||||
from nerfstudio.cameras.rays import RayBundle
|
||||
from nerfstudio.data.scene_box import SceneBox
|
||||
|
||||
@@ -109,7 +108,7 @@ class AABBBoxCollider(SceneCollider):
|
||||
return ray_bundle
|
||||
|
||||
|
||||
@torch_compile(dynamic=True, mode="reduce-overhead")
|
||||
@torch.compile(dynamic=True, mode="reduce-overhead")
|
||||
def _intersect_with_sphere(
|
||||
rays_o: torch.Tensor, rays_d: torch.Tensor, center: torch.Tensor, radius: float = 1.0, near_plane: float = 0.0
|
||||
):
|
||||
|
||||
@@ -21,8 +21,6 @@ import torch
|
||||
from jaxtyping import Bool, Float
|
||||
from torch import Tensor
|
||||
|
||||
from nerfstudio.utils.misc import torch_compile
|
||||
|
||||
|
||||
def components_from_spherical_harmonics(
|
||||
levels: int, directions: Float[Tensor, "*batch 3"]
|
||||
@@ -199,7 +197,7 @@ def expected_sin(x_means: torch.Tensor, x_vars: torch.Tensor) -> torch.Tensor:
|
||||
return torch.exp(-0.5 * x_vars) * torch.sin(x_means)
|
||||
|
||||
|
||||
@torch_compile(dynamic=True, mode="reduce-overhead", backend="eager")
|
||||
@torch.compile(dynamic=True, mode="reduce-overhead", backend="eager")
|
||||
def intersect_aabb(
|
||||
origins: torch.Tensor,
|
||||
directions: torch.Tensor,
|
||||
|
||||
@@ -158,13 +158,3 @@ def strtobool(val) -> bool:
|
||||
FMI https://stackoverflow.com/a/715468
|
||||
"""
|
||||
return val.lower() in ("yes", "y", "true", "t", "on", "1")
|
||||
|
||||
|
||||
if hasattr(torch, "compile"):
|
||||
# PyTorch 2.0+
|
||||
torch_compile = torch.compile
|
||||
else:
|
||||
# PyTorch 1.x
|
||||
def torch_compile(*args, **kwargs):
|
||||
"""Fall back to jit script if using pytorch 1.x, args ignored"""
|
||||
return torch.jit.script
|
||||
Reference in new issue
Block a user