Skip to content

Commit

Permalink
fix: Add log callback
Browse files Browse the repository at this point in the history
  • Loading branch information
abetlen committed Feb 9, 2024
1 parent 2c8ee77 commit af8f9e1
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions tests/test_ggml_backends.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,13 @@
import numpy as np

def test_ggml_backend():
@ggml.ggml_log_callback
def ggml_log_callback_default(level: ctypes.c_int, msg: ctypes.c_char_p, user: ctypes.c_void_p):
print(bytes(msg).decode('utf-8'), end="", flush=True)

def get_backend():
if ggml.ggml_cpu_has_metal():
ggml.ggml_backend_metal_log_set_callback(ggml_log_callback_default, ctypes.c_void_p(0))
backend = ggml.ggml_backend_metal_init()
if backend is not None:
ggml.ggml_backend_metal_set_n_cb(backend, 1)
Expand Down

0 comments on commit af8f9e1

Please sign in to comment.