Skip to content

Commit

Permalink
Fix "'NoneType' object has no attribute 'cast'" error when model is f…
Browse files Browse the repository at this point in the history
…reed (#117)
  • Loading branch information
mczk77 committed Jul 19, 2023
1 parent 25ee75e commit f685aa4
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion rwkv/rwkv_cpp_shared_library.py
Expand Up @@ -90,6 +90,8 @@ def __init__(self, shared_library_path: str):
self.library.rwkv_get_system_info_string.argtypes = []
self.library.rwkv_get_system_info_string.restype = ctypes.c_char_p

self.nullptr = ctypes.cast(0, ctypes.c_void_p)

def rwkv_init_from_file(self, model_file_path: str, thread_count: int) -> RWKVContext:
"""
Loads the model from a file and prepares it for inference.
Expand Down Expand Up @@ -232,7 +234,7 @@ def rwkv_free(self, ctx: RWKVContext) -> None:

self.library.rwkv_free(ctx.ptr)

ctx.ptr = ctypes.cast(0, ctypes.c_void_p)
ctx.ptr = self.nullptr

def rwkv_quantize_model_file(self, model_file_path_in: str, model_file_path_out: str, format_name: str) -> None:
"""
Expand Down

0 comments on commit f685aa4

Please sign in to comment.