Where is the defination of torch._C.CudaFloatTensorBase class

I want to find the defination of torch._C.CudaFloatTensorBase class.But i didn’t find it in the torch/csrc/Module.cpp.Does anyone know where is it? Thanks


This is slightly convoluted in the sense that it used macro to generate all types easily. Here is how it works:

The definition of the class is here and is used with macro to generate all tensors types.
For Cuda types, this is generated from here.
This line is interpreted specially by this build script that replaces it for Cuda Float type:

#define THC_GENERIC_FILE torch/csrc/generic/Tensor.cpp
#include THC/THCGenerateFloatType.h

This include file is present here and is reponsible to set up all the proper macros such that the original generic file is properly interpreted for this lib and type.

If you want a better understanding on how these macro work in the TH/THC libraries and how they are used to generate all type, you can look at this blogpost that describes this.

1 Like