mirror of
https://github.com/facebookresearch/pytorch3d.git
synced 2026-03-13 16:05:59 +08:00
Compare commits
3 Commits
7b5c78460a
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
61cc79aa34 | ||
|
|
7a6157e38e | ||
|
|
d9839a95f2 |
@@ -19,7 +19,7 @@ template <
|
||||
std::is_same<T, double>::value || std::is_same<T, float>::value>>
|
||||
struct vec2 {
|
||||
T x, y;
|
||||
typedef T scalar_t;
|
||||
using scalar_t = T;
|
||||
vec2(T x, T y) : x(x), y(y) {}
|
||||
};
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ template <
|
||||
std::is_same<T, double>::value || std::is_same<T, float>::value>>
|
||||
struct vec3 {
|
||||
T x, y, z;
|
||||
typedef T scalar_t;
|
||||
using scalar_t = T;
|
||||
vec3(T x, T y, T z) : x(x), y(y), z(z) {}
|
||||
};
|
||||
|
||||
|
||||
@@ -223,8 +223,7 @@ def _align_camera_extrinsics(
|
||||
# of centered A and centered B
|
||||
Ac = A - Amu
|
||||
Bc = B - Bmu
|
||||
# pyre-fixme[58]: `**` is not supported for operand types `Tensor` and `int`.
|
||||
align_t_s = (Ac * Bc).mean() / (Ac**2).mean().clamp(eps)
|
||||
align_t_s = (Ac * Bc).mean() / torch.square(Ac).mean().clamp(eps)
|
||||
else:
|
||||
# set the scale to identity
|
||||
align_t_s = 1.0
|
||||
|
||||
@@ -94,13 +94,9 @@ def _sqrt_positive_part(x: torch.Tensor) -> torch.Tensor:
|
||||
Returns torch.sqrt(torch.max(0, x))
|
||||
but with a zero subgradient where x is 0.
|
||||
"""
|
||||
ret = torch.zeros_like(x)
|
||||
positive_mask = x > 0
|
||||
if torch.is_grad_enabled():
|
||||
ret[positive_mask] = torch.sqrt(x[positive_mask])
|
||||
else:
|
||||
ret = torch.where(positive_mask, torch.sqrt(x), ret)
|
||||
return ret
|
||||
safe_x = torch.where(positive_mask, x, 1.0)
|
||||
return torch.where(positive_mask, torch.sqrt(safe_x), 0.0)
|
||||
|
||||
|
||||
def matrix_to_quaternion(matrix: torch.Tensor) -> torch.Tensor:
|
||||
|
||||
Reference in New Issue
Block a user