If I am trying to dump each row of a 2D tensor into an array in C++, is this appropriate?
array<float, 3> data;
float *values_ptr = &tensor_data.data_ptr<float>()[i * tensor_data.stride(1)]
for (int i=0; i < 3; i++) {
data[i] = values_ptr[i];
}
Or is there a faster or more memory-efficient way to do this?