From d10ce627147b194f1bb1f143b99e345ab56a1ed4 Mon Sep 17 00:00:00 2001 From: Andrei Betlen Date: Thu, 20 Jul 2023 18:51:53 -0400 Subject: [PATCH] Revert ctypes argtype change --- llama_cpp/llama_cpp.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/llama_cpp/llama_cpp.py b/llama_cpp/llama_cpp.py index 345d1a4..cff2fb1 100644 --- a/llama_cpp/llama_cpp.py +++ b/llama_cpp/llama_cpp.py @@ -175,6 +175,7 @@ llama_progress_callback = ctypes.CFUNCTYPE(None, c_float, c_void_p) # // context pointer passed to the progress callback # void * progress_callback_user_data; + # // Keep the booleans together to avoid misalignment during copy-by-value. # bool low_vram; // if true, reduce VRAM usage at the cost of performance # bool f16_kv; // use fp16 for KV cache @@ -748,7 +749,12 @@ def llama_get_vocab( return _lib.llama_get_vocab(ctx, strings, scores, capacity) -_lib.llama_get_vocab.argtypes = [llama_context_p, Array[c_char_p], Array[c_float], c_int] +_lib.llama_get_vocab.argtypes = [ + llama_context_p, + POINTER(c_char_p), + POINTER(c_float), + c_int, +] _lib.llama_get_vocab.restype = c_int @@ -766,6 +772,15 @@ def llama_get_vocab_from_model( return _lib.llama_get_vocab_from_model(model, strings, scores, capacity) +_lib.llama_get_vocab_from_model.argtypes = [ + llama_model_p, + POINTER(c_char_p), + POINTER(c_float), + c_int, +] +_lib.llama_get_vocab_from_model.restype = c_int + + # Token logits obtained from the last call to llama_eval() # The logits for the last token are stored in the last row # Can be mutated in order to change the probabilities of the next token