storage_copy.bend
stelliferous@0.0.3.0 · 17 lines · 0 definitions
1# Internal contiguous ranges. Callers establish bounds; the shared copy proof
2# and storage certificates cover the actual loop without a per-element check.
3import Base
4import stelliferous@0.0.3.0/storage_buffer.bend as Storage
5import stelliferous@0.0.3.0/tensor_view.bend as Views
6import stelliferous@0.0.3.0/tensor_access.bend as Access
7import stelliferous@0.0.3.0/tensor_operations.bend as Operations
8import stelliferous@0.0.3.0/proofs/tensor_access_certificate.bend as AccessCertificate
9
10def range(~Element: Data,+count: U32,+source: U32,+destination: U32,input: Storage.Buffer<Element>,output: Storage.Buffer<Element>) ->
11 Storage.Buffer<Element> & Storage.Buffer<Element>:
12 Storage.Buffer{input,input_length,input_certificate} = input
13 Storage.Buffer{output,output_length,output_certificate} = output
14 +view = {Views.View{[Views.Axis{count,1}],source} : Views.View}
15 Operations.pair_buffers(~Element,input_length,output_length,
16 Access.copy_run(~Element,True{},U32.to_nat(count),view,destination,input,output),
17 AccessCertificate.copy(~Element,True{},U32.to_nat(count),view,destination,input,output,input_certificate,output_certificate))