main.bend relies on unsafe/foreign
raw source on the hub · import bendtorch-load@1.0.1.0/main.bend as Main
Temporary loading-only exception: bend-ml-binary-read is foreign C/JavaScript. No file with laws imports this module. Replace it with native Bend when the language supports dense reads (Renan, 2026-10-17).
3 imports
import Base import bend-ml-binary-read@0.1.0.0/main.bend as R import bendtorch@1.0.1.0/main.bend as T
Definitions
def require source · line 7 · raw
@ok:Bool -> @+message:String -> IO(Unit)
def read_done source · line 12 · raw
@+path:String -> @+n:U32 -> @r:Pair(File, Pair(Array<F32>, Result<&1, &1, Pair(U32, String), U32>)) -> IO(Array<F32>)
def read_sized source · line 21 · raw
@+path:String -> @+n:U32 -> @r:Pair(File, Result<&1, &1, Pair(U32, String), U32>) -> IO(Array<F32>)
def read source · line 31 · raw
@+path:String -> @+n:U32 -> IO(Array<F32>)
A raw, exact-size little-endian F32 file, read once into one source array. Counts and file offsets are U32.
def weights_done source · line 38 · raw
@-P:Type -> @+n:U32 -> @r:0xfc8448b10655d3efdb72c022131382f2/main.PA<P> -> IO(P)
Templates
template weights source · line 46 · raw
@-P:Type -> @-X:Type -> @-Y:Type -> @-S:Type -> @-m:0xfc8448b10655d3efdb72c022131382f2/main.Layer<P, X, Y, S> -> @+path:String -> @p:P -> IO(P)
All parameters in Layer.dump order. The source array is released after the model's arrays are filled.
template train_read source · line 54 · raw
@-P:Type -> @-X:Type -> @-Y:Type -> @-S:Type -> @-m:0xfc8448b10655d3efdb72c022131382f2/main.Layer<P, X, Y, S> -> @+path:String -> @+base:U32 -> @+copies:U32 -> @+tail:U32 -> @tr:0xfc8448b10655d3efdb72c022131382f2/main.Train<P> -> IO(0xfc8448b10655d3efdb72c022131382f2/main.Train<P>)
The checkpoint layout is determined by the already initialized optimizer state, without a header: SGD: parameters; momentum: parameters, buffer; Adam/AdamW: parameters, m, v, 1 - b1^t, 1 - b2^t.
template train source · line 61 · raw
@-P:Type -> @-X:Type -> @-Y:Type -> @-S:Type -> @-m:0xfc8448b10655d3efdb72c022131382f2/main.Layer<P, X, Y, S> -> @+path:String -> @tr:0xfc8448b10655d3efdb72c022131382f2/main.Train<P> -> IO(0xfc8448b10655d3efdb72c022131382f2/main.Train<P>)