| 413 | Gemma4e::Gemma4e(xrt::device* npu_device_inst) : AutoModel(npu_device_inst, "Gemma4e") {} |
| 414 | |
| 415 | void Gemma4e::load_model(std::string model_path, json model_info, int default_context_length, bool enable_preemption) { |
| 416 | |
| 417 | this->_shared_load_model(model_path, model_info, default_context_length, enable_preemption); |
| 418 | |
| 419 | this->q4nx = std::make_unique<Q4NX>(this->model_path); |
| 420 | this->lm_engine = std::make_unique<gemma4e_npu>(*this->lm_config, this->npu.get(), this->MAX_L); |
| 421 | |
| 422 | this->lm_engine->load_weights(*this->q4nx); |
| 423 | //free the q4nx |
| 424 | this->q4nx.reset(); |
| 425 | this->lm_engine->clear_context(); |
| 426 | this->setup_tokenizer(model_path); |
| 427 | this->sampler.reset(); |
| 428 | |
| 429 | this->enable_tool = (model_info["size"] > 800000000)? true : false; |
| 430 | |
| 431 | sampler_config config; |
| 432 | config.top_k = 64; |
| 433 | config.top_p = 0.95; |
| 434 | config.min_p = 0.0; |
| 435 | config.temperature = 1.0; |
| 436 | config.rep_penalty = 1.0; |
| 437 | config.freq_penalty = 1.0; |
| 438 | config.pre_penalty = 1.0f; |
| 439 | |
| 440 | this->set_sampler(config); |
| 441 | for (size_t i = 0; i < PROFILER_TYPE_NUM; i++) { |
| 442 | this->profiler_list[i].reset(); |
| 443 | } |
| 444 | } |
| 445 | |
| 446 | void Gemma4e::setup_tokenizer(std::string model_path) { |
| 447 | auto tokenizer_config = this->_shared_setup_tokenizer(model_path); |
nothing calls this directly
no test coverage detected