| 8 | xrt::device npu_device_global; |
| 9 | |
| 10 | int main(int argc, char* argv[]) { |
| 11 | #ifdef __WINDOWS__ |
| 12 | SetConsoleOutputCP(CP_UTF8); |
| 13 | SetConsoleCP(CP_UTF8); |
| 14 | #endif |
| 15 | arg_utils::po::options_description desc("Allowed options"); |
| 16 | arg_utils::po::variables_map vm; |
| 17 | desc.add_options()("model,m", arg_utils::po::value<std::string>()->required(), "Model file"); |
| 18 | desc.add_options()("Short,s", arg_utils::po::value<bool>()->default_value(true), "Short Prompt"); |
| 19 | desc.add_options()("Preemption,p", arg_utils::po::value<bool>()->default_value(false), "Preemption"); |
| 20 | |
| 21 | arg_utils::po::store(arg_utils::po::parse_command_line(argc, argv, desc), vm); |
| 22 | |
| 23 | std::string tag = vm["model"].as<std::string>(); |
| 24 | bool short_prompt = vm["Short"].as<bool>(); |
| 25 | bool preemption = vm["Preemption"].as<bool>(); |
| 26 | std::cout << "Model: " << tag << std::endl; |
| 27 | std::string exe_dir = utils::get_executable_directory(); |
| 28 | std::string model_dir = utils::get_models_directory(); |
| 29 | std::string model_list_path = exe_dir + "/model_list.json"; |
| 30 | model_list model_list(model_list_path, model_dir); |
| 31 | |
| 32 | |
| 33 | |
| 34 | header_print("info", "Initializing chat model..."); |
| 35 | std::string model_path = model_list.get_model_path(tag); |
| 36 | std::pair<std::string, nlohmann::json> model_info_pair = model_list.get_model_info(tag); |
| 37 | nlohmann::json model_info = model_info_pair.second; |
| 38 | std::cout << "Model path: " << model_path << std::endl; |
| 39 | std::cout << "Model info" << model_info.dump(4) << std::endl; |
| 40 | |
| 41 | |
| 42 | npu_device_global = xrt::device(0); |
| 43 | std::unique_ptr<AutoModel> chat = std::make_unique<Gemma3>(&npu_device_global); |
| 44 | |
| 45 | chat->load_model(model_path, model_info, -1, preemption); |
| 46 | chat_meta_info_t meta_info; |
| 47 | lm_uniform_input_t uniformed_input; |
| 48 | std::string response; |
| 49 | |
| 50 | if (short_prompt) { |
| 51 | uniformed_input.prompt = "Describe this?"; |
| 52 | uniformed_input.images.push_back("../../../tb_files/panda.png"); |
| 53 | uniformed_input.image_payload_types.push_back(input_payload_type_t::FILE_NAME); |
| 54 | std::cout << "Prompt: " << uniformed_input.prompt << std::endl; |
| 55 | std::cout << "Response: "; |
| 56 | chat->start_total_timer(); |
| 57 | // std::string response = chat->generate_with_prompt(meta_info, uniformed_input, 1024, std::cout); |
| 58 | if (chat->insert(meta_info, uniformed_input)) |
| 59 | { |
| 60 | response = chat->generate(meta_info, 2048, std::cout); |
| 61 | } |
| 62 | chat->stop_total_timer(); |
| 63 | std::cout << std::endl; |
| 64 | std::cout << std::endl; |
| 65 | std::cout << chat->show_profile() << std::endl; |
| 66 | |
| 67 | uniformed_input.prompt = "Can I have one as a pet?"; |
nothing calls this directly
no test coverage detected