In the C++ version of Libtorch, I found that I can get the value of a float tensor by *tensor_name[0].data<float>()
, in which instead of 0
I can use any other valid index. But, when I have defined an int
tensor by adding option at::kInt
into the tensor creation, I cannot use this structure to get the value of the tensor, i.e. something like *tensor_name[0].data<at::kInt>()
or *tensor_name[0].data<int>()
does not work and the debugger keeps saying that Couldn't find method at::Tensor::data<at::kInt>
or Couldn't find method at::Tensor::data<int>
.
I can get the values by auto value_array = tensor_name=accessor<int,1>()
, but it was easier to use *tensor_name[0].data<int>()
. Can you please let me know how I can use data<>()
to get the value of an int
tensor?
I also have a same problem with bool
type.
auto indx =torch::zeros({batch_size},at::dtype(at::kLong));
and thenp indx[0].item<long>()
gives meCouldn't find method at::Tensor::item<long>
. Also, it comes with types likeByte
, I even do not have same type in C++, andbool
just does not work. – Calcine