KEMBAR78
Add bindings for .cpu() & .cuda() to script by eellison · Pull Request #15904 · pytorch/pytorch · GitHub
Skip to content

Conversation

@eellison
Copy link
Contributor

Adding bindings for .cpu() and .cuda() to script.

It's worth noting that if the device remains unchanged, than the returned tensor aliases the input, but if it does change than they do not alias each other.

@facebook-github-bot facebook-github-bot added the oncall: jit Add this issue/PR to JIT oncall triage queue label Jan 10, 2019
@suo
Copy link
Member

suo commented Jan 10, 2019

Looks good. I would just add a comment about the aliasing thing.

test/test_jit.py Outdated
Copy link
Member

Choose a reason for hiding this comment

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

maybe assert device just to sanity check

@eellison
Copy link
Contributor Author

I'll add a comment. I think the solution here would be to peephole optimize .cpu() in shape analysis if we have the Tensor device type. That way we remove no-ops and don't complicate shape analysis.

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.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

oncall: jit Add this issue/PR to JIT oncall triage queue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants