| 20 | namespace ft = fastertransformer; |
| 21 | |
| 22 | int main(int argc, char* argv[]) |
| 23 | { |
| 24 | if (argc != 10 && argc != 11) { |
| 25 | printf( |
| 26 | "[ERROR] decoding_gemm batch_size beam_width head_num size_per_head inter_size vocab_size max_mem_seq_len memory_hidden_units data_type \n"); |
| 27 | printf("e.g. ./bin/decoding_gemm 32 4 8 64 2048 30000 32 512 0\n"); |
| 28 | return 0; |
| 29 | } |
| 30 | |
| 31 | const int batch_size = atoi(argv[1]); |
| 32 | const int beam_width = atoi(argv[2]); |
| 33 | const int head_num = atoi(argv[3]); |
| 34 | const int size_per_head = atoi(argv[4]); |
| 35 | const int inter_size = atoi(argv[5]); |
| 36 | const int vocab_size = atoi(argv[6]); |
| 37 | const int max_mem_seq_len = atoi(argv[7]); |
| 38 | const int memory_hidden_units = atoi(argv[8]); |
| 39 | const ft::CublasDataType data_type = static_cast<ft::CublasDataType>(atoi(argv[9])); // 0 FP32, 1 FP16, 2 BF 16 |
| 40 | const bool is_append = argc == 11 ? ((bool)atoi(argv[10])) : false; |
| 41 | |
| 42 | printf("[INFO] arguments: \n"); |
| 43 | printf(" batch_size: %d \n", batch_size); |
| 44 | printf(" beam_width: %d \n", beam_width); |
| 45 | printf(" head_num: %d \n", head_num); |
| 46 | printf(" size_per_head: %d \n", size_per_head); |
| 47 | printf(" inter_size: %d \n", inter_size); |
| 48 | printf(" vocab_size: %d \n", vocab_size); |
| 49 | printf(" max_mem_seq_len: %d \n", max_mem_seq_len); |
| 50 | printf(" memory_hidden_units: %d \n", memory_hidden_units); |
| 51 | printf(" data_type: %d \n", data_type); |
| 52 | std::cout << std::endl; |
| 53 | |
| 54 | void* gemm_test_buf; |
| 55 | size_t buf_size_in_byte = ft::calDecodingGemmTestBufSizeInByte(batch_size, |
| 56 | beam_width, |
| 57 | max_mem_seq_len, |
| 58 | head_num, |
| 59 | size_per_head, |
| 60 | inter_size, |
| 61 | memory_hidden_units, |
| 62 | vocab_size, |
| 63 | data_type); |
| 64 | |
| 65 | size_t total, free; |
| 66 | ft::check_cuda_error(cudaMemGetInfo(&free, &total)); |
| 67 | if (free < buf_size_in_byte + 10 * 1024 * 1024) { |
| 68 | printf("[ERROR] There is no enough device memory for gemm test!\n" |
| 69 | " %ld Bytes is needed, but only %ld Bytes is free.\n", |
| 70 | buf_size_in_byte, |
| 71 | free); |
| 72 | gemm_test_buf = NULL; |
| 73 | return -1; |
| 74 | } |
| 75 | else { |
| 76 | ft::deviceMalloc(reinterpret_cast<char**>(&gemm_test_buf), buf_size_in_byte, false); |
| 77 | } |
| 78 | |
| 79 | if (data_type == ft::FLOAT_DATATYPE) { |
nothing calls this directly
no test coverage detected