-
Notifications
You must be signed in to change notification settings - Fork 25.8k
Add stable::Tensor.device() #166694
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
base: gh/mikaylagawarecki/360/base
Are you sure you want to change the base?
Add stable::Tensor.device() #166694
Conversation
[ghstack-poisoned]
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/166694
Note: Links to docs will display an error until the docs builds have been completed. ❗ 1 Active SEVsThere are 1 currently active SEVs. If your PR is affected, please view them below: ✅ You can merge normally! (4 Unrelated Failures)As of commit 7b6869c with merge base 4295a9a ( FLAKY - The following jobs failed but were likely due to flakiness present on trunk:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
torch/csrc/stable/tensor_struct.h
Outdated
| Device device() const { | ||
| int32_t device_type; | ||
| int32_t device_index; | ||
| TORCH_ERROR_CODE_CHECK( |
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.
An alternative to this implementation is adding a new shim function that returns a DeviceHandle, and then converts the DeviceHandle to the device. My understanding is that this current impl returns a new Device object.
/// Returns a `Tensor`'s device.
inline Device device() const {
return impl_->device();
}
This implementation in TensorBase.h suggests that we should be adding a new shim instead to return the same instance. What do you think?
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.
Is my understanding correct that that would mean the Tensor within libtorch owns the device object being used by the extension?
When we pass this across the libtorch/extension boundary, might the device need to outlive the tensor object in libtorch and would returning the DeviceHandle cause any issues?
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.
I don't think passing it through the boundary should change lifetimes if we're just rerouting pointers.
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
Stack from ghstack (oldest at bottom):