Skip to content

Commit 6ea0304

Browse files
committed
update android example
1 parent 3c0b862 commit 6ea0304

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

examples/llama.android/llama/src/main/cpp/llama-android.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -186,11 +186,11 @@ Java_android_llama_cpp_LLamaAndroid_bench_1model(
186186
for (nri = 0; nri < nr; nri++) {
187187
LOGi("Benchmark prompt processing (pp)");
188188

189-
llama_batch_clear(*batch);
189+
common_batch_clear(*batch);
190190

191191
const int n_tokens = pp;
192192
for (i = 0; i < n_tokens; i++) {
193-
llama_batch_add(*batch, 0, i, { 0 }, false);
193+
common_batch_add(*batch, 0, i, { 0 }, false);
194194
}
195195

196196
batch->logits[batch->n_tokens - 1] = true;
@@ -210,9 +210,9 @@ Java_android_llama_cpp_LLamaAndroid_bench_1model(
210210
const auto t_tg_start = ggml_time_us();
211211
for (i = 0; i < tg; i++) {
212212

213-
llama_batch_clear(*batch);
213+
common_batch_clear(*batch);
214214
for (j = 0; j < pl; j++) {
215-
llama_batch_add(*batch, 0, i, { j }, true);
215+
common_batch_add(*batch, 0, i, { j }, true);
216216
}
217217

218218
LOGi("llama_decode() text generation: %d", i);
@@ -357,7 +357,7 @@ Java_android_llama_cpp_LLamaAndroid_completion_1init(
357357
const auto context = reinterpret_cast<llama_context *>(context_pointer);
358358
const auto batch = reinterpret_cast<llama_batch *>(batch_pointer);
359359

360-
const auto tokens_list = llama_tokenize(context, text, 1);
360+
const auto tokens_list = common_tokenize(context, text, 1);
361361

362362
auto n_ctx = llama_n_ctx(context);
363363
auto n_kv_req = tokens_list.size() + (n_len - tokens_list.size());
@@ -369,14 +369,14 @@ Java_android_llama_cpp_LLamaAndroid_completion_1init(
369369
}
370370

371371
for (auto id : tokens_list) {
372-
LOGi("%s", llama_token_to_piece(context, id).c_str());
372+
LOGi("%s", common_token_to_piece(context, id).c_str());
373373
}
374374

375-
llama_batch_clear(*batch);
375+
common_batch_clear(*batch);
376376

377377
// evaluate the initial prompt
378378
for (auto i = 0; i < tokens_list.size(); i++) {
379-
llama_batch_add(*batch, tokens_list[i], i, { 0 }, false);
379+
common_batch_add(*batch, tokens_list[i], i, { 0 }, false);
380380
}
381381

382382
// llama_decode will output logits only for the last token of the prompt
@@ -419,7 +419,7 @@ Java_android_llama_cpp_LLamaAndroid_completion_1loop(
419419
return nullptr;
420420
}
421421

422-
auto new_token_chars = llama_token_to_piece(context, new_token_id);
422+
auto new_token_chars = common_token_to_piece(context, new_token_id);
423423
cached_token_chars += new_token_chars;
424424

425425
jstring new_token = nullptr;
@@ -431,8 +431,8 @@ Java_android_llama_cpp_LLamaAndroid_completion_1loop(
431431
new_token = env->NewStringUTF("");
432432
}
433433

434-
llama_batch_clear(*batch);
435-
llama_batch_add(*batch, new_token_id, n_cur, { 0 }, true);
434+
common_batch_clear(*batch);
435+
common_batch_add(*batch, new_token_id, n_cur, { 0 }, true);
436436

437437
env->CallVoidMethod(intvar_ncur, la_int_var_inc);
438438

0 commit comments

Comments
 (0)