maia: the weights move into the network (no copy), the file's bytes go once read
Peak memory while loading: 79M 940 → 636 MB, 5M 72 → 52 MB. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
0fd40f01b4
commit
a94de00199
3 changed files with 20 additions and 11 deletions
|
|
@ -65,7 +65,7 @@ struct Linear {
|
|||
|
||||
impl Linear {
|
||||
fn load(
|
||||
w: &Weights,
|
||||
w: &mut Weights,
|
||||
name: &str,
|
||||
out: usize,
|
||||
inp: usize,
|
||||
|
|
@ -152,7 +152,7 @@ struct LayerNorm {
|
|||
}
|
||||
|
||||
impl LayerNorm {
|
||||
fn load(w: &Weights, name: &str, n: usize) -> Result<LayerNorm, WeightsError> {
|
||||
fn load(w: &mut Weights, name: &str, n: usize) -> Result<LayerNorm, WeightsError> {
|
||||
Ok(LayerNorm {
|
||||
w: w.get(&format!("{name}.weight"), &[n])?,
|
||||
b: w.get(&format!("{name}.bias"), &[n])?,
|
||||
|
|
@ -246,7 +246,7 @@ pub struct Prediction {
|
|||
}
|
||||
|
||||
impl Net {
|
||||
pub fn new(w: &Weights) -> Result<Net, WeightsError> {
|
||||
pub fn new(w: &mut Weights) -> Result<Net, WeightsError> {
|
||||
let dims = Dims::read(w)?;
|
||||
let Dims {
|
||||
d,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue