Class: LlamaCpp::LlamaBatch
- Inherits:
-
Object
- Object
- LlamaCpp::LlamaBatch
- Defined in:
- ext/llama_cpp/llama_cpp.c,
ext/llama_cpp/llama_cpp.c
Overview
“struct llama_batch” wrapper class
Instance Method Summary collapse
Instance Method Details
#n_tokens ⇒ Integer
287 288 289 290 |
# File 'ext/llama_cpp/llama_cpp.c', line 287
static VALUE llama_batch_get_n_tokens(VALUE self) {
llama_batch* data = get_llama_batch(self);
return INT2NUM(data->n_tokens);
}
|
#token ⇒ Array<Integer>
292 293 294 295 296 297 298 299 300 |
# File 'ext/llama_cpp/llama_cpp.c', line 292
static VALUE llama_batch_get_token(VALUE self) {
llama_batch* data = get_llama_batch(self);
int32_t n_tokens = data->n_tokens;
VALUE token = rb_ary_new2(n_tokens);
for (int32_t i = 0; i < n_tokens; i++) {
rb_ary_store(token, i, INT2NUM(data->token[i]));
}
return token;
}
|