Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/aienux/blob/main/native/om/lm1b/oracle/manifest-dump/src/main.rs # aienux Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `aienux / native / om / lm1b / oracle / manifest-dump / src / main.rs` 45 lines ยท 2174 bytes Raw Blame History 1 // SPDX-License-Identifier: AGPL-3.0-or-later 2 // Reference-oracle tool for native/om/lm1b: print the pinned manifest of a GGUF file in the 3 // exact text form lm1b.om rebuilds at load, using the aienos-infer parser (an independent reader). 4 use aienos_infer::{GgmlType, Gguf, Value}; 5 fn show(s: &str) -> String { 6 let ok = s.len() <= 40 && s.bytes().all(|b| (32..=126).contains(&b) && b != b'"' && b != b'\\'); 7 if ok { format!("{} {}", s.len(), s) } else { format!("{}", s.len()) } 8 } 9 fn main() { 10 let a: Vec = std::env::args().collect(); 11 let bytes = std::fs::read(&a[1]).expect("read"); 12 let g = Gguf::parse(&bytes).expect("gguf"); 13 println!("gguf {} {} {}", g.version, g.tensors().len(), g.kvs().len()); 14 for (k, v) in g.kvs() { 15 let s = match *v { 16 Value::U8(x) => format!("0 {x}"), 17 Value::I8(x) => format!("1 {x}"), 18 Value::U16(x) => format!("2 {x}"), 19 Value::I16(x) => format!("3 {x}"), 20 Value::U32(x) => format!("4 {x}"), 21 Value::I32(x) => format!("5 {x}"), 22 Value::F32(x) => format!("6 {}", x.to_bits()), 23 Value::Bool(x) => format!("7 {}", x as u8), 24 Value::Str(x) => format!("8 {}", show(x)), 25 Value::Array(x) => { 26 let e = match format!("{:?}", x.elem).as_str() { 27 "U8" => 0, "I8" => 1, "U16" => 2, "I16" => 3, "U32" => 4, "I32" => 5, "F32" => 6, 28 "Bool" => 7, "Str" => 8, "Array" => 9, "U64" => 10, "I64" => 11, "F64" => 12, 29 o => panic!("elem {o}"), 30 }; 31 format!("9 {e} {}", x.len()) 32 } 33 Value::U64(x) => format!("10 {x}"), 34 Value::I64(x) => format!("11 {x}"), 35 Value::F64(x) => format!("12 {}", x.to_bits()), 36 }; 37 println!("kv {} {}", show(k), s); 38 } 39 for t in g.tensors() { 40 let code = (0u32..64).find(|c| GgmlType::from_code(*c).ok() == Some(t.ty)).expect("code"); 41 assert!(t.n_dims <= 2); 42 println!("t {} {} {} {} {} {}", t.name, code, t.n_dims, t.dims[0], t.dims[1], t.offset); 43 } 44 println!("data {}", g.data_start); 45 }