Skip to content

Conversation

@apaszke
Copy link
Contributor

@apaszke apaszke commented Jul 11, 2018

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.

@apaszke apaszke requested a review from ezyang July 11, 2018 22:33
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.

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

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.

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

@apaszke
Copy link
Contributor Author

apaszke commented Jul 12, 2018

@zdevito

@ezyang
Copy link
Contributor

ezyang commented Jul 13, 2018

CC @smessmer This is diverging further from your implementation in C10.

}
}
}
void weakRetain() {

This comment was marked as off-topic.

This comment was marked as off-topic.

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.


// 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.

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.

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.

@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.

This comment was marked as off-topic.

zdevito pushed a commit to zdevito/ATen that referenced this pull request Jul 16, 2018
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
petrex pushed a commit to petrex/pytorch that referenced this pull request Jul 16, 2018
* 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)
  ...
facebook-github-bot pushed a commit that referenced this pull request Jul 20, 2018
Summary:
As in the title. Lets us simplify a lot of code.

Depends on #9363, so please review only the last commit.

zdevito
Pull Request resolved: #9414

Reviewed By: zdevito

Differential Revision: D8836496

Pulled By: apaszke

fbshipit-source-id: 9b3c3d1f001a9dc522f8478abc005b6b86cfa3e3
goldsborough pushed a commit to goldsborough/pytorch that referenced this pull request Jul 20, 2018
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
jramseyer pushed a commit to jramseyer/pytorch that referenced this pull request Jul 30, 2018
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
jramseyer pushed a commit to jramseyer/pytorch that referenced this pull request Jul 30, 2018
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
goodlux pushed a commit to goodlux/pytorch that referenced this pull request Aug 15, 2018
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
goodlux pushed a commit to goodlux/pytorch that referenced this pull request Aug 15, 2018
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
@soumith soumith deleted the weak_tensor branch February 21, 2019 12:08
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.

6 participants