| 11 | Nanbeige::Nanbeige(xrt::device* npu_device_inst) : AutoModel(npu_device_inst, "Nanbeige") {} |
| 12 | |
| 13 | void Nanbeige::load_model(std::string model_path, json model_info, int default_context_length, bool enable_preemption) { |
| 14 | this->_shared_load_model(model_path, model_info, default_context_length, enable_preemption); |
| 15 | |
| 16 | this->q4nx = std::make_unique<Q4NX>(this->model_path); |
| 17 | // model_type == nanbeige |
| 18 | this->lm_engine = std::make_unique<nanbeige_npu>(*this->lm_config, this->npu.get(), this->MAX_L); |
| 19 | |
| 20 | this->lm_engine->load_weights(*this->q4nx); |
| 21 | |
| 22 | //free the q4nx |
| 23 | this->q4nx.reset(); |
| 24 | |
| 25 | this->lm_engine->clear_context(); |
| 26 | this->setup_tokenizer(model_path); |
| 27 | this->sampler.reset(); |
| 28 | |
| 29 | sampler_config config; |
| 30 | config.top_k = 20; |
| 31 | config.top_p = 0.95; |
| 32 | config.min_p = 0.0; |
| 33 | config.temperature = 0.6; |
| 34 | |
| 35 | this->set_sampler(config); |
| 36 | for (size_t i = 0; i < PROFILER_TYPE_NUM; i++) { |
| 37 | this->profiler_list[i].reset(); |
| 38 | } |
| 39 | } |
| 40 | |
| 41 | void Nanbeige::setup_tokenizer(std::string model_path) { |
| 42 | auto tokenizer_config = this->_shared_setup_tokenizer(model_path); |
nothing calls this directly
no test coverage detected