Questions and Help
- libtorch 1.2 CU100 or libtorch 1.4 cpu
When I try to convert the the torch::Tensor
to cv::Mat
, I use the following code:
std::memcpy((void *) linkmap.data, score_link.data_ptr(), sizeof(torch::kF32) * score_text.numel())
The tensor type is CPUFloatType
and I use sizeof(torch::kF32)
to get the tensor data, but failed, and I notices that sizeof(torch::kF32)
and sizeof(torch::kU8)
are all equal to 1
, which was not usual, since sizeif(float)
should be 4 and sizeof(char)
should be 1.
I change the code sizeof(torch::kF32)
to 4
and get the right cv::Mat.
My question is why sizeof(torch::kF32)=1
and sizeof(torch::kU8)=1
?