diff --git a/lib/src/llama.dart b/lib/src/llama.dart index e045caf..9ed68dc 100644 --- a/lib/src/llama.dart +++ b/lib/src/llama.dart @@ -1,5 +1,6 @@ import 'dart:convert'; import 'dart:ffi'; +import 'dart:io'; import 'dart:math'; import 'package:ffi/ffi.dart'; @@ -38,7 +39,7 @@ class Llama { int cursor = 0; /// set llama.cpp library path - static String? libraryPath; + static String? libraryPath = Platform.isAndroid ? "libllama.so" : null; /// Getter for the Llama library. /// @@ -76,7 +77,7 @@ class Llama { : modelParams = modelParams ?? ModelParams(), contextParams = contextParams ?? ContextParams(), samplingParams = samplingParams ?? SamplingParams() { - lib.llama_backend_init(false); + lib.llama_backend_init(); llama_model_params modelParams = this.modelParams.get(); Pointer char = modelPath.toNativeUtf8().cast(); diff --git a/lib/src/llama_cpp.dart b/lib/src/llama_cpp.dart index d92c324..0c008c1 100644 --- a/lib/src/llama_cpp.dart +++ b/lib/src/llama_cpp.dart @@ -20,6 +20,72 @@ class llama_cpp { lookup) : _lookup = lookup; + double ggml_fp16_to_fp32( + int x, + ) { + return _ggml_fp16_to_fp32( + x, + ); + } + + late final _ggml_fp16_to_fp32Ptr = + _lookup>( + 'ggml_fp16_to_fp32'); + late final _ggml_fp16_to_fp32 = + _ggml_fp16_to_fp32Ptr.asFunction(); + + int ggml_fp32_to_fp16( + double x, + ) { + return _ggml_fp32_to_fp16( + x, + ); + } + + late final _ggml_fp32_to_fp16Ptr = + _lookup>( + 'ggml_fp32_to_fp16'); + late final _ggml_fp32_to_fp16 = + _ggml_fp32_to_fp16Ptr.asFunction(); + + void ggml_fp16_to_fp32_row( + ffi.Pointer x, + ffi.Pointer y, + int n, + ) { + return _ggml_fp16_to_fp32_row( + x, + y, + n, + ); + } + + late final _ggml_fp16_to_fp32_rowPtr = _lookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, ffi.Pointer, + ffi.Int)>>('ggml_fp16_to_fp32_row'); + late final _ggml_fp16_to_fp32_row = _ggml_fp16_to_fp32_rowPtr.asFunction< + void Function(ffi.Pointer, ffi.Pointer, int)>(); + + void ggml_fp32_to_fp16_row( + ffi.Pointer x, + ffi.Pointer y, + int n, + ) { + return _ggml_fp32_to_fp16_row( + x, + y, + n, + ); + } + + late final _ggml_fp32_to_fp16_rowPtr = _lookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, ffi.Pointer, + ffi.Int)>>('ggml_fp32_to_fp16_row'); + late final _ggml_fp32_to_fp16_row = _ggml_fp32_to_fp16_rowPtr.asFunction< + void Function(ffi.Pointer, ffi.Pointer, int)>(); + late final ffi.Pointer _GGML_OBJECT_SIZE = _lookup('GGML_OBJECT_SIZE'); @@ -84,13 +150,19 @@ class llama_cpp { late final _ggml_print_backtrace = _ggml_print_backtracePtr.asFunction(); - void ggml_numa_init() { - return _ggml_numa_init(); + void ggml_numa_init( + int numa, + ) { + return _ggml_numa_init( + numa, + ); } late final _ggml_numa_initPtr = - _lookup>('ggml_numa_init'); - late final _ggml_numa_init = _ggml_numa_initPtr.asFunction(); + _lookup>( + 'ggml_numa_init'); + late final _ggml_numa_init = + _ggml_numa_initPtr.asFunction(); bool ggml_is_numa() { return _ggml_is_numa(); @@ -3388,13 +3460,17 @@ class llama_cpp { ffi.Pointer ctx, ffi.Pointer a, ffi.Pointer mask, + ffi.Pointer pos, double scale, + double max_bias, ) { return _ggml_soft_max_ext( ctx, a, mask, + pos, scale, + max_bias, ); } @@ -3404,10 +3480,17 @@ class llama_cpp { ffi.Pointer, ffi.Pointer, ffi.Pointer, + ffi.Pointer, + ffi.Float, ffi.Float)>>('ggml_soft_max_ext'); late final _ggml_soft_max_ext = _ggml_soft_max_extPtr.asFunction< - ffi.Pointer Function(ffi.Pointer, - ffi.Pointer, ffi.Pointer, double)>(); + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + double, + double)>(); ffi.Pointer ggml_soft_max_back( ffi.Pointer ctx, @@ -3841,6 +3924,7 @@ class llama_cpp { int d0, int d1, bool is_2D, + int dst_type, ) { return _ggml_im2col( ctx, @@ -3853,6 +3937,7 @@ class llama_cpp { d0, d1, is_2D, + dst_type, ); } @@ -3868,7 +3953,8 @@ class llama_cpp { ffi.Int, ffi.Int, ffi.Int, - ffi.Bool)>>('ggml_im2col'); + ffi.Bool, + ffi.Int32)>>('ggml_im2col'); late final _ggml_im2col = _ggml_im2colPtr.asFunction< ffi.Pointer Function( ffi.Pointer, @@ -3880,7 +3966,8 @@ class llama_cpp { int, int, int, - bool)>(); + bool, + int)>(); ffi.Pointer ggml_conv_depthwise_2d( ffi.Pointer ctx, @@ -5619,6 +5706,34 @@ class llama_cpp { ggml_opt_callback, ffi.Pointer)>(); + void ggml_set_input( + ffi.Pointer tensor, + ) { + return _ggml_set_input( + tensor, + ); + } + + late final _ggml_set_inputPtr = + _lookup)>>( + 'ggml_set_input'); + late final _ggml_set_input = + _ggml_set_inputPtr.asFunction)>(); + + void ggml_set_output( + ffi.Pointer tensor, + ) { + return _ggml_set_output( + tensor, + ); + } + + late final _ggml_set_outputPtr = + _lookup)>>( + 'ggml_set_output'); + late final _ggml_set_output = + _ggml_set_outputPtr.asFunction)>(); + void ggml_quantize_init( int type, ) { @@ -7044,6 +7159,15 @@ class llama_cpp { late final _ggml_cpu_has_vulkan = _ggml_cpu_has_vulkanPtr.asFunction(); + int ggml_cpu_has_kompute() { + return _ggml_cpu_has_kompute(); + } + + late final _ggml_cpu_has_komputePtr = + _lookup>('ggml_cpu_has_kompute'); + late final _ggml_cpu_has_kompute = + _ggml_cpu_has_komputePtr.asFunction(); + int ggml_cpu_has_gpublas() { return _ggml_cpu_has_gpublas(); } @@ -7089,6 +7213,16 @@ class llama_cpp { late final _ggml_cpu_has_vsx = _ggml_cpu_has_vsxPtr.asFunction(); + int ggml_cpu_has_matmul_int8() { + return _ggml_cpu_has_matmul_int8(); + } + + late final _ggml_cpu_has_matmul_int8Ptr = + _lookup>( + 'ggml_cpu_has_matmul_int8'); + late final _ggml_cpu_has_matmul_int8 = + _ggml_cpu_has_matmul_int8Ptr.asFunction(); + ggml_type_traits_t ggml_internal_get_type_traits( int type, ) { @@ -7103,2067 +7237,1968 @@ class llama_cpp { late final _ggml_internal_get_type_traits = _ggml_internal_get_type_traitsPtr .asFunction(); - ggml_allocr_t ggml_allocr_new( - ffi.Pointer data, - int size, - int alignment, + ggml_tallocr_t ggml_tallocr_new( + ggml_backend_buffer_t buffer, ) { - return _ggml_allocr_new( - data, - size, - alignment, + return _ggml_tallocr_new( + buffer, ); } - late final _ggml_allocr_newPtr = _lookup< - ffi.NativeFunction< - ggml_allocr_t Function( - ffi.Pointer, ffi.Size, ffi.Size)>>('ggml_allocr_new'); - late final _ggml_allocr_new = _ggml_allocr_newPtr - .asFunction, int, int)>(); + late final _ggml_tallocr_newPtr = _lookup< + ffi.NativeFunction>( + 'ggml_tallocr_new'); + late final _ggml_tallocr_new = _ggml_tallocr_newPtr + .asFunction(); - ggml_allocr_t ggml_allocr_new_measure( - int alignment, + void ggml_tallocr_free( + ggml_tallocr_t talloc, ) { - return _ggml_allocr_new_measure( - alignment, + return _ggml_tallocr_free( + talloc, ); } - late final _ggml_allocr_new_measurePtr = - _lookup>( - 'ggml_allocr_new_measure'); - late final _ggml_allocr_new_measure = - _ggml_allocr_new_measurePtr.asFunction(); + late final _ggml_tallocr_freePtr = + _lookup>( + 'ggml_tallocr_free'); + late final _ggml_tallocr_free = + _ggml_tallocr_freePtr.asFunction(); - ggml_allocr_t ggml_allocr_new_from_buffer( - ffi.Pointer buffer, + void ggml_tallocr_alloc( + ggml_tallocr_t talloc, + ffi.Pointer tensor, ) { - return _ggml_allocr_new_from_buffer( - buffer, + return _ggml_tallocr_alloc( + talloc, + tensor, ); } - late final _ggml_allocr_new_from_bufferPtr = _lookup< - ffi.NativeFunction< - ggml_allocr_t Function(ffi.Pointer)>>( - 'ggml_allocr_new_from_buffer'); - late final _ggml_allocr_new_from_buffer = _ggml_allocr_new_from_bufferPtr - .asFunction)>(); + late final _ggml_tallocr_allocPtr = _lookup< + ffi.NativeFunction< + ffi.Void Function( + ggml_tallocr_t, ffi.Pointer)>>('ggml_tallocr_alloc'); + late final _ggml_tallocr_alloc = _ggml_tallocr_allocPtr + .asFunction)>(); - ggml_allocr_t ggml_allocr_new_from_backend( - ffi.Pointer backend, - int size, + ggml_gallocr_t ggml_gallocr_new( + ggml_backend_buffer_type_t buft, ) { - return _ggml_allocr_new_from_backend( - backend, - size, + return _ggml_gallocr_new( + buft, ); } - late final _ggml_allocr_new_from_backendPtr = _lookup< - ffi.NativeFunction< - ggml_allocr_t Function(ffi.Pointer, - ffi.Size)>>('ggml_allocr_new_from_backend'); - late final _ggml_allocr_new_from_backend = _ggml_allocr_new_from_backendPtr - .asFunction, int)>(); + late final _ggml_gallocr_newPtr = _lookup< + ffi + .NativeFunction>( + 'ggml_gallocr_new'); + late final _ggml_gallocr_new = _ggml_gallocr_newPtr + .asFunction(); - ggml_allocr_t ggml_allocr_new_measure_from_backend( - ffi.Pointer backend, + ggml_gallocr_t ggml_gallocr_new_n( + ffi.Pointer bufts, + int n_bufs, ) { - return _ggml_allocr_new_measure_from_backend( - backend, + return _ggml_gallocr_new_n( + bufts, + n_bufs, ); } - late final _ggml_allocr_new_measure_from_backendPtr = _lookup< - ffi - .NativeFunction)>>( - 'ggml_allocr_new_measure_from_backend'); - late final _ggml_allocr_new_measure_from_backend = - _ggml_allocr_new_measure_from_backendPtr - .asFunction)>(); + late final _ggml_gallocr_new_nPtr = _lookup< + ffi.NativeFunction< + ggml_gallocr_t Function(ffi.Pointer, + ffi.Int)>>('ggml_gallocr_new_n'); + late final _ggml_gallocr_new_n = _ggml_gallocr_new_nPtr.asFunction< + ggml_gallocr_t Function(ffi.Pointer, int)>(); - ffi.Pointer ggml_allocr_get_buffer( - ggml_allocr_t alloc, + void ggml_gallocr_free( + ggml_gallocr_t galloc, ) { - return _ggml_allocr_get_buffer( - alloc, + return _ggml_gallocr_free( + galloc, ); } - late final _ggml_allocr_get_bufferPtr = _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - ggml_allocr_t)>>('ggml_allocr_get_buffer'); - late final _ggml_allocr_get_buffer = _ggml_allocr_get_bufferPtr - .asFunction Function(ggml_allocr_t)>(); + late final _ggml_gallocr_freePtr = + _lookup>( + 'ggml_gallocr_free'); + late final _ggml_gallocr_free = + _ggml_gallocr_freePtr.asFunction(); - void ggml_allocr_set_parse_seq( - ggml_allocr_t alloc, - ffi.Pointer list, - int n, + bool ggml_gallocr_reserve( + ggml_gallocr_t galloc, + ffi.Pointer graph, ) { - return _ggml_allocr_set_parse_seq( - alloc, - list, - n, + return _ggml_gallocr_reserve( + galloc, + graph, ); } - late final _ggml_allocr_set_parse_seqPtr = _lookup< + late final _ggml_gallocr_reservePtr = _lookup< ffi.NativeFunction< - ffi.Void Function(ggml_allocr_t, ffi.Pointer, - ffi.Int)>>('ggml_allocr_set_parse_seq'); - late final _ggml_allocr_set_parse_seq = _ggml_allocr_set_parse_seqPtr - .asFunction, int)>(); + ffi.Bool Function(ggml_gallocr_t, + ffi.Pointer)>>('ggml_gallocr_reserve'); + late final _ggml_gallocr_reserve = _ggml_gallocr_reservePtr + .asFunction)>(); - void ggml_allocr_free( - ggml_allocr_t alloc, + bool ggml_gallocr_reserve_n( + ggml_gallocr_t galloc, + ffi.Pointer graph, + ffi.Pointer node_buffer_ids, ) { - return _ggml_allocr_free( - alloc, + return _ggml_gallocr_reserve_n( + galloc, + graph, + node_buffer_ids, ); } - late final _ggml_allocr_freePtr = - _lookup>( - 'ggml_allocr_free'); - late final _ggml_allocr_free = - _ggml_allocr_freePtr.asFunction(); + late final _ggml_gallocr_reserve_nPtr = _lookup< + ffi.NativeFunction< + ffi.Bool Function(ggml_gallocr_t, ffi.Pointer, + ffi.Pointer)>>('ggml_gallocr_reserve_n'); + late final _ggml_gallocr_reserve_n = _ggml_gallocr_reserve_nPtr.asFunction< + bool Function( + ggml_gallocr_t, ffi.Pointer, ffi.Pointer)>(); - bool ggml_allocr_is_measure( - ggml_allocr_t alloc, + bool ggml_gallocr_alloc_graph( + ggml_gallocr_t galloc, + ffi.Pointer graph, ) { - return _ggml_allocr_is_measure( - alloc, + return _ggml_gallocr_alloc_graph( + galloc, + graph, ); } - late final _ggml_allocr_is_measurePtr = - _lookup>( - 'ggml_allocr_is_measure'); - late final _ggml_allocr_is_measure = - _ggml_allocr_is_measurePtr.asFunction(); + late final _ggml_gallocr_alloc_graphPtr = _lookup< + ffi.NativeFunction< + ffi.Bool Function(ggml_gallocr_t, + ffi.Pointer)>>('ggml_gallocr_alloc_graph'); + late final _ggml_gallocr_alloc_graph = _ggml_gallocr_alloc_graphPtr + .asFunction)>(); - void ggml_allocr_reset( - ggml_allocr_t alloc, + int ggml_gallocr_get_buffer_size( + ggml_gallocr_t galloc, + int buffer_id, ) { - return _ggml_allocr_reset( - alloc, + return _ggml_gallocr_get_buffer_size( + galloc, + buffer_id, ); } - late final _ggml_allocr_resetPtr = - _lookup>( - 'ggml_allocr_reset'); - late final _ggml_allocr_reset = - _ggml_allocr_resetPtr.asFunction(); + late final _ggml_gallocr_get_buffer_sizePtr = + _lookup>( + 'ggml_gallocr_get_buffer_size'); + late final _ggml_gallocr_get_buffer_size = _ggml_gallocr_get_buffer_sizePtr + .asFunction(); - void ggml_allocr_alloc( - ggml_allocr_t alloc, - ffi.Pointer tensor, + ffi.Pointer ggml_backend_alloc_ctx_tensors_from_buft( + ffi.Pointer ctx, + ggml_backend_buffer_type_t buft, ) { - return _ggml_allocr_alloc( - alloc, - tensor, + return _ggml_backend_alloc_ctx_tensors_from_buft( + ctx, + buft, ); } - late final _ggml_allocr_allocPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function( - ggml_allocr_t, ffi.Pointer)>>('ggml_allocr_alloc'); - late final _ggml_allocr_alloc = _ggml_allocr_allocPtr - .asFunction)>(); + late final _ggml_backend_alloc_ctx_tensors_from_buftPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, ggml_backend_buffer_type_t)>>( + 'ggml_backend_alloc_ctx_tensors_from_buft'); + late final _ggml_backend_alloc_ctx_tensors_from_buft = + _ggml_backend_alloc_ctx_tensors_from_buftPtr.asFunction< + ffi.Pointer Function( + ffi.Pointer, ggml_backend_buffer_type_t)>(); - int ggml_allocr_max_size( - ggml_allocr_t alloc, + ffi.Pointer ggml_backend_alloc_ctx_tensors( + ffi.Pointer ctx, + ggml_backend_t backend, ) { - return _ggml_allocr_max_size( - alloc, + return _ggml_backend_alloc_ctx_tensors( + ctx, + backend, ); } - late final _ggml_allocr_max_sizePtr = - _lookup>( - 'ggml_allocr_max_size'); - late final _ggml_allocr_max_size = - _ggml_allocr_max_sizePtr.asFunction(); + late final _ggml_backend_alloc_ctx_tensorsPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer, + ggml_backend_t)>>('ggml_backend_alloc_ctx_tensors'); + late final _ggml_backend_alloc_ctx_tensors = + _ggml_backend_alloc_ctx_tensorsPtr.asFunction< + ffi.Pointer Function( + ffi.Pointer, ggml_backend_t)>(); - int ggml_allocr_alloc_graph( - ggml_allocr_t alloc, - ffi.Pointer graph, + ffi.Pointer ggml_backend_buft_name( + ggml_backend_buffer_type_t buft, ) { - return _ggml_allocr_alloc_graph( - alloc, - graph, + return _ggml_backend_buft_name( + buft, ); } - late final _ggml_allocr_alloc_graphPtr = _lookup< + late final _ggml_backend_buft_namePtr = _lookup< ffi.NativeFunction< - ffi.Size Function(ggml_allocr_t, - ffi.Pointer)>>('ggml_allocr_alloc_graph'); - late final _ggml_allocr_alloc_graph = _ggml_allocr_alloc_graphPtr - .asFunction)>(); + ffi.Pointer Function( + ggml_backend_buffer_type_t)>>('ggml_backend_buft_name'); + late final _ggml_backend_buft_name = _ggml_backend_buft_namePtr + .asFunction Function(ggml_backend_buffer_type_t)>(); - ggml_tallocr_t ggml_tallocr_new( - ffi.Pointer data, + ggml_backend_buffer_t ggml_backend_buft_alloc_buffer( + ggml_backend_buffer_type_t buft, int size, - int alignment, ) { - return _ggml_tallocr_new( - data, + return _ggml_backend_buft_alloc_buffer( + buft, size, - alignment, ); } - late final _ggml_tallocr_newPtr = _lookup< + late final _ggml_backend_buft_alloc_bufferPtr = _lookup< ffi.NativeFunction< - ggml_tallocr_t Function( - ffi.Pointer, ffi.Size, ffi.Size)>>('ggml_tallocr_new'); - late final _ggml_tallocr_new = _ggml_tallocr_newPtr - .asFunction, int, int)>(); + ggml_backend_buffer_t Function(ggml_backend_buffer_type_t, + ffi.Size)>>('ggml_backend_buft_alloc_buffer'); + late final _ggml_backend_buft_alloc_buffer = + _ggml_backend_buft_alloc_bufferPtr.asFunction< + ggml_backend_buffer_t Function(ggml_backend_buffer_type_t, int)>(); - ggml_tallocr_t ggml_tallocr_new_measure( - int alignment, + int ggml_backend_buft_get_alignment( + ggml_backend_buffer_type_t buft, ) { - return _ggml_tallocr_new_measure( - alignment, + return _ggml_backend_buft_get_alignment( + buft, ); } - late final _ggml_tallocr_new_measurePtr = - _lookup>( - 'ggml_tallocr_new_measure'); - late final _ggml_tallocr_new_measure = - _ggml_tallocr_new_measurePtr.asFunction(); + late final _ggml_backend_buft_get_alignmentPtr = _lookup< + ffi.NativeFunction>( + 'ggml_backend_buft_get_alignment'); + late final _ggml_backend_buft_get_alignment = + _ggml_backend_buft_get_alignmentPtr + .asFunction(); - ggml_tallocr_t ggml_tallocr_new_from_buft( - ffi.Pointer buft, - int size, + int ggml_backend_buft_get_max_size( + ggml_backend_buffer_type_t buft, ) { - return _ggml_tallocr_new_from_buft( + return _ggml_backend_buft_get_max_size( buft, - size, ); } - late final _ggml_tallocr_new_from_buftPtr = _lookup< - ffi.NativeFunction< - ggml_tallocr_t Function(ffi.Pointer, - ffi.Size)>>('ggml_tallocr_new_from_buft'); - late final _ggml_tallocr_new_from_buft = - _ggml_tallocr_new_from_buftPtr.asFunction< - ggml_tallocr_t Function( - ffi.Pointer, int)>(); + late final _ggml_backend_buft_get_max_sizePtr = _lookup< + ffi.NativeFunction>( + 'ggml_backend_buft_get_max_size'); + late final _ggml_backend_buft_get_max_size = + _ggml_backend_buft_get_max_sizePtr + .asFunction(); - ggml_tallocr_t ggml_tallocr_new_from_backend( - ffi.Pointer backend, - int size, + int ggml_backend_buft_get_alloc_size( + ggml_backend_buffer_type_t buft, + ffi.Pointer tensor, ) { - return _ggml_tallocr_new_from_backend( - backend, - size, + return _ggml_backend_buft_get_alloc_size( + buft, + tensor, ); } - late final _ggml_tallocr_new_from_backendPtr = _lookup< + late final _ggml_backend_buft_get_alloc_sizePtr = _lookup< ffi.NativeFunction< - ggml_tallocr_t Function(ffi.Pointer, - ffi.Size)>>('ggml_tallocr_new_from_backend'); - late final _ggml_tallocr_new_from_backend = _ggml_tallocr_new_from_backendPtr - .asFunction, int)>(); + ffi.Size Function(ggml_backend_buffer_type_t, + ffi.Pointer)>>('ggml_backend_buft_get_alloc_size'); + late final _ggml_backend_buft_get_alloc_size = + _ggml_backend_buft_get_alloc_sizePtr.asFunction< + int Function(ggml_backend_buffer_type_t, ffi.Pointer)>(); - ggml_tallocr_t ggml_tallocr_new_from_buffer( - ffi.Pointer buffer, + bool ggml_backend_buft_supports_backend( + ggml_backend_buffer_type_t buft, + ggml_backend_t backend, ) { - return _ggml_tallocr_new_from_buffer( - buffer, + return _ggml_backend_buft_supports_backend( + buft, + backend, ); } - late final _ggml_tallocr_new_from_bufferPtr = _lookup< - ffi.NativeFunction< - ggml_tallocr_t Function(ffi.Pointer)>>( - 'ggml_tallocr_new_from_buffer'); - late final _ggml_tallocr_new_from_buffer = _ggml_tallocr_new_from_bufferPtr - .asFunction)>(); + late final _ggml_backend_buft_supports_backendPtr = _lookup< + ffi.NativeFunction< + ffi.Bool Function(ggml_backend_buffer_type_t, + ggml_backend_t)>>('ggml_backend_buft_supports_backend'); + late final _ggml_backend_buft_supports_backend = + _ggml_backend_buft_supports_backendPtr.asFunction< + bool Function(ggml_backend_buffer_type_t, ggml_backend_t)>(); - ggml_tallocr_t ggml_tallocr_new_measure_from_buft( - ffi.Pointer buft, + bool ggml_backend_buft_is_host( + ggml_backend_buffer_type_t buft, ) { - return _ggml_tallocr_new_measure_from_buft( + return _ggml_backend_buft_is_host( buft, ); } - late final _ggml_tallocr_new_measure_from_buftPtr = _lookup< - ffi.NativeFunction< - ggml_tallocr_t Function(ffi.Pointer)>>( - 'ggml_tallocr_new_measure_from_buft'); - late final _ggml_tallocr_new_measure_from_buft = - _ggml_tallocr_new_measure_from_buftPtr.asFunction< - ggml_tallocr_t Function(ffi.Pointer)>(); - - ggml_tallocr_t ggml_tallocr_new_measure_from_backend( - ffi.Pointer backend, - ) { - return _ggml_tallocr_new_measure_from_backend( - backend, - ); - } - - late final _ggml_tallocr_new_measure_from_backendPtr = _lookup< - ffi - .NativeFunction)>>( - 'ggml_tallocr_new_measure_from_backend'); - late final _ggml_tallocr_new_measure_from_backend = - _ggml_tallocr_new_measure_from_backendPtr - .asFunction)>(); + late final _ggml_backend_buft_is_hostPtr = _lookup< + ffi.NativeFunction>( + 'ggml_backend_buft_is_host'); + late final _ggml_backend_buft_is_host = _ggml_backend_buft_is_hostPtr + .asFunction(); - ffi.Pointer ggml_tallocr_get_buffer( - ggml_tallocr_t talloc, + ffi.Pointer ggml_backend_buffer_name( + ggml_backend_buffer_t buffer, ) { - return _ggml_tallocr_get_buffer( - talloc, + return _ggml_backend_buffer_name( + buffer, ); } - late final _ggml_tallocr_get_bufferPtr = _lookup< + late final _ggml_backend_buffer_namePtr = _lookup< ffi.NativeFunction< - ffi.Pointer Function( - ggml_tallocr_t)>>('ggml_tallocr_get_buffer'); - late final _ggml_tallocr_get_buffer = _ggml_tallocr_get_bufferPtr - .asFunction Function(ggml_tallocr_t)>(); + ffi.Pointer Function( + ggml_backend_buffer_t)>>('ggml_backend_buffer_name'); + late final _ggml_backend_buffer_name = _ggml_backend_buffer_namePtr + .asFunction Function(ggml_backend_buffer_t)>(); - void ggml_tallocr_free( - ggml_tallocr_t talloc, + void ggml_backend_buffer_free( + ggml_backend_buffer_t buffer, ) { - return _ggml_tallocr_free( - talloc, + return _ggml_backend_buffer_free( + buffer, ); } - late final _ggml_tallocr_freePtr = - _lookup>( - 'ggml_tallocr_free'); - late final _ggml_tallocr_free = - _ggml_tallocr_freePtr.asFunction(); + late final _ggml_backend_buffer_freePtr = + _lookup>( + 'ggml_backend_buffer_free'); + late final _ggml_backend_buffer_free = _ggml_backend_buffer_freePtr + .asFunction(); - bool ggml_tallocr_is_measure( - ggml_tallocr_t talloc, + ffi.Pointer ggml_backend_buffer_get_base( + ggml_backend_buffer_t buffer, ) { - return _ggml_tallocr_is_measure( - talloc, + return _ggml_backend_buffer_get_base( + buffer, ); } - late final _ggml_tallocr_is_measurePtr = - _lookup>( - 'ggml_tallocr_is_measure'); - late final _ggml_tallocr_is_measure = - _ggml_tallocr_is_measurePtr.asFunction(); + late final _ggml_backend_buffer_get_basePtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ggml_backend_buffer_t)>>('ggml_backend_buffer_get_base'); + late final _ggml_backend_buffer_get_base = _ggml_backend_buffer_get_basePtr + .asFunction Function(ggml_backend_buffer_t)>(); - void ggml_tallocr_reset( - ggml_tallocr_t talloc, + int ggml_backend_buffer_get_size( + ggml_backend_buffer_t buffer, ) { - return _ggml_tallocr_reset( - talloc, + return _ggml_backend_buffer_get_size( + buffer, ); } - late final _ggml_tallocr_resetPtr = - _lookup>( - 'ggml_tallocr_reset'); - late final _ggml_tallocr_reset = - _ggml_tallocr_resetPtr.asFunction(); + late final _ggml_backend_buffer_get_sizePtr = + _lookup>( + 'ggml_backend_buffer_get_size'); + late final _ggml_backend_buffer_get_size = _ggml_backend_buffer_get_sizePtr + .asFunction(); - void ggml_tallocr_alloc( - ggml_tallocr_t talloc, + void ggml_backend_buffer_init_tensor( + ggml_backend_buffer_t buffer, ffi.Pointer tensor, ) { - return _ggml_tallocr_alloc( - talloc, + return _ggml_backend_buffer_init_tensor( + buffer, tensor, ); } - late final _ggml_tallocr_allocPtr = _lookup< + late final _ggml_backend_buffer_init_tensorPtr = _lookup< ffi.NativeFunction< - ffi.Void Function( - ggml_tallocr_t, ffi.Pointer)>>('ggml_tallocr_alloc'); - late final _ggml_tallocr_alloc = _ggml_tallocr_allocPtr - .asFunction)>(); + ffi.Void Function(ggml_backend_buffer_t, + ffi.Pointer)>>('ggml_backend_buffer_init_tensor'); + late final _ggml_backend_buffer_init_tensor = + _ggml_backend_buffer_init_tensorPtr.asFunction< + void Function(ggml_backend_buffer_t, ffi.Pointer)>(); - int ggml_tallocr_max_size( - ggml_tallocr_t talloc, + int ggml_backend_buffer_get_alignment( + ggml_backend_buffer_t buffer, ) { - return _ggml_tallocr_max_size( - talloc, + return _ggml_backend_buffer_get_alignment( + buffer, ); } - late final _ggml_tallocr_max_sizePtr = - _lookup>( - 'ggml_tallocr_max_size'); - late final _ggml_tallocr_max_size = - _ggml_tallocr_max_sizePtr.asFunction(); - - ggml_gallocr_t ggml_gallocr_new() { - return _ggml_gallocr_new(); - } - - late final _ggml_gallocr_newPtr = - _lookup>( - 'ggml_gallocr_new'); - late final _ggml_gallocr_new = - _ggml_gallocr_newPtr.asFunction(); + late final _ggml_backend_buffer_get_alignmentPtr = + _lookup>( + 'ggml_backend_buffer_get_alignment'); + late final _ggml_backend_buffer_get_alignment = + _ggml_backend_buffer_get_alignmentPtr + .asFunction(); - void ggml_gallocr_free( - ggml_gallocr_t galloc, + int ggml_backend_buffer_get_max_size( + ggml_backend_buffer_t buffer, ) { - return _ggml_gallocr_free( - galloc, + return _ggml_backend_buffer_get_max_size( + buffer, ); } - late final _ggml_gallocr_freePtr = - _lookup>( - 'ggml_gallocr_free'); - late final _ggml_gallocr_free = - _ggml_gallocr_freePtr.asFunction(); + late final _ggml_backend_buffer_get_max_sizePtr = + _lookup>( + 'ggml_backend_buffer_get_max_size'); + late final _ggml_backend_buffer_get_max_size = + _ggml_backend_buffer_get_max_sizePtr + .asFunction(); - void ggml_gallocr_set_parse_seq( - ggml_gallocr_t galloc, - ffi.Pointer list, - int n, + int ggml_backend_buffer_get_alloc_size( + ggml_backend_buffer_t buffer, + ffi.Pointer tensor, ) { - return _ggml_gallocr_set_parse_seq( - galloc, - list, - n, + return _ggml_backend_buffer_get_alloc_size( + buffer, + tensor, ); } - late final _ggml_gallocr_set_parse_seqPtr = _lookup< + late final _ggml_backend_buffer_get_alloc_sizePtr = _lookup< ffi.NativeFunction< - ffi.Void Function(ggml_gallocr_t, ffi.Pointer, - ffi.Int)>>('ggml_gallocr_set_parse_seq'); - late final _ggml_gallocr_set_parse_seq = _ggml_gallocr_set_parse_seqPtr - .asFunction, int)>(); + ffi.Size Function(ggml_backend_buffer_t, + ffi.Pointer)>>('ggml_backend_buffer_get_alloc_size'); + late final _ggml_backend_buffer_get_alloc_size = + _ggml_backend_buffer_get_alloc_sizePtr.asFunction< + int Function(ggml_backend_buffer_t, ffi.Pointer)>(); - int ggml_gallocr_alloc_graph( - ggml_gallocr_t galloc, - ggml_tallocr_t talloc, - ffi.Pointer graph, + void ggml_backend_buffer_clear( + ggml_backend_buffer_t buffer, + int value, ) { - return _ggml_gallocr_alloc_graph( - galloc, - talloc, - graph, + return _ggml_backend_buffer_clear( + buffer, + value, ); } - late final _ggml_gallocr_alloc_graphPtr = _lookup< - ffi.NativeFunction< - ffi.Size Function(ggml_gallocr_t, ggml_tallocr_t, - ffi.Pointer)>>('ggml_gallocr_alloc_graph'); - late final _ggml_gallocr_alloc_graph = - _ggml_gallocr_alloc_graphPtr.asFunction< - int Function( - ggml_gallocr_t, ggml_tallocr_t, ffi.Pointer)>(); + late final _ggml_backend_buffer_clearPtr = _lookup< + ffi + .NativeFunction>( + 'ggml_backend_buffer_clear'); + late final _ggml_backend_buffer_clear = _ggml_backend_buffer_clearPtr + .asFunction(); - void ggml_gallocr_alloc_graph_n( - ggml_gallocr_t galloc, - ffi.Pointer graph, - ggml_hash_set hash_set, - ffi.Pointer hash_node_talloc, + bool ggml_backend_buffer_is_host( + ggml_backend_buffer_t buffer, ) { - return _ggml_gallocr_alloc_graph_n( - galloc, - graph, - hash_set, - hash_node_talloc, + return _ggml_backend_buffer_is_host( + buffer, ); } - late final _ggml_gallocr_alloc_graph_nPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function( - ggml_gallocr_t, - ffi.Pointer, - ggml_hash_set, - ffi.Pointer)>>('ggml_gallocr_alloc_graph_n'); - late final _ggml_gallocr_alloc_graph_n = - _ggml_gallocr_alloc_graph_nPtr.asFunction< - void Function(ggml_gallocr_t, ffi.Pointer, ggml_hash_set, - ffi.Pointer)>(); + late final _ggml_backend_buffer_is_hostPtr = + _lookup>( + 'ggml_backend_buffer_is_host'); + late final _ggml_backend_buffer_is_host = _ggml_backend_buffer_is_hostPtr + .asFunction(); - ffi.Pointer ggml_backend_alloc_ctx_tensors_from_buft( - ffi.Pointer ctx, - ffi.Pointer buft, + void ggml_backend_buffer_set_usage( + ggml_backend_buffer_t buffer, + int usage, ) { - return _ggml_backend_alloc_ctx_tensors_from_buft( - ctx, - buft, + return _ggml_backend_buffer_set_usage( + buffer, + usage, ); } - late final _ggml_backend_alloc_ctx_tensors_from_buftPtr = _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer)>>( - 'ggml_backend_alloc_ctx_tensors_from_buft'); - late final _ggml_backend_alloc_ctx_tensors_from_buft = - _ggml_backend_alloc_ctx_tensors_from_buftPtr.asFunction< - ffi.Pointer Function(ffi.Pointer, - ffi.Pointer)>(); + late final _ggml_backend_buffer_set_usagePtr = _lookup< + ffi + .NativeFunction>( + 'ggml_backend_buffer_set_usage'); + late final _ggml_backend_buffer_set_usage = _ggml_backend_buffer_set_usagePtr + .asFunction(); - ffi.Pointer ggml_backend_alloc_ctx_tensors( - ffi.Pointer ctx, - ffi.Pointer backend, + ggml_backend_buffer_type_t ggml_backend_buffer_get_type( + ggml_backend_buffer_t buffer, ) { - return _ggml_backend_alloc_ctx_tensors( - ctx, - backend, + return _ggml_backend_buffer_get_type( + buffer, ); } - late final _ggml_backend_alloc_ctx_tensorsPtr = _lookup< + late final _ggml_backend_buffer_get_typePtr = _lookup< ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer, - ffi.Pointer)>>('ggml_backend_alloc_ctx_tensors'); - late final _ggml_backend_alloc_ctx_tensors = - _ggml_backend_alloc_ctx_tensorsPtr.asFunction< - ffi.Pointer Function( - ffi.Pointer, ffi.Pointer)>(); + ggml_backend_buffer_type_t Function( + ggml_backend_buffer_t)>>('ggml_backend_buffer_get_type'); + late final _ggml_backend_buffer_get_type = _ggml_backend_buffer_get_typePtr + .asFunction(); - ffi.Pointer ggml_backend_buft_name( - ggml_backend_buffer_type_t buft, + void ggml_backend_buffer_reset( + ggml_backend_buffer_t buffer, ) { - return _ggml_backend_buft_name( - buft, + return _ggml_backend_buffer_reset( + buffer, ); } - late final _ggml_backend_buft_namePtr = _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - ggml_backend_buffer_type_t)>>('ggml_backend_buft_name'); - late final _ggml_backend_buft_name = _ggml_backend_buft_namePtr - .asFunction Function(ggml_backend_buffer_type_t)>(); + late final _ggml_backend_buffer_resetPtr = + _lookup>( + 'ggml_backend_buffer_reset'); + late final _ggml_backend_buffer_reset = _ggml_backend_buffer_resetPtr + .asFunction(); - ggml_backend_buffer_t ggml_backend_buft_alloc_buffer( - ggml_backend_buffer_type_t buft, - int size, + ffi.Pointer ggml_backend_name( + ggml_backend_t backend, ) { - return _ggml_backend_buft_alloc_buffer( - buft, - size, + return _ggml_backend_name( + backend, ); } - late final _ggml_backend_buft_alloc_bufferPtr = _lookup< - ffi.NativeFunction< - ggml_backend_buffer_t Function(ggml_backend_buffer_type_t, - ffi.Size)>>('ggml_backend_buft_alloc_buffer'); - late final _ggml_backend_buft_alloc_buffer = - _ggml_backend_buft_alloc_bufferPtr.asFunction< - ggml_backend_buffer_t Function(ggml_backend_buffer_type_t, int)>(); - - int ggml_backend_buft_get_alignment( - ggml_backend_buffer_type_t buft, - ) { - return _ggml_backend_buft_get_alignment( - buft, - ); - } - - late final _ggml_backend_buft_get_alignmentPtr = _lookup< - ffi.NativeFunction>( - 'ggml_backend_buft_get_alignment'); - late final _ggml_backend_buft_get_alignment = - _ggml_backend_buft_get_alignmentPtr - .asFunction(); + late final _ggml_backend_namePtr = _lookup< + ffi.NativeFunction Function(ggml_backend_t)>>( + 'ggml_backend_name'); + late final _ggml_backend_name = _ggml_backend_namePtr + .asFunction Function(ggml_backend_t)>(); - int ggml_backend_buft_get_max_size( - ggml_backend_buffer_type_t buft, + void ggml_backend_free( + ggml_backend_t backend, ) { - return _ggml_backend_buft_get_max_size( - buft, + return _ggml_backend_free( + backend, ); } - late final _ggml_backend_buft_get_max_sizePtr = _lookup< - ffi.NativeFunction>( - 'ggml_backend_buft_get_max_size'); - late final _ggml_backend_buft_get_max_size = - _ggml_backend_buft_get_max_sizePtr - .asFunction(); + late final _ggml_backend_freePtr = + _lookup>( + 'ggml_backend_free'); + late final _ggml_backend_free = + _ggml_backend_freePtr.asFunction(); - int ggml_backend_buft_get_alloc_size( - ggml_backend_buffer_type_t buft, - ffi.Pointer tensor, + ggml_backend_buffer_type_t ggml_backend_get_default_buffer_type( + ggml_backend_t backend, ) { - return _ggml_backend_buft_get_alloc_size( - buft, - tensor, + return _ggml_backend_get_default_buffer_type( + backend, ); } - late final _ggml_backend_buft_get_alloc_sizePtr = _lookup< - ffi.NativeFunction< - ffi.Size Function(ggml_backend_buffer_type_t, - ffi.Pointer)>>('ggml_backend_buft_get_alloc_size'); - late final _ggml_backend_buft_get_alloc_size = - _ggml_backend_buft_get_alloc_sizePtr.asFunction< - int Function(ggml_backend_buffer_type_t, ffi.Pointer)>(); + late final _ggml_backend_get_default_buffer_typePtr = _lookup< + ffi + .NativeFunction>( + 'ggml_backend_get_default_buffer_type'); + late final _ggml_backend_get_default_buffer_type = + _ggml_backend_get_default_buffer_typePtr + .asFunction(); - bool ggml_backend_buft_supports_backend( - ggml_backend_buffer_type_t buft, + ggml_backend_buffer_t ggml_backend_alloc_buffer( ggml_backend_t backend, + int size, ) { - return _ggml_backend_buft_supports_backend( - buft, + return _ggml_backend_alloc_buffer( backend, + size, ); } - late final _ggml_backend_buft_supports_backendPtr = _lookup< + late final _ggml_backend_alloc_bufferPtr = _lookup< ffi.NativeFunction< - ffi.Bool Function(ggml_backend_buffer_type_t, - ggml_backend_t)>>('ggml_backend_buft_supports_backend'); - late final _ggml_backend_buft_supports_backend = - _ggml_backend_buft_supports_backendPtr.asFunction< - bool Function(ggml_backend_buffer_type_t, ggml_backend_t)>(); + ggml_backend_buffer_t Function( + ggml_backend_t, ffi.Size)>>('ggml_backend_alloc_buffer'); + late final _ggml_backend_alloc_buffer = _ggml_backend_alloc_bufferPtr + .asFunction(); - bool ggml_backend_buft_is_host( - ggml_backend_buffer_type_t buft, + int ggml_backend_get_alignment( + ggml_backend_t backend, ) { - return _ggml_backend_buft_is_host( - buft, + return _ggml_backend_get_alignment( + backend, ); } - late final _ggml_backend_buft_is_hostPtr = _lookup< - ffi.NativeFunction>( - 'ggml_backend_buft_is_host'); - late final _ggml_backend_buft_is_host = _ggml_backend_buft_is_hostPtr - .asFunction(); + late final _ggml_backend_get_alignmentPtr = + _lookup>( + 'ggml_backend_get_alignment'); + late final _ggml_backend_get_alignment = + _ggml_backend_get_alignmentPtr.asFunction(); - ffi.Pointer ggml_backend_buffer_name( - ggml_backend_buffer_t buffer, + int ggml_backend_get_max_size( + ggml_backend_t backend, ) { - return _ggml_backend_buffer_name( - buffer, + return _ggml_backend_get_max_size( + backend, ); } - late final _ggml_backend_buffer_namePtr = _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - ggml_backend_buffer_t)>>('ggml_backend_buffer_name'); - late final _ggml_backend_buffer_name = _ggml_backend_buffer_namePtr - .asFunction Function(ggml_backend_buffer_t)>(); + late final _ggml_backend_get_max_sizePtr = + _lookup>( + 'ggml_backend_get_max_size'); + late final _ggml_backend_get_max_size = + _ggml_backend_get_max_sizePtr.asFunction(); - void ggml_backend_buffer_free( - ggml_backend_buffer_t buffer, + void ggml_backend_tensor_set_async( + ggml_backend_t backend, + ffi.Pointer tensor, + ffi.Pointer data, + int offset, + int size, ) { - return _ggml_backend_buffer_free( - buffer, + return _ggml_backend_tensor_set_async( + backend, + tensor, + data, + offset, + size, ); } - late final _ggml_backend_buffer_freePtr = - _lookup>( - 'ggml_backend_buffer_free'); - late final _ggml_backend_buffer_free = _ggml_backend_buffer_freePtr - .asFunction(); + late final _ggml_backend_tensor_set_asyncPtr = _lookup< + ffi.NativeFunction< + ffi.Void Function( + ggml_backend_t, + ffi.Pointer, + ffi.Pointer, + ffi.Size, + ffi.Size)>>('ggml_backend_tensor_set_async'); + late final _ggml_backend_tensor_set_async = + _ggml_backend_tensor_set_asyncPtr.asFunction< + void Function(ggml_backend_t, ffi.Pointer, + ffi.Pointer, int, int)>(); - ffi.Pointer ggml_backend_buffer_get_base( - ggml_backend_buffer_t buffer, + void ggml_backend_tensor_get_async( + ggml_backend_t backend, + ffi.Pointer tensor, + ffi.Pointer data, + int offset, + int size, ) { - return _ggml_backend_buffer_get_base( - buffer, + return _ggml_backend_tensor_get_async( + backend, + tensor, + data, + offset, + size, ); } - late final _ggml_backend_buffer_get_basePtr = _lookup< + late final _ggml_backend_tensor_get_asyncPtr = _lookup< ffi.NativeFunction< - ffi.Pointer Function( - ggml_backend_buffer_t)>>('ggml_backend_buffer_get_base'); - late final _ggml_backend_buffer_get_base = _ggml_backend_buffer_get_basePtr - .asFunction Function(ggml_backend_buffer_t)>(); + ffi.Void Function( + ggml_backend_t, + ffi.Pointer, + ffi.Pointer, + ffi.Size, + ffi.Size)>>('ggml_backend_tensor_get_async'); + late final _ggml_backend_tensor_get_async = + _ggml_backend_tensor_get_asyncPtr.asFunction< + void Function(ggml_backend_t, ffi.Pointer, + ffi.Pointer, int, int)>(); - int ggml_backend_buffer_get_size( - ggml_backend_buffer_t buffer, + void ggml_backend_tensor_set( + ffi.Pointer tensor, + ffi.Pointer data, + int offset, + int size, ) { - return _ggml_backend_buffer_get_size( - buffer, + return _ggml_backend_tensor_set( + tensor, + data, + offset, + size, ); } - late final _ggml_backend_buffer_get_sizePtr = - _lookup>( - 'ggml_backend_buffer_get_size'); - late final _ggml_backend_buffer_get_size = _ggml_backend_buffer_get_sizePtr - .asFunction(); + late final _ggml_backend_tensor_setPtr = _lookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, ffi.Pointer, + ffi.Size, ffi.Size)>>('ggml_backend_tensor_set'); + late final _ggml_backend_tensor_set = _ggml_backend_tensor_setPtr.asFunction< + void Function( + ffi.Pointer, ffi.Pointer, int, int)>(); - void ggml_backend_buffer_init_tensor( - ggml_backend_buffer_t buffer, + void ggml_backend_tensor_get( ffi.Pointer tensor, + ffi.Pointer data, + int offset, + int size, ) { - return _ggml_backend_buffer_init_tensor( - buffer, + return _ggml_backend_tensor_get( tensor, + data, + offset, + size, ); } - late final _ggml_backend_buffer_init_tensorPtr = _lookup< + late final _ggml_backend_tensor_getPtr = _lookup< ffi.NativeFunction< - ffi.Void Function(ggml_backend_buffer_t, - ffi.Pointer)>>('ggml_backend_buffer_init_tensor'); - late final _ggml_backend_buffer_init_tensor = - _ggml_backend_buffer_init_tensorPtr.asFunction< - void Function(ggml_backend_buffer_t, ffi.Pointer)>(); + ffi.Void Function(ffi.Pointer, ffi.Pointer, + ffi.Size, ffi.Size)>>('ggml_backend_tensor_get'); + late final _ggml_backend_tensor_get = _ggml_backend_tensor_getPtr.asFunction< + void Function( + ffi.Pointer, ffi.Pointer, int, int)>(); - int ggml_backend_buffer_get_alignment( - ggml_backend_buffer_t buffer, + void ggml_backend_synchronize( + ggml_backend_t backend, ) { - return _ggml_backend_buffer_get_alignment( - buffer, + return _ggml_backend_synchronize( + backend, ); } - late final _ggml_backend_buffer_get_alignmentPtr = - _lookup>( - 'ggml_backend_buffer_get_alignment'); - late final _ggml_backend_buffer_get_alignment = - _ggml_backend_buffer_get_alignmentPtr - .asFunction(); + late final _ggml_backend_synchronizePtr = + _lookup>( + 'ggml_backend_synchronize'); + late final _ggml_backend_synchronize = + _ggml_backend_synchronizePtr.asFunction(); - int ggml_backend_buffer_get_max_size( - ggml_backend_buffer_t buffer, + ggml_backend_graph_plan_t ggml_backend_graph_plan_create( + ggml_backend_t backend, + ffi.Pointer cgraph, ) { - return _ggml_backend_buffer_get_max_size( - buffer, + return _ggml_backend_graph_plan_create( + backend, + cgraph, ); } - late final _ggml_backend_buffer_get_max_sizePtr = - _lookup>( - 'ggml_backend_buffer_get_max_size'); - late final _ggml_backend_buffer_get_max_size = - _ggml_backend_buffer_get_max_sizePtr - .asFunction(); + late final _ggml_backend_graph_plan_createPtr = _lookup< + ffi.NativeFunction< + ggml_backend_graph_plan_t Function(ggml_backend_t, + ffi.Pointer)>>('ggml_backend_graph_plan_create'); + late final _ggml_backend_graph_plan_create = + _ggml_backend_graph_plan_createPtr.asFunction< + ggml_backend_graph_plan_t Function( + ggml_backend_t, ffi.Pointer)>(); - int ggml_backend_buffer_get_alloc_size( - ggml_backend_buffer_t buffer, - ffi.Pointer tensor, + void ggml_backend_graph_plan_free( + ggml_backend_t backend, + ggml_backend_graph_plan_t plan, ) { - return _ggml_backend_buffer_get_alloc_size( - buffer, - tensor, + return _ggml_backend_graph_plan_free( + backend, + plan, ); } - late final _ggml_backend_buffer_get_alloc_sizePtr = _lookup< + late final _ggml_backend_graph_plan_freePtr = _lookup< ffi.NativeFunction< - ffi.Size Function(ggml_backend_buffer_t, - ffi.Pointer)>>('ggml_backend_buffer_get_alloc_size'); - late final _ggml_backend_buffer_get_alloc_size = - _ggml_backend_buffer_get_alloc_sizePtr.asFunction< - int Function(ggml_backend_buffer_t, ffi.Pointer)>(); + ffi.Void Function(ggml_backend_t, + ggml_backend_graph_plan_t)>>('ggml_backend_graph_plan_free'); + late final _ggml_backend_graph_plan_free = _ggml_backend_graph_plan_freePtr + .asFunction(); - void ggml_backend_buffer_clear( - ggml_backend_buffer_t buffer, - int value, + void ggml_backend_graph_plan_compute( + ggml_backend_t backend, + ggml_backend_graph_plan_t plan, ) { - return _ggml_backend_buffer_clear( - buffer, - value, + return _ggml_backend_graph_plan_compute( + backend, + plan, ); } - late final _ggml_backend_buffer_clearPtr = _lookup< - ffi - .NativeFunction>( - 'ggml_backend_buffer_clear'); - late final _ggml_backend_buffer_clear = _ggml_backend_buffer_clearPtr - .asFunction(); + late final _ggml_backend_graph_plan_computePtr = _lookup< + ffi.NativeFunction< + ffi.Void Function(ggml_backend_t, + ggml_backend_graph_plan_t)>>('ggml_backend_graph_plan_compute'); + late final _ggml_backend_graph_plan_compute = + _ggml_backend_graph_plan_computePtr.asFunction< + void Function(ggml_backend_t, ggml_backend_graph_plan_t)>(); - bool ggml_backend_buffer_is_host( - ggml_backend_buffer_t buffer, + bool ggml_backend_graph_compute( + ggml_backend_t backend, + ffi.Pointer cgraph, ) { - return _ggml_backend_buffer_is_host( - buffer, + return _ggml_backend_graph_compute( + backend, + cgraph, ); } - late final _ggml_backend_buffer_is_hostPtr = - _lookup>( - 'ggml_backend_buffer_is_host'); - late final _ggml_backend_buffer_is_host = _ggml_backend_buffer_is_hostPtr - .asFunction(); + late final _ggml_backend_graph_computePtr = _lookup< + ffi.NativeFunction< + ffi.Bool Function(ggml_backend_t, + ffi.Pointer)>>('ggml_backend_graph_compute'); + late final _ggml_backend_graph_compute = _ggml_backend_graph_computePtr + .asFunction)>(); - void ggml_backend_buffer_set_usage( - ggml_backend_buffer_t buffer, - int usage, + bool ggml_backend_supports_op( + ggml_backend_t backend, + ffi.Pointer op, ) { - return _ggml_backend_buffer_set_usage( - buffer, - usage, + return _ggml_backend_supports_op( + backend, + op, ); } - late final _ggml_backend_buffer_set_usagePtr = _lookup< - ffi - .NativeFunction>( - 'ggml_backend_buffer_set_usage'); - late final _ggml_backend_buffer_set_usage = _ggml_backend_buffer_set_usagePtr - .asFunction(); + late final _ggml_backend_supports_opPtr = _lookup< + ffi.NativeFunction< + ffi.Bool Function(ggml_backend_t, + ffi.Pointer)>>('ggml_backend_supports_op'); + late final _ggml_backend_supports_op = _ggml_backend_supports_opPtr + .asFunction)>(); - ggml_backend_buffer_type_t ggml_backend_buffer_get_type( - ggml_backend_buffer_t buffer, + void ggml_backend_tensor_copy( + ffi.Pointer src, + ffi.Pointer dst, ) { - return _ggml_backend_buffer_get_type( - buffer, + return _ggml_backend_tensor_copy( + src, + dst, ); } - late final _ggml_backend_buffer_get_typePtr = _lookup< + late final _ggml_backend_tensor_copyPtr = _lookup< ffi.NativeFunction< - ggml_backend_buffer_type_t Function( - ggml_backend_buffer_t)>>('ggml_backend_buffer_get_type'); - late final _ggml_backend_buffer_get_type = _ggml_backend_buffer_get_typePtr - .asFunction(); + ffi.Void Function(ffi.Pointer, + ffi.Pointer)>>('ggml_backend_tensor_copy'); + late final _ggml_backend_tensor_copy = + _ggml_backend_tensor_copyPtr.asFunction< + void Function(ffi.Pointer, ffi.Pointer)>(); - void ggml_backend_buffer_reset( - ggml_backend_buffer_t buffer, + void ggml_backend_tensor_copy_async( + ggml_backend_t backend, + ffi.Pointer src, + ffi.Pointer dst, ) { - return _ggml_backend_buffer_reset( - buffer, + return _ggml_backend_tensor_copy_async( + backend, + src, + dst, ); } - late final _ggml_backend_buffer_resetPtr = - _lookup>( - 'ggml_backend_buffer_reset'); - late final _ggml_backend_buffer_reset = _ggml_backend_buffer_resetPtr - .asFunction(); + late final _ggml_backend_tensor_copy_asyncPtr = _lookup< + ffi.NativeFunction< + ffi.Void Function(ggml_backend_t, ffi.Pointer, + ffi.Pointer)>>('ggml_backend_tensor_copy_async'); + late final _ggml_backend_tensor_copy_async = + _ggml_backend_tensor_copy_asyncPtr.asFunction< + void Function(ggml_backend_t, ffi.Pointer, + ffi.Pointer)>(); - ffi.Pointer ggml_backend_name( - ggml_backend_t backend, - ) { - return _ggml_backend_name( - backend, - ); + ggml_backend_t ggml_backend_cpu_init() { + return _ggml_backend_cpu_init(); } - late final _ggml_backend_namePtr = _lookup< - ffi.NativeFunction Function(ggml_backend_t)>>( - 'ggml_backend_name'); - late final _ggml_backend_name = _ggml_backend_namePtr - .asFunction Function(ggml_backend_t)>(); + late final _ggml_backend_cpu_initPtr = + _lookup>( + 'ggml_backend_cpu_init'); + late final _ggml_backend_cpu_init = + _ggml_backend_cpu_initPtr.asFunction(); - void ggml_backend_free( + bool ggml_backend_is_cpu( ggml_backend_t backend, ) { - return _ggml_backend_free( + return _ggml_backend_is_cpu( backend, ); } - late final _ggml_backend_freePtr = - _lookup>( - 'ggml_backend_free'); - late final _ggml_backend_free = - _ggml_backend_freePtr.asFunction(); + late final _ggml_backend_is_cpuPtr = + _lookup>( + 'ggml_backend_is_cpu'); + late final _ggml_backend_is_cpu = + _ggml_backend_is_cpuPtr.asFunction(); - ggml_backend_buffer_type_t ggml_backend_get_default_buffer_type( - ggml_backend_t backend, + void ggml_backend_cpu_set_n_threads( + ggml_backend_t backend_cpu, + int n_threads, ) { - return _ggml_backend_get_default_buffer_type( - backend, + return _ggml_backend_cpu_set_n_threads( + backend_cpu, + n_threads, ); } - late final _ggml_backend_get_default_buffer_typePtr = _lookup< - ffi - .NativeFunction>( - 'ggml_backend_get_default_buffer_type'); - late final _ggml_backend_get_default_buffer_type = - _ggml_backend_get_default_buffer_typePtr - .asFunction(); + late final _ggml_backend_cpu_set_n_threadsPtr = + _lookup>( + 'ggml_backend_cpu_set_n_threads'); + late final _ggml_backend_cpu_set_n_threads = + _ggml_backend_cpu_set_n_threadsPtr + .asFunction(); - ggml_backend_buffer_t ggml_backend_alloc_buffer( - ggml_backend_t backend, - int size, + void ggml_backend_cpu_set_abort_callback( + ggml_backend_t backend_cpu, + ggml_abort_callback abort_callback, + ffi.Pointer abort_callback_data, ) { - return _ggml_backend_alloc_buffer( - backend, - size, + return _ggml_backend_cpu_set_abort_callback( + backend_cpu, + abort_callback, + abort_callback_data, ); } - late final _ggml_backend_alloc_bufferPtr = _lookup< + late final _ggml_backend_cpu_set_abort_callbackPtr = _lookup< ffi.NativeFunction< - ggml_backend_buffer_t Function( - ggml_backend_t, ffi.Size)>>('ggml_backend_alloc_buffer'); - late final _ggml_backend_alloc_buffer = _ggml_backend_alloc_bufferPtr - .asFunction(); + ffi.Void Function(ggml_backend_t, ggml_abort_callback, + ffi.Pointer)>>('ggml_backend_cpu_set_abort_callback'); + late final _ggml_backend_cpu_set_abort_callback = + _ggml_backend_cpu_set_abort_callbackPtr.asFunction< + void Function( + ggml_backend_t, ggml_abort_callback, ffi.Pointer)>(); - int ggml_backend_get_alignment( - ggml_backend_t backend, + ggml_backend_buffer_t ggml_backend_cpu_buffer_from_ptr( + ffi.Pointer ptr, + int size, ) { - return _ggml_backend_get_alignment( - backend, + return _ggml_backend_cpu_buffer_from_ptr( + ptr, + size, ); } - late final _ggml_backend_get_alignmentPtr = - _lookup>( - 'ggml_backend_get_alignment'); - late final _ggml_backend_get_alignment = - _ggml_backend_get_alignmentPtr.asFunction(); + late final _ggml_backend_cpu_buffer_from_ptrPtr = _lookup< + ffi.NativeFunction< + ggml_backend_buffer_t Function(ffi.Pointer, + ffi.Size)>>('ggml_backend_cpu_buffer_from_ptr'); + late final _ggml_backend_cpu_buffer_from_ptr = + _ggml_backend_cpu_buffer_from_ptrPtr.asFunction< + ggml_backend_buffer_t Function(ffi.Pointer, int)>(); - int ggml_backend_get_max_size( - ggml_backend_t backend, - ) { - return _ggml_backend_get_max_size( - backend, - ); + ggml_backend_buffer_type_t ggml_backend_cpu_buffer_type() { + return _ggml_backend_cpu_buffer_type(); } - late final _ggml_backend_get_max_sizePtr = - _lookup>( - 'ggml_backend_get_max_size'); - late final _ggml_backend_get_max_size = - _ggml_backend_get_max_sizePtr.asFunction(); + late final _ggml_backend_cpu_buffer_typePtr = + _lookup>( + 'ggml_backend_cpu_buffer_type'); + late final _ggml_backend_cpu_buffer_type = _ggml_backend_cpu_buffer_typePtr + .asFunction(); - void ggml_backend_tensor_set_async( - ggml_backend_t backend, - ffi.Pointer tensor, - ffi.Pointer data, - int offset, - int size, + int ggml_backend_reg_get_count() { + return _ggml_backend_reg_get_count(); + } + + late final _ggml_backend_reg_get_countPtr = + _lookup>( + 'ggml_backend_reg_get_count'); + late final _ggml_backend_reg_get_count = + _ggml_backend_reg_get_countPtr.asFunction(); + + int ggml_backend_reg_find_by_name( + ffi.Pointer name, ) { - return _ggml_backend_tensor_set_async( - backend, - tensor, - data, - offset, - size, + return _ggml_backend_reg_find_by_name( + name, ); } - late final _ggml_backend_tensor_set_asyncPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function( - ggml_backend_t, - ffi.Pointer, - ffi.Pointer, - ffi.Size, - ffi.Size)>>('ggml_backend_tensor_set_async'); - late final _ggml_backend_tensor_set_async = - _ggml_backend_tensor_set_asyncPtr.asFunction< - void Function(ggml_backend_t, ffi.Pointer, - ffi.Pointer, int, int)>(); + late final _ggml_backend_reg_find_by_namePtr = + _lookup)>>( + 'ggml_backend_reg_find_by_name'); + late final _ggml_backend_reg_find_by_name = _ggml_backend_reg_find_by_namePtr + .asFunction)>(); - void ggml_backend_tensor_get_async( - ggml_backend_t backend, - ffi.Pointer tensor, - ffi.Pointer data, - int offset, - int size, + ggml_backend_t ggml_backend_reg_init_backend_from_str( + ffi.Pointer backend_str, ) { - return _ggml_backend_tensor_get_async( - backend, - tensor, - data, - offset, - size, + return _ggml_backend_reg_init_backend_from_str( + backend_str, ); } - late final _ggml_backend_tensor_get_asyncPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function( - ggml_backend_t, - ffi.Pointer, - ffi.Pointer, - ffi.Size, - ffi.Size)>>('ggml_backend_tensor_get_async'); - late final _ggml_backend_tensor_get_async = - _ggml_backend_tensor_get_asyncPtr.asFunction< - void Function(ggml_backend_t, ffi.Pointer, - ffi.Pointer, int, int)>(); + late final _ggml_backend_reg_init_backend_from_strPtr = _lookup< + ffi.NativeFunction)>>( + 'ggml_backend_reg_init_backend_from_str'); + late final _ggml_backend_reg_init_backend_from_str = + _ggml_backend_reg_init_backend_from_strPtr + .asFunction)>(); - void ggml_backend_tensor_set( - ffi.Pointer tensor, - ffi.Pointer data, - int offset, - int size, + ffi.Pointer ggml_backend_reg_get_name( + int i, ) { - return _ggml_backend_tensor_set( - tensor, - data, - offset, - size, + return _ggml_backend_reg_get_name( + i, ); } - late final _ggml_backend_tensor_setPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, ffi.Pointer, - ffi.Size, ffi.Size)>>('ggml_backend_tensor_set'); - late final _ggml_backend_tensor_set = _ggml_backend_tensor_setPtr.asFunction< - void Function( - ffi.Pointer, ffi.Pointer, int, int)>(); + late final _ggml_backend_reg_get_namePtr = + _lookup Function(ffi.Size)>>( + 'ggml_backend_reg_get_name'); + late final _ggml_backend_reg_get_name = _ggml_backend_reg_get_namePtr + .asFunction Function(int)>(); - void ggml_backend_tensor_get( - ffi.Pointer tensor, - ffi.Pointer data, - int offset, - int size, + ggml_backend_t ggml_backend_reg_init_backend( + int i, + ffi.Pointer params, ) { - return _ggml_backend_tensor_get( - tensor, - data, - offset, - size, + return _ggml_backend_reg_init_backend( + i, + params, ); } - late final _ggml_backend_tensor_getPtr = _lookup< + late final _ggml_backend_reg_init_backendPtr = _lookup< ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, ffi.Pointer, - ffi.Size, ffi.Size)>>('ggml_backend_tensor_get'); - late final _ggml_backend_tensor_get = _ggml_backend_tensor_getPtr.asFunction< - void Function( - ffi.Pointer, ffi.Pointer, int, int)>(); + ggml_backend_t Function(ffi.Size, + ffi.Pointer)>>('ggml_backend_reg_init_backend'); + late final _ggml_backend_reg_init_backend = _ggml_backend_reg_init_backendPtr + .asFunction)>(); - void ggml_backend_synchronize( - ggml_backend_t backend, + ggml_backend_buffer_type_t ggml_backend_reg_get_default_buffer_type( + int i, ) { - return _ggml_backend_synchronize( - backend, + return _ggml_backend_reg_get_default_buffer_type( + i, ); } - late final _ggml_backend_synchronizePtr = - _lookup>( - 'ggml_backend_synchronize'); - late final _ggml_backend_synchronize = - _ggml_backend_synchronizePtr.asFunction(); + late final _ggml_backend_reg_get_default_buffer_typePtr = _lookup< + ffi.NativeFunction>( + 'ggml_backend_reg_get_default_buffer_type'); + late final _ggml_backend_reg_get_default_buffer_type = + _ggml_backend_reg_get_default_buffer_typePtr + .asFunction(); - ggml_backend_graph_plan_t ggml_backend_graph_plan_create( - ggml_backend_t backend, - ffi.Pointer cgraph, + ggml_backend_buffer_t ggml_backend_reg_alloc_buffer( + int i, + int size, ) { - return _ggml_backend_graph_plan_create( - backend, - cgraph, + return _ggml_backend_reg_alloc_buffer( + i, + size, ); } - late final _ggml_backend_graph_plan_createPtr = _lookup< - ffi.NativeFunction< - ggml_backend_graph_plan_t Function(ggml_backend_t, - ffi.Pointer)>>('ggml_backend_graph_plan_create'); - late final _ggml_backend_graph_plan_create = - _ggml_backend_graph_plan_createPtr.asFunction< - ggml_backend_graph_plan_t Function( - ggml_backend_t, ffi.Pointer)>(); + late final _ggml_backend_reg_alloc_bufferPtr = _lookup< + ffi + .NativeFunction>( + 'ggml_backend_reg_alloc_buffer'); + late final _ggml_backend_reg_alloc_buffer = _ggml_backend_reg_alloc_bufferPtr + .asFunction(); - void ggml_backend_graph_plan_free( - ggml_backend_t backend, - ggml_backend_graph_plan_t plan, + ggml_backend_sched_t ggml_backend_sched_new( + ffi.Pointer backends, + ffi.Pointer bufts, + int n_backends, + int graph_size, ) { - return _ggml_backend_graph_plan_free( - backend, - plan, + return _ggml_backend_sched_new( + backends, + bufts, + n_backends, + graph_size, ); } - late final _ggml_backend_graph_plan_freePtr = _lookup< + late final _ggml_backend_sched_newPtr = _lookup< ffi.NativeFunction< - ffi.Void Function(ggml_backend_t, - ggml_backend_graph_plan_t)>>('ggml_backend_graph_plan_free'); - late final _ggml_backend_graph_plan_free = _ggml_backend_graph_plan_freePtr - .asFunction(); + ggml_backend_sched_t Function( + ffi.Pointer, + ffi.Pointer, + ffi.Int, + ffi.Size)>>('ggml_backend_sched_new'); + late final _ggml_backend_sched_new = _ggml_backend_sched_newPtr.asFunction< + ggml_backend_sched_t Function(ffi.Pointer, + ffi.Pointer, int, int)>(); - void ggml_backend_graph_plan_compute( - ggml_backend_t backend, - ggml_backend_graph_plan_t plan, + void ggml_backend_sched_free( + ggml_backend_sched_t sched, ) { - return _ggml_backend_graph_plan_compute( - backend, - plan, + return _ggml_backend_sched_free( + sched, ); } - late final _ggml_backend_graph_plan_computePtr = _lookup< - ffi.NativeFunction< - ffi.Void Function(ggml_backend_t, - ggml_backend_graph_plan_t)>>('ggml_backend_graph_plan_compute'); - late final _ggml_backend_graph_plan_compute = - _ggml_backend_graph_plan_computePtr.asFunction< - void Function(ggml_backend_t, ggml_backend_graph_plan_t)>(); + late final _ggml_backend_sched_freePtr = + _lookup>( + 'ggml_backend_sched_free'); + late final _ggml_backend_sched_free = _ggml_backend_sched_freePtr + .asFunction(); - bool ggml_backend_graph_compute( - ggml_backend_t backend, - ffi.Pointer cgraph, + bool ggml_backend_sched_reserve( + ggml_backend_sched_t sched, + ffi.Pointer measure_graph, ) { - return _ggml_backend_graph_compute( - backend, - cgraph, + return _ggml_backend_sched_reserve( + sched, + measure_graph, ); } - late final _ggml_backend_graph_computePtr = _lookup< + late final _ggml_backend_sched_reservePtr = _lookup< ffi.NativeFunction< - ffi.Bool Function(ggml_backend_t, - ffi.Pointer)>>('ggml_backend_graph_compute'); - late final _ggml_backend_graph_compute = _ggml_backend_graph_computePtr - .asFunction)>(); + ffi.Bool Function(ggml_backend_sched_t, + ffi.Pointer)>>('ggml_backend_sched_reserve'); + late final _ggml_backend_sched_reserve = + _ggml_backend_sched_reservePtr.asFunction< + bool Function(ggml_backend_sched_t, ffi.Pointer)>(); - bool ggml_backend_supports_op( - ggml_backend_t backend, - ffi.Pointer op, + int ggml_backend_sched_get_n_splits( + ggml_backend_sched_t sched, ) { - return _ggml_backend_supports_op( - backend, - op, - ); - } - - late final _ggml_backend_supports_opPtr = _lookup< - ffi.NativeFunction< - ffi.Bool Function(ggml_backend_t, - ffi.Pointer)>>('ggml_backend_supports_op'); - late final _ggml_backend_supports_op = _ggml_backend_supports_opPtr - .asFunction)>(); - - void ggml_backend_tensor_copy( - ffi.Pointer src, - ffi.Pointer dst, - ) { - return _ggml_backend_tensor_copy( - src, - dst, + return _ggml_backend_sched_get_n_splits( + sched, ); } - late final _ggml_backend_tensor_copyPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, - ffi.Pointer)>>('ggml_backend_tensor_copy'); - late final _ggml_backend_tensor_copy = - _ggml_backend_tensor_copyPtr.asFunction< - void Function(ffi.Pointer, ffi.Pointer)>(); + late final _ggml_backend_sched_get_n_splitsPtr = + _lookup>( + 'ggml_backend_sched_get_n_splits'); + late final _ggml_backend_sched_get_n_splits = + _ggml_backend_sched_get_n_splitsPtr + .asFunction(); - void ggml_backend_tensor_copy_async( + int ggml_backend_sched_get_buffer_size( + ggml_backend_sched_t sched, ggml_backend_t backend, - ffi.Pointer src, - ffi.Pointer dst, ) { - return _ggml_backend_tensor_copy_async( + return _ggml_backend_sched_get_buffer_size( + sched, backend, - src, - dst, ); } - late final _ggml_backend_tensor_copy_asyncPtr = _lookup< + late final _ggml_backend_sched_get_buffer_sizePtr = _lookup< ffi.NativeFunction< - ffi.Void Function(ggml_backend_t, ffi.Pointer, - ffi.Pointer)>>('ggml_backend_tensor_copy_async'); - late final _ggml_backend_tensor_copy_async = - _ggml_backend_tensor_copy_asyncPtr.asFunction< - void Function(ggml_backend_t, ffi.Pointer, - ffi.Pointer)>(); - - ggml_backend_t ggml_backend_cpu_init() { - return _ggml_backend_cpu_init(); - } - - late final _ggml_backend_cpu_initPtr = - _lookup>( - 'ggml_backend_cpu_init'); - late final _ggml_backend_cpu_init = - _ggml_backend_cpu_initPtr.asFunction(); + ffi.Size Function(ggml_backend_sched_t, + ggml_backend_t)>>('ggml_backend_sched_get_buffer_size'); + late final _ggml_backend_sched_get_buffer_size = + _ggml_backend_sched_get_buffer_sizePtr + .asFunction(); - bool ggml_backend_is_cpu( + void ggml_backend_sched_set_node_backend( + ggml_backend_sched_t sched, + ffi.Pointer node, ggml_backend_t backend, ) { - return _ggml_backend_is_cpu( + return _ggml_backend_sched_set_node_backend( + sched, + node, backend, ); } - late final _ggml_backend_is_cpuPtr = - _lookup>( - 'ggml_backend_is_cpu'); - late final _ggml_backend_is_cpu = - _ggml_backend_is_cpuPtr.asFunction(); + late final _ggml_backend_sched_set_node_backendPtr = _lookup< + ffi.NativeFunction< + ffi.Void Function(ggml_backend_sched_t, ffi.Pointer, + ggml_backend_t)>>('ggml_backend_sched_set_node_backend'); + late final _ggml_backend_sched_set_node_backend = + _ggml_backend_sched_set_node_backendPtr.asFunction< + void Function(ggml_backend_sched_t, ffi.Pointer, + ggml_backend_t)>(); - void ggml_backend_cpu_set_n_threads( - ggml_backend_t backend_cpu, - int n_threads, + ggml_backend_t ggml_backend_sched_get_node_backend( + ggml_backend_sched_t sched, + ffi.Pointer node, ) { - return _ggml_backend_cpu_set_n_threads( - backend_cpu, - n_threads, + return _ggml_backend_sched_get_node_backend( + sched, + node, ); } - late final _ggml_backend_cpu_set_n_threadsPtr = - _lookup>( - 'ggml_backend_cpu_set_n_threads'); - late final _ggml_backend_cpu_set_n_threads = - _ggml_backend_cpu_set_n_threadsPtr - .asFunction(); + late final _ggml_backend_sched_get_node_backendPtr = _lookup< + ffi.NativeFunction< + ggml_backend_t Function( + ggml_backend_sched_t, ffi.Pointer)>>( + 'ggml_backend_sched_get_node_backend'); + late final _ggml_backend_sched_get_node_backend = + _ggml_backend_sched_get_node_backendPtr.asFunction< + ggml_backend_t Function( + ggml_backend_sched_t, ffi.Pointer)>(); - ggml_backend_buffer_t ggml_backend_cpu_buffer_from_ptr( - ffi.Pointer ptr, - int size, + bool ggml_backend_sched_graph_compute( + ggml_backend_sched_t sched, + ffi.Pointer graph, ) { - return _ggml_backend_cpu_buffer_from_ptr( - ptr, - size, + return _ggml_backend_sched_graph_compute( + sched, + graph, ); } - late final _ggml_backend_cpu_buffer_from_ptrPtr = _lookup< + late final _ggml_backend_sched_graph_computePtr = _lookup< ffi.NativeFunction< - ggml_backend_buffer_t Function(ffi.Pointer, - ffi.Size)>>('ggml_backend_cpu_buffer_from_ptr'); - late final _ggml_backend_cpu_buffer_from_ptr = - _ggml_backend_cpu_buffer_from_ptrPtr.asFunction< - ggml_backend_buffer_t Function(ffi.Pointer, int)>(); - - ggml_backend_buffer_type_t ggml_backend_cpu_buffer_type() { - return _ggml_backend_cpu_buffer_type(); - } - - late final _ggml_backend_cpu_buffer_typePtr = - _lookup>( - 'ggml_backend_cpu_buffer_type'); - late final _ggml_backend_cpu_buffer_type = _ggml_backend_cpu_buffer_typePtr - .asFunction(); - - int ggml_backend_reg_get_count() { - return _ggml_backend_reg_get_count(); - } - - late final _ggml_backend_reg_get_countPtr = - _lookup>( - 'ggml_backend_reg_get_count'); - late final _ggml_backend_reg_get_count = - _ggml_backend_reg_get_countPtr.asFunction(); + ffi.Bool Function(ggml_backend_sched_t, + ffi.Pointer)>>('ggml_backend_sched_graph_compute'); + late final _ggml_backend_sched_graph_compute = + _ggml_backend_sched_graph_computePtr.asFunction< + bool Function(ggml_backend_sched_t, ffi.Pointer)>(); - int ggml_backend_reg_find_by_name( - ffi.Pointer name, + void ggml_backend_sched_reset( + ggml_backend_sched_t sched, ) { - return _ggml_backend_reg_find_by_name( - name, + return _ggml_backend_sched_reset( + sched, ); } - late final _ggml_backend_reg_find_by_namePtr = - _lookup)>>( - 'ggml_backend_reg_find_by_name'); - late final _ggml_backend_reg_find_by_name = _ggml_backend_reg_find_by_namePtr - .asFunction)>(); + late final _ggml_backend_sched_resetPtr = + _lookup>( + 'ggml_backend_sched_reset'); + late final _ggml_backend_sched_reset = _ggml_backend_sched_resetPtr + .asFunction(); - ggml_backend_t ggml_backend_reg_init_backend_from_str( - ffi.Pointer backend_str, + void ggml_backend_sched_set_eval_callback( + ggml_backend_sched_t sched, + ggml_backend_sched_eval_callback callback, + ffi.Pointer user_data, ) { - return _ggml_backend_reg_init_backend_from_str( - backend_str, + return _ggml_backend_sched_set_eval_callback( + sched, + callback, + user_data, ); } - late final _ggml_backend_reg_init_backend_from_strPtr = _lookup< - ffi.NativeFunction)>>( - 'ggml_backend_reg_init_backend_from_str'); - late final _ggml_backend_reg_init_backend_from_str = - _ggml_backend_reg_init_backend_from_strPtr - .asFunction)>(); + late final _ggml_backend_sched_set_eval_callbackPtr = _lookup< + ffi.NativeFunction< + ffi.Void Function( + ggml_backend_sched_t, + ggml_backend_sched_eval_callback, + ffi.Pointer)>>('ggml_backend_sched_set_eval_callback'); + late final _ggml_backend_sched_set_eval_callback = + _ggml_backend_sched_set_eval_callbackPtr.asFunction< + void Function(ggml_backend_sched_t, ggml_backend_sched_eval_callback, + ffi.Pointer)>(); - ffi.Pointer ggml_backend_reg_get_name( - int i, + ggml_backend_graph_copy ggml_backend_graph_copy1( + ggml_backend_t backend, + ffi.Pointer graph, ) { - return _ggml_backend_reg_get_name( - i, + return _ggml_backend_graph_copy1( + backend, + graph, ); } - late final _ggml_backend_reg_get_namePtr = - _lookup Function(ffi.Size)>>( - 'ggml_backend_reg_get_name'); - late final _ggml_backend_reg_get_name = _ggml_backend_reg_get_namePtr - .asFunction Function(int)>(); + late final _ggml_backend_graph_copy1Ptr = _lookup< + ffi.NativeFunction< + ggml_backend_graph_copy Function(ggml_backend_t, + ffi.Pointer)>>('ggml_backend_graph_copy'); + late final _ggml_backend_graph_copy1 = + _ggml_backend_graph_copy1Ptr.asFunction< + ggml_backend_graph_copy Function( + ggml_backend_t, ffi.Pointer)>(); - ggml_backend_t ggml_backend_reg_init_backend( - int i, - ffi.Pointer params, + void ggml_backend_graph_copy_free( + ggml_backend_graph_copy copy, ) { - return _ggml_backend_reg_init_backend( - i, - params, + return _ggml_backend_graph_copy_free( + copy, ); } - late final _ggml_backend_reg_init_backendPtr = _lookup< - ffi.NativeFunction< - ggml_backend_t Function(ffi.Size, - ffi.Pointer)>>('ggml_backend_reg_init_backend'); - late final _ggml_backend_reg_init_backend = _ggml_backend_reg_init_backendPtr - .asFunction)>(); + late final _ggml_backend_graph_copy_freePtr = + _lookup>( + 'ggml_backend_graph_copy_free'); + late final _ggml_backend_graph_copy_free = _ggml_backend_graph_copy_freePtr + .asFunction(); - ggml_backend_buffer_type_t ggml_backend_reg_get_default_buffer_type( - int i, + bool ggml_backend_compare_graph_backend( + ggml_backend_t backend1, + ggml_backend_t backend2, + ffi.Pointer graph, + ggml_backend_eval_callback callback, + ffi.Pointer user_data, ) { - return _ggml_backend_reg_get_default_buffer_type( - i, + return _ggml_backend_compare_graph_backend( + backend1, + backend2, + graph, + callback, + user_data, ); } - late final _ggml_backend_reg_get_default_buffer_typePtr = _lookup< - ffi.NativeFunction>( - 'ggml_backend_reg_get_default_buffer_type'); - late final _ggml_backend_reg_get_default_buffer_type = - _ggml_backend_reg_get_default_buffer_typePtr - .asFunction(); + late final _ggml_backend_compare_graph_backendPtr = _lookup< + ffi.NativeFunction< + ffi.Bool Function( + ggml_backend_t, + ggml_backend_t, + ffi.Pointer, + ggml_backend_eval_callback, + ffi.Pointer)>>('ggml_backend_compare_graph_backend'); + late final _ggml_backend_compare_graph_backend = + _ggml_backend_compare_graph_backendPtr.asFunction< + bool Function( + ggml_backend_t, + ggml_backend_t, + ffi.Pointer, + ggml_backend_eval_callback, + ffi.Pointer)>(); - ggml_backend_buffer_t ggml_backend_reg_alloc_buffer( - int i, - int size, + void ggml_backend_tensor_alloc( + ggml_backend_buffer_t buffer, + ffi.Pointer tensor, + ffi.Pointer addr, ) { - return _ggml_backend_reg_alloc_buffer( - i, - size, + return _ggml_backend_tensor_alloc( + buffer, + tensor, + addr, ); } - late final _ggml_backend_reg_alloc_bufferPtr = _lookup< - ffi - .NativeFunction>( - 'ggml_backend_reg_alloc_buffer'); - late final _ggml_backend_reg_alloc_buffer = _ggml_backend_reg_alloc_bufferPtr - .asFunction(); + late final _ggml_backend_tensor_allocPtr = _lookup< + ffi.NativeFunction< + ffi.Void Function(ggml_backend_buffer_t, ffi.Pointer, + ffi.Pointer)>>('ggml_backend_tensor_alloc'); + late final _ggml_backend_tensor_alloc = + _ggml_backend_tensor_allocPtr.asFunction< + void Function(ggml_backend_buffer_t, ffi.Pointer, + ffi.Pointer)>(); - ggml_backend_sched_t ggml_backend_sched_new( - ffi.Pointer backends, - ffi.Pointer bufts, - int n_backends, - int graph_size, + void ggml_backend_view_init( + ggml_backend_buffer_t buffer, + ffi.Pointer tensor, ) { - return _ggml_backend_sched_new( - backends, - bufts, - n_backends, - graph_size, + return _ggml_backend_view_init( + buffer, + tensor, ); } - late final _ggml_backend_sched_newPtr = _lookup< + late final _ggml_backend_view_initPtr = _lookup< ffi.NativeFunction< - ggml_backend_sched_t Function( - ffi.Pointer, - ffi.Pointer, - ffi.Int, - ffi.Size)>>('ggml_backend_sched_new'); - late final _ggml_backend_sched_new = _ggml_backend_sched_newPtr.asFunction< - ggml_backend_sched_t Function(ffi.Pointer, - ffi.Pointer, int, int)>(); + ffi.Void Function(ggml_backend_buffer_t, + ffi.Pointer)>>('ggml_backend_view_init'); + late final _ggml_backend_view_init = _ggml_backend_view_initPtr.asFunction< + void Function(ggml_backend_buffer_t, ffi.Pointer)>(); - void ggml_backend_sched_free( - ggml_backend_sched_t sched, + late final ffi.Pointer> _stdin = + _lookup>('stdin'); + + ffi.Pointer get stdin => _stdin.value; + + set stdin(ffi.Pointer value) => _stdin.value = value; + + late final ffi.Pointer> _stdout = + _lookup>('stdout'); + + ffi.Pointer get stdout => _stdout.value; + + set stdout(ffi.Pointer value) => _stdout.value = value; + + late final ffi.Pointer> _stderr = + _lookup>('stderr'); + + ffi.Pointer get stderr => _stderr.value; + + set stderr(ffi.Pointer value) => _stderr.value = value; + + int remove( + ffi.Pointer __filename, ) { - return _ggml_backend_sched_free( - sched, + return _remove( + __filename, ); } - late final _ggml_backend_sched_freePtr = - _lookup>( - 'ggml_backend_sched_free'); - late final _ggml_backend_sched_free = _ggml_backend_sched_freePtr - .asFunction(); + late final _removePtr = + _lookup)>>( + 'remove'); + late final _remove = + _removePtr.asFunction)>(); - void ggml_backend_sched_init_measure( - ggml_backend_sched_t sched, - ffi.Pointer measure_graph, + int rename( + ffi.Pointer __old, + ffi.Pointer __new, ) { - return _ggml_backend_sched_init_measure( - sched, - measure_graph, + return _rename( + __old, + __new, ); } - late final _ggml_backend_sched_init_measurePtr = _lookup< + late final _renamePtr = _lookup< ffi.NativeFunction< - ffi.Void Function(ggml_backend_sched_t, - ffi.Pointer)>>('ggml_backend_sched_init_measure'); - late final _ggml_backend_sched_init_measure = - _ggml_backend_sched_init_measurePtr.asFunction< - void Function(ggml_backend_sched_t, ffi.Pointer)>(); + ffi.Int Function( + ffi.Pointer, ffi.Pointer)>>('rename'); + late final _rename = _renamePtr + .asFunction, ffi.Pointer)>(); - int ggml_backend_sched_get_n_splits( - ggml_backend_sched_t sched, + int renameat( + int __oldfd, + ffi.Pointer __old, + int __newfd, + ffi.Pointer __new, ) { - return _ggml_backend_sched_get_n_splits( - sched, + return _renameat( + __oldfd, + __old, + __newfd, + __new, ); } - late final _ggml_backend_sched_get_n_splitsPtr = - _lookup>( - 'ggml_backend_sched_get_n_splits'); - late final _ggml_backend_sched_get_n_splits = - _ggml_backend_sched_get_n_splitsPtr - .asFunction(); + late final _renameatPtr = _lookup< + ffi.NativeFunction< + ffi.Int Function(ffi.Int, ffi.Pointer, ffi.Int, + ffi.Pointer)>>('renameat'); + late final _renameat = _renameatPtr.asFunction< + int Function(int, ffi.Pointer, int, ffi.Pointer)>(); - ggml_tallocr_t ggml_backend_sched_get_tallocr( - ggml_backend_sched_t sched, - ggml_backend_t backend, + int fclose( + ffi.Pointer __stream, ) { - return _ggml_backend_sched_get_tallocr( - sched, - backend, + return _fclose( + __stream, ); } - late final _ggml_backend_sched_get_tallocrPtr = _lookup< - ffi.NativeFunction< - ggml_tallocr_t Function(ggml_backend_sched_t, - ggml_backend_t)>>('ggml_backend_sched_get_tallocr'); - late final _ggml_backend_sched_get_tallocr = - _ggml_backend_sched_get_tallocrPtr.asFunction< - ggml_tallocr_t Function(ggml_backend_sched_t, ggml_backend_t)>(); + late final _fclosePtr = + _lookup)>>( + 'fclose'); + late final _fclose = _fclosePtr.asFunction)>(); - ggml_backend_buffer_t ggml_backend_sched_get_buffer( - ggml_backend_sched_t sched, - ggml_backend_t backend, - ) { - return _ggml_backend_sched_get_buffer( - sched, - backend, - ); + ffi.Pointer tmpfile() { + return _tmpfile(); } - late final _ggml_backend_sched_get_bufferPtr = _lookup< - ffi.NativeFunction< - ggml_backend_buffer_t Function(ggml_backend_sched_t, - ggml_backend_t)>>('ggml_backend_sched_get_buffer'); - late final _ggml_backend_sched_get_buffer = - _ggml_backend_sched_get_bufferPtr.asFunction< - ggml_backend_buffer_t Function( - ggml_backend_sched_t, ggml_backend_t)>(); + late final _tmpfilePtr = + _lookup Function()>>('tmpfile'); + late final _tmpfile = _tmpfilePtr.asFunction Function()>(); - void ggml_backend_sched_set_node_backend( - ggml_backend_sched_t sched, - ffi.Pointer node, - ggml_backend_t backend, + ffi.Pointer tmpnam( + ffi.Pointer arg0, ) { - return _ggml_backend_sched_set_node_backend( - sched, - node, - backend, + return _tmpnam( + arg0, ); } - late final _ggml_backend_sched_set_node_backendPtr = _lookup< + late final _tmpnamPtr = _lookup< ffi.NativeFunction< - ffi.Void Function(ggml_backend_sched_t, ffi.Pointer, - ggml_backend_t)>>('ggml_backend_sched_set_node_backend'); - late final _ggml_backend_sched_set_node_backend = - _ggml_backend_sched_set_node_backendPtr.asFunction< - void Function(ggml_backend_sched_t, ffi.Pointer, - ggml_backend_t)>(); + ffi.Pointer Function(ffi.Pointer)>>('tmpnam'); + late final _tmpnam = _tmpnamPtr + .asFunction Function(ffi.Pointer)>(); - ggml_backend_t ggml_backend_sched_get_node_backend( - ggml_backend_sched_t sched, - ffi.Pointer node, + ffi.Pointer tmpnam_r( + ffi.Pointer __s, ) { - return _ggml_backend_sched_get_node_backend( - sched, - node, + return _tmpnam_r( + __s, ); } - late final _ggml_backend_sched_get_node_backendPtr = _lookup< - ffi.NativeFunction< - ggml_backend_t Function( - ggml_backend_sched_t, ffi.Pointer)>>( - 'ggml_backend_sched_get_node_backend'); - late final _ggml_backend_sched_get_node_backend = - _ggml_backend_sched_get_node_backendPtr.asFunction< - ggml_backend_t Function( - ggml_backend_sched_t, ffi.Pointer)>(); + late final _tmpnam_rPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer)>>('tmpnam_r'); + late final _tmpnam_r = _tmpnam_rPtr + .asFunction Function(ffi.Pointer)>(); - void ggml_backend_sched_graph_compute( - ggml_backend_sched_t sched, - ffi.Pointer graph, + ffi.Pointer tempnam( + ffi.Pointer __dir, + ffi.Pointer __pfx, ) { - return _ggml_backend_sched_graph_compute( - sched, - graph, + return _tempnam( + __dir, + __pfx, ); } - late final _ggml_backend_sched_graph_computePtr = _lookup< + late final _tempnamPtr = _lookup< ffi.NativeFunction< - ffi.Void Function(ggml_backend_sched_t, - ffi.Pointer)>>('ggml_backend_sched_graph_compute'); - late final _ggml_backend_sched_graph_compute = - _ggml_backend_sched_graph_computePtr.asFunction< - void Function(ggml_backend_sched_t, ffi.Pointer)>(); + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>>('tempnam'); + late final _tempnam = _tempnamPtr.asFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>(); - void ggml_backend_sched_reset( - ggml_backend_sched_t sched, + int fflush( + ffi.Pointer __stream, ) { - return _ggml_backend_sched_reset( - sched, + return _fflush( + __stream, ); } - late final _ggml_backend_sched_resetPtr = - _lookup>( - 'ggml_backend_sched_reset'); - late final _ggml_backend_sched_reset = _ggml_backend_sched_resetPtr - .asFunction(); + late final _fflushPtr = + _lookup)>>( + 'fflush'); + late final _fflush = _fflushPtr.asFunction)>(); - void ggml_backend_sched_set_eval_callback( - ggml_backend_sched_t sched, - ggml_backend_sched_eval_callback callback, - ffi.Pointer user_data, + int fflush_unlocked( + ffi.Pointer __stream, ) { - return _ggml_backend_sched_set_eval_callback( - sched, - callback, - user_data, + return _fflush_unlocked( + __stream, ); } - late final _ggml_backend_sched_set_eval_callbackPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function( - ggml_backend_sched_t, - ggml_backend_sched_eval_callback, - ffi.Pointer)>>('ggml_backend_sched_set_eval_callback'); - late final _ggml_backend_sched_set_eval_callback = - _ggml_backend_sched_set_eval_callbackPtr.asFunction< - void Function(ggml_backend_sched_t, ggml_backend_sched_eval_callback, - ffi.Pointer)>(); + late final _fflush_unlockedPtr = + _lookup)>>( + 'fflush_unlocked'); + late final _fflush_unlocked = + _fflush_unlockedPtr.asFunction)>(); - ggml_backend_graph_copy ggml_backend_graph_copy1( - ggml_backend_t backend, - ffi.Pointer graph, + ffi.Pointer fopen( + ffi.Pointer __filename, + ffi.Pointer __modes, ) { - return _ggml_backend_graph_copy1( - backend, - graph, + return _fopen( + __filename, + __modes, ); } - late final _ggml_backend_graph_copy1Ptr = _lookup< + late final _fopenPtr = _lookup< ffi.NativeFunction< - ggml_backend_graph_copy Function(ggml_backend_t, - ffi.Pointer)>>('ggml_backend_graph_copy'); - late final _ggml_backend_graph_copy1 = - _ggml_backend_graph_copy1Ptr.asFunction< - ggml_backend_graph_copy Function( - ggml_backend_t, ffi.Pointer)>(); + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>>('fopen'); + late final _fopen = _fopenPtr.asFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>(); - void ggml_backend_graph_copy_free( - ggml_backend_graph_copy copy, + ffi.Pointer freopen( + ffi.Pointer __filename, + ffi.Pointer __modes, + ffi.Pointer __stream, ) { - return _ggml_backend_graph_copy_free( - copy, + return _freopen( + __filename, + __modes, + __stream, ); } - late final _ggml_backend_graph_copy_freePtr = - _lookup>( - 'ggml_backend_graph_copy_free'); - late final _ggml_backend_graph_copy_free = _ggml_backend_graph_copy_freePtr - .asFunction(); + late final _freopenPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>>('freopen'); + late final _freopen = _freopenPtr.asFunction< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer, ffi.Pointer)>(); - bool ggml_backend_compare_graph_backend( - ggml_backend_t backend1, - ggml_backend_t backend2, - ffi.Pointer graph, - ggml_backend_eval_callback callback, - ffi.Pointer user_data, + ffi.Pointer fdopen( + int __fd, + ffi.Pointer __modes, ) { - return _ggml_backend_compare_graph_backend( - backend1, - backend2, - graph, - callback, - user_data, + return _fdopen( + __fd, + __modes, ); } - late final _ggml_backend_compare_graph_backendPtr = _lookup< + late final _fdopenPtr = _lookup< ffi.NativeFunction< - ffi.Bool Function( - ggml_backend_t, - ggml_backend_t, - ffi.Pointer, - ggml_backend_eval_callback, - ffi.Pointer)>>('ggml_backend_compare_graph_backend'); - late final _ggml_backend_compare_graph_backend = - _ggml_backend_compare_graph_backendPtr.asFunction< - bool Function( - ggml_backend_t, - ggml_backend_t, - ffi.Pointer, - ggml_backend_eval_callback, - ffi.Pointer)>(); + ffi.Pointer Function( + ffi.Int, ffi.Pointer)>>('fdopen'); + late final _fdopen = _fdopenPtr + .asFunction Function(int, ffi.Pointer)>(); - void ggml_backend_tensor_alloc( - ggml_backend_buffer_t buffer, - ffi.Pointer tensor, - ffi.Pointer addr, + ffi.Pointer fmemopen( + ffi.Pointer __s, + int __len, + ffi.Pointer __modes, ) { - return _ggml_backend_tensor_alloc( - buffer, - tensor, - addr, + return _fmemopen( + __s, + __len, + __modes, ); } - late final _ggml_backend_tensor_allocPtr = _lookup< + late final _fmemopenPtr = _lookup< ffi.NativeFunction< - ffi.Void Function(ggml_backend_buffer_t, ffi.Pointer, - ffi.Pointer)>>('ggml_backend_tensor_alloc'); - late final _ggml_backend_tensor_alloc = - _ggml_backend_tensor_allocPtr.asFunction< - void Function(ggml_backend_buffer_t, ffi.Pointer, - ffi.Pointer)>(); + ffi.Pointer Function(ffi.Pointer, ffi.Size, + ffi.Pointer)>>('fmemopen'); + late final _fmemopen = _fmemopenPtr.asFunction< + ffi.Pointer Function( + ffi.Pointer, int, ffi.Pointer)>(); - void ggml_backend_view_init( - ggml_backend_buffer_t buffer, - ffi.Pointer tensor, + ffi.Pointer open_memstream( + ffi.Pointer> __bufloc, + ffi.Pointer __sizeloc, ) { - return _ggml_backend_view_init( - buffer, - tensor, + return _open_memstream( + __bufloc, + __sizeloc, ); } - late final _ggml_backend_view_initPtr = _lookup< + late final _open_memstreamPtr = _lookup< ffi.NativeFunction< - ffi.Void Function(ggml_backend_buffer_t, - ffi.Pointer)>>('ggml_backend_view_init'); - late final _ggml_backend_view_init = _ggml_backend_view_initPtr.asFunction< - void Function(ggml_backend_buffer_t, ffi.Pointer)>(); + ffi.Pointer Function(ffi.Pointer>, + ffi.Pointer)>>('open_memstream'); + late final _open_memstream = _open_memstreamPtr.asFunction< + ffi.Pointer Function( + ffi.Pointer>, ffi.Pointer)>(); - int renameat( - int arg0, - ffi.Pointer arg1, - int arg2, - ffi.Pointer arg3, + void setbuf( + ffi.Pointer __stream, + ffi.Pointer __buf, ) { - return _renameat( - arg0, - arg1, - arg2, - arg3, + return _setbuf( + __stream, + __buf, ); } - late final _renameatPtr = _lookup< + late final _setbufPtr = _lookup< ffi.NativeFunction< - ffi.Int Function(ffi.Int, ffi.Pointer, ffi.Int, - ffi.Pointer)>>('renameat'); - late final _renameat = _renameatPtr.asFunction< - int Function(int, ffi.Pointer, int, ffi.Pointer)>(); + ffi.Void Function( + ffi.Pointer, ffi.Pointer)>>('setbuf'); + late final _setbuf = _setbufPtr + .asFunction, ffi.Pointer)>(); - int renamex_np( - ffi.Pointer arg0, - ffi.Pointer arg1, - int arg2, + int setvbuf( + ffi.Pointer __stream, + ffi.Pointer __buf, + int __modes, + int __n, ) { - return _renamex_np( - arg0, - arg1, - arg2, + return _setvbuf( + __stream, + __buf, + __modes, + __n, ); } - late final _renamex_npPtr = _lookup< + late final _setvbufPtr = _lookup< ffi.NativeFunction< - ffi.Int Function(ffi.Pointer, ffi.Pointer, - ffi.UnsignedInt)>>('renamex_np'); - late final _renamex_np = _renamex_npPtr.asFunction< - int Function(ffi.Pointer, ffi.Pointer, int)>(); - - int renameatx_np( - int arg0, - ffi.Pointer arg1, - int arg2, - ffi.Pointer arg3, - int arg4, - ) { - return _renameatx_np( - arg0, - arg1, - arg2, - arg3, - arg4, + ffi.Int Function(ffi.Pointer, ffi.Pointer, ffi.Int, + ffi.Size)>>('setvbuf'); + late final _setvbuf = _setvbufPtr.asFunction< + int Function(ffi.Pointer, ffi.Pointer, int, int)>(); + + void setbuffer( + ffi.Pointer __stream, + ffi.Pointer __buf, + int __size, + ) { + return _setbuffer( + __stream, + __buf, + __size, ); } - late final _renameatx_npPtr = _lookup< + late final _setbufferPtr = _lookup< ffi.NativeFunction< - ffi.Int Function(ffi.Int, ffi.Pointer, ffi.Int, - ffi.Pointer, ffi.UnsignedInt)>>('renameatx_np'); - late final _renameatx_np = _renameatx_npPtr.asFunction< - int Function( - int, ffi.Pointer, int, ffi.Pointer, int)>(); - - late final ffi.Pointer> ___stdinp = - _lookup>('__stdinp'); - - ffi.Pointer get __stdinp => ___stdinp.value; - - set __stdinp(ffi.Pointer value) => ___stdinp.value = value; - - late final ffi.Pointer> ___stdoutp = - _lookup>('__stdoutp'); - - ffi.Pointer get __stdoutp => ___stdoutp.value; - - set __stdoutp(ffi.Pointer value) => ___stdoutp.value = value; - - late final ffi.Pointer> ___stderrp = - _lookup>('__stderrp'); - - ffi.Pointer get __stderrp => ___stderrp.value; - - set __stderrp(ffi.Pointer value) => ___stderrp.value = value; + ffi.Void Function(ffi.Pointer, ffi.Pointer, + ffi.Size)>>('setbuffer'); + late final _setbuffer = _setbufferPtr.asFunction< + void Function(ffi.Pointer, ffi.Pointer, int)>(); - void clearerr( - ffi.Pointer arg0, + void setlinebuf( + ffi.Pointer __stream, ) { - return _clearerr( - arg0, + return _setlinebuf( + __stream, ); } - late final _clearerrPtr = + late final _setlinebufPtr = _lookup)>>( - 'clearerr'); - late final _clearerr = - _clearerrPtr.asFunction)>(); + 'setlinebuf'); + late final _setlinebuf = + _setlinebufPtr.asFunction)>(); - int fclose( - ffi.Pointer arg0, + int fprintf( + ffi.Pointer __stream, + ffi.Pointer __format, ) { - return _fclose( - arg0, + return _fprintf( + __stream, + __format, ); } - late final _fclosePtr = - _lookup)>>( - 'fclose'); - late final _fclose = _fclosePtr.asFunction)>(); + late final _fprintfPtr = _lookup< + ffi.NativeFunction< + ffi.Int Function( + ffi.Pointer, ffi.Pointer)>>('fprintf'); + late final _fprintf = _fprintfPtr + .asFunction, ffi.Pointer)>(); - int feof( - ffi.Pointer arg0, + int printf( + ffi.Pointer __format, ) { - return _feof( - arg0, + return _printf( + __format, ); } - late final _feofPtr = - _lookup)>>('feof'); - late final _feof = _feofPtr.asFunction)>(); + late final _printfPtr = + _lookup)>>( + 'printf'); + late final _printf = + _printfPtr.asFunction)>(); - int ferror( - ffi.Pointer arg0, + int sprintf( + ffi.Pointer __s, + ffi.Pointer __format, ) { - return _ferror( - arg0, + return _sprintf( + __s, + __format, ); } - late final _ferrorPtr = - _lookup)>>( - 'ferror'); - late final _ferror = _ferrorPtr.asFunction)>(); - - int fflush( - ffi.Pointer arg0, - ) { - return _fflush( - arg0, - ); - } - - late final _fflushPtr = - _lookup)>>( - 'fflush'); - late final _fflush = _fflushPtr.asFunction)>(); + late final _sprintfPtr = _lookup< + ffi.NativeFunction< + ffi.Int Function( + ffi.Pointer, ffi.Pointer)>>('sprintf'); + late final _sprintf = _sprintfPtr + .asFunction, ffi.Pointer)>(); - int fgetc( - ffi.Pointer arg0, + int vfprintf( + ffi.Pointer __s, + ffi.Pointer __format, + ffi.Pointer<__va_list_tag> __arg, ) { - return _fgetc( - arg0, + return _vfprintf( + __s, + __format, + __arg, ); } - late final _fgetcPtr = - _lookup)>>('fgetc'); - late final _fgetc = _fgetcPtr.asFunction)>(); + late final _vfprintfPtr = _lookup< + ffi.NativeFunction< + ffi.Int Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer<__va_list_tag>)>>('vfprintf'); + late final _vfprintf = _vfprintfPtr.asFunction< + int Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer<__va_list_tag>)>(); - int fgetpos( - ffi.Pointer arg0, - ffi.Pointer arg1, + int vprintf( + ffi.Pointer __format, + ffi.Pointer<__va_list_tag> __arg, ) { - return _fgetpos( - arg0, - arg1, + return _vprintf( + __format, + __arg, ); } - late final _fgetposPtr = _lookup< + late final _vprintfPtr = _lookup< ffi.NativeFunction< - ffi.Int Function(ffi.Pointer, ffi.Pointer)>>('fgetpos'); - late final _fgetpos = _fgetposPtr - .asFunction, ffi.Pointer)>(); + ffi.Int Function( + ffi.Pointer, ffi.Pointer<__va_list_tag>)>>('vprintf'); + late final _vprintf = _vprintfPtr.asFunction< + int Function(ffi.Pointer, ffi.Pointer<__va_list_tag>)>(); - ffi.Pointer fgets( - ffi.Pointer arg0, - int arg1, - ffi.Pointer arg2, + int vsprintf( + ffi.Pointer __s, + ffi.Pointer __format, + ffi.Pointer<__va_list_tag> __arg, ) { - return _fgets( - arg0, - arg1, - arg2, + return _vsprintf( + __s, + __format, + __arg, ); } - late final _fgetsPtr = _lookup< + late final _vsprintfPtr = _lookup< ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, ffi.Int, ffi.Pointer)>>('fgets'); - late final _fgets = _fgetsPtr.asFunction< - ffi.Pointer Function( - ffi.Pointer, int, ffi.Pointer)>(); + ffi.Int Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer<__va_list_tag>)>>('vsprintf'); + late final _vsprintf = _vsprintfPtr.asFunction< + int Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer<__va_list_tag>)>(); - ffi.Pointer fopen( - ffi.Pointer __filename, - ffi.Pointer __mode, + int snprintf( + ffi.Pointer __s, + int __maxlen, + ffi.Pointer __format, ) { - return _fopen( - __filename, - __mode, + return _snprintf( + __s, + __maxlen, + __format, ); } - late final _fopenPtr = _lookup< + late final _snprintfPtr = _lookup< ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, ffi.Pointer)>>('fopen'); - late final _fopen = _fopenPtr.asFunction< - ffi.Pointer Function( - ffi.Pointer, ffi.Pointer)>(); + ffi.Int Function(ffi.Pointer, ffi.Size, + ffi.Pointer)>>('snprintf'); + late final _snprintf = _snprintfPtr.asFunction< + int Function(ffi.Pointer, int, ffi.Pointer)>(); - int fprintf( - ffi.Pointer arg0, - ffi.Pointer arg1, + int vsnprintf( + ffi.Pointer __s, + int __maxlen, + ffi.Pointer __format, + ffi.Pointer<__va_list_tag> __arg, ) { - return _fprintf( - arg0, - arg1, + return _vsnprintf( + __s, + __maxlen, + __format, + __arg, ); } - late final _fprintfPtr = _lookup< + late final _vsnprintfPtr = _lookup< ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer, ffi.Pointer)>>('fprintf'); - late final _fprintf = _fprintfPtr - .asFunction, ffi.Pointer)>(); + ffi.Int Function(ffi.Pointer, ffi.Size, + ffi.Pointer, ffi.Pointer<__va_list_tag>)>>('vsnprintf'); + late final _vsnprintf = _vsnprintfPtr.asFunction< + int Function(ffi.Pointer, int, ffi.Pointer, + ffi.Pointer<__va_list_tag>)>(); - int fputc( - int arg0, - ffi.Pointer arg1, + int vdprintf( + int __fd, + ffi.Pointer __fmt, + ffi.Pointer<__va_list_tag> __arg, ) { - return _fputc( - arg0, - arg1, + return _vdprintf( + __fd, + __fmt, + __arg, ); } - late final _fputcPtr = - _lookup)>>( - 'fputc'); - late final _fputc = - _fputcPtr.asFunction)>(); + late final _vdprintfPtr = _lookup< + ffi.NativeFunction< + ffi.Int Function(ffi.Int, ffi.Pointer, + ffi.Pointer<__va_list_tag>)>>('vdprintf'); + late final _vdprintf = _vdprintfPtr.asFunction< + int Function(int, ffi.Pointer, ffi.Pointer<__va_list_tag>)>(); - int fputs( - ffi.Pointer arg0, - ffi.Pointer arg1, + int dprintf( + int __fd, + ffi.Pointer __fmt, ) { - return _fputs( - arg0, - arg1, + return _dprintf( + __fd, + __fmt, ); } - late final _fputsPtr = _lookup< - ffi.NativeFunction< - ffi.Int Function(ffi.Pointer, ffi.Pointer)>>('fputs'); - late final _fputs = _fputsPtr - .asFunction, ffi.Pointer)>(); + late final _dprintfPtr = _lookup< + ffi.NativeFunction)>>( + 'dprintf'); + late final _dprintf = + _dprintfPtr.asFunction)>(); - int fread( - ffi.Pointer __ptr, - int __size, - int __nitems, + int fscanf( ffi.Pointer __stream, + ffi.Pointer __format, ) { - return _fread( - __ptr, - __size, - __nitems, + return _fscanf( __stream, + __format, ); } - late final _freadPtr = _lookup< + late final _fscanfPtr = _lookup< ffi.NativeFunction< - ffi.UnsignedLong Function(ffi.Pointer, ffi.Size, ffi.Size, - ffi.Pointer)>>('fread'); - late final _fread = _freadPtr.asFunction< - int Function(ffi.Pointer, int, int, ffi.Pointer)>(); + ffi.Int Function( + ffi.Pointer, ffi.Pointer)>>('fscanf'); + late final _fscanf = _fscanfPtr + .asFunction, ffi.Pointer)>(); - ffi.Pointer freopen( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, + int scanf( + ffi.Pointer __format, ) { - return _freopen( - arg0, - arg1, - arg2, + return _scanf( + __format, ); } - late final _freopenPtr = _lookup< - ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer, - ffi.Pointer, ffi.Pointer)>>('freopen'); - late final _freopen = _freopenPtr.asFunction< - ffi.Pointer Function( - ffi.Pointer, ffi.Pointer, ffi.Pointer)>(); + late final _scanfPtr = + _lookup)>>( + 'scanf'); + late final _scanf = + _scanfPtr.asFunction)>(); - int fscanf( - ffi.Pointer arg0, - ffi.Pointer arg1, + int sscanf( + ffi.Pointer __s, + ffi.Pointer __format, ) { - return _fscanf( - arg0, - arg1, + return _sscanf( + __s, + __format, ); } - late final _fscanfPtr = _lookup< + late final _sscanfPtr = _lookup< ffi.NativeFunction< ffi.Int Function( - ffi.Pointer, ffi.Pointer)>>('fscanf'); - late final _fscanf = _fscanfPtr - .asFunction, ffi.Pointer)>(); + ffi.Pointer, ffi.Pointer)>>('sscanf'); + late final _sscanf = _sscanfPtr + .asFunction, ffi.Pointer)>(); - int fseek( - ffi.Pointer arg0, - int arg1, - int arg2, + int vfscanf( + ffi.Pointer __s, + ffi.Pointer __format, + ffi.Pointer<__va_list_tag> __arg, ) { - return _fseek( - arg0, - arg1, - arg2, + return _vfscanf( + __s, + __format, + __arg, ); } - late final _fseekPtr = _lookup< + late final _vfscanfPtr = _lookup< ffi.NativeFunction< - ffi.Int Function(ffi.Pointer, ffi.Long, ffi.Int)>>('fseek'); - late final _fseek = - _fseekPtr.asFunction, int, int)>(); + ffi.Int Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer<__va_list_tag>)>>('vfscanf'); + late final _vfscanf = _vfscanfPtr.asFunction< + int Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer<__va_list_tag>)>(); - int fsetpos( - ffi.Pointer arg0, - ffi.Pointer arg1, + int vscanf( + ffi.Pointer __format, + ffi.Pointer<__va_list_tag> __arg, ) { - return _fsetpos( - arg0, - arg1, + return _vscanf( + __format, + __arg, ); } - late final _fsetposPtr = _lookup< + late final _vscanfPtr = _lookup< ffi.NativeFunction< - ffi.Int Function(ffi.Pointer, ffi.Pointer)>>('fsetpos'); - late final _fsetpos = _fsetposPtr - .asFunction, ffi.Pointer)>(); + ffi.Int Function( + ffi.Pointer, ffi.Pointer<__va_list_tag>)>>('vscanf'); + late final _vscanf = _vscanfPtr.asFunction< + int Function(ffi.Pointer, ffi.Pointer<__va_list_tag>)>(); - int ftell( - ffi.Pointer arg0, + int vsscanf( + ffi.Pointer __s, + ffi.Pointer __format, + ffi.Pointer<__va_list_tag> __arg, ) { - return _ftell( - arg0, + return _vsscanf( + __s, + __format, + __arg, ); } - late final _ftellPtr = - _lookup)>>( - 'ftell'); - late final _ftell = _ftellPtr.asFunction)>(); + late final _vsscanfPtr = _lookup< + ffi.NativeFunction< + ffi.Int Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer<__va_list_tag>)>>('vsscanf'); + late final _vsscanf = _vsscanfPtr.asFunction< + int Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer<__va_list_tag>)>(); - int fwrite( - ffi.Pointer __ptr, - int __size, - int __nitems, + int fgetc( ffi.Pointer __stream, ) { - return _fwrite( - __ptr, - __size, - __nitems, + return _fgetc( __stream, ); } - late final _fwritePtr = _lookup< - ffi.NativeFunction< - ffi.UnsignedLong Function(ffi.Pointer, ffi.Size, ffi.Size, - ffi.Pointer)>>('fwrite'); - late final _fwrite = _fwritePtr.asFunction< - int Function(ffi.Pointer, int, int, ffi.Pointer)>(); + late final _fgetcPtr = + _lookup)>>('fgetc'); + late final _fgetc = _fgetcPtr.asFunction)>(); int getc( - ffi.Pointer arg0, + ffi.Pointer __stream, ) { return _getc( - arg0, + __stream, ); } @@ -9179,55 +9214,66 @@ class llama_cpp { _lookup>('getchar'); late final _getchar = _getcharPtr.asFunction(); - ffi.Pointer gets( - ffi.Pointer arg0, + int getc_unlocked( + ffi.Pointer __stream, ) { - return _gets( - arg0, + return _getc_unlocked( + __stream, ); } - late final _getsPtr = _lookup< - ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer)>>('gets'); - late final _gets = _getsPtr - .asFunction Function(ffi.Pointer)>(); + late final _getc_unlockedPtr = + _lookup)>>( + 'getc_unlocked'); + late final _getc_unlocked = + _getc_unlockedPtr.asFunction)>(); - void perror( - ffi.Pointer arg0, + int getchar_unlocked() { + return _getchar_unlocked(); + } + + late final _getchar_unlockedPtr = + _lookup>('getchar_unlocked'); + late final _getchar_unlocked = + _getchar_unlockedPtr.asFunction(); + + int fgetc_unlocked( + ffi.Pointer __stream, ) { - return _perror( - arg0, + return _fgetc_unlocked( + __stream, ); } - late final _perrorPtr = - _lookup)>>( - 'perror'); - late final _perror = - _perrorPtr.asFunction)>(); + late final _fgetc_unlockedPtr = + _lookup)>>( + 'fgetc_unlocked'); + late final _fgetc_unlocked = + _fgetc_unlockedPtr.asFunction)>(); - int printf( - ffi.Pointer arg0, + int fputc( + int __c, + ffi.Pointer __stream, ) { - return _printf( - arg0, + return _fputc( + __c, + __stream, ); } - late final _printfPtr = - _lookup)>>( - 'printf'); - late final _printf = - _printfPtr.asFunction)>(); + late final _fputcPtr = + _lookup)>>( + 'fputc'); + late final _fputc = + _fputcPtr.asFunction)>(); int putc( - int arg0, - ffi.Pointer arg1, + int __c, + ffi.Pointer __stream, ) { return _putc( - arg0, - arg1, + __c, + __stream, ); } @@ -9238,10 +9284,10 @@ class llama_cpp { _putcPtr.asFunction)>(); int putchar( - int arg0, + int __c, ) { return _putchar( - arg0, + __c, ); } @@ -9249,179 +9295,203 @@ class llama_cpp { _lookup>('putchar'); late final _putchar = _putcharPtr.asFunction(); - int puts( - ffi.Pointer arg0, + int fputc_unlocked( + int __c, + ffi.Pointer __stream, ) { - return _puts( - arg0, + return _fputc_unlocked( + __c, + __stream, ); } - late final _putsPtr = - _lookup)>>( - 'puts'); - late final _puts = _putsPtr.asFunction)>(); + late final _fputc_unlockedPtr = + _lookup)>>( + 'fputc_unlocked'); + late final _fputc_unlocked = + _fputc_unlockedPtr.asFunction)>(); - int remove( - ffi.Pointer arg0, + int putc_unlocked( + int __c, + ffi.Pointer __stream, ) { - return _remove( - arg0, + return _putc_unlocked( + __c, + __stream, ); } - late final _removePtr = - _lookup)>>( - 'remove'); - late final _remove = - _removePtr.asFunction)>(); + late final _putc_unlockedPtr = + _lookup)>>( + 'putc_unlocked'); + late final _putc_unlocked = + _putc_unlockedPtr.asFunction)>(); - int rename( - ffi.Pointer __old, - ffi.Pointer __new, + int putchar_unlocked( + int __c, ) { - return _rename( - __old, - __new, + return _putchar_unlocked( + __c, ); } - late final _renamePtr = _lookup< - ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer, ffi.Pointer)>>('rename'); - late final _rename = _renamePtr - .asFunction, ffi.Pointer)>(); + late final _putchar_unlockedPtr = + _lookup>( + 'putchar_unlocked'); + late final _putchar_unlocked = + _putchar_unlockedPtr.asFunction(); - void rewind( - ffi.Pointer arg0, + int getw( + ffi.Pointer __stream, ) { - return _rewind( - arg0, + return _getw( + __stream, ); } - late final _rewindPtr = - _lookup)>>( - 'rewind'); - late final _rewind = - _rewindPtr.asFunction)>(); + late final _getwPtr = + _lookup)>>('getw'); + late final _getw = _getwPtr.asFunction)>(); - int scanf( - ffi.Pointer arg0, + int putw( + int __w, + ffi.Pointer __stream, ) { - return _scanf( - arg0, + return _putw( + __w, + __stream, ); } - late final _scanfPtr = - _lookup)>>( - 'scanf'); - late final _scanf = - _scanfPtr.asFunction)>(); + late final _putwPtr = + _lookup)>>( + 'putw'); + late final _putw = + _putwPtr.asFunction)>(); - void setbuf( - ffi.Pointer arg0, - ffi.Pointer arg1, + ffi.Pointer fgets( + ffi.Pointer __s, + int __n, + ffi.Pointer __stream, ) { - return _setbuf( - arg0, - arg1, + return _fgets( + __s, + __n, + __stream, ); } - late final _setbufPtr = _lookup< + late final _fgetsPtr = _lookup< ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, ffi.Pointer)>>('setbuf'); - late final _setbuf = _setbufPtr - .asFunction, ffi.Pointer)>(); + ffi.Pointer Function( + ffi.Pointer, ffi.Int, ffi.Pointer)>>('fgets'); + late final _fgets = _fgetsPtr.asFunction< + ffi.Pointer Function( + ffi.Pointer, int, ffi.Pointer)>(); - int setvbuf( - ffi.Pointer arg0, - ffi.Pointer arg1, - int arg2, - int arg3, + int __getdelim( + ffi.Pointer> __lineptr, + ffi.Pointer __n, + int __delimiter, + ffi.Pointer __stream, ) { - return _setvbuf( - arg0, - arg1, - arg2, - arg3, + return ___getdelim( + __lineptr, + __n, + __delimiter, + __stream, ); } - late final _setvbufPtr = _lookup< + late final ___getdelimPtr = _lookup< ffi.NativeFunction< - ffi.Int Function(ffi.Pointer, ffi.Pointer, ffi.Int, - ffi.Size)>>('setvbuf'); - late final _setvbuf = _setvbufPtr.asFunction< - int Function(ffi.Pointer, ffi.Pointer, int, int)>(); + __ssize_t Function( + ffi.Pointer>, + ffi.Pointer, + ffi.Int, + ffi.Pointer)>>('__getdelim'); + late final ___getdelim = ___getdelimPtr.asFunction< + int Function(ffi.Pointer>, ffi.Pointer, + int, ffi.Pointer)>(); - int sprintf( - ffi.Pointer arg0, - ffi.Pointer arg1, + int getdelim( + ffi.Pointer> __lineptr, + ffi.Pointer __n, + int __delimiter, + ffi.Pointer __stream, ) { - return _sprintf( - arg0, - arg1, + return _getdelim( + __lineptr, + __n, + __delimiter, + __stream, ); } - late final _sprintfPtr = _lookup< + late final _getdelimPtr = _lookup< ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer, ffi.Pointer)>>('sprintf'); - late final _sprintf = _sprintfPtr - .asFunction, ffi.Pointer)>(); + __ssize_t Function(ffi.Pointer>, + ffi.Pointer, ffi.Int, ffi.Pointer)>>('getdelim'); + late final _getdelim = _getdelimPtr.asFunction< + int Function(ffi.Pointer>, ffi.Pointer, + int, ffi.Pointer)>(); - int sscanf( - ffi.Pointer arg0, - ffi.Pointer arg1, + int getline( + ffi.Pointer> __lineptr, + ffi.Pointer __n, + ffi.Pointer __stream, ) { - return _sscanf( - arg0, - arg1, + return _getline( + __lineptr, + __n, + __stream, ); } - late final _sscanfPtr = _lookup< + late final _getlinePtr = _lookup< ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer, ffi.Pointer)>>('sscanf'); - late final _sscanf = _sscanfPtr - .asFunction, ffi.Pointer)>(); + __ssize_t Function(ffi.Pointer>, + ffi.Pointer, ffi.Pointer)>>('getline'); + late final _getline = _getlinePtr.asFunction< + int Function(ffi.Pointer>, ffi.Pointer, + ffi.Pointer)>(); - ffi.Pointer tmpfile() { - return _tmpfile(); + int fputs( + ffi.Pointer __s, + ffi.Pointer __stream, + ) { + return _fputs( + __s, + __stream, + ); } - late final _tmpfilePtr = - _lookup Function()>>('tmpfile'); - late final _tmpfile = _tmpfilePtr.asFunction Function()>(); + late final _fputsPtr = _lookup< + ffi.NativeFunction< + ffi.Int Function(ffi.Pointer, ffi.Pointer)>>('fputs'); + late final _fputs = _fputsPtr + .asFunction, ffi.Pointer)>(); - ffi.Pointer tmpnam( - ffi.Pointer arg0, + int puts( + ffi.Pointer __s, ) { - return _tmpnam( - arg0, + return _puts( + __s, ); } - late final _tmpnamPtr = _lookup< - ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer)>>('tmpnam'); - late final _tmpnam = _tmpnamPtr - .asFunction Function(ffi.Pointer)>(); + late final _putsPtr = + _lookup)>>( + 'puts'); + late final _puts = _putsPtr.asFunction)>(); int ungetc( - int arg0, - ffi.Pointer arg1, + int __c, + ffi.Pointer __stream, ) { return _ungetc( - arg0, - arg1, + __c, + __stream, ); } @@ -9431,936 +9501,511 @@ class llama_cpp { late final _ungetc = _ungetcPtr.asFunction)>(); - int vfprintf( - ffi.Pointer arg0, - ffi.Pointer arg1, - va_list arg2, + int fread( + ffi.Pointer __ptr, + int __size, + int __n, + ffi.Pointer __stream, ) { - return _vfprintf( - arg0, - arg1, - arg2, + return _fread( + __ptr, + __size, + __n, + __stream, ); } - late final _vfprintfPtr = _lookup< + late final _freadPtr = _lookup< ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer, ffi.Pointer, va_list)>>('vfprintf'); - late final _vfprintf = _vfprintfPtr.asFunction< - int Function(ffi.Pointer, ffi.Pointer, va_list)>(); + ffi.UnsignedLong Function(ffi.Pointer, ffi.Size, ffi.Size, + ffi.Pointer)>>('fread'); + late final _fread = _freadPtr.asFunction< + int Function(ffi.Pointer, int, int, ffi.Pointer)>(); - int vprintf( - ffi.Pointer arg0, - va_list arg1, + int fwrite( + ffi.Pointer __ptr, + int __size, + int __n, + ffi.Pointer __s, ) { - return _vprintf( - arg0, - arg1, + return _fwrite( + __ptr, + __size, + __n, + __s, ); } - late final _vprintfPtr = _lookup< - ffi.NativeFunction, va_list)>>( - 'vprintf'); - late final _vprintf = - _vprintfPtr.asFunction, va_list)>(); + late final _fwritePtr = _lookup< + ffi.NativeFunction< + ffi.UnsignedLong Function(ffi.Pointer, ffi.Size, ffi.Size, + ffi.Pointer)>>('fwrite'); + late final _fwrite = _fwritePtr.asFunction< + int Function(ffi.Pointer, int, int, ffi.Pointer)>(); - int vsprintf( - ffi.Pointer arg0, - ffi.Pointer arg1, - va_list arg2, + int fread_unlocked( + ffi.Pointer __ptr, + int __size, + int __n, + ffi.Pointer __stream, ) { - return _vsprintf( - arg0, - arg1, - arg2, + return _fread_unlocked( + __ptr, + __size, + __n, + __stream, ); } - late final _vsprintfPtr = _lookup< + late final _fread_unlockedPtr = _lookup< ffi.NativeFunction< - ffi.Int Function(ffi.Pointer, ffi.Pointer, - va_list)>>('vsprintf'); - late final _vsprintf = _vsprintfPtr.asFunction< - int Function(ffi.Pointer, ffi.Pointer, va_list)>(); + ffi.Size Function(ffi.Pointer, ffi.Size, ffi.Size, + ffi.Pointer)>>('fread_unlocked'); + late final _fread_unlocked = _fread_unlockedPtr.asFunction< + int Function(ffi.Pointer, int, int, ffi.Pointer)>(); - ffi.Pointer ctermid( - ffi.Pointer arg0, + int fwrite_unlocked( + ffi.Pointer __ptr, + int __size, + int __n, + ffi.Pointer __stream, ) { - return _ctermid( - arg0, + return _fwrite_unlocked( + __ptr, + __size, + __n, + __stream, ); } - late final _ctermidPtr = _lookup< + late final _fwrite_unlockedPtr = _lookup< ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer)>>('ctermid'); - late final _ctermid = _ctermidPtr - .asFunction Function(ffi.Pointer)>(); + ffi.Size Function(ffi.Pointer, ffi.Size, ffi.Size, + ffi.Pointer)>>('fwrite_unlocked'); + late final _fwrite_unlocked = _fwrite_unlockedPtr.asFunction< + int Function(ffi.Pointer, int, int, ffi.Pointer)>(); - ffi.Pointer fdopen( - int arg0, - ffi.Pointer arg1, + int fseek( + ffi.Pointer __stream, + int __off, + int __whence, ) { - return _fdopen( - arg0, - arg1, + return _fseek( + __stream, + __off, + __whence, ); } - late final _fdopenPtr = _lookup< + late final _fseekPtr = _lookup< ffi.NativeFunction< - ffi.Pointer Function( - ffi.Int, ffi.Pointer)>>('fdopen'); - late final _fdopen = _fdopenPtr - .asFunction Function(int, ffi.Pointer)>(); + ffi.Int Function(ffi.Pointer, ffi.Long, ffi.Int)>>('fseek'); + late final _fseek = + _fseekPtr.asFunction, int, int)>(); - int fileno( - ffi.Pointer arg0, + int ftell( + ffi.Pointer __stream, ) { - return _fileno( - arg0, + return _ftell( + __stream, ); } - late final _filenoPtr = - _lookup)>>( - 'fileno'); - late final _fileno = _filenoPtr.asFunction)>(); + late final _ftellPtr = + _lookup)>>( + 'ftell'); + late final _ftell = _ftellPtr.asFunction)>(); - int pclose( - ffi.Pointer arg0, + void rewind( + ffi.Pointer __stream, ) { - return _pclose( - arg0, + return _rewind( + __stream, ); } - late final _pclosePtr = - _lookup)>>( - 'pclose'); - late final _pclose = _pclosePtr.asFunction)>(); + late final _rewindPtr = + _lookup)>>( + 'rewind'); + late final _rewind = + _rewindPtr.asFunction)>(); - ffi.Pointer popen( - ffi.Pointer arg0, - ffi.Pointer arg1, + int fseeko( + ffi.Pointer __stream, + int __off, + int __whence, ) { - return _popen( - arg0, - arg1, + return _fseeko( + __stream, + __off, + __whence, ); } - late final _popenPtr = _lookup< + late final _fseekoPtr = _lookup< ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, ffi.Pointer)>>('popen'); - late final _popen = _popenPtr.asFunction< - ffi.Pointer Function( - ffi.Pointer, ffi.Pointer)>(); + ffi.Int Function(ffi.Pointer, __off_t, ffi.Int)>>('fseeko'); + late final _fseeko = + _fseekoPtr.asFunction, int, int)>(); - int __srget( - ffi.Pointer arg0, + int ftello( + ffi.Pointer __stream, ) { - return ___srget( - arg0, + return _ftello( + __stream, ); } - late final ___srgetPtr = - _lookup)>>( - '__srget'); - late final ___srget = - ___srgetPtr.asFunction)>(); + late final _ftelloPtr = + _lookup)>>( + 'ftello'); + late final _ftello = _ftelloPtr.asFunction)>(); - int __svfscanf( - ffi.Pointer arg0, - ffi.Pointer arg1, - va_list arg2, + int fgetpos( + ffi.Pointer __stream, + ffi.Pointer __pos, ) { - return ___svfscanf( - arg0, - arg1, - arg2, + return _fgetpos( + __stream, + __pos, ); } - late final ___svfscanfPtr = _lookup< + late final _fgetposPtr = _lookup< ffi.NativeFunction< - ffi.Int Function(ffi.Pointer, ffi.Pointer, - va_list)>>('__svfscanf'); - late final ___svfscanf = ___svfscanfPtr.asFunction< - int Function(ffi.Pointer, ffi.Pointer, va_list)>(); + ffi.Int Function(ffi.Pointer, ffi.Pointer)>>('fgetpos'); + late final _fgetpos = _fgetposPtr + .asFunction, ffi.Pointer)>(); - int __swbuf( - int arg0, - ffi.Pointer arg1, + int fsetpos( + ffi.Pointer __stream, + ffi.Pointer __pos, ) { - return ___swbuf( - arg0, - arg1, + return _fsetpos( + __stream, + __pos, ); } - late final ___swbufPtr = - _lookup)>>( - '__swbuf'); - late final ___swbuf = - ___swbufPtr.asFunction)>(); + late final _fsetposPtr = _lookup< + ffi.NativeFunction< + ffi.Int Function(ffi.Pointer, ffi.Pointer)>>('fsetpos'); + late final _fsetpos = _fsetposPtr + .asFunction, ffi.Pointer)>(); - void flockfile( - ffi.Pointer arg0, + void clearerr( + ffi.Pointer __stream, ) { - return _flockfile( - arg0, + return _clearerr( + __stream, ); } - late final _flockfilePtr = + late final _clearerrPtr = _lookup)>>( - 'flockfile'); - late final _flockfile = - _flockfilePtr.asFunction)>(); + 'clearerr'); + late final _clearerr = + _clearerrPtr.asFunction)>(); - int ftrylockfile( - ffi.Pointer arg0, + int feof( + ffi.Pointer __stream, ) { - return _ftrylockfile( - arg0, + return _feof( + __stream, ); } - late final _ftrylockfilePtr = + late final _feofPtr = + _lookup)>>('feof'); + late final _feof = _feofPtr.asFunction)>(); + + int ferror( + ffi.Pointer __stream, + ) { + return _ferror( + __stream, + ); + } + + late final _ferrorPtr = _lookup)>>( - 'ftrylockfile'); - late final _ftrylockfile = - _ftrylockfilePtr.asFunction)>(); + 'ferror'); + late final _ferror = _ferrorPtr.asFunction)>(); - void funlockfile( - ffi.Pointer arg0, + void clearerr_unlocked( + ffi.Pointer __stream, ) { - return _funlockfile( - arg0, + return _clearerr_unlocked( + __stream, ); } - late final _funlockfilePtr = + late final _clearerr_unlockedPtr = _lookup)>>( - 'funlockfile'); - late final _funlockfile = - _funlockfilePtr.asFunction)>(); + 'clearerr_unlocked'); + late final _clearerr_unlocked = + _clearerr_unlockedPtr.asFunction)>(); - int getc_unlocked( - ffi.Pointer arg0, + int feof_unlocked( + ffi.Pointer __stream, ) { - return _getc_unlocked( - arg0, + return _feof_unlocked( + __stream, ); } - late final _getc_unlockedPtr = + late final _feof_unlockedPtr = _lookup)>>( - 'getc_unlocked'); - late final _getc_unlocked = - _getc_unlockedPtr.asFunction)>(); + 'feof_unlocked'); + late final _feof_unlocked = + _feof_unlockedPtr.asFunction)>(); - int getchar_unlocked() { - return _getchar_unlocked(); + int ferror_unlocked( + ffi.Pointer __stream, + ) { + return _ferror_unlocked( + __stream, + ); } - late final _getchar_unlockedPtr = - _lookup>('getchar_unlocked'); - late final _getchar_unlocked = - _getchar_unlockedPtr.asFunction(); + late final _ferror_unlockedPtr = + _lookup)>>( + 'ferror_unlocked'); + late final _ferror_unlocked = + _ferror_unlockedPtr.asFunction)>(); - int putc_unlocked( - int arg0, - ffi.Pointer arg1, + void perror( + ffi.Pointer __s, ) { - return _putc_unlocked( - arg0, - arg1, + return _perror( + __s, ); } - late final _putc_unlockedPtr = - _lookup)>>( - 'putc_unlocked'); - late final _putc_unlocked = - _putc_unlockedPtr.asFunction)>(); + late final _perrorPtr = + _lookup)>>( + 'perror'); + late final _perror = + _perrorPtr.asFunction)>(); - int putchar_unlocked( - int arg0, + int fileno( + ffi.Pointer __stream, ) { - return _putchar_unlocked( - arg0, + return _fileno( + __stream, ); } - late final _putchar_unlockedPtr = - _lookup>( - 'putchar_unlocked'); - late final _putchar_unlocked = - _putchar_unlockedPtr.asFunction(); + late final _filenoPtr = + _lookup)>>( + 'fileno'); + late final _fileno = _filenoPtr.asFunction)>(); - int getw( - ffi.Pointer arg0, + int fileno_unlocked( + ffi.Pointer __stream, ) { - return _getw( - arg0, + return _fileno_unlocked( + __stream, ); } - late final _getwPtr = - _lookup)>>('getw'); - late final _getw = _getwPtr.asFunction)>(); + late final _fileno_unlockedPtr = + _lookup)>>( + 'fileno_unlocked'); + late final _fileno_unlocked = + _fileno_unlockedPtr.asFunction)>(); - int putw( - int arg0, - ffi.Pointer arg1, + int pclose( + ffi.Pointer __stream, ) { - return _putw( - arg0, - arg1, + return _pclose( + __stream, ); } - late final _putwPtr = - _lookup)>>( - 'putw'); - late final _putw = - _putwPtr.asFunction)>(); + late final _pclosePtr = + _lookup)>>( + 'pclose'); + late final _pclose = _pclosePtr.asFunction)>(); - ffi.Pointer tempnam( - ffi.Pointer __dir, - ffi.Pointer __prefix, + ffi.Pointer popen( + ffi.Pointer __command, + ffi.Pointer __modes, ) { - return _tempnam( - __dir, - __prefix, + return _popen( + __command, + __modes, ); } - late final _tempnamPtr = _lookup< + late final _popenPtr = _lookup< ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, ffi.Pointer)>>('tempnam'); - late final _tempnam = _tempnamPtr.asFunction< - ffi.Pointer Function( + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>>('popen'); + late final _popen = _popenPtr.asFunction< + ffi.Pointer Function( ffi.Pointer, ffi.Pointer)>(); - int fseeko( - ffi.Pointer __stream, - int __offset, - int __whence, + ffi.Pointer ctermid( + ffi.Pointer __s, ) { - return _fseeko( - __stream, - __offset, - __whence, + return _ctermid( + __s, ); } - late final _fseekoPtr = _lookup< + late final _ctermidPtr = _lookup< ffi.NativeFunction< - ffi.Int Function(ffi.Pointer, off_t, ffi.Int)>>('fseeko'); - late final _fseeko = - _fseekoPtr.asFunction, int, int)>(); + ffi.Pointer Function(ffi.Pointer)>>('ctermid'); + late final _ctermid = _ctermidPtr + .asFunction Function(ffi.Pointer)>(); - int ftello( + void flockfile( ffi.Pointer __stream, ) { - return _ftello( + return _flockfile( __stream, ); } - late final _ftelloPtr = - _lookup)>>('ftello'); - late final _ftello = _ftelloPtr.asFunction)>(); + late final _flockfilePtr = + _lookup)>>( + 'flockfile'); + late final _flockfile = + _flockfilePtr.asFunction)>(); - int snprintf( - ffi.Pointer __str, - int __size, - ffi.Pointer __format, + int ftrylockfile( + ffi.Pointer __stream, ) { - return _snprintf( - __str, - __size, - __format, + return _ftrylockfile( + __stream, ); } - late final _snprintfPtr = _lookup< - ffi.NativeFunction< - ffi.Int Function(ffi.Pointer, ffi.Size, - ffi.Pointer)>>('snprintf'); - late final _snprintf = _snprintfPtr.asFunction< - int Function(ffi.Pointer, int, ffi.Pointer)>(); + late final _ftrylockfilePtr = + _lookup)>>( + 'ftrylockfile'); + late final _ftrylockfile = + _ftrylockfilePtr.asFunction)>(); - int vfscanf( + void funlockfile( ffi.Pointer __stream, - ffi.Pointer __format, - va_list arg2, ) { - return _vfscanf( + return _funlockfile( __stream, - __format, - arg2, ); } - late final _vfscanfPtr = _lookup< - ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer, ffi.Pointer, va_list)>>('vfscanf'); - late final _vfscanf = _vfscanfPtr.asFunction< - int Function(ffi.Pointer, ffi.Pointer, va_list)>(); + late final _funlockfilePtr = + _lookup)>>( + 'funlockfile'); + late final _funlockfile = + _funlockfilePtr.asFunction)>(); - int vscanf( - ffi.Pointer __format, - va_list arg1, + int __uflow( + ffi.Pointer arg0, ) { - return _vscanf( - __format, - arg1, + return ___uflow( + arg0, ); } - late final _vscanfPtr = _lookup< - ffi.NativeFunction, va_list)>>( - 'vscanf'); - late final _vscanf = - _vscanfPtr.asFunction, va_list)>(); + late final ___uflowPtr = + _lookup)>>( + '__uflow'); + late final ___uflow = + ___uflowPtr.asFunction)>(); - int vsnprintf( - ffi.Pointer __str, - int __size, - ffi.Pointer __format, - va_list arg3, + int __overflow( + ffi.Pointer arg0, + int arg1, ) { - return _vsnprintf( - __str, - __size, - __format, - arg3, + return ___overflow( + arg0, + arg1, ); } - late final _vsnprintfPtr = _lookup< - ffi.NativeFunction< - ffi.Int Function(ffi.Pointer, ffi.Size, - ffi.Pointer, va_list)>>('vsnprintf'); - late final _vsnprintf = _vsnprintfPtr.asFunction< - int Function( - ffi.Pointer, int, ffi.Pointer, va_list)>(); + late final ___overflowPtr = + _lookup, ffi.Int)>>( + '__overflow'); + late final ___overflow = + ___overflowPtr.asFunction, int)>(); - int vsscanf( - ffi.Pointer __str, - ffi.Pointer __format, - va_list arg2, - ) { - return _vsscanf( - __str, - __format, - arg2, - ); + llama_model_params llama_model_default_params() { + return _llama_model_default_params(); } - late final _vsscanfPtr = _lookup< - ffi.NativeFunction< - ffi.Int Function(ffi.Pointer, ffi.Pointer, - va_list)>>('vsscanf'); - late final _vsscanf = _vsscanfPtr.asFunction< - int Function(ffi.Pointer, ffi.Pointer, va_list)>(); + late final _llama_model_default_paramsPtr = + _lookup>( + 'llama_model_default_params'); + late final _llama_model_default_params = _llama_model_default_paramsPtr + .asFunction(); - int dprintf( - int arg0, - ffi.Pointer arg1, - ) { - return _dprintf( - arg0, - arg1, - ); + llama_context_params llama_context_default_params() { + return _llama_context_default_params(); } - late final _dprintfPtr = _lookup< - ffi.NativeFunction)>>( - 'dprintf'); - late final _dprintf = - _dprintfPtr.asFunction)>(); + late final _llama_context_default_paramsPtr = + _lookup>( + 'llama_context_default_params'); + late final _llama_context_default_params = _llama_context_default_paramsPtr + .asFunction(); - int vdprintf( - int arg0, - ffi.Pointer arg1, - va_list arg2, - ) { - return _vdprintf( - arg0, - arg1, - arg2, - ); + llama_model_quantize_params llama_model_quantize_default_params() { + return _llama_model_quantize_default_params(); } - late final _vdprintfPtr = _lookup< - ffi.NativeFunction< - ffi.Int Function( - ffi.Int, ffi.Pointer, va_list)>>('vdprintf'); - late final _vdprintf = _vdprintfPtr - .asFunction, va_list)>(); + late final _llama_model_quantize_default_paramsPtr = + _lookup>( + 'llama_model_quantize_default_params'); + late final _llama_model_quantize_default_params = + _llama_model_quantize_default_paramsPtr + .asFunction(); - int getdelim( - ffi.Pointer> __linep, - ffi.Pointer __linecapp, - int __delimiter, - ffi.Pointer __stream, - ) { - return _getdelim( - __linep, - __linecapp, - __delimiter, - __stream, - ); + void llama_backend_init() { + return _llama_backend_init(); } - late final _getdelimPtr = _lookup< - ffi.NativeFunction< - ssize_t Function(ffi.Pointer>, - ffi.Pointer, ffi.Int, ffi.Pointer)>>('getdelim'); - late final _getdelim = _getdelimPtr.asFunction< - int Function(ffi.Pointer>, ffi.Pointer, - int, ffi.Pointer)>(); + late final _llama_backend_initPtr = + _lookup>('llama_backend_init'); + late final _llama_backend_init = + _llama_backend_initPtr.asFunction(); - int getline( - ffi.Pointer> __linep, - ffi.Pointer __linecapp, - ffi.Pointer __stream, + void llama_numa_init( + int numa, ) { - return _getline( - __linep, - __linecapp, - __stream, + return _llama_numa_init( + numa, ); } - late final _getlinePtr = _lookup< - ffi.NativeFunction< - ssize_t Function(ffi.Pointer>, - ffi.Pointer, ffi.Pointer)>>('getline'); - late final _getline = _getlinePtr.asFunction< - int Function(ffi.Pointer>, ffi.Pointer, - ffi.Pointer)>(); + late final _llama_numa_initPtr = + _lookup>( + 'llama_numa_init'); + late final _llama_numa_init = + _llama_numa_initPtr.asFunction(); - ffi.Pointer fmemopen( - ffi.Pointer __buf, - int __size, - ffi.Pointer __mode, + void llama_backend_free() { + return _llama_backend_free(); + } + + late final _llama_backend_freePtr = + _lookup>('llama_backend_free'); + late final _llama_backend_free = + _llama_backend_freePtr.asFunction(); + + ffi.Pointer llama_load_model_from_file( + ffi.Pointer path_model, + llama_model_params params, ) { - return _fmemopen( - __buf, - __size, - __mode, + return _llama_load_model_from_file( + path_model, + params, ); } - late final _fmemopenPtr = _lookup< - ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer, ffi.Size, - ffi.Pointer)>>('fmemopen'); - late final _fmemopen = _fmemopenPtr.asFunction< - ffi.Pointer Function( - ffi.Pointer, int, ffi.Pointer)>(); - - ffi.Pointer open_memstream( - ffi.Pointer> __bufp, - ffi.Pointer __sizep, - ) { - return _open_memstream( - __bufp, - __sizep, - ); - } - - late final _open_memstreamPtr = _lookup< - ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer>, - ffi.Pointer)>>('open_memstream'); - late final _open_memstream = _open_memstreamPtr.asFunction< - ffi.Pointer Function( - ffi.Pointer>, ffi.Pointer)>(); - - late final ffi.Pointer _sys_nerr = _lookup('sys_nerr'); - - int get sys_nerr => _sys_nerr.value; - - set sys_nerr(int value) => _sys_nerr.value = value; - - late final ffi.Pointer>> _sys_errlist = - _lookup>>('sys_errlist'); - - ffi.Pointer> get sys_errlist => _sys_errlist.value; - - set sys_errlist(ffi.Pointer> value) => - _sys_errlist.value = value; - - int asprintf( - ffi.Pointer> arg0, - ffi.Pointer arg1, - ) { - return _asprintf( - arg0, - arg1, - ); - } - - late final _asprintfPtr = _lookup< - ffi.NativeFunction< - ffi.Int Function(ffi.Pointer>, - ffi.Pointer)>>('asprintf'); - late final _asprintf = _asprintfPtr.asFunction< - int Function( - ffi.Pointer>, ffi.Pointer)>(); - - ffi.Pointer ctermid_r( - ffi.Pointer arg0, - ) { - return _ctermid_r( - arg0, - ); - } - - late final _ctermid_rPtr = _lookup< - ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer)>>('ctermid_r'); - late final _ctermid_r = _ctermid_rPtr - .asFunction Function(ffi.Pointer)>(); - - ffi.Pointer fgetln( - ffi.Pointer arg0, - ffi.Pointer arg1, - ) { - return _fgetln( - arg0, - arg1, - ); - } - - late final _fgetlnPtr = _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, ffi.Pointer)>>('fgetln'); - late final _fgetln = _fgetlnPtr.asFunction< - ffi.Pointer Function( - ffi.Pointer, ffi.Pointer)>(); - - ffi.Pointer fmtcheck( - ffi.Pointer arg0, - ffi.Pointer arg1, - ) { - return _fmtcheck( - arg0, - arg1, - ); - } - - late final _fmtcheckPtr = _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, ffi.Pointer)>>('fmtcheck'); - late final _fmtcheck = _fmtcheckPtr.asFunction< - ffi.Pointer Function( - ffi.Pointer, ffi.Pointer)>(); - - int fpurge( - ffi.Pointer arg0, - ) { - return _fpurge( - arg0, - ); - } - - late final _fpurgePtr = - _lookup)>>( - 'fpurge'); - late final _fpurge = _fpurgePtr.asFunction)>(); - - void setbuffer( - ffi.Pointer arg0, - ffi.Pointer arg1, - int arg2, - ) { - return _setbuffer( - arg0, - arg1, - arg2, - ); - } - - late final _setbufferPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, ffi.Pointer, ffi.Int)>>('setbuffer'); - late final _setbuffer = _setbufferPtr.asFunction< - void Function(ffi.Pointer, ffi.Pointer, int)>(); - - int setlinebuf( - ffi.Pointer arg0, - ) { - return _setlinebuf( - arg0, - ); - } - - late final _setlinebufPtr = - _lookup)>>( - 'setlinebuf'); - late final _setlinebuf = - _setlinebufPtr.asFunction)>(); - - int vasprintf( - ffi.Pointer> arg0, - ffi.Pointer arg1, - va_list arg2, - ) { - return _vasprintf( - arg0, - arg1, - arg2, - ); - } - - late final _vasprintfPtr = _lookup< - ffi.NativeFunction< - ffi.Int Function(ffi.Pointer>, - ffi.Pointer, va_list)>>('vasprintf'); - late final _vasprintf = _vasprintfPtr.asFunction< - int Function(ffi.Pointer>, ffi.Pointer, - va_list)>(); - - ffi.Pointer funopen( - ffi.Pointer arg0, - ffi.Pointer< - ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer, ffi.Pointer, ffi.Int)>> - arg1, - ffi.Pointer< - ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer, ffi.Pointer, ffi.Int)>> - arg2, - ffi.Pointer< - ffi.NativeFunction< - fpos_t Function(ffi.Pointer, fpos_t, ffi.Int)>> - arg3, - ffi.Pointer)>> - arg4, - ) { - return _funopen( - arg0, - arg1, - arg2, - arg3, - arg4, - ); - } - - late final _funopenPtr = _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer< - ffi.NativeFunction< - ffi.Int Function(ffi.Pointer, - ffi.Pointer, ffi.Int)>>, - ffi.Pointer< - ffi.NativeFunction< - ffi.Int Function(ffi.Pointer, - ffi.Pointer, ffi.Int)>>, - ffi.Pointer< - ffi.NativeFunction< - fpos_t Function(ffi.Pointer, fpos_t, ffi.Int)>>, - ffi.Pointer< - ffi.NativeFunction< - ffi.Int Function(ffi.Pointer)>>)>>('funopen'); - late final _funopen = _funopenPtr.asFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer< - ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer, ffi.Pointer, ffi.Int)>>, - ffi.Pointer< - ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer, ffi.Pointer, ffi.Int)>>, - ffi.Pointer< - ffi.NativeFunction< - fpos_t Function(ffi.Pointer, fpos_t, ffi.Int)>>, - ffi.Pointer< - ffi.NativeFunction)>>)>(); - - int __sprintf_chk( - ffi.Pointer arg0, - int arg1, - int arg2, - ffi.Pointer arg3, - ) { - return ___sprintf_chk( - arg0, - arg1, - arg2, - arg3, - ); - } - - late final ___sprintf_chkPtr = _lookup< - ffi.NativeFunction< - ffi.Int Function(ffi.Pointer, ffi.Int, ffi.Size, - ffi.Pointer)>>('__sprintf_chk'); - late final ___sprintf_chk = ___sprintf_chkPtr.asFunction< - int Function(ffi.Pointer, int, int, ffi.Pointer)>(); - - int __snprintf_chk( - ffi.Pointer arg0, - int arg1, - int arg2, - int arg3, - ffi.Pointer arg4, - ) { - return ___snprintf_chk( - arg0, - arg1, - arg2, - arg3, - arg4, - ); - } - - late final ___snprintf_chkPtr = _lookup< - ffi.NativeFunction< - ffi.Int Function(ffi.Pointer, ffi.Size, ffi.Int, ffi.Size, - ffi.Pointer)>>('__snprintf_chk'); - late final ___snprintf_chk = ___snprintf_chkPtr.asFunction< - int Function( - ffi.Pointer, int, int, int, ffi.Pointer)>(); - - int __vsprintf_chk( - ffi.Pointer arg0, - int arg1, - int arg2, - ffi.Pointer arg3, - va_list arg4, - ) { - return ___vsprintf_chk( - arg0, - arg1, - arg2, - arg3, - arg4, - ); - } - - late final ___vsprintf_chkPtr = _lookup< - ffi.NativeFunction< - ffi.Int Function(ffi.Pointer, ffi.Int, ffi.Size, - ffi.Pointer, va_list)>>('__vsprintf_chk'); - late final ___vsprintf_chk = ___vsprintf_chkPtr.asFunction< - int Function( - ffi.Pointer, int, int, ffi.Pointer, va_list)>(); - - int __vsnprintf_chk( - ffi.Pointer arg0, - int arg1, - int arg2, - int arg3, - ffi.Pointer arg4, - va_list arg5, - ) { - return ___vsnprintf_chk( - arg0, - arg1, - arg2, - arg3, - arg4, - arg5, - ); - } - - late final ___vsnprintf_chkPtr = _lookup< - ffi.NativeFunction< - ffi.Int Function(ffi.Pointer, ffi.Size, ffi.Int, ffi.Size, - ffi.Pointer, va_list)>>('__vsnprintf_chk'); - late final ___vsnprintf_chk = ___vsnprintf_chkPtr.asFunction< - int Function(ffi.Pointer, int, int, int, ffi.Pointer, - va_list)>(); - - llama_model_params llama_model_default_params() { - return _llama_model_default_params(); - } - - late final _llama_model_default_paramsPtr = - _lookup>( - 'llama_model_default_params'); - late final _llama_model_default_params = _llama_model_default_paramsPtr - .asFunction(); - - llama_context_params llama_context_default_params() { - return _llama_context_default_params(); - } - - late final _llama_context_default_paramsPtr = - _lookup>( - 'llama_context_default_params'); - late final _llama_context_default_params = _llama_context_default_paramsPtr - .asFunction(); - - llama_model_quantize_params llama_model_quantize_default_params() { - return _llama_model_quantize_default_params(); - } - - late final _llama_model_quantize_default_paramsPtr = - _lookup>( - 'llama_model_quantize_default_params'); - late final _llama_model_quantize_default_params = - _llama_model_quantize_default_paramsPtr - .asFunction(); - - void llama_backend_init( - bool numa, - ) { - return _llama_backend_init( - numa, - ); - } - - late final _llama_backend_initPtr = - _lookup>( - 'llama_backend_init'); - late final _llama_backend_init = - _llama_backend_initPtr.asFunction(); - - void llama_backend_free() { - return _llama_backend_free(); - } - - late final _llama_backend_freePtr = - _lookup>('llama_backend_free'); - late final _llama_backend_free = - _llama_backend_freePtr.asFunction(); - - ffi.Pointer llama_load_model_from_file( - ffi.Pointer path_model, - llama_model_params params, - ) { - return _llama_load_model_from_file( - path_model, - params, - ); - } - - late final _llama_load_model_from_filePtr = _lookup< + late final _llama_load_model_from_filePtr = _lookup< ffi.NativeFunction< ffi.Pointer Function(ffi.Pointer, llama_model_params)>>('llama_load_model_from_file'); @@ -10429,10 +10074,38 @@ class llama_cpp { } late final _llama_max_devicesPtr = - _lookup>('llama_max_devices'); + _lookup>('llama_max_devices'); late final _llama_max_devices = _llama_max_devicesPtr.asFunction(); + bool llama_supports_mmap() { + return _llama_supports_mmap(); + } + + late final _llama_supports_mmapPtr = + _lookup>('llama_supports_mmap'); + late final _llama_supports_mmap = + _llama_supports_mmapPtr.asFunction(); + + bool llama_supports_mlock() { + return _llama_supports_mlock(); + } + + late final _llama_supports_mlockPtr = + _lookup>('llama_supports_mlock'); + late final _llama_supports_mlock = + _llama_supports_mlockPtr.asFunction(); + + bool llama_supports_gpu_offload() { + return _llama_supports_gpu_offload(); + } + + late final _llama_supports_gpu_offloadPtr = + _lookup>( + 'llama_supports_gpu_offload'); + late final _llama_supports_gpu_offload = + _llama_supports_gpu_offloadPtr.asFunction(); + bool llama_mmap_supported() { return _llama_mmap_supported(); } @@ -11279,6 +10952,24 @@ class llama_cpp { late final _llama_get_embeddings = _llama_get_embeddingsPtr.asFunction< ffi.Pointer Function(ffi.Pointer)>(); + ffi.Pointer llama_get_embeddings_ith( + ffi.Pointer ctx, + int i, + ) { + return _llama_get_embeddings_ith( + ctx, + i, + ); + } + + late final _llama_get_embeddings_ithPtr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Int32)>>('llama_get_embeddings_ith'); + late final _llama_get_embeddings_ith = + _llama_get_embeddings_ithPtr.asFunction< + ffi.Pointer Function(ffi.Pointer, int)>(); + ffi.Pointer llama_token_get_text( ffi.Pointer model, int token, @@ -11518,6 +11209,57 @@ class llama_cpp { int Function( ffi.Pointer, int, ffi.Pointer, int)>(); + /// Apply chat template. Inspired by hf apply_chat_template() on python. + /// Both "model" and "custom_template" are optional, but at least one is required. "custom_template" has higher precedence than "model" + /// NOTE: This function only support some known jinja templates. It is not a jinja parser. + /// @param tmpl A Jinja template to use for this chat. If this is nullptr, the model’s default chat template will be used instead. + /// @param chat Pointer to a list of multiple llama_chat_message + /// @param n_msg Number of llama_chat_message in this chat + /// @param add_ass Whether to end the prompt with the token(s) that indicate the start of an assistant message. + /// @param buf A buffer to hold the output formatted prompt. The recommended alloc size is 2 * (total number of characters of all messages) + /// @param length The size of the allocated buffer + /// @return The total number of bytes of the formatted prompt. If is it larger than the size of buffer, you may need to re-alloc it and then re-apply the template. + int llama_chat_apply_template( + ffi.Pointer model, + ffi.Pointer tmpl, + ffi.Pointer chat, + int n_msg, + bool add_ass, + ffi.Pointer buf, + int length, + ) { + return _llama_chat_apply_template( + model, + tmpl, + chat, + n_msg, + add_ass, + buf, + length, + ); + } + + late final _llama_chat_apply_templatePtr = _lookup< + ffi.NativeFunction< + ffi.Int32 Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Size, + ffi.Bool, + ffi.Pointer, + ffi.Int32)>>('llama_chat_apply_template'); + late final _llama_chat_apply_template = + _llama_chat_apply_templatePtr.asFunction< + int Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + int, + bool, + ffi.Pointer, + int)>(); + ffi.Pointer llama_grammar_init( ffi.Pointer> rules, int n_rules, @@ -12207,97 +11949,15 @@ class llama_cpp { void Function(ffi.Pointer, ffi.Pointer)>(); } -final class __mbstate_t extends ffi.Union { - @ffi.Array.multi([128]) - external ffi.Array __mbstate8; - - @ffi.LongLong() - external int _mbstateL; -} - -final class __darwin_pthread_handler_rec extends ffi.Struct { - external ffi - .Pointer)>> - __routine; - - external ffi.Pointer __arg; - - external ffi.Pointer<__darwin_pthread_handler_rec> __next; -} - -final class _opaque_pthread_attr_t extends ffi.Struct { - @ffi.Long() - external int __sig; - - @ffi.Array.multi([56]) - external ffi.Array __opaque; -} - -final class _opaque_pthread_cond_t extends ffi.Struct { - @ffi.Long() - external int __sig; - - @ffi.Array.multi([40]) - external ffi.Array __opaque; -} - -final class _opaque_pthread_condattr_t extends ffi.Struct { - @ffi.Long() - external int __sig; - - @ffi.Array.multi([8]) - external ffi.Array __opaque; -} - -final class _opaque_pthread_mutex_t extends ffi.Struct { - @ffi.Long() - external int __sig; - - @ffi.Array.multi([56]) - external ffi.Array __opaque; -} - -final class _opaque_pthread_mutexattr_t extends ffi.Struct { - @ffi.Long() - external int __sig; - - @ffi.Array.multi([8]) - external ffi.Array __opaque; -} - -final class _opaque_pthread_once_t extends ffi.Struct { - @ffi.Long() - external int __sig; - - @ffi.Array.multi([8]) - external ffi.Array __opaque; -} - -final class _opaque_pthread_rwlock_t extends ffi.Struct { - @ffi.Long() - external int __sig; - - @ffi.Array.multi([192]) - external ffi.Array __opaque; -} - -final class _opaque_pthread_rwlockattr_t extends ffi.Struct { - @ffi.Long() - external int __sig; - - @ffi.Array.multi([16]) - external ffi.Array __opaque; +final class __fsid_t extends ffi.Struct { + @ffi.Array.multi([2]) + external ffi.Array __val; } -final class _opaque_pthread_t extends ffi.Struct { - @ffi.Long() - external int __sig; +final class max_align_t extends ffi.Opaque {} - external ffi.Pointer<__darwin_pthread_handler_rec> __cleanup_stack; - - @ffi.Array.multi([8176]) - external ffi.Array __opaque; -} +typedef ggml_fp16_t = ffi.Uint16; +typedef Dartggml_fp16_t = int; final class ggml_object extends ffi.Struct { @ffi.Size() @@ -12340,10 +12000,12 @@ abstract class ggml_type { static const int GGML_TYPE_Q8_K = 15; static const int GGML_TYPE_IQ2_XXS = 16; static const int GGML_TYPE_IQ2_XS = 17; - static const int GGML_TYPE_I8 = 18; - static const int GGML_TYPE_I16 = 19; - static const int GGML_TYPE_I32 = 20; - static const int GGML_TYPE_COUNT = 21; + static const int GGML_TYPE_IQ3_XXS = 18; + static const int GGML_TYPE_IQ1_S = 19; + static const int GGML_TYPE_I8 = 20; + static const int GGML_TYPE_I16 = 21; + static const int GGML_TYPE_I32 = 22; + static const int GGML_TYPE_COUNT = 23; } abstract class ggml_prec { @@ -12374,6 +12036,8 @@ abstract class ggml_ftype { static const int GGML_FTYPE_MOSTLY_Q6_K = 14; static const int GGML_FTYPE_MOSTLY_IQ2_XXS = 15; static const int GGML_FTYPE_MOSTLY_IQ2_XS = 16; + static const int GGML_FTYPE_MOSTLY_IQ3_XXS = 17; + static const int GGML_FTYPE_MOSTLY_IQ1_S = 18; } abstract class ggml_op { @@ -12475,6 +12139,12 @@ abstract class ggml_log_level { static const int GGML_LOG_LEVEL_DEBUG = 5; } +abstract class ggml_tensor_flag { + static const int GGML_TENSOR_FLAG_INPUT = 1; + static const int GGML_TENSOR_FLAG_OUTPUT = 2; + static const int GGML_TENSOR_FLAG_PARAM = 4; +} + final class ggml_tensor extends ffi.Struct { @ffi.Int32() external int type; @@ -12496,8 +12166,8 @@ final class ggml_tensor extends ffi.Struct { @ffi.Array.multi([16]) external ffi.Array op_params; - @ffi.Bool() - external bool is_param; + @ffi.Int32() + external int flags; external ffi.Pointer grad; @@ -12540,13 +12210,18 @@ final class ggml_cplan extends ffi.Struct { @ffi.Int() external int n_threads; - external ffi.Pointer< - ffi.NativeFunction data)>> - abort_callback; + external ggml_abort_callback abort_callback; external ffi.Pointer abort_callback_data; } +typedef ggml_abort_callback + = ffi.Pointer>; +typedef ggml_abort_callbackFunction = ffi.Bool Function( + ffi.Pointer data); +typedef Dartggml_abort_callbackFunction = bool Function( + ffi.Pointer data); + abstract class ggml_cgraph_eval_order { static const int GGML_CGRAPH_EVAL_ORDER_LEFT_TO_RIGHT = 0; static const int GGML_CGRAPH_EVAL_ORDER_RIGHT_TO_LEFT = 1; @@ -12633,6 +12308,15 @@ final class ggml_compute_params extends ffi.Struct { external ffi.Pointer wdata; } +abstract class ggml_numa_strategy { + static const int GGML_NUMA_STRATEGY_DISABLED = 0; + static const int GGML_NUMA_STRATEGY_DISTRIBUTE = 1; + static const int GGML_NUMA_STRATEGY_ISOLATE = 2; + static const int GGML_NUMA_STRATEGY_NUMACTL = 3; + static const int GGML_NUMA_STRATEGY_MIRROR = 4; + static const int GGML_NUMA_STRATEGY_COUNT = 5; +} + abstract class ggml_op_pool { static const int GGML_OP_POOL_MAX = 0; static const int GGML_OP_POOL_AVG = 1; @@ -12722,1703 +12406,1208 @@ typedef ggml_custom3_op_tFunction = ffi.Void Function( ffi.Pointer b, ffi.Pointer c, ffi.Int ith, - ffi.Int nth, - ffi.Pointer userdata); -typedef Dartggml_custom3_op_tFunction = void Function( - ffi.Pointer dst, - ffi.Pointer a, - ffi.Pointer b, - ffi.Pointer c, - int ith, - int nth, - ffi.Pointer userdata); - -abstract class ggml_opt_type { - static const int GGML_OPT_ADAM = 0; - static const int GGML_OPT_LBFGS = 1; -} - -abstract class ggml_linesearch { - static const int GGML_LINESEARCH_DEFAULT = 1; - static const int GGML_LINESEARCH_BACKTRACKING_ARMIJO = 0; - static const int GGML_LINESEARCH_BACKTRACKING_WOLFE = 1; - static const int GGML_LINESEARCH_BACKTRACKING_STRONG_WOLFE = 2; -} - -abstract class ggml_opt_result { - static const int GGML_OPT_OK = 0; - static const int GGML_OPT_DID_NOT_CONVERGE = 1; - static const int GGML_OPT_NO_CONTEXT = 2; - static const int GGML_OPT_INVALID_WOLFE = 3; - static const int GGML_OPT_FAIL = 4; - static const int GGML_OPT_CANCEL = 5; - static const int GGML_LINESEARCH_FAIL = -128; - static const int GGML_LINESEARCH_MINIMUM_STEP = -127; - static const int GGML_LINESEARCH_MAXIMUM_STEP = -126; - static const int GGML_LINESEARCH_MAXIMUM_ITERATIONS = -125; - static const int GGML_LINESEARCH_INVALID_PARAMETERS = -124; -} - -final class ggml_opt_params extends ffi.Struct { - @ffi.Int32() - external int type; - - @ffi.Size() - external int graph_size; - - @ffi.Int() - external int n_threads; - - @ffi.Int() - external int past; - - @ffi.Float() - external double delta; - - @ffi.Int() - external int max_no_improvement; - - @ffi.Bool() - external bool print_forward_graph; - - @ffi.Bool() - external bool print_backward_graph; - - @ffi.Int() - external int n_gradient_accumulation; - - external UnnamedStruct1 adam; - - external UnnamedStruct2 lbfgs; -} - -final class UnnamedStruct1 extends ffi.Struct { - @ffi.Int() - external int n_iter; - - @ffi.Float() - external double sched; - - @ffi.Float() - external double decay; - - @ffi.Int() - external int decay_min_ndim; - - @ffi.Float() - external double alpha; - - @ffi.Float() - external double beta1; - - @ffi.Float() - external double beta2; - - @ffi.Float() - external double eps; - - @ffi.Float() - external double eps_f; - - @ffi.Float() - external double eps_g; - - @ffi.Float() - external double gclip; -} - -final class UnnamedStruct2 extends ffi.Struct { - @ffi.Int() - external int m; - - @ffi.Int() - external int n_iter; - - @ffi.Int() - external int max_linesearch; - - @ffi.Float() - external double eps; - - @ffi.Float() - external double ftol; - - @ffi.Float() - external double wolfe; - - @ffi.Float() - external double min_step; - - @ffi.Float() - external double max_step; - - @ffi.Int32() - external int linesearch; -} - -final class ggml_opt_context extends ffi.Struct { - external ffi.Pointer ctx; - - external ggml_opt_params params; - - @ffi.Int() - external int iter; - - @ffi.Int64() - external int nx; - - @ffi.Bool() - external bool just_initialized; - - @ffi.Float() - external double loss_before; - - @ffi.Float() - external double loss_after; - - external UnnamedStruct3 adam; - - external UnnamedStruct4 lbfgs; -} - -final class UnnamedStruct3 extends ffi.Struct { - external ffi.Pointer g; - - external ffi.Pointer m; - - external ffi.Pointer v; - - external ffi.Pointer pf; - - @ffi.Float() - external double fx_best; - - @ffi.Float() - external double fx_prev; - - @ffi.Int() - external int n_no_improvement; -} - -final class UnnamedStruct4 extends ffi.Struct { - external ffi.Pointer x; - - external ffi.Pointer xp; - - external ffi.Pointer g; - - external ffi.Pointer gp; - - external ffi.Pointer d; - - external ffi.Pointer pf; - - external ffi.Pointer lmal; - - external ffi.Pointer lmys; - - external ffi.Pointer lms; - - external ffi.Pointer lmy; - - @ffi.Float() - external double fx_best; - - @ffi.Float() - external double step; - - @ffi.Int() - external int j; - - @ffi.Int() - external int k; - - @ffi.Int() - external int end; - - @ffi.Int() - external int n_no_improvement; -} - -typedef ggml_opt_callback - = ffi.Pointer>; -typedef ggml_opt_callbackFunction = ffi.Void Function( - ffi.Pointer data, - ffi.Int accum_step, - ffi.Pointer sched, - ffi.Pointer cancel); -typedef Dartggml_opt_callbackFunction = void Function( - ffi.Pointer data, - int accum_step, - ffi.Pointer sched, - ffi.Pointer cancel); - -abstract class gguf_type { - static const int GGUF_TYPE_UINT8 = 0; - static const int GGUF_TYPE_INT8 = 1; - static const int GGUF_TYPE_UINT16 = 2; - static const int GGUF_TYPE_INT16 = 3; - static const int GGUF_TYPE_UINT32 = 4; - static const int GGUF_TYPE_INT32 = 5; - static const int GGUF_TYPE_FLOAT32 = 6; - static const int GGUF_TYPE_BOOL = 7; - static const int GGUF_TYPE_STRING = 8; - static const int GGUF_TYPE_ARRAY = 9; - static const int GGUF_TYPE_UINT64 = 10; - static const int GGUF_TYPE_INT64 = 11; - static const int GGUF_TYPE_FLOAT64 = 12; - static const int GGUF_TYPE_COUNT = 13; -} - -final class gguf_context extends ffi.Opaque {} - -final class gguf_init_params extends ffi.Struct { - @ffi.Bool() - external bool no_alloc; - - external ffi.Pointer> ctx; -} - -final class ggml_type_traits_t extends ffi.Struct { - external ffi.Pointer type_name; - - @ffi.Int() - external int blck_size; - - @ffi.Size() - external int type_size; - - @ffi.Bool() - external bool is_quantized; - - external ggml_to_float_t to_float; - - external ggml_from_float_t from_float; - - external ggml_from_float_t from_float_reference; - - external ggml_vec_dot_t vec_dot; - - @ffi.Int32() - external int vec_dot_type; -} - -typedef ggml_to_float_t - = ffi.Pointer>; -typedef ggml_to_float_tFunction = ffi.Void Function( - ffi.Pointer x, ffi.Pointer y, ffi.Int k); -typedef Dartggml_to_float_tFunction = void Function( - ffi.Pointer x, ffi.Pointer y, int k); -typedef ggml_from_float_t - = ffi.Pointer>; -typedef ggml_from_float_tFunction = ffi.Void Function( - ffi.Pointer x, ffi.Pointer y, ffi.Int k); -typedef Dartggml_from_float_tFunction = void Function( - ffi.Pointer x, ffi.Pointer y, int k); -typedef ggml_vec_dot_t - = ffi.Pointer>; -typedef ggml_vec_dot_tFunction = ffi.Void Function(ffi.Int n, - ffi.Pointer s, ffi.Pointer x, ffi.Pointer y); -typedef Dartggml_vec_dot_tFunction = void Function(int n, - ffi.Pointer s, ffi.Pointer x, ffi.Pointer y); - -final class ggml_backend extends ffi.Opaque {} - -final class ggml_backend_buffer_type extends ffi.Opaque {} - -final class ggml_allocr extends ffi.Opaque {} - -typedef ggml_allocr_t = ffi.Pointer; - -final class ggml_tallocr extends ffi.Opaque {} - -typedef ggml_tallocr_t = ffi.Pointer; - -final class ggml_gallocr extends ffi.Opaque {} - -typedef ggml_gallocr_t = ffi.Pointer; -typedef ggml_backend_buffer_type_t = ffi.Pointer; -typedef ggml_backend_buffer_t = ffi.Pointer; -typedef ggml_backend_t = ffi.Pointer; - -abstract class ggml_backend_buffer_usage { - static const int GGML_BACKEND_BUFFER_USAGE_ANY = 0; - static const int GGML_BACKEND_BUFFER_USAGE_WEIGHTS = 1; -} - -typedef ggml_backend_graph_plan_t = ffi.Pointer; - -final class ggml_backend_sched extends ffi.Opaque {} - -typedef ggml_backend_sched_t = ffi.Pointer; -typedef ggml_backend_sched_eval_callback - = ffi.Pointer>; -typedef ggml_backend_sched_eval_callbackFunction = ffi.Bool Function( - ffi.Pointer t, ffi.Bool ask, ffi.Pointer user_data); -typedef Dartggml_backend_sched_eval_callbackFunction = bool Function( - ffi.Pointer t, bool ask, ffi.Pointer user_data); - -final class ggml_backend_graph_copy extends ffi.Struct { - external ggml_backend_buffer_t buffer; - - external ffi.Pointer ctx_allocated; - - external ffi.Pointer ctx_unallocated; - - external ffi.Pointer graph; -} - -typedef ggml_backend_eval_callback - = ffi.Pointer>; -typedef ggml_backend_eval_callbackFunction = ffi.Bool Function( - ffi.Int node_index, - ffi.Pointer t1, - ffi.Pointer t2, - ffi.Pointer user_data); -typedef Dartggml_backend_eval_callbackFunction = bool Function( - int node_index, - ffi.Pointer t1, - ffi.Pointer t2, - ffi.Pointer user_data); - -final class __sbuf extends ffi.Struct { - external ffi.Pointer _base; - - @ffi.Int() - external int _size; -} - -final class __sFILEX extends ffi.Opaque {} - -final class __sFILE extends ffi.Struct { - external ffi.Pointer _p; - - @ffi.Int() - external int _r; - - @ffi.Int() - external int _w; - - @ffi.Short() - external int _flags; - - @ffi.Short() - external int _file; - - external __sbuf _bf; - - @ffi.Int() - external int _lbfsize; - - external ffi.Pointer _cookie; - - external ffi - .Pointer)>> - _close; - - external ffi.Pointer< - ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer, ffi.Pointer, ffi.Int)>> _read; - - external ffi.Pointer< - ffi.NativeFunction< - fpos_t Function(ffi.Pointer, fpos_t, ffi.Int)>> _seek; - - external ffi.Pointer< - ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer, ffi.Pointer, ffi.Int)>> _write; - - external __sbuf _ub; - - external ffi.Pointer<__sFILEX> _extra; - - @ffi.Int() - external int _ur; - - @ffi.Array.multi([3]) - external ffi.Array _ubuf; - - @ffi.Array.multi([1]) - external ffi.Array _nbuf; - - external __sbuf _lb; - - @ffi.Int() - external int _blksize; - - @fpos_t() - external int _offset; -} - -typedef fpos_t = __darwin_off_t; -typedef __darwin_off_t = __int64_t; -typedef __int64_t = ffi.LongLong; -typedef Dart__int64_t = int; -typedef FILE = __sFILE; -typedef va_list = __darwin_va_list; -typedef __darwin_va_list = __builtin_va_list; -typedef __builtin_va_list = ffi.Pointer; -typedef off_t = __darwin_off_t; -typedef ssize_t = __darwin_ssize_t; -typedef __darwin_ssize_t = ffi.Long; -typedef Dart__darwin_ssize_t = int; - -final class llama_model extends ffi.Opaque {} - -final class llama_context extends ffi.Opaque {} - -abstract class llama_vocab_type { - static const int LLAMA_VOCAB_TYPE_SPM = 0; - static const int LLAMA_VOCAB_TYPE_BPE = 1; -} - -abstract class llama_token_type { - static const int LLAMA_TOKEN_TYPE_UNDEFINED = 0; - static const int LLAMA_TOKEN_TYPE_NORMAL = 1; - static const int LLAMA_TOKEN_TYPE_UNKNOWN = 2; - static const int LLAMA_TOKEN_TYPE_CONTROL = 3; - static const int LLAMA_TOKEN_TYPE_USER_DEFINED = 4; - static const int LLAMA_TOKEN_TYPE_UNUSED = 5; - static const int LLAMA_TOKEN_TYPE_BYTE = 6; -} - -abstract class llama_ftype { - static const int LLAMA_FTYPE_ALL_F32 = 0; - static const int LLAMA_FTYPE_MOSTLY_F16 = 1; - static const int LLAMA_FTYPE_MOSTLY_Q4_0 = 2; - static const int LLAMA_FTYPE_MOSTLY_Q4_1 = 3; - static const int LLAMA_FTYPE_MOSTLY_Q4_1_SOME_F16 = 4; - static const int LLAMA_FTYPE_MOSTLY_Q8_0 = 7; - static const int LLAMA_FTYPE_MOSTLY_Q5_0 = 8; - static const int LLAMA_FTYPE_MOSTLY_Q5_1 = 9; - static const int LLAMA_FTYPE_MOSTLY_Q2_K = 10; - static const int LLAMA_FTYPE_MOSTLY_Q3_K_S = 11; - static const int LLAMA_FTYPE_MOSTLY_Q3_K_M = 12; - static const int LLAMA_FTYPE_MOSTLY_Q3_K_L = 13; - static const int LLAMA_FTYPE_MOSTLY_Q4_K_S = 14; - static const int LLAMA_FTYPE_MOSTLY_Q4_K_M = 15; - static const int LLAMA_FTYPE_MOSTLY_Q5_K_S = 16; - static const int LLAMA_FTYPE_MOSTLY_Q5_K_M = 17; - static const int LLAMA_FTYPE_MOSTLY_Q6_K = 18; - static const int LLAMA_FTYPE_MOSTLY_IQ2_XXS = 19; - static const int LLAMA_FTYPE_MOSTLY_IQ2_XS = 20; - static const int LLAMA_FTYPE_MOSTLY_Q2_K_S = 21; - static const int LLAMA_FTYPE_MOSTLY_Q3_K_XS = 22; - static const int LLAMA_FTYPE_GUESSED = 1024; -} - -abstract class llama_rope_scaling_type { - static const int LLAMA_ROPE_SCALING_UNSPECIFIED = -1; - static const int LLAMA_ROPE_SCALING_NONE = 0; - static const int LLAMA_ROPE_SCALING_LINEAR = 1; - static const int LLAMA_ROPE_SCALING_YARN = 2; - static const int LLAMA_ROPE_SCALING_MAX_VALUE = 2; -} - -abstract class llama_split_mode { - static const int LLAMA_SPLIT_NONE = 0; - static const int LLAMA_SPLIT_LAYER = 1; - static const int LLAMA_SPLIT_ROW = 2; -} - -final class llama_token_data extends ffi.Struct { - @llama_token() - external int id; - - @ffi.Float() - external double logit; - - @ffi.Float() - external double p; -} - -typedef llama_token = ffi.Int32; -typedef Dartllama_token = int; - -final class llama_token_data_array extends ffi.Struct { - external ffi.Pointer data; - - @ffi.Size() - external int size; - - @ffi.Bool() - external bool sorted; -} - -final class llama_batch extends ffi.Struct { - @ffi.Int32() - external int n_tokens; - - external ffi.Pointer token; - - external ffi.Pointer embd; - - external ffi.Pointer pos; - - external ffi.Pointer n_seq_id; - - external ffi.Pointer> seq_id; - - external ffi.Pointer logits; - - @llama_pos() - external int all_pos_0; - - @llama_pos() - external int all_pos_1; - - @llama_seq_id() - external int all_seq_id; -} - -typedef llama_pos = ffi.Int32; -typedef Dartllama_pos = int; -typedef llama_seq_id = ffi.Int32; -typedef Dartllama_seq_id = int; - -abstract class llama_model_kv_override_type { - static const int LLAMA_KV_OVERRIDE_INT = 0; - static const int LLAMA_KV_OVERRIDE_FLOAT = 1; - static const int LLAMA_KV_OVERRIDE_BOOL = 2; -} - -final class llama_model_kv_override extends ffi.Struct { - @ffi.Array.multi([128]) - external ffi.Array key; - - @ffi.Int32() - external int tag; - - external UnnamedUnion1 unnamed; -} - -final class UnnamedUnion1 extends ffi.Union { - @ffi.Int64() - external int int_value; - - @ffi.Double() - external double float_value; - - @ffi.Bool() - external bool bool_value; -} - -final class llama_model_params extends ffi.Struct { - @ffi.Int32() - external int n_gpu_layers; - - @ffi.Int32() - external int split_mode; - - @ffi.Int32() - external int main_gpu; - - external ffi.Pointer tensor_split; - - external llama_progress_callback progress_callback; - - external ffi.Pointer progress_callback_user_data; - - external ffi.Pointer kv_overrides; - - @ffi.Bool() - external bool vocab_only; - - @ffi.Bool() - external bool use_mmap; - - @ffi.Bool() - external bool use_mlock; -} - -typedef llama_progress_callback - = ffi.Pointer>; -typedef llama_progress_callbackFunction = ffi.Bool Function( - ffi.Float progress, ffi.Pointer ctx); -typedef Dartllama_progress_callbackFunction = bool Function( - double progress, ffi.Pointer ctx); - -final class llama_context_params extends ffi.Struct { - @ffi.Uint32() - external int seed; - - @ffi.Uint32() - external int n_ctx; - - @ffi.Uint32() - external int n_batch; - - @ffi.Uint32() - external int n_threads; - - @ffi.Uint32() - external int n_threads_batch; - - @ffi.Int8() - external int rope_scaling_type; - - @ffi.Float() - external double rope_freq_base; - - @ffi.Float() - external double rope_freq_scale; - - @ffi.Float() - external double yarn_ext_factor; - - @ffi.Float() - external double yarn_attn_factor; - - @ffi.Float() - external double yarn_beta_fast; - - @ffi.Float() - external double yarn_beta_slow; - - @ffi.Uint32() - external int yarn_orig_ctx; - - external ggml_backend_sched_eval_callback cb_eval; - - external ffi.Pointer cb_eval_user_data; - - @ffi.Int32() - external int type_k; - - @ffi.Int32() - external int type_v; - - @ffi.Bool() - external bool mul_mat_q; - - @ffi.Bool() - external bool logits_all; - - @ffi.Bool() - external bool embedding; - - @ffi.Bool() - external bool offload_kqv; -} - -final class llama_model_quantize_params extends ffi.Struct { - @ffi.Int32() - external int nthread; - - @ffi.Int32() - external int ftype; - - @ffi.Bool() - external bool allow_requantize; - - @ffi.Bool() - external bool quantize_output_tensor; - - @ffi.Bool() - external bool only_copy; - - @ffi.Bool() - external bool pure; - - external ffi.Pointer imatrix; -} - -final class llama_grammar extends ffi.Opaque {} - -abstract class llama_gretype { - static const int LLAMA_GRETYPE_END = 0; - static const int LLAMA_GRETYPE_ALT = 1; - static const int LLAMA_GRETYPE_RULE_REF = 2; - static const int LLAMA_GRETYPE_CHAR = 3; - static const int LLAMA_GRETYPE_CHAR_NOT = 4; - static const int LLAMA_GRETYPE_CHAR_RNG_UPPER = 5; - static const int LLAMA_GRETYPE_CHAR_ALT = 6; -} - -final class llama_grammar_element extends ffi.Struct { - @ffi.Int32() - external int type; - - @ffi.Uint32() - external int value; -} - -final class llama_timings extends ffi.Struct { - @ffi.Double() - external double t_start_ms; - - @ffi.Double() - external double t_end_ms; - - @ffi.Double() - external double t_load_ms; - - @ffi.Double() - external double t_sample_ms; - - @ffi.Double() - external double t_p_eval_ms; - - @ffi.Double() - external double t_eval_ms; - - @ffi.Int32() - external int n_sample; - - @ffi.Int32() - external int n_p_eval; - - @ffi.Int32() - external int n_eval; -} - -final class llama_kv_cache_view_cell extends ffi.Struct { - @llama_pos() - external int pos; -} - -final class llama_kv_cache_view extends ffi.Struct { - @ffi.Int32() - external int n_cells; - - @ffi.Int32() - external int n_max_seq; - - @ffi.Int32() - external int token_count; - - @ffi.Int32() - external int used_cells; - - @ffi.Int32() - external int max_contiguous; - - @ffi.Int32() - external int max_contiguous_idx; - - external ffi.Pointer cells; + ffi.Int nth, + ffi.Pointer userdata); +typedef Dartggml_custom3_op_tFunction = void Function( + ffi.Pointer dst, + ffi.Pointer a, + ffi.Pointer b, + ffi.Pointer c, + int ith, + int nth, + ffi.Pointer userdata); - external ffi.Pointer cells_sequences; +abstract class ggml_opt_type { + static const int GGML_OPT_ADAM = 0; + static const int GGML_OPT_LBFGS = 1; } -final class llama_beam_view extends ffi.Struct { - external ffi.Pointer tokens; - - @ffi.Size() - external int n_tokens; - - @ffi.Float() - external double p; - - @ffi.Bool() - external bool eob; +abstract class ggml_linesearch { + static const int GGML_LINESEARCH_DEFAULT = 1; + static const int GGML_LINESEARCH_BACKTRACKING_ARMIJO = 0; + static const int GGML_LINESEARCH_BACKTRACKING_WOLFE = 1; + static const int GGML_LINESEARCH_BACKTRACKING_STRONG_WOLFE = 2; } -final class llama_beams_state extends ffi.Struct { - external ffi.Pointer beam_views; - - @ffi.Size() - external int n_beams; - - @ffi.Size() - external int common_prefix_length; - - @ffi.Bool() - external bool last_call; +abstract class ggml_opt_result { + static const int GGML_OPT_OK = 0; + static const int GGML_OPT_DID_NOT_CONVERGE = 1; + static const int GGML_OPT_NO_CONTEXT = 2; + static const int GGML_OPT_INVALID_WOLFE = 3; + static const int GGML_OPT_FAIL = 4; + static const int GGML_OPT_CANCEL = 5; + static const int GGML_LINESEARCH_FAIL = -128; + static const int GGML_LINESEARCH_MINIMUM_STEP = -127; + static const int GGML_LINESEARCH_MAXIMUM_STEP = -126; + static const int GGML_LINESEARCH_MAXIMUM_ITERATIONS = -125; + static const int GGML_LINESEARCH_INVALID_PARAMETERS = -124; } -typedef llama_beam_search_callback_fn_t - = ffi.Pointer>; -typedef llama_beam_search_callback_fn_tFunction = ffi.Void Function( - ffi.Pointer, llama_beams_state); -typedef Dartllama_beam_search_callback_fn_tFunction = void Function( - ffi.Pointer, llama_beams_state); -typedef ggml_log_callback - = ffi.Pointer>; -typedef ggml_log_callbackFunction = ffi.Void Function(ffi.Int32 level, - ffi.Pointer text, ffi.Pointer user_data); -typedef Dartggml_log_callbackFunction = void Function( - int level, ffi.Pointer text, ffi.Pointer user_data); - -const int __WORDSIZE = 64; - -const int __DARWIN_ONLY_64_BIT_INO_T = 1; - -const int __DARWIN_ONLY_UNIX_CONFORMANCE = 1; - -const int __DARWIN_ONLY_VERS_1050 = 1; - -const int __DARWIN_UNIX03 = 1; - -const int __DARWIN_64_BIT_INO_T = 1; - -const int __DARWIN_VERS_1050 = 1; - -const int __DARWIN_NON_CANCELABLE = 0; - -const String __DARWIN_SUF_EXTSN = '\$DARWIN_EXTSN'; - -const int __DARWIN_C_ANSI = 4096; - -const int __DARWIN_C_FULL = 900000; - -const int __DARWIN_C_LEVEL = 900000; - -const int __STDC_WANT_LIB_EXT1__ = 1; - -const int __DARWIN_NO_LONG_LONG = 0; - -const int _DARWIN_FEATURE_64_BIT_INODE = 1; - -const int _DARWIN_FEATURE_ONLY_64_BIT_INODE = 1; - -const int _DARWIN_FEATURE_ONLY_VERS_1050 = 1; - -const int _DARWIN_FEATURE_ONLY_UNIX_CONFORMANCE = 1; - -const int _DARWIN_FEATURE_UNIX_CONFORMANCE = 3; - -const int __has_ptrcheck = 0; - -const int __DARWIN_NULL = 0; - -const int __PTHREAD_SIZE__ = 8176; - -const int __PTHREAD_ATTR_SIZE__ = 56; - -const int __PTHREAD_MUTEXATTR_SIZE__ = 8; - -const int __PTHREAD_MUTEX_SIZE__ = 56; - -const int __PTHREAD_CONDATTR_SIZE__ = 8; - -const int __PTHREAD_COND_SIZE__ = 40; - -const int __PTHREAD_ONCE_SIZE__ = 8; - -const int __PTHREAD_RWLOCK_SIZE__ = 192; - -const int __PTHREAD_RWLOCKATTR_SIZE__ = 16; - -const int USER_ADDR_NULL = 0; - -const int INT8_MAX = 127; - -const int INT16_MAX = 32767; - -const int INT32_MAX = 2147483647; - -const int INT64_MAX = 9223372036854775807; - -const int INT8_MIN = -128; - -const int INT16_MIN = -32768; - -const int INT32_MIN = -2147483648; - -const int INT64_MIN = -9223372036854775808; - -const int UINT8_MAX = 255; +final class ggml_opt_params extends ffi.Struct { + @ffi.Int32() + external int type; -const int UINT16_MAX = 65535; + @ffi.Size() + external int graph_size; -const int UINT32_MAX = 4294967295; + @ffi.Int() + external int n_threads; -const int UINT64_MAX = -1; + @ffi.Int() + external int past; -const int INT_LEAST8_MIN = -128; + @ffi.Float() + external double delta; -const int INT_LEAST16_MIN = -32768; + @ffi.Int() + external int max_no_improvement; -const int INT_LEAST32_MIN = -2147483648; + @ffi.Bool() + external bool print_forward_graph; -const int INT_LEAST64_MIN = -9223372036854775808; + @ffi.Bool() + external bool print_backward_graph; -const int INT_LEAST8_MAX = 127; + @ffi.Int() + external int n_gradient_accumulation; -const int INT_LEAST16_MAX = 32767; + external UnnamedStruct1 adam; -const int INT_LEAST32_MAX = 2147483647; + external UnnamedStruct2 lbfgs; +} -const int INT_LEAST64_MAX = 9223372036854775807; +final class UnnamedStruct1 extends ffi.Struct { + @ffi.Int() + external int n_iter; -const int UINT_LEAST8_MAX = 255; + @ffi.Float() + external double sched; -const int UINT_LEAST16_MAX = 65535; + @ffi.Float() + external double decay; -const int UINT_LEAST32_MAX = 4294967295; + @ffi.Int() + external int decay_min_ndim; -const int UINT_LEAST64_MAX = -1; + @ffi.Float() + external double alpha; -const int INT_FAST8_MIN = -128; + @ffi.Float() + external double beta1; -const int INT_FAST16_MIN = -32768; + @ffi.Float() + external double beta2; -const int INT_FAST32_MIN = -2147483648; + @ffi.Float() + external double eps; -const int INT_FAST64_MIN = -9223372036854775808; + @ffi.Float() + external double eps_f; -const int INT_FAST8_MAX = 127; + @ffi.Float() + external double eps_g; -const int INT_FAST16_MAX = 32767; + @ffi.Float() + external double gclip; +} -const int INT_FAST32_MAX = 2147483647; +final class UnnamedStruct2 extends ffi.Struct { + @ffi.Int() + external int m; -const int INT_FAST64_MAX = 9223372036854775807; + @ffi.Int() + external int n_iter; -const int UINT_FAST8_MAX = 255; + @ffi.Int() + external int max_linesearch; -const int UINT_FAST16_MAX = 65535; + @ffi.Float() + external double eps; -const int UINT_FAST32_MAX = 4294967295; + @ffi.Float() + external double ftol; -const int UINT_FAST64_MAX = -1; + @ffi.Float() + external double wolfe; -const int INTPTR_MAX = 9223372036854775807; + @ffi.Float() + external double min_step; -const int INTPTR_MIN = -9223372036854775808; + @ffi.Float() + external double max_step; -const int UINTPTR_MAX = -1; + @ffi.Int32() + external int linesearch; +} -const int INTMAX_MAX = 9223372036854775807; +final class ggml_opt_context extends ffi.Struct { + external ffi.Pointer ctx; -const int UINTMAX_MAX = -1; + external ggml_opt_params params; -const int INTMAX_MIN = -9223372036854775808; + @ffi.Int() + external int iter; -const int PTRDIFF_MIN = -9223372036854775808; + @ffi.Int64() + external int nx; -const int PTRDIFF_MAX = 9223372036854775807; + @ffi.Bool() + external bool just_initialized; -const int SIZE_MAX = -1; + @ffi.Float() + external double loss_before; -const int RSIZE_MAX = 9223372036854775807; + @ffi.Float() + external double loss_after; -const int WCHAR_MAX = 2147483647; + external UnnamedStruct3 adam; -const int WCHAR_MIN = -2147483648; + external UnnamedStruct4 lbfgs; +} -const int WINT_MIN = -2147483648; +final class UnnamedStruct3 extends ffi.Struct { + external ffi.Pointer g; -const int WINT_MAX = 2147483647; + external ffi.Pointer m; -const int SIG_ATOMIC_MIN = -2147483648; + external ffi.Pointer v; -const int SIG_ATOMIC_MAX = 2147483647; + external ffi.Pointer pf; -const int __DARWIN_WCHAR_MAX = 2147483647; + @ffi.Float() + external double fx_best; -const int __DARWIN_WCHAR_MIN = -2147483648; + @ffi.Float() + external double fx_prev; -const int __DARWIN_WEOF = -1; + @ffi.Int() + external int n_no_improvement; +} -const int _FORTIFY_SOURCE = 2; +final class UnnamedStruct4 extends ffi.Struct { + external ffi.Pointer x; -const int NULL = 0; + external ffi.Pointer xp; -const int __bool_true_false_are_defined = 1; + external ffi.Pointer g; -const int true1 = 1; + external ffi.Pointer gp; -const int false1 = 0; + external ffi.Pointer d; -const int GGML_FILE_MAGIC = 1734831468; + external ffi.Pointer pf; -const int GGML_FILE_VERSION = 1; + external ffi.Pointer lmal; -const int GGML_QNT_VERSION = 2; + external ffi.Pointer lmys; -const int GGML_QNT_VERSION_FACTOR = 1000; + external ffi.Pointer lms; -const int GGML_MAX_DIMS = 4; + external ffi.Pointer lmy; -const int GGML_MAX_PARAMS = 2048; + @ffi.Float() + external double fx_best; -const int GGML_MAX_CONTEXTS = 64; + @ffi.Float() + external double step; -const int GGML_MAX_SRC = 10; + @ffi.Int() + external int j; -const int GGML_MAX_NAME = 64; + @ffi.Int() + external int k; -const int GGML_MAX_OP_PARAMS = 64; + @ffi.Int() + external int end; -const int GGML_DEFAULT_N_THREADS = 4; + @ffi.Int() + external int n_no_improvement; +} -const int GGML_DEFAULT_GRAPH_SIZE = 2048; +typedef ggml_opt_callback + = ffi.Pointer>; +typedef ggml_opt_callbackFunction = ffi.Void Function( + ffi.Pointer data, + ffi.Int accum_step, + ffi.Pointer sched, + ffi.Pointer cancel); +typedef Dartggml_opt_callbackFunction = void Function( + ffi.Pointer data, + int accum_step, + ffi.Pointer sched, + ffi.Pointer cancel); -const int GGML_MEM_ALIGN = 16; +abstract class gguf_type { + static const int GGUF_TYPE_UINT8 = 0; + static const int GGUF_TYPE_INT8 = 1; + static const int GGUF_TYPE_UINT16 = 2; + static const int GGUF_TYPE_INT16 = 3; + static const int GGUF_TYPE_UINT32 = 4; + static const int GGUF_TYPE_INT32 = 5; + static const int GGUF_TYPE_FLOAT32 = 6; + static const int GGUF_TYPE_BOOL = 7; + static const int GGUF_TYPE_STRING = 8; + static const int GGUF_TYPE_ARRAY = 9; + static const int GGUF_TYPE_UINT64 = 10; + static const int GGUF_TYPE_INT64 = 11; + static const int GGUF_TYPE_FLOAT64 = 12; + static const int GGUF_TYPE_COUNT = 13; +} -const int GGML_EXIT_SUCCESS = 0; +final class gguf_context extends ffi.Opaque {} -const int GGML_EXIT_ABORTED = 1; +final class gguf_init_params extends ffi.Struct { + @ffi.Bool() + external bool no_alloc; -const String GGUF_MAGIC = 'GGUF'; + external ffi.Pointer> ctx; +} -const int GGUF_VERSION = 3; +final class ggml_type_traits_t extends ffi.Struct { + external ffi.Pointer type_name; -const int GGUF_DEFAULT_ALIGNMENT = 32; + @ffi.Int() + external int blck_size; -const int GGML_N_TASKS_MAX = -1; + @ffi.Size() + external int type_size; -const int LLAMA_MAX_DEVICES = 1; + @ffi.Bool() + external bool is_quantized; -const int __API_TO_BE_DEPRECATED = 100000; + external ggml_to_float_t to_float; -const int __API_TO_BE_DEPRECATED_MACOS = 100000; + external ggml_from_float_t from_float; -const int __API_TO_BE_DEPRECATED_IOS = 100000; + external ggml_from_float_t from_float_reference; -const int __API_TO_BE_DEPRECATED_MACCATALYST = 100000; + external ggml_vec_dot_t vec_dot; -const int __API_TO_BE_DEPRECATED_WATCHOS = 100000; + @ffi.Int32() + external int vec_dot_type; -const int __API_TO_BE_DEPRECATED_TVOS = 100000; + @ffi.Int64() + external int nrows; +} -const int __API_TO_BE_DEPRECATED_DRIVERKIT = 100000; +typedef ggml_to_float_t + = ffi.Pointer>; +typedef ggml_to_float_tFunction = ffi.Void Function( + ffi.Pointer x, ffi.Pointer y, ffi.Int k); +typedef Dartggml_to_float_tFunction = void Function( + ffi.Pointer x, ffi.Pointer y, int k); +typedef ggml_from_float_t + = ffi.Pointer>; +typedef ggml_from_float_tFunction = ffi.Void Function( + ffi.Pointer x, ffi.Pointer y, ffi.Int k); +typedef Dartggml_from_float_tFunction = void Function( + ffi.Pointer x, ffi.Pointer y, int k); +typedef ggml_vec_dot_t + = ffi.Pointer>; +typedef ggml_vec_dot_tFunction = ffi.Void Function( + ffi.Int n, + ffi.Pointer s, + ffi.Size bs, + ffi.Pointer x, + ffi.Size bx, + ffi.Pointer y, + ffi.Size by, + ffi.Int nrc); +typedef Dartggml_vec_dot_tFunction = void Function( + int n, + ffi.Pointer s, + int bs, + ffi.Pointer x, + int bx, + ffi.Pointer y, + int by, + int nrc); -const int __API_TO_BE_DEPRECATED_VISIONOS = 100000; +final class ggml_backend_buffer_type extends ffi.Opaque {} -const int __MAC_10_0 = 1000; +final class ggml_backend extends ffi.Opaque {} -const int __MAC_10_1 = 1010; +final class ggml_tallocr extends ffi.Opaque {} -const int __MAC_10_2 = 1020; +typedef ggml_tallocr_t = ffi.Pointer; +typedef ggml_backend_buffer_t = ffi.Pointer; -const int __MAC_10_3 = 1030; +final class ggml_gallocr extends ffi.Opaque {} -const int __MAC_10_4 = 1040; +typedef ggml_gallocr_t = ffi.Pointer; +typedef ggml_backend_buffer_type_t = ffi.Pointer; +typedef ggml_backend_t = ffi.Pointer; -const int __MAC_10_5 = 1050; +abstract class ggml_backend_buffer_usage { + static const int GGML_BACKEND_BUFFER_USAGE_ANY = 0; + static const int GGML_BACKEND_BUFFER_USAGE_WEIGHTS = 1; +} -const int __MAC_10_6 = 1060; +typedef ggml_backend_graph_plan_t = ffi.Pointer; -const int __MAC_10_7 = 1070; +final class ggml_backend_sched extends ffi.Opaque {} -const int __MAC_10_8 = 1080; +typedef ggml_backend_sched_t = ffi.Pointer; +typedef ggml_backend_sched_eval_callback + = ffi.Pointer>; +typedef ggml_backend_sched_eval_callbackFunction = ffi.Bool Function( + ffi.Pointer t, ffi.Bool ask, ffi.Pointer user_data); +typedef Dartggml_backend_sched_eval_callbackFunction = bool Function( + ffi.Pointer t, bool ask, ffi.Pointer user_data); -const int __MAC_10_9 = 1090; +final class ggml_backend_graph_copy extends ffi.Struct { + external ggml_backend_buffer_t buffer; -const int __MAC_10_10 = 101000; + external ffi.Pointer ctx_allocated; -const int __MAC_10_10_2 = 101002; + external ffi.Pointer ctx_unallocated; -const int __MAC_10_10_3 = 101003; + external ffi.Pointer graph; +} -const int __MAC_10_11 = 101100; +typedef ggml_backend_eval_callback + = ffi.Pointer>; +typedef ggml_backend_eval_callbackFunction = ffi.Bool Function( + ffi.Int node_index, + ffi.Pointer t1, + ffi.Pointer t2, + ffi.Pointer user_data); +typedef Dartggml_backend_eval_callbackFunction = bool Function( + int node_index, + ffi.Pointer t1, + ffi.Pointer t2, + ffi.Pointer user_data); -const int __MAC_10_11_2 = 101102; +final class __mbstate_t extends ffi.Struct { + @ffi.Int() + external int __count; -const int __MAC_10_11_3 = 101103; + external UnnamedUnion1 __value; +} -const int __MAC_10_11_4 = 101104; +final class UnnamedUnion1 extends ffi.Union { + @ffi.UnsignedInt() + external int __wch; -const int __MAC_10_12 = 101200; + @ffi.Array.multi([4]) + external ffi.Array __wchb; +} -const int __MAC_10_12_1 = 101201; +final class _G_fpos_t extends ffi.Struct { + @__off_t() + external int __pos; -const int __MAC_10_12_2 = 101202; + external __mbstate_t __state; +} -const int __MAC_10_12_4 = 101204; +typedef __off_t = ffi.Long; +typedef Dart__off_t = int; -const int __MAC_10_13 = 101300; +final class _G_fpos64_t extends ffi.Struct { + @__off64_t() + external int __pos; -const int __MAC_10_13_1 = 101301; + external __mbstate_t __state; +} -const int __MAC_10_13_2 = 101302; +typedef __off64_t = ffi.Long; +typedef Dart__off64_t = int; -const int __MAC_10_13_4 = 101304; +final class _IO_FILE extends ffi.Struct { + @ffi.Int() + external int _flags; -const int __MAC_10_14 = 101400; + external ffi.Pointer _IO_read_ptr; -const int __MAC_10_14_1 = 101401; + external ffi.Pointer _IO_read_end; -const int __MAC_10_14_4 = 101404; + external ffi.Pointer _IO_read_base; -const int __MAC_10_14_5 = 101405; + external ffi.Pointer _IO_write_base; -const int __MAC_10_14_6 = 101406; + external ffi.Pointer _IO_write_ptr; -const int __MAC_10_15 = 101500; + external ffi.Pointer _IO_write_end; -const int __MAC_10_15_1 = 101501; + external ffi.Pointer _IO_buf_base; -const int __MAC_10_15_4 = 101504; + external ffi.Pointer _IO_buf_end; -const int __MAC_10_16 = 101600; + external ffi.Pointer _IO_save_base; -const int __MAC_11_0 = 110000; + external ffi.Pointer _IO_backup_base; -const int __MAC_11_1 = 110100; + external ffi.Pointer _IO_save_end; -const int __MAC_11_3 = 110300; + external ffi.Pointer<_IO_marker> _markers; -const int __MAC_11_4 = 110400; + external ffi.Pointer<_IO_FILE> _chain; -const int __MAC_11_5 = 110500; + @ffi.Int() + external int _fileno; -const int __MAC_11_6 = 110600; + @ffi.Int() + external int _flags2; -const int __MAC_12_0 = 120000; + @__off_t() + external int _old_offset; -const int __MAC_12_1 = 120100; + @ffi.UnsignedShort() + external int _cur_column; -const int __MAC_12_2 = 120200; + @ffi.SignedChar() + external int _vtable_offset; -const int __MAC_12_3 = 120300; + @ffi.Array.multi([1]) + external ffi.Array _shortbuf; -const int __MAC_12_4 = 120400; + external ffi.Pointer<_IO_lock_t> _lock; -const int __MAC_12_5 = 120500; + @__off64_t() + external int _offset; -const int __MAC_12_6 = 120600; + external ffi.Pointer<_IO_codecvt> _codecvt; -const int __MAC_12_7 = 120700; + external ffi.Pointer<_IO_wide_data> _wide_data; -const int __MAC_13_0 = 130000; + external ffi.Pointer<_IO_FILE> _freeres_list; -const int __MAC_13_1 = 130100; + external ffi.Pointer _freeres_buf; -const int __MAC_13_2 = 130200; + @ffi.Size() + external int __pad5; -const int __MAC_13_3 = 130300; + @ffi.Int() + external int _mode; -const int __MAC_13_4 = 130400; + @ffi.Array.multi([20]) + external ffi.Array _unused2; +} -const int __MAC_13_5 = 130500; +final class _IO_marker extends ffi.Opaque {} -const int __MAC_13_6 = 130600; +typedef _IO_lock_t = ffi.Void; +typedef Dart_IO_lock_t = void; -const int __MAC_14_0 = 140000; +final class _IO_codecvt extends ffi.Opaque {} -const int __MAC_14_1 = 140100; +final class _IO_wide_data extends ffi.Opaque {} -const int __MAC_14_2 = 140200; +typedef FILE = _IO_FILE; -const int __IPHONE_2_0 = 20000; +final class __va_list_tag extends ffi.Struct { + @ffi.UnsignedInt() + external int gp_offset; -const int __IPHONE_2_1 = 20100; + @ffi.UnsignedInt() + external int fp_offset; -const int __IPHONE_2_2 = 20200; + external ffi.Pointer overflow_arg_area; -const int __IPHONE_3_0 = 30000; + external ffi.Pointer reg_save_area; +} -const int __IPHONE_3_1 = 30100; +typedef __ssize_t = ffi.Long; +typedef Dart__ssize_t = int; +typedef fpos_t = __fpos_t; +typedef __fpos_t = _G_fpos_t; -const int __IPHONE_3_2 = 30200; +final class llama_model extends ffi.Opaque {} -const int __IPHONE_4_0 = 40000; +final class llama_context extends ffi.Opaque {} -const int __IPHONE_4_1 = 40100; +abstract class llama_vocab_type { + static const int LLAMA_VOCAB_TYPE_SPM = 0; + static const int LLAMA_VOCAB_TYPE_BPE = 1; + static const int LLAMA_VOCAB_TYPE_WPM = 2; +} -const int __IPHONE_4_2 = 40200; +abstract class llama_token_type { + static const int LLAMA_TOKEN_TYPE_UNDEFINED = 0; + static const int LLAMA_TOKEN_TYPE_NORMAL = 1; + static const int LLAMA_TOKEN_TYPE_UNKNOWN = 2; + static const int LLAMA_TOKEN_TYPE_CONTROL = 3; + static const int LLAMA_TOKEN_TYPE_USER_DEFINED = 4; + static const int LLAMA_TOKEN_TYPE_UNUSED = 5; + static const int LLAMA_TOKEN_TYPE_BYTE = 6; +} -const int __IPHONE_4_3 = 40300; +abstract class llama_ftype { + static const int LLAMA_FTYPE_ALL_F32 = 0; + static const int LLAMA_FTYPE_MOSTLY_F16 = 1; + static const int LLAMA_FTYPE_MOSTLY_Q4_0 = 2; + static const int LLAMA_FTYPE_MOSTLY_Q4_1 = 3; + static const int LLAMA_FTYPE_MOSTLY_Q4_1_SOME_F16 = 4; + static const int LLAMA_FTYPE_MOSTLY_Q8_0 = 7; + static const int LLAMA_FTYPE_MOSTLY_Q5_0 = 8; + static const int LLAMA_FTYPE_MOSTLY_Q5_1 = 9; + static const int LLAMA_FTYPE_MOSTLY_Q2_K = 10; + static const int LLAMA_FTYPE_MOSTLY_Q3_K_S = 11; + static const int LLAMA_FTYPE_MOSTLY_Q3_K_M = 12; + static const int LLAMA_FTYPE_MOSTLY_Q3_K_L = 13; + static const int LLAMA_FTYPE_MOSTLY_Q4_K_S = 14; + static const int LLAMA_FTYPE_MOSTLY_Q4_K_M = 15; + static const int LLAMA_FTYPE_MOSTLY_Q5_K_S = 16; + static const int LLAMA_FTYPE_MOSTLY_Q5_K_M = 17; + static const int LLAMA_FTYPE_MOSTLY_Q6_K = 18; + static const int LLAMA_FTYPE_MOSTLY_IQ2_XXS = 19; + static const int LLAMA_FTYPE_MOSTLY_IQ2_XS = 20; + static const int LLAMA_FTYPE_MOSTLY_Q2_K_S = 21; + static const int LLAMA_FTYPE_MOSTLY_Q3_K_XS = 22; + static const int LLAMA_FTYPE_MOSTLY_IQ3_XXS = 23; + static const int LLAMA_FTYPE_MOSTLY_IQ1_S = 24; + static const int LLAMA_FTYPE_GUESSED = 1024; +} -const int __IPHONE_5_0 = 50000; +abstract class llama_rope_scaling_type { + static const int LLAMA_ROPE_SCALING_UNSPECIFIED = -1; + static const int LLAMA_ROPE_SCALING_NONE = 0; + static const int LLAMA_ROPE_SCALING_LINEAR = 1; + static const int LLAMA_ROPE_SCALING_YARN = 2; + static const int LLAMA_ROPE_SCALING_MAX_VALUE = 2; +} -const int __IPHONE_5_1 = 50100; +abstract class llama_pooling_type { + static const int LLAMA_POOLING_NONE = 0; + static const int LLAMA_POOLING_MEAN = 1; + static const int LLAMA_POOLING_CLS = 2; +} -const int __IPHONE_6_0 = 60000; +abstract class llama_split_mode { + static const int LLAMA_SPLIT_NONE = 0; + static const int LLAMA_SPLIT_LAYER = 1; + static const int LLAMA_SPLIT_ROW = 2; +} -const int __IPHONE_6_1 = 60100; +final class llama_token_data extends ffi.Struct { + @llama_token() + external int id; -const int __IPHONE_7_0 = 70000; + @ffi.Float() + external double logit; -const int __IPHONE_7_1 = 70100; + @ffi.Float() + external double p; +} -const int __IPHONE_8_0 = 80000; +typedef llama_token = ffi.Int32; +typedef Dartllama_token = int; -const int __IPHONE_8_1 = 80100; +final class llama_token_data_array extends ffi.Struct { + external ffi.Pointer data; -const int __IPHONE_8_2 = 80200; + @ffi.Size() + external int size; -const int __IPHONE_8_3 = 80300; + @ffi.Bool() + external bool sorted; +} -const int __IPHONE_8_4 = 80400; +final class llama_batch extends ffi.Struct { + @ffi.Int32() + external int n_tokens; -const int __IPHONE_9_0 = 90000; + external ffi.Pointer token; -const int __IPHONE_9_1 = 90100; + external ffi.Pointer embd; -const int __IPHONE_9_2 = 90200; + external ffi.Pointer pos; -const int __IPHONE_9_3 = 90300; + external ffi.Pointer n_seq_id; -const int __IPHONE_10_0 = 100000; + external ffi.Pointer> seq_id; -const int __IPHONE_10_1 = 100100; + external ffi.Pointer logits; -const int __IPHONE_10_2 = 100200; + @llama_pos() + external int all_pos_0; -const int __IPHONE_10_3 = 100300; + @llama_pos() + external int all_pos_1; -const int __IPHONE_11_0 = 110000; + @llama_seq_id() + external int all_seq_id; +} -const int __IPHONE_11_1 = 110100; +typedef llama_pos = ffi.Int32; +typedef Dartllama_pos = int; +typedef llama_seq_id = ffi.Int32; +typedef Dartllama_seq_id = int; -const int __IPHONE_11_2 = 110200; +abstract class llama_model_kv_override_type { + static const int LLAMA_KV_OVERRIDE_INT = 0; + static const int LLAMA_KV_OVERRIDE_FLOAT = 1; + static const int LLAMA_KV_OVERRIDE_BOOL = 2; +} -const int __IPHONE_11_3 = 110300; +final class llama_model_kv_override extends ffi.Struct { + @ffi.Array.multi([128]) + external ffi.Array key; -const int __IPHONE_11_4 = 110400; + @ffi.Int32() + external int tag; -const int __IPHONE_12_0 = 120000; + external UnnamedUnion2 unnamed; +} -const int __IPHONE_12_1 = 120100; +final class UnnamedUnion2 extends ffi.Union { + @ffi.Int64() + external int int_value; -const int __IPHONE_12_2 = 120200; + @ffi.Double() + external double float_value; -const int __IPHONE_12_3 = 120300; + @ffi.Bool() + external bool bool_value; +} -const int __IPHONE_12_4 = 120400; +final class llama_model_params extends ffi.Struct { + @ffi.Int32() + external int n_gpu_layers; -const int __IPHONE_13_0 = 130000; + @ffi.Int32() + external int split_mode; -const int __IPHONE_13_1 = 130100; + @ffi.Int32() + external int main_gpu; -const int __IPHONE_13_2 = 130200; + external ffi.Pointer tensor_split; -const int __IPHONE_13_3 = 130300; + external llama_progress_callback progress_callback; -const int __IPHONE_13_4 = 130400; + external ffi.Pointer progress_callback_user_data; -const int __IPHONE_13_5 = 130500; + external ffi.Pointer kv_overrides; -const int __IPHONE_13_6 = 130600; + @ffi.Bool() + external bool vocab_only; -const int __IPHONE_13_7 = 130700; + @ffi.Bool() + external bool use_mmap; -const int __IPHONE_14_0 = 140000; + @ffi.Bool() + external bool use_mlock; +} -const int __IPHONE_14_1 = 140100; +typedef llama_progress_callback + = ffi.Pointer>; +typedef llama_progress_callbackFunction = ffi.Bool Function( + ffi.Float progress, ffi.Pointer ctx); +typedef Dartllama_progress_callbackFunction = bool Function( + double progress, ffi.Pointer ctx); -const int __IPHONE_14_2 = 140200; +final class llama_context_params extends ffi.Struct { + @ffi.Uint32() + external int seed; -const int __IPHONE_14_3 = 140300; + @ffi.Uint32() + external int n_ctx; -const int __IPHONE_14_5 = 140500; + @ffi.Uint32() + external int n_batch; -const int __IPHONE_14_4 = 140400; + @ffi.Uint32() + external int n_threads; -const int __IPHONE_14_6 = 140600; + @ffi.Uint32() + external int n_threads_batch; -const int __IPHONE_14_7 = 140700; + @ffi.Int32() + external int rope_scaling_type; -const int __IPHONE_14_8 = 140800; + @ffi.Float() + external double rope_freq_base; -const int __IPHONE_15_0 = 150000; + @ffi.Float() + external double rope_freq_scale; -const int __IPHONE_15_1 = 150100; + @ffi.Float() + external double yarn_ext_factor; -const int __IPHONE_15_2 = 150200; + @ffi.Float() + external double yarn_attn_factor; -const int __IPHONE_15_3 = 150300; + @ffi.Float() + external double yarn_beta_fast; -const int __IPHONE_15_4 = 150400; + @ffi.Float() + external double yarn_beta_slow; -const int __IPHONE_15_5 = 150500; + @ffi.Uint32() + external int yarn_orig_ctx; -const int __IPHONE_15_6 = 150600; + external ggml_backend_sched_eval_callback cb_eval; -const int __IPHONE_16_0 = 160000; + external ffi.Pointer cb_eval_user_data; -const int __IPHONE_16_1 = 160100; + @ffi.Int32() + external int type_k; -const int __IPHONE_16_2 = 160200; + @ffi.Int32() + external int type_v; -const int __IPHONE_16_3 = 160300; + @ffi.Bool() + external bool mul_mat_q; -const int __IPHONE_16_4 = 160400; + @ffi.Bool() + external bool logits_all; -const int __IPHONE_16_5 = 160500; + @ffi.Bool() + external bool embedding; -const int __IPHONE_16_6 = 160600; + @ffi.Bool() + external bool offload_kqv; -const int __IPHONE_16_7 = 160700; + @ffi.Bool() + external bool do_pooling; +} -const int __IPHONE_17_0 = 170000; +final class llama_model_quantize_params extends ffi.Struct { + @ffi.Int32() + external int nthread; -const int __IPHONE_17_1 = 170100; + @ffi.Int32() + external int ftype; -const int __IPHONE_17_2 = 170200; + @ffi.Bool() + external bool allow_requantize; -const int __WATCHOS_1_0 = 10000; + @ffi.Bool() + external bool quantize_output_tensor; -const int __WATCHOS_2_0 = 20000; + @ffi.Bool() + external bool only_copy; -const int __WATCHOS_2_1 = 20100; + @ffi.Bool() + external bool pure; -const int __WATCHOS_2_2 = 20200; + external ffi.Pointer imatrix; +} -const int __WATCHOS_3_0 = 30000; +final class llama_grammar extends ffi.Opaque {} -const int __WATCHOS_3_1 = 30100; +abstract class llama_gretype { + static const int LLAMA_GRETYPE_END = 0; + static const int LLAMA_GRETYPE_ALT = 1; + static const int LLAMA_GRETYPE_RULE_REF = 2; + static const int LLAMA_GRETYPE_CHAR = 3; + static const int LLAMA_GRETYPE_CHAR_NOT = 4; + static const int LLAMA_GRETYPE_CHAR_RNG_UPPER = 5; + static const int LLAMA_GRETYPE_CHAR_ALT = 6; +} -const int __WATCHOS_3_1_1 = 30101; +final class llama_grammar_element extends ffi.Struct { + @ffi.Int32() + external int type; -const int __WATCHOS_3_2 = 30200; + @ffi.Uint32() + external int value; +} -const int __WATCHOS_4_0 = 40000; +final class llama_timings extends ffi.Struct { + @ffi.Double() + external double t_start_ms; -const int __WATCHOS_4_1 = 40100; + @ffi.Double() + external double t_end_ms; -const int __WATCHOS_4_2 = 40200; + @ffi.Double() + external double t_load_ms; -const int __WATCHOS_4_3 = 40300; + @ffi.Double() + external double t_sample_ms; -const int __WATCHOS_5_0 = 50000; + @ffi.Double() + external double t_p_eval_ms; -const int __WATCHOS_5_1 = 50100; + @ffi.Double() + external double t_eval_ms; -const int __WATCHOS_5_2 = 50200; + @ffi.Int32() + external int n_sample; -const int __WATCHOS_5_3 = 50300; + @ffi.Int32() + external int n_p_eval; -const int __WATCHOS_6_0 = 60000; + @ffi.Int32() + external int n_eval; +} -const int __WATCHOS_6_1 = 60100; +final class llama_chat_message extends ffi.Struct { + external ffi.Pointer role; -const int __WATCHOS_6_2 = 60200; + external ffi.Pointer content; +} -const int __WATCHOS_7_0 = 70000; +final class llama_kv_cache_view_cell extends ffi.Struct { + @llama_pos() + external int pos; +} -const int __WATCHOS_7_1 = 70100; +final class llama_kv_cache_view extends ffi.Struct { + @ffi.Int32() + external int n_cells; -const int __WATCHOS_7_2 = 70200; + @ffi.Int32() + external int n_max_seq; -const int __WATCHOS_7_3 = 70300; + @ffi.Int32() + external int token_count; -const int __WATCHOS_7_4 = 70400; + @ffi.Int32() + external int used_cells; -const int __WATCHOS_7_5 = 70500; + @ffi.Int32() + external int max_contiguous; -const int __WATCHOS_7_6 = 70600; + @ffi.Int32() + external int max_contiguous_idx; -const int __WATCHOS_8_0 = 80000; + external ffi.Pointer cells; -const int __WATCHOS_8_1 = 80100; + external ffi.Pointer cells_sequences; +} -const int __WATCHOS_8_3 = 80300; +final class llama_beam_view extends ffi.Struct { + external ffi.Pointer tokens; -const int __WATCHOS_8_4 = 80400; + @ffi.Size() + external int n_tokens; -const int __WATCHOS_8_5 = 80500; + @ffi.Float() + external double p; -const int __WATCHOS_8_6 = 80600; + @ffi.Bool() + external bool eob; +} -const int __WATCHOS_8_7 = 80700; +final class llama_beams_state extends ffi.Struct { + external ffi.Pointer beam_views; -const int __WATCHOS_9_0 = 90000; + @ffi.Size() + external int n_beams; -const int __WATCHOS_9_1 = 90100; + @ffi.Size() + external int common_prefix_length; -const int __WATCHOS_9_2 = 90200; + @ffi.Bool() + external bool last_call; +} -const int __WATCHOS_9_3 = 90300; +typedef llama_beam_search_callback_fn_t + = ffi.Pointer>; +typedef llama_beam_search_callback_fn_tFunction = ffi.Void Function( + ffi.Pointer, llama_beams_state); +typedef Dartllama_beam_search_callback_fn_tFunction = void Function( + ffi.Pointer, llama_beams_state); +typedef ggml_log_callback + = ffi.Pointer>; +typedef ggml_log_callbackFunction = ffi.Void Function(ffi.Int32 level, + ffi.Pointer text, ffi.Pointer user_data); +typedef Dartggml_log_callbackFunction = void Function( + int level, ffi.Pointer text, ffi.Pointer user_data); -const int __WATCHOS_9_4 = 90400; +const int _STDINT_H = 1; -const int __WATCHOS_9_5 = 90500; +const int _FEATURES_H = 1; -const int __WATCHOS_9_6 = 90600; +const int _DEFAULT_SOURCE = 1; -const int __WATCHOS_10_0 = 100000; +const int __GLIBC_USE_ISOC2X = 1; -const int __WATCHOS_10_1 = 100100; +const int __USE_ISOC11 = 1; -const int __WATCHOS_10_2 = 100200; +const int __USE_ISOC99 = 1; -const int __TVOS_9_0 = 90000; +const int __USE_ISOC95 = 1; -const int __TVOS_9_1 = 90100; +const int _POSIX_SOURCE = 1; -const int __TVOS_9_2 = 90200; +const int _POSIX_C_SOURCE = 200809; -const int __TVOS_10_0 = 100000; +const int __USE_POSIX = 1; -const int __TVOS_10_0_1 = 100001; +const int __USE_POSIX2 = 1; -const int __TVOS_10_1 = 100100; +const int __USE_POSIX199309 = 1; -const int __TVOS_10_2 = 100200; +const int __USE_POSIX199506 = 1; -const int __TVOS_11_0 = 110000; +const int __USE_XOPEN2K = 1; -const int __TVOS_11_1 = 110100; +const int __USE_XOPEN2K8 = 1; -const int __TVOS_11_2 = 110200; +const int _ATFILE_SOURCE = 1; -const int __TVOS_11_3 = 110300; +const int __WORDSIZE = 64; -const int __TVOS_11_4 = 110400; +const int __WORDSIZE_TIME64_COMPAT32 = 1; -const int __TVOS_12_0 = 120000; +const int __SYSCALL_WORDSIZE = 64; -const int __TVOS_12_1 = 120100; +const int __TIMESIZE = 64; -const int __TVOS_12_2 = 120200; +const int __USE_MISC = 1; -const int __TVOS_12_3 = 120300; +const int __USE_ATFILE = 1; -const int __TVOS_12_4 = 120400; +const int __USE_FORTIFY_LEVEL = 0; -const int __TVOS_13_0 = 130000; +const int __GLIBC_USE_DEPRECATED_GETS = 0; -const int __TVOS_13_2 = 130200; +const int __GLIBC_USE_DEPRECATED_SCANF = 0; -const int __TVOS_13_3 = 130300; +const int _STDC_PREDEF_H = 1; -const int __TVOS_13_4 = 130400; +const int __STDC_IEC_559__ = 1; -const int __TVOS_14_0 = 140000; +const int __STDC_IEC_60559_BFP__ = 201404; -const int __TVOS_14_1 = 140100; +const int __STDC_IEC_559_COMPLEX__ = 1; -const int __TVOS_14_2 = 140200; +const int __STDC_IEC_60559_COMPLEX__ = 201404; -const int __TVOS_14_3 = 140300; +const int __STDC_ISO_10646__ = 201706; -const int __TVOS_14_5 = 140500; +const int __GNU_LIBRARY__ = 6; -const int __TVOS_14_6 = 140600; +const int __GLIBC__ = 2; -const int __TVOS_14_7 = 140700; +const int __GLIBC_MINOR__ = 35; -const int __TVOS_15_0 = 150000; +const int _SYS_CDEFS_H = 1; -const int __TVOS_15_1 = 150100; +const int __THROW = 1; -const int __TVOS_15_2 = 150200; +const int __THROWNL = 1; -const int __TVOS_15_3 = 150300; +const int __glibc_c99_flexarr_available = 1; -const int __TVOS_15_4 = 150400; +const int __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI = 0; -const int __TVOS_15_5 = 150500; +const int __HAVE_GENERIC_SELECTION = 0; -const int __TVOS_15_6 = 150600; +const int __GLIBC_USE_LIB_EXT2 = 1; -const int __TVOS_16_0 = 160000; +const int __GLIBC_USE_IEC_60559_BFP_EXT = 1; -const int __TVOS_16_1 = 160100; +const int __GLIBC_USE_IEC_60559_BFP_EXT_C2X = 1; -const int __TVOS_16_2 = 160200; +const int __GLIBC_USE_IEC_60559_EXT = 1; -const int __TVOS_16_3 = 160300; +const int __GLIBC_USE_IEC_60559_FUNCS_EXT = 1; -const int __TVOS_16_4 = 160400; +const int __GLIBC_USE_IEC_60559_FUNCS_EXT_C2X = 1; -const int __TVOS_16_5 = 160500; +const int __GLIBC_USE_IEC_60559_TYPES_EXT = 1; -const int __TVOS_16_6 = 160600; +const int _BITS_TYPES_H = 1; -const int __TVOS_17_0 = 170000; +const int _BITS_TYPESIZES_H = 1; -const int __TVOS_17_1 = 170100; +const int __OFF_T_MATCHES_OFF64_T = 1; -const int __TVOS_17_2 = 170200; +const int __INO_T_MATCHES_INO64_T = 1; -const int __BRIDGEOS_2_0 = 20000; +const int __RLIM_T_MATCHES_RLIM64_T = 1; -const int __BRIDGEOS_3_0 = 30000; +const int __STATFS_MATCHES_STATFS64 = 1; -const int __BRIDGEOS_3_1 = 30100; +const int __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64 = 1; -const int __BRIDGEOS_3_4 = 30400; +const int __FD_SETSIZE = 1024; -const int __BRIDGEOS_4_0 = 40000; +const int _BITS_TIME64_H = 1; -const int __BRIDGEOS_4_1 = 40100; +const int _BITS_WCHAR_H = 1; -const int __BRIDGEOS_5_0 = 50000; +const int __WCHAR_MAX = 2147483647; -const int __BRIDGEOS_5_1 = 50100; +const int __WCHAR_MIN = -2147483648; -const int __BRIDGEOS_5_3 = 50300; +const int _BITS_STDINT_INTN_H = 1; -const int __BRIDGEOS_6_0 = 60000; +const int _BITS_STDINT_UINTN_H = 1; -const int __BRIDGEOS_6_2 = 60200; +const int INT8_MIN = -128; -const int __BRIDGEOS_6_4 = 60400; +const int INT16_MIN = -32768; -const int __BRIDGEOS_6_5 = 60500; +const int INT32_MIN = -2147483648; -const int __BRIDGEOS_6_6 = 60600; +const int INT64_MIN = -9223372036854775808; -const int __BRIDGEOS_7_0 = 70000; +const int INT8_MAX = 127; -const int __BRIDGEOS_7_1 = 70100; +const int INT16_MAX = 32767; -const int __BRIDGEOS_7_2 = 70200; +const int INT32_MAX = 2147483647; -const int __BRIDGEOS_7_3 = 70300; +const int INT64_MAX = 9223372036854775807; -const int __BRIDGEOS_7_4 = 70400; +const int UINT8_MAX = 255; -const int __BRIDGEOS_7_6 = 70600; +const int UINT16_MAX = 65535; -const int __BRIDGEOS_8_0 = 80000; +const int UINT32_MAX = 4294967295; -const int __BRIDGEOS_8_1 = 80100; +const int UINT64_MAX = -1; -const int __BRIDGEOS_8_2 = 80200; +const int INT_LEAST8_MIN = -128; -const int __DRIVERKIT_19_0 = 190000; +const int INT_LEAST16_MIN = -32768; -const int __DRIVERKIT_20_0 = 200000; +const int INT_LEAST32_MIN = -2147483648; -const int __DRIVERKIT_21_0 = 210000; +const int INT_LEAST64_MIN = -9223372036854775808; -const int __DRIVERKIT_22_0 = 220000; +const int INT_LEAST8_MAX = 127; -const int __DRIVERKIT_22_4 = 220400; +const int INT_LEAST16_MAX = 32767; -const int __DRIVERKIT_22_5 = 220500; +const int INT_LEAST32_MAX = 2147483647; -const int __DRIVERKIT_22_6 = 220600; +const int INT_LEAST64_MAX = 9223372036854775807; -const int __DRIVERKIT_23_0 = 230000; +const int UINT_LEAST8_MAX = 255; -const int __DRIVERKIT_23_1 = 230100; +const int UINT_LEAST16_MAX = 65535; -const int __DRIVERKIT_23_2 = 230200; +const int UINT_LEAST32_MAX = 4294967295; -const int __VISIONOS_1_0 = 10000; +const int UINT_LEAST64_MAX = -1; -const int MAC_OS_X_VERSION_10_0 = 1000; +const int INT_FAST8_MIN = -128; -const int MAC_OS_X_VERSION_10_1 = 1010; +const int INT_FAST16_MIN = -9223372036854775808; -const int MAC_OS_X_VERSION_10_2 = 1020; +const int INT_FAST32_MIN = -9223372036854775808; -const int MAC_OS_X_VERSION_10_3 = 1030; +const int INT_FAST64_MIN = -9223372036854775808; -const int MAC_OS_X_VERSION_10_4 = 1040; +const int INT_FAST8_MAX = 127; -const int MAC_OS_X_VERSION_10_5 = 1050; +const int INT_FAST16_MAX = 9223372036854775807; -const int MAC_OS_X_VERSION_10_6 = 1060; +const int INT_FAST32_MAX = 9223372036854775807; -const int MAC_OS_X_VERSION_10_7 = 1070; +const int INT_FAST64_MAX = 9223372036854775807; -const int MAC_OS_X_VERSION_10_8 = 1080; +const int UINT_FAST8_MAX = 255; -const int MAC_OS_X_VERSION_10_9 = 1090; +const int UINT_FAST16_MAX = -1; -const int MAC_OS_X_VERSION_10_10 = 101000; +const int UINT_FAST32_MAX = -1; -const int MAC_OS_X_VERSION_10_10_2 = 101002; +const int UINT_FAST64_MAX = -1; -const int MAC_OS_X_VERSION_10_10_3 = 101003; +const int INTPTR_MIN = -9223372036854775808; -const int MAC_OS_X_VERSION_10_11 = 101100; +const int INTPTR_MAX = 9223372036854775807; -const int MAC_OS_X_VERSION_10_11_2 = 101102; +const int UINTPTR_MAX = -1; -const int MAC_OS_X_VERSION_10_11_3 = 101103; +const int INTMAX_MIN = -9223372036854775808; -const int MAC_OS_X_VERSION_10_11_4 = 101104; +const int INTMAX_MAX = 9223372036854775807; -const int MAC_OS_X_VERSION_10_12 = 101200; +const int UINTMAX_MAX = -1; -const int MAC_OS_X_VERSION_10_12_1 = 101201; +const int PTRDIFF_MIN = -9223372036854775808; -const int MAC_OS_X_VERSION_10_12_2 = 101202; +const int PTRDIFF_MAX = 9223372036854775807; -const int MAC_OS_X_VERSION_10_12_4 = 101204; +const int SIG_ATOMIC_MIN = -2147483648; -const int MAC_OS_X_VERSION_10_13 = 101300; +const int SIG_ATOMIC_MAX = 2147483647; -const int MAC_OS_X_VERSION_10_13_1 = 101301; +const int SIZE_MAX = -1; -const int MAC_OS_X_VERSION_10_13_2 = 101302; +const int WCHAR_MIN = -2147483648; -const int MAC_OS_X_VERSION_10_13_4 = 101304; +const int WCHAR_MAX = 2147483647; -const int MAC_OS_X_VERSION_10_14 = 101400; +const int WINT_MIN = 0; -const int MAC_OS_X_VERSION_10_14_1 = 101401; +const int WINT_MAX = 4294967295; -const int MAC_OS_X_VERSION_10_14_4 = 101404; +const int NULL = 0; -const int MAC_OS_X_VERSION_10_14_5 = 101405; +const int true1 = 1; -const int MAC_OS_X_VERSION_10_14_6 = 101406; +const int false1 = 0; -const int MAC_OS_X_VERSION_10_15 = 101500; +const int __bool_true_false_are_defined = 1; -const int MAC_OS_X_VERSION_10_15_1 = 101501; +const int GGML_FILE_MAGIC = 1734831468; -const int MAC_OS_X_VERSION_10_15_4 = 101504; +const int GGML_FILE_VERSION = 1; -const int MAC_OS_X_VERSION_10_16 = 101600; +const int GGML_QNT_VERSION = 2; -const int MAC_OS_VERSION_11_0 = 110000; +const int GGML_QNT_VERSION_FACTOR = 1000; -const int MAC_OS_VERSION_11_1 = 110100; +const int GGML_MAX_DIMS = 4; -const int MAC_OS_VERSION_11_3 = 110300; +const int GGML_MAX_PARAMS = 2048; -const int MAC_OS_VERSION_11_4 = 110400; +const int GGML_MAX_CONTEXTS = 64; -const int MAC_OS_VERSION_11_5 = 110500; +const int GGML_MAX_SRC = 10; -const int MAC_OS_VERSION_11_6 = 110600; +const int GGML_MAX_NAME = 64; -const int MAC_OS_VERSION_12_0 = 120000; +const int GGML_MAX_OP_PARAMS = 64; -const int MAC_OS_VERSION_12_1 = 120100; +const int GGML_DEFAULT_N_THREADS = 4; -const int MAC_OS_VERSION_12_2 = 120200; +const int GGML_DEFAULT_GRAPH_SIZE = 2048; -const int MAC_OS_VERSION_12_3 = 120300; +const int GGML_MEM_ALIGN = 16; -const int MAC_OS_VERSION_12_4 = 120400; +const int GGML_EXIT_SUCCESS = 0; -const int MAC_OS_VERSION_12_5 = 120500; +const int GGML_EXIT_ABORTED = 1; -const int MAC_OS_VERSION_12_6 = 120600; +const String GGUF_MAGIC = 'GGUF'; -const int MAC_OS_VERSION_12_7 = 120700; +const int GGUF_VERSION = 3; -const int MAC_OS_VERSION_13_0 = 130000; +const int GGUF_DEFAULT_ALIGNMENT = 32; -const int MAC_OS_VERSION_13_1 = 130100; +const int GGML_N_TASKS_MAX = -1; -const int MAC_OS_VERSION_13_2 = 130200; +const int _STDIO_H = 1; -const int MAC_OS_VERSION_13_3 = 130300; +const int __GNUC_VA_LIST = 1; -const int MAC_OS_VERSION_13_4 = 130400; +const int _____fpos_t_defined = 1; -const int MAC_OS_VERSION_13_5 = 130500; +const int ____mbstate_t_defined = 1; -const int MAC_OS_VERSION_13_6 = 130600; +const int _____fpos64_t_defined = 1; -const int MAC_OS_VERSION_14_0 = 140000; +const int ____FILE_defined = 1; -const int MAC_OS_VERSION_14_1 = 140100; +const int __FILE_defined = 1; -const int MAC_OS_VERSION_14_2 = 140200; +const int __struct_FILE_defined = 1; -const int __MAC_OS_X_VERSION_MIN_REQUIRED = 140000; +const int _IO_EOF_SEEN = 16; -const int __MAC_OS_X_VERSION_MAX_ALLOWED = 140200; +const int _IO_ERR_SEEN = 32; -const int __ENABLE_LEGACY_MAC_AVAILABILITY = 1; +const int _IO_USER_LOCK = 32768; -const int RENAME_SECLUDE = 1; +const int _IOFBF = 0; -const int RENAME_SWAP = 2; +const int _IOLBF = 1; -const int RENAME_EXCL = 4; +const int _IONBF = 2; -const int RENAME_RESERVED1 = 8; +const int BUFSIZ = 8192; -const int RENAME_NOFOLLOW_ANY = 16; +const int EOF = -1; const int SEEK_SET = 0; @@ -14426,63 +13615,53 @@ const int SEEK_CUR = 1; const int SEEK_END = 2; -const int SEEK_HOLE = 3; - -const int SEEK_DATA = 4; +const String P_tmpdir = '/tmp'; -const int __SLBF = 1; +const int _BITS_STDIO_LIM_H = 1; -const int __SNBF = 2; +const int L_tmpnam = 20; -const int __SRD = 4; +const int TMP_MAX = 238328; -const int __SWR = 8; +const int FILENAME_MAX = 4096; -const int __SRW = 16; +const int L_ctermid = 9; -const int __SEOF = 32; +const int FOPEN_MAX = 16; -const int __SERR = 64; +const int __HAVE_FLOAT128 = 0; -const int __SMBF = 128; +const int __HAVE_DISTINCT_FLOAT128 = 0; -const int __SAPP = 256; +const int __HAVE_FLOAT64X = 1; -const int __SSTR = 512; +const int __HAVE_FLOAT64X_LONG_DOUBLE = 1; -const int __SOPT = 1024; +const int __HAVE_FLOAT16 = 0; -const int __SNPT = 2048; +const int __HAVE_FLOAT32 = 1; -const int __SOFF = 4096; +const int __HAVE_FLOAT64 = 1; -const int __SMOD = 8192; +const int __HAVE_FLOAT32X = 1; -const int __SALC = 16384; +const int __HAVE_FLOAT128X = 0; -const int __SIGN = 32768; +const int __HAVE_DISTINCT_FLOAT16 = 0; -const int _IOFBF = 0; - -const int _IOLBF = 1; - -const int _IONBF = 2; - -const int BUFSIZ = 1024; - -const int EOF = -1; +const int __HAVE_DISTINCT_FLOAT32 = 0; -const int FOPEN_MAX = 20; +const int __HAVE_DISTINCT_FLOAT64 = 0; -const int FILENAME_MAX = 1024; +const int __HAVE_DISTINCT_FLOAT32X = 0; -const String P_tmpdir = '/var/tmp/'; +const int __HAVE_DISTINCT_FLOAT64X = 0; -const int L_tmpnam = 1024; +const int __HAVE_DISTINCT_FLOAT128X = 0; -const int TMP_MAX = 308915776; +const int __HAVE_FLOAT128_UNLIKE_LDBL = 0; -const int L_ctermid = 1024; +const int __HAVE_FLOATN_NOT_TYPEDEF = 0; const int LLAMA_DEFAULT_SEED = 4294967295; diff --git a/src/llama.cpp b/src/llama.cpp index 4a3d35a..54f0ad5 160000 --- a/src/llama.cpp +++ b/src/llama.cpp @@ -1 +1 @@ -Subproject commit 4a3d35a77d515ab24ec3638fab7828cadea9515f +Subproject commit 54f0ad5bc6ee1348ca89870e7c55229068903d27