Hi, I’m new with torch cpp extensions and I’m having trouble when trying to access part of the bits stored on a tensor.
void foo(torch::Tensor A) {
void* ptr = A.data_ptr();
((uint16_t*)ptr)[0] = 1;
printf("byte 0 = %u\n", ((uint8_t*)ptr)[0]);
printf("byte 1 = %u\n", ((uint8_t*)ptr)[1]);
}
returns :
byte 0 = 1
byte 1 = 0
It seems that the 8 bits array and the 16 bits array are not aligned, the 16 bits one starting one byte before the other. Why is that so ?