def fold_slice

stelliferous@0.0.2.0 · tensor_layout.bend:412

import stelliferous@0.0.2.0/tensor_layout.bend as TensorLayout
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/tensor_operations.bend as Operations

412# Reduction along one axis. The output starts at the initial value and takes
413# the slices of the axis in increasing index, so each output element is
414# operation(... operation(operation(initial, x[0]), x[1]) ..., x[extent - 1]).
415def fold_slice(~Element: Data,~operation: Element -> Element -> Element,valid: Bool,slice: Maybe<&2,Views.View>,target: Maybe<&2,Views.View>,
416  output: Storage.Buffer<Element>,input: Storage.Buffer<Element>) -> (Storage.Buffer<Element> & Storage.Buffer<Element>) & Bool:
417  match slice target:
418    case Some{slice} Some{target}: settle(~Element,valid,Operations.combine(~Element,~operation,output,target,input,slice))
419    case slice target: ((output,input),False{})

Uses (8)

Used by (1)