diff options
author | Sebastian Messmer <messmer@fb.com> | 2019-04-18 14:07:30 -0700 |
---|---|---|
committer | Facebook Github Bot <facebook-github-bot@users.noreply.github.com> | 2019-04-18 14:13:26 -0700 |
commit | 17f05ad5e562830127dd06be6c11c10453a86d0e (patch) | |
tree | 300da7039b43054838e9dd94553cf4ed1913c7bf /caffe2 | |
parent | 88f70a16708369ad5d179fbe515f43739c0f2591 (diff) | |
download | pytorch-17f05ad5e562830127dd06be6c11c10453a86d0e.tar.gz pytorch-17f05ad5e562830127dd06be6c11c10453a86d0e.tar.bz2 pytorch-17f05ad5e562830127dd06be6c11c10453a86d0e.zip |
Moving at::Tensor into caffe2::Tensor without bumping refcount (#19388)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/19388
The old implementation forced a refcount bump when converting at::Tensor to caffe2::Tensor.
Now, it is possible to move it without a refcount bump.
Reviewed By: dzhulgakov
Differential Revision: D14986815
fbshipit-source-id: 92b4b0a6f323ed38376ffad75f960cad250ecd9b
Diffstat (limited to 'caffe2')
-rw-r--r-- | caffe2/core/tensor.h | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/caffe2/core/tensor.h b/caffe2/core/tensor.h index 4846d9af48..d6a5030934 100644 --- a/caffe2/core/tensor.h +++ b/caffe2/core/tensor.h @@ -115,8 +115,8 @@ class CAFFE2_API Tensor final { * The tensor will share the same instance (data, strides, sizes, etc) but * a different subset of APIs would be available */ - explicit Tensor(const at::Tensor& tensor) - : impl_(std::move(tensor.getIntrusivePtr())) { + explicit Tensor(at::Tensor tensor) + : impl_(std::move(tensor.impl_)) { enforce_invariants(); } |