Help on torch::gather in C++ libtorch please

Hi, All

In pytorch it is
Prob_label = torch.gather(output_label, 1, y.unsqueeze(1))

In libtorch, I write it as
torch::Tensor prob_label = torch::Tensor::gather(output_label, 1, y.unsqueeze(1),false);

it gives the error on “torch:Tenosr::gather” as call to non-static member function without an object argument.

Any comment is appreciated.


if I use torch::gather(…) it says no matching function for torch::gather.


1 Like

torch::Tensor prob_label = torch::gather(torch::Tensor output_label, 1, y.unsqueeze(1));

I changed to the above, it says "expected ( for function-style cast or type construction.