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

simplify add_ #60

Open
LucasMourot opened this issue Apr 6, 2021 · 1 comment
Open

simplify add_ #60

LucasMourot opened this issue Apr 6, 2021 · 1 comment

Comments

@LucasMourot
Copy link

Hi,

I have a small optimization to suggest:

Is there any particular reason to not simplify

[line 84] p_data_fp32.add_(-group['weight_decay'] * group['lr'], p_data_fp32)

into

p_data_fp32.mul_(-group['weight_decay'] * group['lr'])

?
Other lines could be simplified the same manner.

@brandondube
Copy link

Addition and multiplication are different operations. The above line 84 is equivalent to

p_data_fp32 += -weight_decay * lr

Your modification is equivalent to

p_data_fp32 *= (-weight_decay * lr)

These are very different updates

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants