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

Optimize implementation of torch.pow #46830

Closed
wants to merge 2 commits into from

Conversation

Kiyosora
Copy link
Contributor

@Kiyosora Kiyosora commented Oct 26, 2020

@dr-ci
Copy link

dr-ci bot commented Oct 26, 2020

💊 CI failures summary and remediations

As of commit dfe8670175 (more details on the Dr. CI page):


💚 💚 Looks good so far! There are no failures yet. 💚 💚


This comment was automatically generated by Dr. CI (expand for details).Follow this link to opt-out of these comments for your Pull Requests.

Please report bugs/suggestions to the (internal) Dr. CI Users group.

@Kiyosora Kiyosora force-pushed the pow_implementation_optimize branch 4 times, most recently from e0f9115 to 0b9deb5 Compare October 27, 2020 06:17
@Kiyosora Kiyosora changed the title [WIP] Optimize implementation of torch.pow Optimize implementation of torch.pow Oct 27, 2020
@Kiyosora Kiyosora marked this pull request as ready for review October 27, 2020 10:02
@mrshenli mrshenli requested a review from ezyang October 27, 2020 14:57
@mrshenli mrshenli added the module: custom-operators custom operators, custom ops, custom-operators, custom-ops label Oct 27, 2020
@mrshenli mrshenli added module: named tensor Named tensor support triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module labels Oct 27, 2020
@mrshenli
Copy link
Contributor

adding @zou3519, as this PR is adding named tensor support to the operator

Copy link
Contributor

@ezyang ezyang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okey dokey

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@ezyang ezyang requested a review from anjali411 October 30, 2020 15:51
@ezyang
Copy link
Contributor

ezyang commented Oct 30, 2020

@anjali411 I just realized that this PR intersects with your fix for the accidental complex promotion. Do you think you could work these changes into your patchset in some way? Otherwise I'll wait for your fix to land and rebase this on top of yours.

@Kiyosora
Copy link
Contributor Author

I rebased this PR since it has been a while. BTW, if there is anything else I can do for this PR, I‘d like to be the help.

@anjali411
Copy link
Contributor

@ezyang sorry I completely missed this PR. let me merge my pow PR as is and then we can merge this as a follow-up change.

@anjali411
Copy link
Contributor

Hi @Kiyosora can you rebase this PR on the latest master?

@Kiyosora
Copy link
Contributor Author

Hi @Kiyosora can you rebase this PR on the latest master?

Sure, I've rebase this PR on the latest master. @anjali411

result.resize_as_(base).copy_(base);
auto exponent = (exp.isComplex()) ? exp.toComplexDouble() : exp.toDouble();

if (exponent == 0.0) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Kiyosora can you please retain this check to exp.equal(0.0) (as in master)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed!

result.resize_as_(base).fill_(1);
} else if (exp.equal(1.0)) {
result.resize_as_(base).copy_(base);
auto exponent = (exp.isComplex()) ? exp.toComplexDouble() : exp.toDouble();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is no longer needed. let's remove this!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed!

resize_output(result, base.sizes());
result.fill_(1);
namedinference::propagate_names(result, base);
} else if (exponent == 1.0) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same comment as above

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed!

} else if (!base.isComplex() && base.toDouble() == 1.0) {
result.resize_as_(exp).fill_(1);

auto exponent = (base.isComplex()) ? base.toComplexDouble() : base.toDouble();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same comment as above

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed!


auto exponent = (base.isComplex()) ? base.toComplexDouble() : base.toDouble();

if (exponent == 1.0) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed!

@Kiyosora Kiyosora force-pushed the pow_implementation_optimize branch 2 times, most recently from dfe8670 to 779026a Compare January 14, 2021 14:47
Copy link
Contributor

@anjali411 anjali411 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM thanks @Kiyosora

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@facebook-github-bot
Copy link
Contributor

@anjali411 merged this pull request in d140ca8.

@Kiyosora Kiyosora deleted the pow_implementation_optimize branch January 25, 2021 02:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla signed Merged module: custom-operators custom operators, custom ops, custom-operators, custom-ops module: named tensor Named tensor support open source triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants