| 110 | |
| 111 | template<typename T> |
| 112 | int decodingExample(const size_t batch_size, |
| 113 | const size_t beam_width, |
| 114 | const size_t head_num, |
| 115 | const size_t size_per_head, |
| 116 | const size_t inter_size, |
| 117 | const size_t vocab_size, |
| 118 | const size_t num_layers, |
| 119 | const size_t max_seq_len, |
| 120 | const size_t memory_max_seq_len, |
| 121 | const size_t memory_hidden_units, |
| 122 | const int top_k, |
| 123 | const float top_p) |
| 124 | { |
| 125 | const size_t hidden_units = head_num * size_per_head; |
| 126 | const int start_id = 0; |
| 127 | const int end_id = 1; |
| 128 | |
| 129 | cudaStream_t stream; |
| 130 | cublasHandle_t cublas_handle; |
| 131 | cublasLtHandle_t cublaslt_handle; |
| 132 | cudaStreamCreate(&stream); |
| 133 | cublasCreate(&cublas_handle); |
| 134 | cublasLtCreate(&cublaslt_handle); |
| 135 | cublasSetStream(cublas_handle, stream); |
| 136 | cublasAlgoMap* cublas_algo_map = new cublasAlgoMap("gemm_config.in"); |
| 137 | |
| 138 | Allocator<AllocatorType::CUDA> allocator(getDevice()); |
| 139 | |
| 140 | std::mutex* cublas_wrapper_mutex = new std::mutex(); |
| 141 | cublasMMWrapper cublas_wrapper = |
| 142 | cublasMMWrapper(cublas_handle, cublaslt_handle, stream, cublas_algo_map, cublas_wrapper_mutex, &allocator); |
| 143 | if (std::is_same<T, half>::value) { |
| 144 | cublas_wrapper.setFP16GemmConfig(); |
| 145 | } |
| 146 | #ifdef ENABLE_BF16 |
| 147 | else if (std::is_same<T, __nv_bfloat16>::value) { |
| 148 | cublas_wrapper.setBF16GemmConfig(); |
| 149 | } |
| 150 | #endif |
| 151 | else if (std::is_same<T, float>::value) { |
| 152 | cublas_wrapper.setFP32GemmConfig(); |
| 153 | } |
| 154 | struct cudaDeviceProp prop; |
| 155 | check_cuda_error(cudaGetDeviceProperties(&prop, 0)); |
| 156 | |
| 157 | fastertransformer::DecodingWeight<T> decoding_weights( |
| 158 | hidden_units, inter_size, vocab_size, num_layers, max_seq_len, memory_hidden_units); |
| 159 | Decoding<T> decoding = Decoding<T>(batch_size, |
| 160 | max_seq_len, |
| 161 | memory_max_seq_len, |
| 162 | beam_width, |
| 163 | head_num, |
| 164 | size_per_head, |
| 165 | inter_size, |
| 166 | num_layers, |
| 167 | vocab_size, |
| 168 | start_id, |
| 169 | end_id, |
nothing calls this directly
no test coverage detected