From 17f05ad5e562830127dd06be6c11c10453a86d0e Mon Sep 17 00:00:00 2001 From: Sebastian Messmer Date: Thu, 18 Apr 2019 14:07:30 -0700 Subject: 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 --- caffe2/core/tensor.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'caffe2') 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(); } -- cgit v1.2.3