At the line below, a "value" TensorCPU is created, and then its data is shared with the blob.
However, at the end of this block, the "value" TensorCPU is destroyed, and so its data is "lost".
I think it's only by accident that its data is still intact when it is used further down the line.
Actually, I realised that data_ is a shared_ptr<>, so it won't be deleted, and will in fact be shared. Since it's not gonna be modified through the original Tensor, it's ok! Closing the issue...
At the line below, a "value" TensorCPU is created, and then its data is shared with the blob. However, at the end of this block, the "value" TensorCPU is destroyed, and so its data is "lost". I think it's only by accident that its data is still intact when it is used further down the line.
https://github.com/leonardvandriel/caffe2_cpp_tutorial/blob/d5daf4e89b9b1a12979649e783d68f4c821a554f/src/caffe2/binaries/intro.cc#L37
Instead, it should be:
tensor->CopyFrom (value);