-
Notifications
You must be signed in to change notification settings - Fork 26.3k
Implement tensor weak references #9363
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
facebook-github-bot
left a comment
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.
@apaszke has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
facebook-github-bot
left a comment
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.
@apaszke has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
|
CC @smessmer This is diverging further from your implementation in C10. |
aten/src/ATen/Retainable.h
Outdated
| } | ||
| } | ||
| } | ||
| void weakRetain() { |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
aten/src/ATen/TensorBase.h
Outdated
| throw std::runtime_error("TensorBaseImpl with nullptr not supported"); | ||
| } | ||
| if(retain && pImpl != UndefinedTensor::singleton()) { | ||
| retainable_traits<is_strong>::retain(pImpl); |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
aten/src/ATen/templates/Tensor.h
Outdated
|
|
||
| // XXX: this can return undefined tensors | ||
| // Ideally it would be at::optional<Tensor>, but MSVC is too cool for that | ||
| Tensor lock() { |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
aten/src/ATen/templates/Tensor.h
Outdated
| WeakTensor(WeakTensor && rhs) noexcept = default; | ||
| WeakTensor(const Tensor& t) : WeakTensorBase(t.pImpl, true) {} | ||
|
|
||
| // reimplemented from TensorBase so the return type is Tensor rather than TensorBase |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
facebook-github-bot
left a comment
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.
@apaszke has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
| // refcounted objects that include tensors | ||
| struct Retainable { | ||
| Retainable(): refcount(1) {} | ||
| Retainable(): refcount(1), weak_refcount(1) {} |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
Summary: Add `WeakTensor` - a `Tensor` counterpart which doesn't keep the data (or any other expensive resources) alive. They can be `.lock()`ed and return `at::optional<Tensor>` if they're still alive. Pull Request resolved: pytorch/pytorch#9363 Reviewed By: ezyang Differential Revision: D8815434 Pulled By: apaszke fbshipit-source-id: 1b3e96503c1285d78ef124c585e65c7630f3253e
* upstream/master: (24 commits) Implement tensor weak references (pytorch#9363) Nuke TestCollectEnv (pytorch#9459) Add test case for segmentation fault fix in grad_fn (pytorch#9457) Add peephole optimization for type_as operators. (pytorch#9316) Fix out-of-range error for test_neg (pytorch#9431) add depthwise conv support for mkldnn (pytorch#8782) Refactor `_log_sum_exp` (pytorch#9173) Add ModuleDict and ParameterDict containers (pytorch#8463) Introduce SupervisedPtr, delete THAllocator and THCDeviceAllocator (pytorch#9358) Introducing IsInf (pytorch#9169) add device to CUDAEvent (pytorch#9415) Make localScalar error message more intuitive (pytorch#9443) Only accept continguous tensors in TopK for cuda (pytorch#9441) Add support for .norm() pytorch onnx export and ReduceL1/ReduceL2 caffe2 operators (pytorch#9299) Only view() rhs of index_put if we need to (pytorch#9424) Add BatchBucketizeOp in caffe2 (pytorch#9385) Implementation of Wngrad optimizer caffe2 python wrapper and unit test on least square regression (pytorch#9001) Implementation and operator test for Wngrad optimizer (pytorch#8999) Fix segmentation fault in grad_fn (pytorch#9292) update docs (pytorch#9423) ...
Summary: Add `WeakTensor` - a `Tensor` counterpart which doesn't keep the data (or any other expensive resources) alive. They can be `.lock()`ed and return `at::optional<Tensor>` if they're still alive. Pull Request resolved: pytorch#9363 Reviewed By: ezyang Differential Revision: D8815434 Pulled By: apaszke fbshipit-source-id: 1b3e96503c1285d78ef124c585e65c7630f3253e
Summary: Add `WeakTensor` - a `Tensor` counterpart which doesn't keep the data (or any other expensive resources) alive. They can be `.lock()`ed and return `at::optional<Tensor>` if they're still alive. Pull Request resolved: pytorch#9363 Reviewed By: ezyang Differential Revision: D8815434 Pulled By: apaszke fbshipit-source-id: 1b3e96503c1285d78ef124c585e65c7630f3253e
Summary: As in the title. Lets us simplify a lot of code. Depends on pytorch#9363, so please review only the last commit. zdevito Pull Request resolved: pytorch#9414 Reviewed By: zdevito Differential Revision: D8836496 Pulled By: apaszke fbshipit-source-id: 9b3c3d1f001a9dc522f8478abc005b6b86cfa3e3
Summary: Add `WeakTensor` - a `Tensor` counterpart which doesn't keep the data (or any other expensive resources) alive. They can be `.lock()`ed and return `at::optional<Tensor>` if they're still alive. Pull Request resolved: pytorch#9363 Reviewed By: ezyang Differential Revision: D8815434 Pulled By: apaszke fbshipit-source-id: 1b3e96503c1285d78ef124c585e65c7630f3253e
Summary: As in the title. Lets us simplify a lot of code. Depends on pytorch#9363, so please review only the last commit. zdevito Pull Request resolved: pytorch#9414 Reviewed By: zdevito Differential Revision: D8836496 Pulled By: apaszke fbshipit-source-id: 9b3c3d1f001a9dc522f8478abc005b6b86cfa3e3
Add
WeakTensor- aTensorcounterpart which doesn't keep the data (or any other expensive resources) alive. They can be.lock()ed and returnat::optional<Tensor>if they're still alive.