auto my_tensor = torch::ones({1,3,512,512},torch::device(torch::kCUDA,0));
so how can I copy the data in a cuda memory to a cuda tensor ,or copy from cuda tensor to cuda memory directly? What I want is to be able to complete the copy inside GPU without having to do GPU->CPU->GPU copy.
thanks tom,you said I can create a cuda tensor and use the tensor.data_ptr() as a destination, so can I be sure the return of datr_ptr() from a cuda tensor is a cuda memory address ?
I had tried to use the data_ptr() of a created cuda tensor as the destination or source pointer of cudaMemcpy() before, it works well, but I’m not sure it is valid;