I have a std::vector<std::vector<double>>
where I want to conver it into a torch::Tensor
in libtorch. However it seems, the torch::tensor()
, or torch::from_blob()
, can't be used for this purpose!
I tried to use c10::ArrayRef
and then use that for converting the data into a torch::Tensor
by doing c10::ArrayRef<std::vector<std::vector<double>>> res(myvecs)
but this also seems useless as I can't seem to find a way to convert it into torch::Tensor
.
How should I go about this conversion in libtorch? What are my other options other than e.g:
auto tensor = torch::zeros({ 46,85 });
for (size_t i = 0; i < 46; i++)
{
for (size_t j = 0; j < 85; j++)
{
tensor[i][j] = probs[i][j];
}
}