-
Notifications
You must be signed in to change notification settings - Fork 52
Improve description of device handling, add array.to_device
#171
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
LGTM, but I guess we need someone from TensorFlow to give a green light? IIRC TF allows implicit transfer. |
Right, this PR is meant to be just a clarification based on what we already discussed earlier. Quoting from #39 (comment):
I think in the end this is an execution rather than a syntax/semantics question, so maybe the "with the convention ..." phrase in this PR should be replaced with a phrase that's more like "strong recommendation". |
LGTM. One nit is that the |
Thanks @token. |
Sorry I meant even when the device is specified, a particular op may choose to output on a different device than where the kernel is executed (e.g. copy, shape, rpc related ops, etc). If this property is restricted to array creation functions only then the two devices will likely match. |
It is. Thanks for clarifying. Are the cases where an array creation call would still end up on a different device restricted to avoiding an out-of-memory error? If so, we can explicitly add that as a note. |
|
||
This standard chooses to add support for method 3 (local control), because it's the most explicit and granular, with its only downside being verbosity. A context manager may be added in the future - see {ref}`device-out-of-scope` for details. | ||
This standard chooses to add support for method 3 (local control), with the convention that execution takes place on the same device where all argument arrays are allocated. The rationale for choosing method 3 is because it's the most explicit and granular, with its only downside being verbosity. A context manager may be added in the future - see {ref}`device-out-of-scope` for details. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to clarify: for libraries that follow this convention, it would be an error to perform an operation with tensors that are not all allocated on the same device?
|
||
- **out**: _<array>_ | ||
|
||
- an array with the same data and dtype, located on the specified device. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If self
is already on device
, do we expect a no-op (returning self
) or a copy?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, should specify that. I'd say no-op.
Let's get this PR in, as no body objects and we don't want to drag indefinitely. We can continue the discussion and pick up any loose ends in the follow-up PR #259. |
Closes gh-157