mirror of
https://github.com/ggerganov/llama.cpp.git
synced 2025-01-14 22:38:58 +01:00
swift : fix build
ggml-ci
This commit is contained in:
parent
fff1e8a54a
commit
608f449880
@ -79,7 +79,7 @@ batch.n_tokens = Int32(tokens.count)
|
|||||||
|
|
||||||
for (i, token) in tokens.enumerated() {
|
for (i, token) in tokens.enumerated() {
|
||||||
batch.token[i] = token
|
batch.token[i] = token
|
||||||
batch.pos[i] = Float(i)
|
batch.pos[i] = llama_pos(i)
|
||||||
batch.n_seq_id[i] = 1
|
batch.n_seq_id[i] = 1
|
||||||
// batch.seq_id[i][0] = 0
|
// batch.seq_id[i][0] = 0
|
||||||
// TODO: is this the proper way to do this?
|
// 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 {
|
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 {
|
if n_parallel > 1 {
|
||||||
@ -173,7 +173,7 @@ while n_cur <= n_len {
|
|||||||
|
|
||||||
// push this new token for next evaluation
|
// push this new token for next evaluation
|
||||||
batch.token[Int(batch.n_tokens)] = new_token_id
|
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
|
batch.n_seq_id[Int(batch.n_tokens)] = 1
|
||||||
if let seq_id = batch.seq_id[Int(batch.n_tokens)] {
|
if let seq_id = batch.seq_id[Int(batch.n_tokens)] {
|
||||||
seq_id[0] = Int32(i)
|
seq_id[0] = Int32(i)
|
||||||
|
@ -129,7 +129,7 @@ actor LlamaContext {
|
|||||||
|
|
||||||
for i1 in 0..<tokens_list.count {
|
for i1 in 0..<tokens_list.count {
|
||||||
let i = Int(i1)
|
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
|
batch.logits[Int(batch.n_tokens) - 1] = 1 // true
|
||||||
|
|
||||||
@ -183,7 +183,7 @@ actor LlamaContext {
|
|||||||
// tokens_list.append(new_token_id)
|
// tokens_list.append(new_token_id)
|
||||||
|
|
||||||
llama_batch_clear(&batch)
|
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_decode += 1
|
||||||
n_cur += 1
|
n_cur += 1
|
||||||
@ -210,7 +210,7 @@ actor LlamaContext {
|
|||||||
let n_tokens = pp
|
let n_tokens = pp
|
||||||
|
|
||||||
for i in 0..<n_tokens {
|
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
|
batch.logits[Int(batch.n_tokens) - 1] = 1 // true
|
||||||
|
|
||||||
@ -234,7 +234,7 @@ actor LlamaContext {
|
|||||||
llama_batch_clear(&batch)
|
llama_batch_clear(&batch)
|
||||||
|
|
||||||
for j in 0..<pl {
|
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 {
|
if llama_decode(context, batch) != 0 {
|
||||||
|
Loading…
Reference in New Issue
Block a user