Skip to content

Commit

Permalink
Remove inplace operations
Browse files Browse the repository at this point in the history
  • Loading branch information
eigenvivek committed May 3, 2024
1 parent fdf0ce9 commit bc2d869
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 3 additions & 3 deletions diffdrr/pose.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,9 @@ def rotation_9d_to_matrix(rotation: torch.Tensor) -> torch.Tensor:
m = rotation.view(-1, 3, 3)
u, s, v = torch.svd(m)
vt = v.transpose(1, 2)
vt[:, -1:] *= (
(u @ vt).det().view(-1, 1, 1)
) # Scale by determinant to project onto SO(3)
# Scale by determinant to project onto SO(3)
det = (u @ vt).det().view(-1, 1, 1)
vt = torch.concat([vt[:, :2], det * vt[:, -1:]], dim=1)
return u @ vt


Expand Down
4 changes: 3 additions & 1 deletion notebooks/api/06_pose.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,9 @@
" m = rotation.view(-1, 3, 3)\n",
" u, s, v = torch.svd(m)\n",
" vt = v.transpose(1, 2)\n",
" vt[:, -1:] *= (u @ vt).det().view(-1, 1, 1) # Scale by determinant to project onto SO(3)\n",
" # Scale by determinant to project onto SO(3)\n",
" det = (u @ vt).det().view(-1, 1, 1)\n",
" vt = torch.concat([vt[:, :2], det * vt[:, -1:]], dim=1)\n",
" return u @ vt\n",
"\n",
"\n",
Expand Down

0 comments on commit bc2d869

Please sign in to comment.