Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🚀 Increase performance of axis-angle conversions #1544

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

Theo-Cheynel
Copy link
Contributor

Motivations and context

When converting from axis-angle to matrix and back, current rotation_conversions.py does an intermediate step by converting to quaternions. There exists a faster way using Rodrigues' rotation formula .

Changes

Used the formulas for both axis-angle to matrix and matrix to axis-angle conversions.
The changes work with any number of batch dimensions, just like the original functions.

Effect

There is a 2x speedup when converting from axis-angle to matrix, and this speedup is consistent regardless of device and batch size.
There is a 5-8x speedup when converting from matrix to axis-angle.

The only difference in the results happens in matrix_to_axis_angle, when you give as input a matrix that is not a rotation matrix. This behaviour is undocumented anyway and the results do not make sense either way.
If this is really an issue, we can always merge only the first part of the changes, or we could check that the matrix is orthogonal and run the previous code if it isn't (for backwards compatibility)

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label May 24, 2023
@facebook-github-bot
Copy link
Contributor

@bottler has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@bottler
Copy link
Contributor

bottler commented Jul 14, 2023

I'm worried about very small angles here. The current implementations delegate to other functions which are being really careful about nasty angles.

@facebook-github-bot
Copy link
Contributor

@Theo-Cheynel has updated the pull request. You must reimport the pull request before landing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants