File tree 1 file changed +5
-3
lines changed
examples/batched.swift/Sources
1 file changed +5
-3
lines changed Original file line number Diff line number Diff line change @@ -69,7 +69,7 @@ for id: llama_token in tokens {
69
69
70
70
print ( " \n " )
71
71
72
- var batch = llama_batch_init ( max ( Int32 ( tokens. count) , Int32 ( n_parallel) ) , 0 )
72
+ var batch = llama_batch_init ( max ( Int32 ( tokens. count) , Int32 ( n_parallel) ) , 0 , 1 )
73
73
defer {
74
74
llama_batch_free ( batch)
75
75
}
@@ -80,7 +80,8 @@ batch.n_tokens = Int32(tokens.count)
80
80
for (i, token) in tokens. enumerated ( ) {
81
81
batch. token [ i] = token
82
82
batch. pos [ i] = Int32 ( i)
83
- batch. seq_id [ i] = 0
83
+ batch. n_seq_id [ i] = 1
84
+ batch. seq_id [ i] [ 0 ] = 0
84
85
batch. logits [ i] = 0
85
86
}
86
87
@@ -169,7 +170,8 @@ while n_cur <= n_len {
169
170
// push this new token for next evaluation
170
171
batch. token [ Int ( batch. n_tokens) ] = new_token_id
171
172
batch. pos [ Int ( batch. n_tokens) ] = n_cur
172
- batch. seq_id [ Int ( batch. n_tokens) ] = Int32 ( i)
173
+ batch. n_seq_id [ Int ( batch. n_tokens) ] = 1
174
+ batch. seq_id [ Int ( batch. n_tokens) ] [ 0 ] = Int32 ( i)
173
175
batch. logits [ Int ( batch. n_tokens) ] = 1
174
176
175
177
i_batch [ i] = batch. n_tokens
You can’t perform that action at this time.
0 commit comments