Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Fix issue with scalars and __rpow__#16687

Closed
vishwakftw wants to merge 1 commit into
pytorch:masterfrom
vishwakftw:scalar-rpow-fix
Closed

Fix issue with scalars and __rpow__#16687
vishwakftw wants to merge 1 commit into
pytorch:masterfrom
vishwakftw:scalar-rpow-fix

Conversation

@vishwakftw
Copy link
Copy Markdown
Contributor

Changelog:

  • Modify rpow function in tensor.py to adapt to scalars

Test plan:

  • Add scalar entry in test_rpow
  • Add CUDA port

Fixes #16685

Changelog:

- Modify __rpow__ function in tensor.py to adapt to scalars

Test plan:

- Add scalar entry in test_rpow
- Add CUDA port
@vishwakftw
Copy link
Copy Markdown
Contributor Author

cc: @soumith @fritzo

Copy link
Copy Markdown
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.

@soumith is landing this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

soumith pushed a commit that referenced this pull request Feb 3, 2019
Summary:
Changelog:

- Modify __rpow__ function in tensor.py to adapt to scalars
Pull Request resolved: #16687

Differential Revision: D13936720

Pulled By: soumith

fbshipit-source-id: b0c8727968b04efbc6e7461807c812d962f03370
Comment thread torch/tensor.py

def __rpow__(self, other):
return self.new([other]) ** self
return self.new_tensor(other) ** self
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

shouldn't this be as_tensor? Also, new_tensor throws a warning when the input is already a tensor...

Copy link
Copy Markdown
Contributor Author

@vishwakftw vishwakftw Feb 3, 2019

Choose a reason for hiding this comment

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

If other is a tensor, then this would be dispatched to the __pow__ function instead right?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Oh you are correct! Sorry!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

No worries 😄

@vishwakftw vishwakftw deleted the scalar-rpow-fix branch February 3, 2019 05:56
laurentdupin pushed a commit to laurentdupin/pytorch that referenced this pull request Apr 24, 2026
Summary:
Changelog:

- Modify __rpow__ function in tensor.py to adapt to scalars
Pull Request resolved: pytorch#16687

Differential Revision: D13936720

Pulled By: soumith

fbshipit-source-id: b0c8727968b04efbc6e7461807c812d962f03370
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Incorrect size for __rpow__(scalar, float)

4 participants