Skip to content

Commit

Permalink
cargo fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
thewh1teagle committed Aug 31, 2024
1 parent ef4a37e commit 5da6a85
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 29 deletions.
2 changes: 1 addition & 1 deletion llama-cpp-2/src/context/sample/sampler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
//! like [`crate::context::LlamaContext`] or token history to the sampler.
//!
//! # Example
//!
//!
//! **Llama.cpp default sampler**
//!
//! ```rust
Expand Down
8 changes: 6 additions & 2 deletions llama-cpp-2/src/model.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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)
}
Expand Down
8 changes: 2 additions & 6 deletions llama-cpp-2/src/model/params/kv_overrides.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
}
}
}
Expand Down
49 changes: 29 additions & 20 deletions llama-cpp-sys-2/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -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)
}

Expand Down

0 comments on commit 5da6a85

Please sign in to comment.