Skip to content

Commit 14a8a06

Browse files
committed
squash! llama : rename batch.logits to batch.output
Update examples/batched.swift/Sources/main.swift, examples/llama.android/llama/src/main/cpp/llama-android.cpp, examples/llama.swiftui/llama.cpp.swift/LibLlama.swift to use the new batch.output field instead of batch.logits.
1 parent bbbcaae commit 14a8a06

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

examples/batched.swift/Sources/main.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,11 @@ for (i, token) in tokens.enumerated() {
9999
if let seq_id = batch.seq_id[i] {
100100
seq_id[0] = 0
101101
}
102-
batch.logits[i] = 0
102+
batch.output[i] = 0
103103
}
104104

105105
// llama_decode will output logits only for the last token of the prompt
106-
batch.logits[Int(batch.n_tokens) - 1] = 1
106+
batch.output[Int(batch.n_tokens) - 1] = 1
107107

108108
if llama_decode(context, batch) != 0 {
109109
print("llama_decode() failed")
@@ -166,7 +166,7 @@ while n_cur <= n_len {
166166
if let seq_id = batch.seq_id[Int(batch.n_tokens)] {
167167
seq_id[0] = Int32(i)
168168
}
169-
batch.logits[Int(batch.n_tokens)] = 1
169+
batch.output[Int(batch.n_tokens)] = 1
170170

171171
i_batch[i] = batch.n_tokens
172172

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ Java_android_llama_cpp_LLamaAndroid_bench_1model(
193193
common_batch_add(*batch, 0, i, { 0 }, false);
194194
}
195195

196-
batch->logits[batch->n_tokens - 1] = true;
196+
batch->output[batch->n_tokens - 1] = true;
197197
llama_kv_cache_clear(context);
198198

199199
const auto t_pp_start = ggml_time_us();
@@ -297,7 +297,7 @@ Java_android_llama_cpp_LLamaAndroid_new_1batch(JNIEnv *, jobject, jint n_tokens,
297297
for (int i = 0; i < n_tokens; ++i) {
298298
batch->seq_id[i] = (llama_seq_id *) malloc(sizeof(llama_seq_id) * n_seq_max);
299299
}
300-
batch->logits = (int8_t *) malloc(sizeof(int8_t) * n_tokens);
300+
batch->output = (int8_t *) malloc(sizeof(int8_t) * n_tokens);
301301

302302
return reinterpret_cast<jlong>(batch);
303303
}
@@ -377,7 +377,7 @@ Java_android_llama_cpp_LLamaAndroid_completion_1init(
377377
}
378378

379379
// llama_decode will output logits only for the last token of the prompt
380-
batch->logits[batch->n_tokens - 1] = true;
380+
batch->output[batch->n_tokens - 1] = true;
381381

382382
if (llama_decode(context, *batch) != 0) {
383383
LOGe("llama_decode() failed");

examples/llama.swiftui/llama.cpp.swift/LibLlama.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ actor LlamaContext {
137137
let i = Int(i1)
138138
llama_batch_add(&batch, tokens_list[i], Int32(i), [0], false)
139139
}
140-
batch.logits[Int(batch.n_tokens) - 1] = 1 // true
140+
batch.output[Int(batch.n_tokens) - 1] = 1 // true
141141

142142
if llama_decode(context, batch) != 0 {
143143
print("llama_decode() failed")
@@ -206,7 +206,7 @@ actor LlamaContext {
206206
for i in 0..<n_tokens {
207207
llama_batch_add(&batch, 0, Int32(i), [0], false)
208208
}
209-
batch.logits[Int(batch.n_tokens) - 1] = 1 // true
209+
batch.output[Int(batch.n_tokens) - 1] = 1 // true
210210

211211
llama_kv_cache_clear(context)
212212

0 commit comments

Comments
 (0)