def scatter
stelliferous@0.0.2.0 · tensor_operations.bend:68
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_shape.bend as Shapes
import stelliferous@0.0.2.0/tensor_view.bend as Views
import stelliferous@0.0.2.0/proofs/storage_certificate.bend as Certificate
68def scatter(~Element: Data,input: Storage.Buffer<Element>,+source: Views.View,
69 output: Storage.Buffer<Element>,+target: Views.View) -> Outcome<(Storage.Buffer<Element> & Storage.Buffer<Element>)>:
70 Storage.Buffer{input,+input_length,input_certificate} = input
71 Certificate.Certificate{+input_depth,input_equation} = input_certificate
72 Storage.Buffer{output,+output_length,output_certificate} = output
73 Certificate.Certificate{+output_depth,output_equation} = output_certificate
74 scatter_when(~Element,Shapes.same(Views.shape(source),Views.shape(target)) && Views.is_contiguous(source) &&
75 valid_buffer(input_length,U32.shln(1,input_depth),source) &&
76 valid_buffer(output_length,U32.shln(1,output_depth),target),Views.numel(target),source,target,
77 Storage.Buffer{input,input_length,Certificate.Certificate{input_depth,input_equation}},Storage.Buffer{output,output_length,Certificate.Certificate{output_depth,output_equation}})