Hi
I was wondering how to use the existing cublas handle defined inside a pytorch backedn for a custom C extension.
For instance, in the ffi c extension example from pytorch website (https://github.com/pytorch/extension-ffi/ 4),

  
      github.com
  
  
    pytorch/extension-ffi/blob/master/package/my_package/src/my_lib_cuda.c#L4 1

#include <THC/THC.h>


// this symbol will be resolved automatically from PyTorch libs
extern THCState *state;


int my_lib_add_forward_cuda(THCudaTensor *input1, THCudaTensor *input2,
		       THCudaTensor *output)
{
if (!THCudaTensor_isSameSizeAs(state, input1, input2))
  return 0;
THCudaTensor_resizeAs(state, output, input1);
THCudaTensor_cadd(state, output, input1, 1.0, input2);
return 1;
}



  
  
    
    
  
  


#include <THC/THC.h>

// this symbol will be resolved automatically from PyTorch libs
extern THCState *state;

The THCState if exposed and can be used from a custom ffi extension. I was wondering the cublas handle is also exposed like this. If not, is there a way to pass it through the cffi function?
Thanks!