I’m trying to find the definition of Tensor as used in the C++ parts of PyTorch, for example in pytorch/aten/src/ATen/native/ReduceOps.cpp in line 746 we have the function
This is declared in a generated header include/ATen/core/TensorBody.h which you find in LibTorch / PyTorch installations. The template is in aten/src/ATen/templates/TensorBody.h.
The current version’s return tensor is declared this way:
Tensor result;
result = at::empty({}, self.options().dtype(dtype));
I computed the result I want to return with std::vectors (probably not optimal, feel free to suggest something better). Now I’m wondering how I can pass this vector to the result tensor. I think I have to use following in some way, and was trying to find its implementation by asking about the location of the Tensor class:
self.data_ptr<scalar_t>()
I can’t seem to infer this from the information you gave me above. Can you explain to me to how I can properly give my data to the return tensor? Is there maybe an instructive function somewhere I could look at.