MCPcopy Create free account
hub / github.com/NVIDIAGameWorks/Falcor / length_safe

Function length_safe

scripts/inv-rendering/mesh_utils.py:16–17  ·  view source on GitHub ↗
(x: torch.Tensor, eps: float = EPS)

Source from the content-addressed store, hash-verified

14
15
16def length_safe(x: torch.Tensor, eps: float = EPS) -> torch.Tensor:
17 return torch.sqrt(torch.clamp(dot(x, x), min=eps*eps)) # Clamp to avoid NaN gradients because grad(sqrt(0)) = NaN.
18
19
20def normalize_safe(x: torch.Tensor, eps: float = EPS) -> torch.Tensor:

Callers 1

normalize_safeFunction · 0.85

Calls 1

dotFunction · 0.70

Tested by

no test coverage detected