kernel_parameter_gradient_buffer.bend

stelliferous@0.0.3.0 · 16 lines · 0 definitions

1# Rebuild source owners once after the complete read-only native traversal.
2import Base
3import stelliferous@0.0.3.0/kernel_parameter_gradient.bend as Kernel
4import stelliferous@0.0.3.0/storage_buffer.bend as Storage
5import stelliferous@0.0.3.0/proofs/parameter_gradient_certificate.bend as Certificate
6import stelliferous@0.0.3.0/proofs/storage_certificate.bend as StorageCertificate
7
8def bias_kept(length: Nat,result: Array<F32> & Storage.Buffer<F32>,certificate: StorageCertificate.Certificate<F32,Certificate.source(~Array<F32>,result)>) ->
9  Storage.Buffer<F32> & Storage.Buffer<F32>:
10  (d,values) = result
11  (Storage.Buffer{d,length,certificate},values)
12
13# d is read; every output is written into result.
14def bias(+work: Kernel.Work,d: Storage.Buffer<F32>,result: Storage.Buffer<F32>) -> Storage.Buffer<F32> & Storage.Buffer<F32>:
15  Storage.Buffer{d,length,certificate} = d
16  bias_kept(length,Kernel.bias(work,d,result),Certificate.bias(work,d,result,certificate))