Skip to content

Commit eaffba0

Browse files
committed
llama_batch_ext_ptr::from_text/embd
1 parent 8e7714f commit eaffba0

File tree

12 files changed

+34
-14
lines changed

12 files changed

+34
-14
lines changed

examples/cvector-generator/cvector-generator.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ static bool cb_eval(struct ggml_tensor * t, bool ask, void * user_data) {
343343

344344
static bool get_hidden_layers(llama_context * ctx, std::vector<llama_token> & tokens) {
345345
llama_kv_self_clear(ctx);
346-
llama_batch_ext_ptr batch(llama_batch_ext_init_from_text(tokens.data(), tokens.size(), 0, 0, true));
346+
auto batch = llama_batch_ext_ptr::from_text(tokens.data(), tokens.size(), 0, 0, true);
347347
if (llama_decode_ext(ctx, batch.get())) {
348348
fprintf(stderr, "%s : failed to eval\n", __func__);
349349
return false;

examples/eval-callback/eval-callback.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ static bool run(llama_context * ctx, const common_params & params) {
134134

135135
std::vector<llama_token> tokens = common_tokenize(ctx, params.prompt, add_bos);
136136

137-
llama_batch_ext_ptr batch(llama_batch_ext_init_from_text(tokens.data(), tokens.size(), 0, 0, true));
137+
auto batch = llama_batch_ext_ptr::from_text(tokens.data(), tokens.size(), 0, 0, true);
138138
if (llama_decode_ext(ctx, batch.get())) {
139139
LOG_ERR("%s : failed to eval\n", __func__);
140140
return false;

examples/infill/infill.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ int main(int argc, char ** argv) {
353353

354354
LOG_DBG("eval: %s\n", string_from(ctx, embd).c_str());
355355

356-
llama_batch_ext_ptr batch(llama_batch_ext_init_from_text(&embd[i], n_eval, n_past, 0, true));
356+
auto batch = llama_batch_ext_ptr::from_text(&embd[i], n_eval, n_past, 0, true);
357357
if (llama_decode_ext(ctx, batch.get())) {
358358
LOG_ERR("%s : failed to eval\n", __func__);
359359
return 1;

examples/llama-bench/llama-bench.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1444,7 +1444,7 @@ static void test_prompt(llama_context * ctx, int n_prompt, int n_past, int n_bat
14441444
for (int i = 1; i < n_tokens; i++) {
14451445
tokens[i] = std::rand() % n_vocab;
14461446
}
1447-
llama_batch_ext_ptr batch(llama_batch_ext_init_from_text(tokens.data(), n_tokens, n_past + n_processed, 0, true));
1447+
auto batch = llama_batch_ext_ptr::from_text(tokens.data(), n_tokens, n_past + n_processed, 0, true);
14481448
llama_decode_ext(ctx, batch.get());
14491449
n_processed += n_tokens;
14501450
}
@@ -1462,7 +1462,7 @@ static void test_gen(llama_context * ctx, int n_gen, int n_past, int n_threads)
14621462
llama_token token = llama_vocab_get_add_bos(vocab) ? llama_vocab_bos(vocab) : std::rand() % n_vocab;
14631463

14641464
for (int i = 0; i < n_gen; i++) {
1465-
llama_batch_ext_ptr batch(llama_batch_ext_init_from_text(&token, 1, n_past + i, 0, true));
1465+
auto batch = llama_batch_ext_ptr::from_text(&token, 1, n_past + i, 0, true);
14661466
llama_decode_ext(ctx, batch.get());
14671467
llama_synchronize(ctx);
14681468
token = std::rand() % n_vocab;

examples/llava/llava-cli.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ static bool eval_tokens(struct llama_context * ctx_llama, std::vector<llama_toke
2020
if (n_eval > n_batch) {
2121
n_eval = n_batch;
2222
}
23-
llama_batch_ext_ptr batch(llama_batch_ext_init_from_text(&tokens[i], n_eval, *n_past, 0, true));
23+
auto batch = llama_batch_ext_ptr::from_text(&tokens[i], n_eval, *n_past, 0, true);
2424
if (llama_decode_ext(ctx_llama, batch.get())) {
2525
LOG_ERR("%s : failed to eval. token %d/%d (batch size %d, n_past %d)\n", __func__, i, N, n_batch, *n_past);
2626
return false;

examples/llava/llava.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ bool llava_eval_image_embed(llama_context * ctx_llama, const struct llava_image_
448448
n_eval = n_batch;
449449
}
450450
float * embd = image_embed->embed+i*n_embd;
451-
llama_batch_ext_ptr batch(llama_batch_ext_init_from_embd(embd, n_eval, n_embd, 0, 0));
451+
auto batch = llama_batch_ext_ptr::from_embd(embd, n_eval, n_embd, 0, 0);
452452
if (llama_decode_ext(ctx_llama, batch.get())) {
453453
LOG_ERR("%s : failed to eval\n", __func__);
454454
return false;

examples/llava/minicpmv-cli.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ static bool eval_tokens(struct llama_context * ctx_llama, std::vector<llama_toke
101101
if (n_eval > n_batch) {
102102
n_eval = n_batch;
103103
}
104-
llama_batch_ext_ptr batch(llama_batch_ext_init_from_text(&tokens[i], n_eval, *n_past, 0, true));
104+
auto batch = llama_batch_ext_ptr::from_text(&tokens[i], n_eval, *n_past, 0, true);
105105
if (llama_decode_ext(ctx_llama, batch.get())) {
106106
LOG_ERR("%s : failed to eval. token %d/%d (batch size %d, n_past %d)\n", __func__, i, N, n_batch, *n_past);
107107
return false;

examples/llava/qwen2vl-cli.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ static bool qwen2vl_eval_image_embed(llama_context * ctx_llama, const struct lla
6767
memcpy(&batch_mrope_pos[n_eval * 3], &mrope_pos[img_tokens * 3 + processed], n_eval * sizeof(llama_pos));
6868

6969
float * batch_embd = image_embed->embed+i*n_embd;
70-
llama_batch_ext_ptr batch(llama_batch_ext_init_from_embd(batch_embd, n_eval, n_embd, 0, 0));
70+
auto batch = llama_batch_ext_ptr::from_embd(batch_embd, n_eval, n_embd, 0, 0);
7171
llama_batch_ext_set_pos(batch.get(), batch_mrope_pos.data(), n_eval);
7272

7373
if (llama_decode_ext(ctx_llama, batch.get())) {

examples/main/main.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,7 @@ int main(int argc, char ** argv) {
548548
int enc_input_size = embd_inp.size();
549549
llama_token * enc_input_buf = embd_inp.data();
550550

551-
llama_batch_ext_ptr batch(llama_batch_ext_init_from_text(enc_input_buf, enc_input_size, 0, 0, true));
551+
auto batch = llama_batch_ext_ptr::from_text(enc_input_buf, enc_input_size, 0, 0, true);
552552
if (llama_decode_ext(ctx, batch.get())) {
553553
LOG_ERR("%s : failed to eval\n", __func__);
554554
return 1;
@@ -669,7 +669,7 @@ int main(int argc, char ** argv) {
669669

670670
LOG_DBG("eval: %s\n", string_from(ctx, embd).c_str());
671671

672-
llama_batch_ext_ptr batch(llama_batch_ext_init_from_text(&embd[i], n_eval, n_past, 0, true));
672+
auto batch = llama_batch_ext_ptr::from_text(&embd[i], n_eval, n_past, 0, true);
673673
llama_batch_ext_set_output_last(batch.get());
674674
if (llama_decode_ext(ctx, batch.get())) {
675675
LOG_ERR("%s : failed to eval\n", __func__);

examples/run/run.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -947,7 +947,7 @@ static int generate(LlamaData & llama_data, const std::string & prompt, std::str
947947
}
948948

949949
// prepare a batch for the prompt
950-
llama_batch_ext_ptr batch(llama_batch_ext_init_from_text(tokens.data(), tokens.size(), llama_data.n_past, 0, true));
950+
auto batch = llama_batch_ext_ptr::from_text(tokens.data(), tokens.size(), llama_data.n_past, 0, true);
951951
llama_token new_token_id;
952952
while (true) {
953953
check_context_size(llama_data.context, batch);

0 commit comments

Comments
 (0)