My understanding of THCudaTensor_data( state, tensor ) is that its general function is to retrieve the data from a pytorch’s tensor and save it as an array. However, I cannot understand the specifics.

what is the state?
what if the initial tensor is 2D or beyond? Does it flatten the 2D into long 1D array?
is the date type of the items inside the pytorch’s tensor preserved?
what is the return type, and does the array reside in global memory or stack?

Thanks!