def apply_indexed
stelliferous@0.0.2.0 · tensor_operations.bend:172
import stelliferous@0.0.2.0/tensor_operations.bend as TensorOperations
import Base
import stelliferous@0.0.2.0/storage_buffer.bend as Storage
import stelliferous@0.0.2.0/tensor_view.bend as Views
import stelliferous@0.0.2.0/proofs/storage_certificate.bend as Certificate
172
173def apply_indexed(~Element: Data,~operation: U32 -> Element -> Element,input: Storage.Buffer<Element>,+view: Views.View,
174 output: Storage.Buffer<Element>) -> Outcome<(Storage.Buffer<Element> & Storage.Buffer<Element>)>:
175 Storage.Buffer{input,+input_length,input_certificate} = input
176 Certificate.Certificate{+input_depth,input_equation} = input_certificate
177 Storage.Buffer{output,+output_length,output_certificate} = output
178 Certificate.Certificate{+output_depth,output_equation} = output_certificate
179 apply_indexed_when(~Element,~operation,Views.is_contiguous(view) && valid_buffer(input_length,U32.shln(1,input_depth),view) &&
180 holds(Views.numel(view),output_length,U32.shln(1,output_depth)),Views.numel(view),view,
181 Storage.Buffer{input,input_length,Certificate.Certificate{input_depth,input_equation}},Storage.Buffer{output,output_length,Certificate.Certificate{output_depth,output_equation}})