1*da0073e9SAndroid Build Coastguard Workerc10/cuda is a core library with CUDA functionality. It is distinguished 2*da0073e9SAndroid Build Coastguard Workerfrom c10 in that it links against the CUDA library, but like c10 it doesn't 3*da0073e9SAndroid Build Coastguard Workercontain any kernels, and consists solely of core functionality that is generally 4*da0073e9SAndroid Build Coastguard Workeruseful when writing CUDA code; for example, C++ wrappers for the CUDA C API. 5*da0073e9SAndroid Build Coastguard Worker 6*da0073e9SAndroid Build Coastguard Worker**Important notes for developers.** If you want to add files or functionality 7*da0073e9SAndroid Build Coastguard Workerto this folder, TAKE NOTE. The code in this folder is very special, 8*da0073e9SAndroid Build Coastguard Workerbecause on our AMD GPU build, we transpile it into c10/hip to provide a 9*da0073e9SAndroid Build Coastguard WorkerROCm environment. Thus, if you write: 10*da0073e9SAndroid Build Coastguard Worker 11*da0073e9SAndroid Build Coastguard Worker``` 12*da0073e9SAndroid Build Coastguard Worker// c10/cuda/CUDAFoo.h 13*da0073e9SAndroid Build Coastguard Workernamespace c10 { namespace cuda { 14*da0073e9SAndroid Build Coastguard Worker 15*da0073e9SAndroid Build Coastguard Workervoid my_func(); 16*da0073e9SAndroid Build Coastguard Worker 17*da0073e9SAndroid Build Coastguard Worker}} 18*da0073e9SAndroid Build Coastguard Worker``` 19*da0073e9SAndroid Build Coastguard Worker 20*da0073e9SAndroid Build Coastguard Workerthis will get transpiled into: 21*da0073e9SAndroid Build Coastguard Worker 22*da0073e9SAndroid Build Coastguard Worker 23*da0073e9SAndroid Build Coastguard Worker``` 24*da0073e9SAndroid Build Coastguard Worker// c10/hip/HIPFoo.h 25*da0073e9SAndroid Build Coastguard Workernamespace c10 { namespace hip { 26*da0073e9SAndroid Build Coastguard Worker 27*da0073e9SAndroid Build Coastguard Workervoid my_func(); 28*da0073e9SAndroid Build Coastguard Worker 29*da0073e9SAndroid Build Coastguard Worker}} 30*da0073e9SAndroid Build Coastguard Worker``` 31*da0073e9SAndroid Build Coastguard Worker 32*da0073e9SAndroid Build Coastguard WorkerThus, if you add new functionality to c10, you must also update `C10_MAPPINGS` 33*da0073e9SAndroid Build Coastguard Worker`torch/utils/hipify/cuda_to_hip_mappings.py` to transpile 34*da0073e9SAndroid Build Coastguard Workeroccurrences of `cuda::my_func` to `hip::my_func`. (At the moment, 35*da0073e9SAndroid Build Coastguard Workerwe do NOT have a catch all `cuda::` to `hip::` namespace conversion, 36*da0073e9SAndroid Build Coastguard Workeras not all `cuda` namespaces are converted to `hip::`, even though 37*da0073e9SAndroid Build Coastguard Workerc10's are.) 38*da0073e9SAndroid Build Coastguard Worker 39*da0073e9SAndroid Build Coastguard WorkerTranspilation inside this folder is controlled by `CAFFE2_SPECIFIC_MAPPINGS` 40*da0073e9SAndroid Build Coastguard Worker(oddly enough.) `C10_MAPPINGS` apply to ALL source files. 41*da0073e9SAndroid Build Coastguard Worker 42*da0073e9SAndroid Build Coastguard WorkerIf you add a new directory to this folder, you MUST update both 43*da0073e9SAndroid Build Coastguard Workerc10/cuda/CMakeLists.txt and c10/hip/CMakeLists.txt 44