From 3d5df479726eee14a3be82ac7d4ee2663b690828 Mon Sep 17 00:00:00 2001 From: Lukas Kreussel <65088241+LLukas22@users.noreply.github.com> Date: Thu, 27 Jul 2023 12:22:45 +0200 Subject: [PATCH] Pull latest metal fixes from `llama.cpp` --- crates/ggml/sys/llama-cpp | 2 +- crates/ggml/sys/src/lib.rs | 32 ++++++++++++++++++++++++++++++-- 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/crates/ggml/sys/llama-cpp b/crates/ggml/sys/llama-cpp index eb542d39..1a941869 160000 --- a/crates/ggml/sys/llama-cpp +++ b/crates/ggml/sys/llama-cpp @@ -1 +1 @@ -Subproject commit eb542d39324574a6778fad9ba9e34ba7a14a82a3 +Subproject commit 1a941869cbef8e9cc351a6c6987e4ae3b0f021f7 diff --git a/crates/ggml/sys/src/lib.rs b/crates/ggml/sys/src/lib.rs index 0a50d07e..10412720 100644 --- a/crates/ggml/sys/src/lib.rs +++ b/crates/ggml/sys/src/lib.rs @@ -158,13 +158,18 @@ pub const ggml_unary_op_GGML_UNARY_OP_GELU: ggml_unary_op = 7; pub const ggml_unary_op_GGML_UNARY_OP_GELU_QUICK: ggml_unary_op = 8; pub const ggml_unary_op_GGML_UNARY_OP_SILU: ggml_unary_op = 9; pub type ggml_unary_op = ::std::os::raw::c_int; +pub const ggml_object_type_GGML_OBJECT_TENSOR: ggml_object_type = 0; +pub const ggml_object_type_GGML_OBJECT_GRAPH: ggml_object_type = 1; +pub const ggml_object_type_GGML_OBJECT_WORK_BUFFER: ggml_object_type = 2; +pub type ggml_object_type = ::std::os::raw::c_int; #[repr(C)] #[derive(Debug, Copy, Clone)] pub struct ggml_object { pub offs: usize, pub size: usize, pub next: *mut ggml_object, - pub padding: [::std::os::raw::c_char; 8usize], + pub type_: ggml_object_type, + pub padding: [::std::os::raw::c_char; 4usize], } #[test] fn bindgen_test_layout_ggml_object() { @@ -211,8 +216,18 @@ fn bindgen_test_layout_ggml_object() { ) ); assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).padding) as usize - ptr as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).type_) as usize - ptr as usize }, 24usize, + concat!( + "Offset of field: ", + stringify!(ggml_object), + "::", + stringify!(type_) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).padding) as usize - ptr as usize }, + 28usize, concat!( "Offset of field: ", stringify!(ggml_object), @@ -633,6 +648,7 @@ fn bindgen_test_layout_ggml_cgraph() { ) ); } +pub const GGML_GRAPH_SIZE: usize = 164520; #[repr(C)] #[derive(Debug, Copy, Clone)] pub struct ggml_scratch { @@ -1845,6 +1861,18 @@ extern "C" { keep: bool, ) -> ggml_cgraph; } +extern "C" { + pub fn ggml_new_graph(ctx: *mut ggml_context) -> *mut ggml_cgraph; +} +extern "C" { + pub fn ggml_build_forward_ctx( + ctx: *mut ggml_context, + tensor: *mut ggml_tensor, + ) -> *mut ggml_cgraph; +} +extern "C" { + pub fn ggml_graph_overhead() -> usize; +} extern "C" { pub fn ggml_graph_plan( cgraph: *mut ggml_cgraph,