Skip to content

Commit 209ad86

Browse files
authored
Merge pull request #689 from vlovich/expose-head-n-kv
Expose n_head_kv
2 parents b0d355c + bde9248 commit 209ad86

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

llama-cpp-2/src/model.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -484,6 +484,13 @@ impl LlamaModel {
484484
u32::try_from(unsafe { llama_cpp_sys_2::llama_model_n_head(self.model.as_ptr()) }).unwrap()
485485
}
486486

487+
/// Returns the number of KV attention heads.
488+
pub fn n_head_kv(&self) -> u32 {
489+
// It's never possible for this to panic because while the API interface is defined as an int32_t,
490+
// the field it's accessing is a uint32_t.
491+
u32::try_from(unsafe { llama_cpp_sys_2::llama_model_n_head_kv(self.model.as_ptr()) }).unwrap()
492+
}
493+
487494
/// Returns the rope type of the model.
488495
pub fn rope_type(&self) -> Option<RopeType> {
489496
match unsafe { llama_cpp_sys_2::llama_model_rope_type(self.model.as_ptr()) } {

llama-cpp-sys-2/llama.cpp

0 commit comments

Comments
 (0)