Modern Apps git

← Modern-Apps.git

ml: split weights format constants under the file-length limit

Commit
932de7f60f2051218098cd25361ff3951df2b412
Author
Vayun Mathur <[email protected]>
When
2026-11-18 16:28 UTC (17 days ago)
Parents
fac0585
Move the .maml format constants from weights.rs (501 lines) into the new weights_part10.rs include so the file satisfies the 500-line Rust file-length gate; modelrunner lib tests still pass (865).

Diff

library/ml/src/main/rust/src/weights.rs
diff --git a/library/ml/src/main/rust/src/weights.rs b/library/ml/src/main/rust/src/weights.rsindex 509d78909e..940a08ac38 100644--- a/library/ml/src/main/rust/src/weights.rs+++ b/library/ml/src/main/rust/src/weights.rs@@ -21,21 +21,7 @@ use std::fs::File;  use crate::preprocess::f16_to_f32; -/// `b"MAML"`, little-endian, at offset 0.-const MAGIC: [u8; 4] = *b"MAML";-/// Bumped when the layout below changes incompatibly.-///-/// Version 1 is header + table + blob. Version 2 appends a graph section after the blob-/// (see [`Graph`]); a v1 reader rejects a v2 file here, loudly, rather than running a-/// topology it cannot see.-#[cfg(test)]-const FORMAT_VERSION: u32 = 1;-/// The newest version this reader accepts. Kept distinct from [`FORMAT_VERSION`] — the-/// version *written* by the converter — so emitting v2 files is a separate, deliberate-/// step from reading them.-const FORMAT_READ_VERSION: u32 = 2;-const HEADER_BYTES: usize = 64;-const TENSOR_ENTRY_BYTES: usize = 32;+// Format constants live in weights_part10.rs (included below). /// fp16 tensor encoding. `pub(crate)` for the fusion tests' hand-made header; the /// format's dtypes are otherwise an internal detail of the parser. pub(crate) const DTYPE_F16: u32 = 0;@@ -498,4 +484,4 @@ include!("weights_part5.rs"); include!("weights_part6.rs"); include!("weights_part7.rs"); include!("weights_part8.rs");-include!("weights_part9.rs");\ No newline at end of file+include!("weights_part9.rs");include!("weights_part10.rs");
library/ml/src/main/rust/src/weights_part10.rs
diff --git a/library/ml/src/main/rust/src/weights_part10.rs b/library/ml/src/main/rust/src/weights_part10.rsnew file mode 100644index 0000000000..0f5526811e--- /dev/null+++ b/library/ml/src/main/rust/src/weights_part10.rs@@ -0,0 +1,15 @@+/// `b"MAML"`, little-endian, at offset 0.+const MAGIC: [u8; 4] = *b"MAML";+/// Bumped when the layout below changes incompatibly.+///+/// Version 1 is header + table + blob. Version 2 appends a graph section after the blob+/// (see [`Graph`]); a v1 reader rejects a v2 file here, loudly, rather than running a+/// topology it cannot see.+#[cfg(test)]+const FORMAT_VERSION: u32 = 1;+/// The newest version this reader accepts. Kept distinct from [`FORMAT_VERSION`] — the+/// version *written* by the converter — so emitting v2 files is a separate, deliberate+/// step from reading them.+const FORMAT_READ_VERSION: u32 = 2;+const HEADER_BYTES: usize = 64;+const TENSOR_ENTRY_BYTES: usize = 32;