def read_bf16_at

bendtorch-load@1.3.0.0 · main.bend:150

import bendtorch-load@1.3.0.0/main.bend as BendtorchLoad
import Base
import bend-ml-binary-read@0.2.0.0/main.bend as R
import bendtorch@1.3.0.0/main.bend as T

150# n little-endian BF16 numbers at byte `off` of a file of any size, each widened exactly to F32 (bf16.to(torch.float32))
151def read_bf16_at(+path: String, off: W64, +n: U32) -> IO(Array<F32>):
152  match off:
153    case W64{hi, lo}:
154      do IO<Array<F32>>:
155        f : File <- IO.try(File, File.open(path, "r"))
156        rr : File & (Array<F32> & Result<&1, &1, U32 & String, U32>) <- R.read_bf16_at(f, hi, lo, n, Array.new(F32, T.depth(U32.to_nat(n)), 0.0))
157        read_done(path, n, rr)

Uses (17)

Used by (0)

No other definition uses this definition.