diff --git a/llama-cpp-2/src/context/sample/sampler.rs b/llama-cpp-2/src/context/sample/sampler.rs index cfe90499..948a1aa5 100644 --- a/llama-cpp-2/src/context/sample/sampler.rs +++ b/llama-cpp-2/src/context/sample/sampler.rs @@ -3,7 +3,7 @@ //! like [`crate::context::LlamaContext`] or token history to the sampler. //! //! # Example -//! +//! //! **Llama.cpp default sampler** //! //! ```rust diff --git a/llama-cpp-2/src/model.rs b/llama-cpp-2/src/model.rs index 38965200..39e3ea3b 100644 --- a/llama-cpp-2/src/model.rs +++ b/llama-cpp-2/src/model.rs @@ -1,6 +1,6 @@ //! A safe wrapper around `llama_model`. -use std::ffi::CString; use std::ffi::CStr; +use std::ffi::CString; use std::num::NonZeroU16; use std::os::raw::c_int; use std::path::Path; @@ -550,7 +550,11 @@ impl LlamaModel { if res > buff.len() as i32 { return Err(ApplyChatTemplateError::BuffSizeError); } - Ok::<String, ApplyChatTemplateError>(CStr::from_ptr(buff.as_mut_ptr()).to_string_lossy().to_string()) + Ok::<String, ApplyChatTemplateError>( + CStr::from_ptr(buff.as_mut_ptr()) + .to_string_lossy() + .to_string(), + ) }?; Ok(formatted_chat) } diff --git a/llama-cpp-2/src/model/params/kv_overrides.rs b/llama-cpp-2/src/model/params/kv_overrides.rs index 7d10256d..8bbcbdd4 100644 --- a/llama-cpp-2/src/model/params/kv_overrides.rs +++ b/llama-cpp-2/src/model/params/kv_overrides.rs @@ -33,17 +33,13 @@ impl ParamOverrideValue { llama_cpp_sys_2::llama_model_kv_override__bindgen_ty_1 { val_bool: *value } } ParamOverrideValue::Float(value) => { - llama_cpp_sys_2::llama_model_kv_override__bindgen_ty_1 { - val_f64: *value, - } + llama_cpp_sys_2::llama_model_kv_override__bindgen_ty_1 { val_f64: *value } } ParamOverrideValue::Int(value) => { llama_cpp_sys_2::llama_model_kv_override__bindgen_ty_1 { val_i64: *value } } ParamOverrideValue::Str(c_string) => { - llama_cpp_sys_2::llama_model_kv_override__bindgen_ty_1 { - val_str: *c_string, - } + llama_cpp_sys_2::llama_model_kv_override__bindgen_ty_1 { val_str: *c_string } } } } diff --git a/llama-cpp-sys-2/build.rs b/llama-cpp-sys-2/build.rs index 35b393ec..24bd7fc5 100644 --- a/llama-cpp-sys-2/build.rs +++ b/llama-cpp-sys-2/build.rs @@ -91,11 +91,9 @@ fn compile_bindings( llama_header_path: &Path, ) -> Result<(), Box<dyn std::error::Error + 'static>> { println!("Generating bindings.."); - - let includes = [ - llama_header_path.join("ggml").join("include"), - ]; - + + let includes = [llama_header_path.join("ggml").join("include")]; + let bindings = bindgen::Builder::default() .clang_args(includes.map(|path| format!("-I{}", path.to_string_lossy()))) .header( @@ -425,9 +423,7 @@ fn compile_cuda(cx: &mut Build, cxx: &mut Build, featless_cxx: Build) -> &'stati // nvcc.flag("-Wno-pedantic"); // } - for lib in [ - "cuda", "cublas", "cudart", "cublasLt" - ] { + for lib in ["cuda", "cublas", "cudart", "cublasLt"] { println!("cargo:rustc-link-lib={}", lib); } if !nvcc.get_compiler().is_like_msvc() { @@ -623,31 +619,44 @@ fn gen_vulkan_shaders(out_path: impl AsRef<Path>) -> (impl AsRef<Path>, impl AsR .cpp(true) .get_compiler(); - assert!(!cxx.is_like_msvc(), "Compiling Vulkan GGML with MSVC is not supported at this time."); + assert!( + !cxx.is_like_msvc(), + "Compiling Vulkan GGML with MSVC is not supported at this time." + ); let vulkan_shaders_gen_bin = out_path.as_ref().join("vulkan-shaders-gen"); cxx.to_command() .args([ - vulkan_shaders_src.join("vulkan-shaders-gen.cpp").as_os_str(), - "-o".as_ref(), vulkan_shaders_gen_bin.as_os_str() + vulkan_shaders_src + .join("vulkan-shaders-gen.cpp") + .as_os_str(), + "-o".as_ref(), + vulkan_shaders_gen_bin.as_os_str(), ]) - .output().expect("Could not compile Vulkan shader generator"); + .output() + .expect("Could not compile Vulkan shader generator"); let header = out_path.as_ref().join("ggml-vulkan-shaders.hpp"); let source = out_path.as_ref().join("ggml-vulkan-shaders.cpp"); Command::new(vulkan_shaders_gen_bin) .args([ - "--glslc".as_ref(), "glslc".as_ref(), - "--input-dir".as_ref(), vulkan_shaders_src.as_os_str(), - "--output-dir".as_ref(), out_path.as_ref().join("vulkan-shaders.spv").as_os_str(), - "--target-hpp".as_ref(), header.as_os_str(), - "--target-cpp".as_ref(), source.as_os_str(), - "--no-clean".as_ref() + "--glslc".as_ref(), + "glslc".as_ref(), + "--input-dir".as_ref(), + vulkan_shaders_src.as_os_str(), + "--output-dir".as_ref(), + out_path.as_ref().join("vulkan-shaders.spv").as_os_str(), + "--target-hpp".as_ref(), + header.as_os_str(), + "--target-cpp".as_ref(), + source.as_os_str(), + "--no-clean".as_ref(), ]) - .output().expect("Could not run Vulkan shader generator"); - + .output() + .expect("Could not run Vulkan shader generator"); + (out_path, source) }