PyTorch 1.4 compat

Summary: Restore compatibility with PyTorch 1.4 and 1.5, and a few lint fixes.

Reviewed By: patricklabatut

Differential Revision: D30048115

fbshipit-source-id: ee05efa7c625f6079fb06a3cc23be93e48df9433
This commit is contained in:
Jeremy Reizenstein
2021-08-03 08:09:39 -07:00
committed by Facebook GitHub Bot
parent 55aaec4d83
commit 5ecce83217
4 changed files with 21 additions and 20 deletions

View File

@@ -140,8 +140,10 @@ def matrix_to_quaternion(matrix: torch.Tensor) -> torch.Tensor:
dim=-2,
)
# clipping is not important here; if q_abs is small, the candidate won't be picked
quat_candidates = quat_by_rijk / (2.0 * q_abs[..., None].clip(0.1))
# We floor here at 0.1 but the exact level is not important; if q_abs is small,
# the candidate won't be picked.
# pyre-ignore [16]: `torch.Tensor` has no attribute `new_tensor`.
quat_candidates = quat_by_rijk / (2.0 * q_abs[..., None].max(q_abs.new_tensor(0.1)))
# if not for numerical problems, quat_candidates[i] should be same (up to a sign),
# forall i; we pick the best-conditioned one (with the largest denominator)