MCPcopy Create free account
hub / github.com/antirez/llama.cpp-deepseek-v4-flash / pos_next

Method pos_next

tools/server/server-common.cpp:246–287  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

244}
245
246llama_pos server_tokens::pos_next(int64_t n_tokens) const {
247 if (!has_mtmd) {
248 if (n_tokens < 0) {
249 return tokens.size();
250 }
251
252 return n_tokens;
253 }
254
255 if (n_tokens < 0) {
256 llama_pos res = tokens.size();
257
258 for (auto it = map_idx_to_media.begin(); it != map_idx_to_media.end(); ++it) {
259 const auto & chunk = it->second;
260 res += mtmd_input_chunk_get_n_pos(chunk.get()) - mtmd_input_chunk_get_n_tokens(chunk.get());
261 }
262
263 return res;
264 }
265
266 int64_t idx = 0;
267 llama_pos pos = 0;
268
269 GGML_ASSERT(n_tokens <= (int64_t)tokens.size());
270
271 while (idx < n_tokens) {
272 const auto media_it = map_idx_to_media.find(idx);
273 if (media_it != map_idx_to_media.end()) {
274 const auto & chunk = media_it->second;
275 const llama_pos n_pos = mtmd_input_chunk_get_n_pos(chunk.get());
276 const size_t n_tok = mtmd_input_chunk_get_n_tokens(chunk.get());
277
278 pos += n_pos;
279 idx += n_tok;
280 } else {
281 pos++;
282 idx++;
283 }
284 }
285
286 return pos;
287}
288
289size_t server_tokens::size_up_to_pos(llama_pos max_pos) const {
290 if (!has_mtmd) {

Callers 2

update_batchMethod · 0.80
update_slotsMethod · 0.80

Calls 7

endMethod · 0.80
findMethod · 0.80
sizeMethod · 0.45
beginMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected