| #if defined(TH_REAL_IS_FLOAT) || defined(TH_REAL_IS_DOUBLE) || \ |
| defined(THC_REAL_IS_FLOAT) || defined(THC_REAL_IS_DOUBLE) || \ |
| defined(THC_REAL_IS_HALF) |
| #define RealStr "float" |
| #else |
| #define RealStr "int" |
| #endif |
| |
| #ifdef THC_REAL_IS_HALF |
| #define AS_REAL(x) THC_float2half(x) |
| #else |
| #define AS_REAL(x) x |
| #endif |
| |
| #ifndef THC_GENERIC_FILE |
| #define IS_CUDA false |
| #define CUDA_FLOAT false |
| #else |
| #define IS_CUDA true |
| #define CUDA_BYTE defined(THC_REAL_IS_BYTE) |
| #define CUDA_CHAR defined(THC_REAL_IS_CHAR) |
| #define CUDA_SHORT defined(THC_REAL_IS_SHORT) |
| #define CUDA_INT defined(THC_REAL_IS_INT) |
| #define CUDA_LONG defined(THC_REAL_IS_LONG) |
| #define CUDA_FLOAT defined(THC_REAL_IS_FLOAT) |
| #define CUDA_DOUBLE defined(THC_REAL_IS_DOUBLE) |
| #define CUDA_HALF defined(THC_REAL_IS_HALF) |
| #endif |
| |
| #if IS_CUDA |
| #define THIndexTensor THCudaLongTensor |
| #define THIndexTensor_(NAME) TH_CONCAT_2(THCudaLongTensor_,NAME) |
| #define THPIndexTensor THCPLongTensor |
| #define THPIndexTensorClass THCPLongTensorClass |
| #else |
| #define THIndexTensor THLongTensor |
| #define THIndexTensor_(NAME) TH_CONCAT_2(THLongTensor_,NAME) |
| #define THPIndexTensor THPLongTensor |
| #define THPIndexTensorClass THPLongTensorClass |
| #endif |
| |
| #if IS_CUDA |
| #define THPBoolTensor THCPByteTensor |
| #define THPBoolTensorClass THCPByteTensorClass |
| #else |
| #define THPBoolTensor THPByteTensor |
| #define THPBoolTensorClass THPByteTensorClass |
| #endif |
| |
| #if !IS_CUDA |
| #define THPModuleStr "torch." |
| #else |
| #define THPModuleStr "torch.cuda." |
| #endif |
| |
| // The C API uses THLongStorage for size and stride, but the Python API uses |
| // torch.Size or tuple |
| typedef THLongStorage THSize; |
| typedef THLongStorage THStride; |
| |
| !!inc methods/Tensor.cwrap |
| !!inc methods/TensorSerialization.cwrap |
| !!inc methods/TensorApply.cwrap |
| !!inc methods/TensorMath.cwrap |
| !!inc methods/TensorCompare.cwrap |
| !!inc methods/TensorRandom.cwrap |
| !!inc methods/TensorCuda.cwrap |
| |
| !!inc methods/SparseTensor.cwrap |
| |
| // cwrap should put definitions before undefs, so let's mark this place |
| // PUT DEFINITIONS IN HERE PLEASE |
| |
| #undef IS_CUDA |
| #undef CUDA_BYTE |
| #undef CUDA_CHAR |
| #undef CUDA_SHORT |
| #undef CUDA_INT |
| #undef CUDA_LONG |
| #undef CUDA_FLOAT |
| #undef CUDA_DOUBLE |
| #undef CUDA_HALF |
| #undef THIndexTensor |
| #undef THIndexTensor_ |
| #undef THPIndexTensor |
| #undef THPIndexTensorClass |
| #undef THPBoolTensor |
| #undef THPBoolTensorClass |
| #undef RealStr |
| #undef AS_REAL |