MCPcopy Create free account
hub / github.com/FastFlowLM/FastFlowLM / _shared_load_model

Method _shared_load_model

src/common/AutoModel/automodel.cpp:114–145  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

112
113
114void AutoModel::_shared_load_model(std::string model_path, json model_info, int default_context_length, bool enable_preemption) {
115 if (this->is_model_loaded && this->model_path == model_path) {
116 header_print("FLM", "Model already loaded: " << this->model_path);
117 return;
118 }
119
120 this->model_path = model_path;
121 header_print("FLM", "Loading model: " << this->model_path);
122 this->lm_config = std::make_unique<LM_Config>();
123 this->lm_config->from_pretrained(this->model_path);
124 if (this->npu_device_inst == nullptr) {
125 header_print("ERROR", "NPU device instance is nullptr");
126 exit(1);
127 }
128 this->npu = std::make_unique<npu_xclbin_manager>(npu_device::device_npu2, this->npu_device_inst, enable_preemption);
129 this->enable_preemption = enable_preemption;
130 // Set context length: use provided value if not -1, otherwise use model default
131 if (default_context_length != -1) {
132 this->MAX_L = default_context_length;
133 } else {
134 this->MAX_L = model_info["default_context_length"];
135 }
136
137 this->is_model_loaded = true;
138
139 this->token_history.clear();
140 this->token_history.reserve(this->MAX_L);
141 this->tokenizer = std::make_unique<Tokenizer>(this->model_path);
142
143 this->last_token = -1;
144 this->total_tokens = 0;
145}
146
147bool AutoModel::_shared_insert(chat_meta_info_t& meta_info, std::vector<int>& tokens, std::function<bool()> is_cancelled, void* payload, int first_len_run) {
148

Callers 13

load_modelMethod · 0.45
load_modelMethod · 0.45
load_modelMethod · 0.45
load_modelMethod · 0.45
load_modelMethod · 0.45
load_modelMethod · 0.45
load_modelMethod · 0.45
load_modelMethod · 0.45
load_modelMethod · 0.45
load_modelMethod · 0.45
load_modelMethod · 0.45
load_modelMethod · 0.45

Calls 3

clearMethod · 0.80
from_pretrainedMethod · 0.45
reserveMethod · 0.45

Tested by

no test coverage detected