CUDA for pytorch: CUDA C++ stream and state
I am trying to follow this tutorial and make a simple c++ extension with CUDA backend.
My CPU implementation seems to work fine.

I am having trouble finding examples and documentation (it seems like things are constantly changing).

Specifically,


I see pytorch cuda functions getting THCState *state argument - where does this argument come from? How can I get a state for my function as well?
For instance, in cuda implementation of tensor.cat:


void THCTensor_(cat)(THCState *state, THCTensor *result, THCTensor *ta, THCTensor *tb, int dimension)



However, when calling tensor.cat() from python one does not provide any state argument, pytorch provides it "behind the scene". How pytorch provides this information and how can I get it?
state is then converted to cudaStream_t stream = THCState_getCurrentStream(state);
For some reason, THCState_getCurrentStream is no longer defined? How can I get the stream from my state?


I also tried asking on pytorch forum - so far to no avail.  

It's deprecated (without documentation!)
See here:
https://github.com/pytorch/pytorch/pull/14500

In short: use at::cuda::getCurrentCUDAStream()
