mirror of
https://github.com/facebookresearch/pytorch3d.git
synced 2026-03-11 23:06:04 +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>>
|
std::is_same<T, double>::value || std::is_same<T, float>::value>>
|
||||||
struct vec2 {
|
struct vec2 {
|
||||||
T x, y;
|
T x, y;
|
||||||
typedef T scalar_t;
|
using scalar_t = T;
|
||||||
vec2(T x, T y) : x(x), y(y) {}
|
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>>
|
std::is_same<T, double>::value || std::is_same<T, float>::value>>
|
||||||
struct vec3 {
|
struct vec3 {
|
||||||
T x, y, z;
|
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) {}
|
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
|
# of centered A and centered B
|
||||||
Ac = A - Amu
|
Ac = A - Amu
|
||||||
Bc = B - Bmu
|
Bc = B - Bmu
|
||||||
# pyre-fixme[58]: `**` is not supported for operand types `Tensor` and `int`.
|
align_t_s = (Ac * Bc).mean() / torch.square(Ac).mean().clamp(eps)
|
||||||
align_t_s = (Ac * Bc).mean() / (Ac**2).mean().clamp(eps)
|
|
||||||
else:
|
else:
|
||||||
# set the scale to identity
|
# set the scale to identity
|
||||||
align_t_s = 1.0
|
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))
|
Returns torch.sqrt(torch.max(0, x))
|
||||||
but with a zero subgradient where x is 0.
|
but with a zero subgradient where x is 0.
|
||||||
"""
|
"""
|
||||||
ret = torch.zeros_like(x)
|
|
||||||
positive_mask = x > 0
|
positive_mask = x > 0
|
||||||
if torch.is_grad_enabled():
|
safe_x = torch.where(positive_mask, x, 1.0)
|
||||||
ret[positive_mask] = torch.sqrt(x[positive_mask])
|
return torch.where(positive_mask, torch.sqrt(safe_x), 0.0)
|
||||||
else:
|
|
||||||
ret = torch.where(positive_mask, torch.sqrt(x), ret)
|
|
||||||
return ret
|
|
||||||
|
|
||||||
|
|
||||||
def matrix_to_quaternion(matrix: torch.Tensor) -> torch.Tensor:
|
def matrix_to_quaternion(matrix: torch.Tensor) -> torch.Tensor:
|
||||||
|
|||||||
Reference in New Issue
Block a user