Skip to content
This repository was archived by the owner on Apr 28, 2023. It is now read-only.

Commit f953ade

Browse files
nicolasvasilacheJules Pondard
authored andcommitted
Update to support upcoming Caffe2 API
Caffe2 API killed the copy constructor so we need to update `GetNamedTensor`. So we use the Caffe2 API to return a new tensor that shares the data with the tensor from the workspace. Tested internally with the latest API.
1 parent f306bee commit f953ade

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

test/caffe2/test_harness-inl.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,11 @@ caffe2::Tensor<typename Caffe2Backend::Context> GetNamedTensor(
6969
caffe2::Workspace& ws,
7070
const std::string& name) {
7171
// Resolved dynamically
72-
return caffe2::Tensor<typename Caffe2Backend::Context>(
73-
ws.GetBlob(name)->Get<typename Caffe2Backend::Tensor>());
72+
auto& t = ws.GetBlob(name)->Get<typename Caffe2Backend::Tensor>();
73+
caffe2::Tensor<typename Caffe2Backend::Context> res;
74+
res.ResizeLike(t);
75+
res.ShareData(t);
76+
return res;
7477
}
7578

7679
// helper functions to construct an ATen tensor from a caffe2 tensor

0 commit comments

Comments
 (0)