Skip to content

Commit 7edaee7

Browse files
bottlerfacebook-github-bot
authored andcommitted
allow matrix_to_quaternion onnx export
Summary: Attempt to allow torch.onnx.dynamo_export(matrix_to_quaternion) to work. Differential Revision: D59812279 fbshipit-source-id: 4497e5b543bec9d5c2bdccfb779d154750a075ad
1 parent d0d0e02 commit 7edaee7

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

pytorch3d/transforms/rotation_conversions.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,10 @@ def _sqrt_positive_part(x: torch.Tensor) -> torch.Tensor:
9797
"""
9898
ret = torch.zeros_like(x)
9999
positive_mask = x > 0
100-
ret[positive_mask] = torch.sqrt(x[positive_mask])
100+
if torch.is_grad_enabled():
101+
ret[positive_mask] = torch.sqrt(x[positive_mask])
102+
else:
103+
ret = torch.where(positive_mask, torch.sqrt(x), ret)
101104
return ret
102105

103106

0 commit comments

Comments
 (0)