def tensors_from

bendtorch-load@1.3.0.0 · main.bend:574

import bendtorch-load@1.3.0.0/main.bend as BendtorchLoad
import Base
import bendtorch@1.3.0.0/main.bend as T

574# The tensors `layout` names, read from the file whose header is h, in the layout's order, into one array of n numbers
575def tensors_from(+path: String, h: Header, +n: U32, +layout: List<&2, Entry>) -> IO(Array<F32>):
576  match h:
577    case Header{start, recs}:
578      do IO<Array<F32>>:
579        require(U32.is_eq(St.total(layout), n), path ++ ": the layout holds " ++ U32.show(St.total(layout)) ++ " numbers, the model " ++ U32.show(n))
580        f : File <- IO.try(File, File.open(path, "r"))
581        St.fill(layout, path, start, recs, f, Array.new(F32, T.depth(U32.to_nat(n)), 0.0), 0)

Uses (22)

Used by (2)