| 28 | |
| 29 | template<typename T> |
| 30 | void test(int version, int model_type, int window_size, int img_size, int batch) |
| 31 | { |
| 32 | cudnnHandle_t cudnn_handle; |
| 33 | cublasHandle_t cublas_handle; |
| 34 | cublasLtHandle_t cublaslt_handle; |
| 35 | cudaStream_t stream = 0; |
| 36 | checkCUDNN(cudnnCreate(&cudnn_handle)); |
| 37 | checkCUDNN(cudnnSetStream(cudnn_handle, stream)); |
| 38 | check_cuda_error(cublasCreate(&cublas_handle)); |
| 39 | check_cuda_error(cublasSetStream(cublas_handle, stream)); |
| 40 | check_cuda_error(cublasLtCreate(&cublaslt_handle)); |
| 41 | |
| 42 | cublasAlgoMap* cublas_algo_map = new cublasAlgoMap(GEMM_CONFIG); |
| 43 | |
| 44 | std::mutex* cublas_wrapper_mutex = new std::mutex(); |
| 45 | |
| 46 | cublasMMWrapper* cublas_wrapper = |
| 47 | new cublasMMWrapper(cublas_handle, cublaslt_handle, stream, cublas_algo_map, cublas_wrapper_mutex, nullptr); |
| 48 | |
| 49 | if (std::is_same<T, half>::value) { |
| 50 | cublas_wrapper->setFP16GemmConfig(); |
| 51 | } |
| 52 | #ifdef ENABLE_BF16 |
| 53 | else if (std::is_same<T, __nv_bfloat16>::value) { |
| 54 | cublas_wrapper->setBF16GemmConfig(); |
| 55 | } |
| 56 | #endif |
| 57 | else if (std::is_same<T, float>::value) { |
| 58 | cublas_wrapper->setFP32GemmConfig(); |
| 59 | } |
| 60 | |
| 61 | int embed_dim; |
| 62 | int shift_size; |
| 63 | int depths[4], num_heads[4]; |
| 64 | |
| 65 | if (model_type == 0) { // tiny |
| 66 | embed_dim = 96; |
| 67 | shift_size = window_size / 2; |
| 68 | depths[0] = 2; |
| 69 | depths[1] = 2; |
| 70 | depths[2] = 6; |
| 71 | depths[3] = 2; |
| 72 | num_heads[0] = 3; |
| 73 | num_heads[1] = 6; |
| 74 | num_heads[2] = 12; |
| 75 | num_heads[3] = 24; |
| 76 | } |
| 77 | else if (model_type == 1) { // small |
| 78 | embed_dim = 96; |
| 79 | shift_size = window_size / 2; |
| 80 | depths[0] = 2; |
| 81 | depths[1] = 2; |
| 82 | depths[2] = 18; |
| 83 | depths[3] = 2; |
| 84 | num_heads[0] = 3; |
| 85 | num_heads[1] = 6; |
| 86 | num_heads[2] = 12; |
| 87 | num_heads[3] = 24; |
nothing calls this directly
no test coverage detected