| 31 | void gpt_example(const INIReader reader); |
| 32 | |
| 33 | int main(int argc, char* argv[]) |
| 34 | { |
| 35 | srand(0); |
| 36 | struct cudaDeviceProp prop; |
| 37 | check_cuda_error(cudaGetDeviceProperties(&prop, 0)); |
| 38 | printf("Device %s\n", prop.name); |
| 39 | |
| 40 | std::string ini_name; |
| 41 | if (argc == 2) { |
| 42 | ini_name = std::string(argv[1]); |
| 43 | } |
| 44 | else { |
| 45 | ini_name = "../examples/cpp/gpt/gpt_config.ini"; |
| 46 | } |
| 47 | |
| 48 | INIReader reader = INIReader(ini_name); |
| 49 | if (reader.ParseError() < 0) { |
| 50 | std::cout << "[ERROR] Can't load '" << ini_name << "'\n"; |
| 51 | return -1; |
| 52 | } |
| 53 | const std::string data_type = reader.Get("ft_instance_hyperparameter", "data_type"); |
| 54 | |
| 55 | if (data_type == "fp32") { |
| 56 | gpt_example<float>(reader); |
| 57 | } |
| 58 | else if (data_type == "fp16") { |
| 59 | gpt_example<half>(reader); |
| 60 | } |
| 61 | #ifdef ENABLE_BF16 |
| 62 | else if (data_type == "bf16") { |
| 63 | gpt_example<__nv_bfloat16>(reader); |
| 64 | } |
| 65 | #endif |
| 66 | else { |
| 67 | printf("[ERROR] data_type should be fp32, fp16 or bf16 ! \n"); |
| 68 | return -1; |
| 69 | } |
| 70 | return 0; |
| 71 | } |
| 72 |
nothing calls this directly
no test coverage detected