def stream_exact
bend-ml-llama@0.2.1.0 · main.bend:1498
import bend-ml-llama@0.2.1.0/main.bend as BendMlLlama
import Base
import bend-ml-tensor-array@0.1.19.0/main.bend as TA
1498
1499
1500def stream_exact(k: Nat, -r: Nat, -c: Nat, +rem: Nat, +off: U32, +idx: U32, m: File & Result<&1, &1, U32 & String, List<&2, U32>>, acc: TA.Mat<r, c>) -> IO(TA.Mat<r, c>):
1501 match k m:
1502 case 0n Tuple{f, rs}:
1503 do IO<TA.Mat<r, c>>:
1504 File.close(f)
1505 return acc
1506 case 1n+p Tuple{f, rs}:
1507 do IO<TA.Mat<r, c>>:
1508 bs : List<&2, U32> <- IO.pass(List<&2, U32>, rs)
1509 m2 : File & Result<&1, &1, U32 & String, List<&2, U32>> <- File.read_at(f, (off + 1048576 : U32), U32.from_nat(Nat.min(1048576n, Nat.sub(rem, 1048576n))))
1510 stream_exact(p, r, c, Nat.sub(rem, 1048576n), (off + 1048576 : U32), (idx + 524288 : U32), m2, fill_bf16_mat(r, c, idx, bs, acc))