KEMBAR78
Fix issue with scalars and __rpow__ by vishwakftw · Pull Request #16687 · pytorch/pytorch · GitHub
Skip to content

Conversation

@vishwakftw
Copy link
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
Contributor Author

cc: @soumith @fritzo

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.

@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

def __rpow__(self, other):
return self.new([other]) ** self
return self.new_tensor(other) ** self
Copy link
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
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
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
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
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