Skip to content
This repository was archived by the owner on Mar 13, 2024. It is now read-only.

Refactor FourierEmb for optimization and clarity#3

Open
zuazo wants to merge 2 commits into
facebookresearch:mainfrom
ekarrieta:fourier-emb-refactor
Open

Refactor FourierEmb for optimization and clarity#3
zuazo wants to merge 2 commits into
facebookresearch:mainfrom
ekarrieta:fourier-emb-refactor

Conversation

@zuazo
Copy link
Copy Markdown

@zuazo zuazo commented Oct 26, 2023

This pull request refactors the FourierEmb class by moving constant calculations from the forward method to the constructor. With this change, we're avoiding unnecessary computations every time the forward method is called. This also improves code clarity.

Changes:

  • Moved the calculation of width, freqs_y, freqs_x, p_x, and p_y to the constructor.
  • Updated the forward method to utilize pre-computed values, ensuring they are on the correct device.
  • Removed duplicated line: *O, D = positions.shape.

I hope you'll find this change beneficial. I'm open to feedback and further modifications if necessary. And thank you for sharing all your research work and code!

@facebook-github-bot
Copy link
Copy Markdown

Hi @zuazo!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

@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 Oct 26, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

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.

2 participants