About convert torch.LongTensor(l) to C++

Hi, All

I am wondering how to convert label= torch.LongTensor(l) as torch::LongTensor does not exist.

Any suggestion is welcome.

Thanks

1 Like

Hi,

You can use the equivalent of torch.tensor(l, dtype=torch.long).
Not sure what is the exact c++ way to write that though :confused:

Thanks a lot.

Actually, I use y=l[0].to(tensor:kFloat32)
in dype in C++ in libtorch it seems that there is no “Long” but I am not sure if they are good approximation in this case.

I think the name is torch::kInt64 of the torch namespace (or at::kLong but the torch version should be used I think).

2 Likes