def stream_exact
bend-ml-llama@0.2.0.0 · main.bend:1220
import bend-ml-llama@0.2.0.0/main.bend as BendMlLlama
import Base
import bend-ml-tensor-array@0.1.14.0/main.bend as TA
1220
1221
1222def 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>):
1223 match k m:
1224 case 0n Tuple{f, rs}:
1225 do IO<TA.Mat<r, c>>:
1226 File.close(f)
1227 return acc
1228 case 1n+p Tuple{f, rs}:
1229 do IO<TA.Mat<r, c>>:
1230 bs : List<&2, U32> <- IO.pass(List<&2, U32>, rs)
1231 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))))
1232 stream_exact(p, r, c, Nat.sub(rem, 1048576n), (off + 1048576 : U32), (idx + 262144 : U32), m2, fill_bytes_mat(r, c, idx, bs, acc))