Hi, everyone, I’m facing a problem that I need to copy a tensor to CUDA. The code are as follows:
torch::Tensor r_data1 = torch::from_blob(raw_data.data(), {batch_size, arr_size}).to(torch::kInt64);
auto tmp_data = static_cast<size_t*>(r_data1.storage().data());
size_t tmp_size = r_data1.numel();
cout << "r data1 tensor ";
for (size_t i = 0; i < tmp_size; i++) {
    cout << tmp_data[i] << "\t";
}
cout << endl;

torch::Tensor r_data2 = r_data1.cuda();
tmp_data = static_cast<size_t*>(r_data2.cpu().storage().data());
tmp_size = r_data2.numel();
cout << "r data tensor ";
for (size_t i = 0; i < tmp_size; i++) {
    cout << tmp_data[i] << "\t";
}
cout << endl;

But the results are:
r data1 tensor  101 4886 2456 4689 3787 2336 2356 1298 2128 2356 4886 2456 4689 1298 2128 2356 736 6963 7252 5401 3215 3333 1921 3441 8110 1384
r data tensor  139682015587936 139682014923568 2456 4689 3787 2336 2356 1298 2128 2356 4886 2456 4689 1298 2128 2356 736 6963 7252 5401 3215 3333 1921 3441 8110 1384
The ids have been changed. Why? Have you come into this problem?