| 30 | bool is_remove_padding); |
| 31 | |
| 32 | int main(int argc, char** argv) |
| 33 | { |
| 34 | if (argc != 8) { |
| 35 | FT_LOG_ERROR("bert_example batch_size num_layers seq_len head_num size_per_head data_type is_remove_padding"); |
| 36 | FT_LOG_ERROR("e.g., ./bin/bert_example 32 12 32 12 64 0 0"); |
| 37 | return 0; |
| 38 | } |
| 39 | |
| 40 | int batch_size = atoi(argv[1]); |
| 41 | int num_layers = atoi(argv[2]); |
| 42 | int seq_len = atoi(argv[3]); |
| 43 | int head_num = atoi(argv[4]); |
| 44 | int size_per_head = atoi(argv[5]); |
| 45 | bool is_remove_padding = static_cast<bool>(atoi(argv[7])); |
| 46 | const CublasDataType data_type = static_cast<CublasDataType>(atoi(argv[6])); // 0 FP32, 1 FP16, 2 BF 16 |
| 47 | |
| 48 | if (data_type == FLOAT_DATATYPE) { |
| 49 | return bertExample<float>(batch_size, num_layers, seq_len, head_num, size_per_head, is_remove_padding); |
| 50 | } |
| 51 | else if (data_type == HALF_DATATYPE) { |
| 52 | return bertExample<half>(batch_size, num_layers, seq_len, head_num, size_per_head, is_remove_padding); |
| 53 | } |
| 54 | #ifdef ENABLE_BF16 |
| 55 | else if (data_type == BFLOAT16_DATATYPE) { |
| 56 | return bertExample<__nv_bfloat16>(batch_size, num_layers, seq_len, head_num, size_per_head, is_remove_padding); |
| 57 | } |
| 58 | #endif |
| 59 | else { |
| 60 | throw std::runtime_error(std::string("[FT][ERROR] is_fp16 should be 0 (use float)" |
| 61 | "or 1 (use half). \n ")); |
| 62 | } |
| 63 | } |
| 64 | |
| 65 | template<typename T> |
| 66 | int bertExample( |
nothing calls this directly
no outgoing calls
no test coverage detected