Initialize a ggml context, which will be freed automatically when the pointer is garbage collected.
(mem_size: int, mem_buffer: ffi.CData = ffi.NULL, no_alloc: bool = False)
| 6 | import numpy as np |
| 7 | |
| 8 | def init(mem_size: int, mem_buffer: ffi.CData = ffi.NULL, no_alloc: bool = False) -> ffi.CData: |
| 9 | """ |
| 10 | Initialize a ggml context, which will be freed automatically when the pointer is garbage collected. |
| 11 | """ |
| 12 | params = ffi.new('struct ggml_init_params*') |
| 13 | params.mem_size = mem_size |
| 14 | params.mem_buffer = mem_buffer |
| 15 | params.no_alloc = no_alloc |
| 16 | return ffi.gc(lib.ggml_init(params[0]), lib.ggml_free) |
| 17 | |
| 18 | TensorLike = Union[ffi.CData, np.ndarray] |
| 19 |
no outgoing calls