Reputation: 3291
I have a torch tensor of size H, W, 3. I can easily swap this in Pytorch with image[:, :, [2,1,0]]
However, in C++ Libtorch I cannot figure it out:
I tried:
std::vector<long> index_vector = {0,1,2};
auto index_tensor = torch::from_blob((long*)(index_vector.data()), {3}, torch::kLong);
std::vector<at::indexing::TensorIndex> index;
index = {"...", "...", index_tensor};
img_tensor = img_tensor.index(index);
But it does not work
Upvotes: 2
Views: 2626