Fix some typing problems (#1940)

* Fix some typing problems

* nerfstudio.data typing error fixes

* Add tiny fixes

* Remove ABC from pipeline

* Prevent circular imports

* Tweak ModuleList typing

* TrainingCallbackAttributes cleanup

* Various minor nits

* More nits

* Run `ruff`

---------

Co-authored-by: Brent Yi <yibrenth@gmail.com>
This commit is contained in:
Jonáš KulhánekandBrent Yi authored and GitHub committed 2023-05-17 17:36:56 -07:00
1 parent c6111e377e
commit f481f5ebec
27 files changed
+154 -75

No files matched your search

+15 -3
View File
@@ -16,7 +16,11 @@
Special activation functions.
"""
from typing import TYPE_CHECKING
import torch
from jaxtyping import Float
from torch import Tensor
from torch.autograd import Function
from torch.cuda.amp import custom_bwd, custom_fwd
@@ -37,6 +41,14 @@ class _TruncExp(Function):
return g * torch.exp(x.clamp(-15, 15))
trunc_exp = _TruncExp.apply
"""Same as torch.exp, but with the backward pass clipped to prevent vanishing/exploding
gradients."""
if TYPE_CHECKING:
def trunc_exp(_: Float[Tensor, "*bs"], /) -> Float[Tensor, "*bs"]:
"""Same as torch.exp, but with the backward pass clipped to prevent vanishing/exploding
gradients."""
raise NotImplementedError()
else:
trunc_exp = _TruncExp.apply
"""Same as torch.exp, but with the backward pass clipped to prevent vanishing/exploding
gradients."""