Hi,
This is because the data returned by data_ptr<>() is only valid as long as the original Tensor exists.
But here the CPU tensor goes out of scope so the the data_ptr becomes invalid. This is expected.