swift : fix build

ggml-ci
This commit is contained in:
Georgi Gerganov 2024-02-23 19:02:09 +02:00
parent fff1e8a54a
commit 608f449880
No known key found for this signature in database
GPG Key ID: 449E073F9DC10735
2 changed files with 7 additions and 7 deletions

View File

@ -79,7 +79,7 @@ batch.n_tokens = Int32(tokens.count)
for (i, token) in tokens.enumerated() {
batch.token[i] = token
batch.pos[i] = Float(i)
batch.pos[i] = llama_pos(i)
batch.n_seq_id[i] = 1
// batch.seq_id[i][0] = 0
// TODO: is this the proper way to do this?
@ -98,7 +98,7 @@ if llama_decode(context, batch) != 0 {
}
for i in 1 ..< n_parallel {
llama_kv_cache_seq_cp(context, 0, Int32(i), 0, Float(batch.n_tokens))
llama_kv_cache_seq_cp(context, 0, Int32(i), 0, llama_pos(batch.n_tokens))
}
if n_parallel > 1 {
@ -173,7 +173,7 @@ while n_cur <= n_len {
// push this new token for next evaluation
batch.token[Int(batch.n_tokens)] = new_token_id
batch.pos[Int(batch.n_tokens)] = Float(n_cur)
batch.pos[Int(batch.n_tokens)] = llama_pos(n_cur)
batch.n_seq_id[Int(batch.n_tokens)] = 1
if let seq_id = batch.seq_id[Int(batch.n_tokens)] {
seq_id[0] = Int32(i)

View File

@ -129,7 +129,7 @@ actor LlamaContext {
for i1 in 0..<tokens_list.count {
let i = Int(i1)
llama_batch_add(&batch, tokens_list[i], Int32(i), [0], false)
llama_batch_add(&batch, tokens_list[i], llama_pos(i), [0], false)
}
batch.logits[Int(batch.n_tokens) - 1] = 1 // true
@ -183,7 +183,7 @@ actor LlamaContext {
// tokens_list.append(new_token_id)
llama_batch_clear(&batch)
llama_batch_add(&batch, new_token_id, n_cur, [0], true)
llama_batch_add(&batch, new_token_id, llama_pos(n_cur), [0], true)
n_decode += 1
n_cur += 1
@ -210,7 +210,7 @@ actor LlamaContext {
let n_tokens = pp
for i in 0..<n_tokens {
llama_batch_add(&batch, 0, Int32(i), [0], false)
llama_batch_add(&batch, 0, llama_pos(i), [0], false)
}
batch.logits[Int(batch.n_tokens) - 1] = 1 // true
@ -234,7 +234,7 @@ actor LlamaContext {
llama_batch_clear(&batch)
for j in 0..<pl {
llama_batch_add(&batch, 0, Int32(i), [Int32(j)], true)
llama_batch_add(&batch, 0, llama_pos(i), [Int32(j)], true)
}
if llama_decode(context, batch) != 0 {