def pad_constant

stelliferous@0.0.2.0 · tensor_layout.bend:527

import stelliferous@0.0.2.0/tensor_layout.bend as TensorLayout
import Base
import stelliferous@0.0.2.0/tensor.bend as Tensors

527# Constant padding: storage of the padded extents filled with the value, then
528# the tensor written through the interior view. One copy whatever the axes.
529def pad_constant(~Element: Data,unchanged: Bool,+value: Element,tensor: Tensors.Tensor<Element>,+before: List<&2,U32>,+padded: List<&2,U32>) -> Tensors.Tensor<Element>:
530  match unchanged:
531    case True{}: tensor
532    case False{}:
533      Tensors.with_dense(~Element,~Tensors.Tensor<Element>,tensor,part => part_shape => part_fill => part_status => part_workers =>
534        +part_shape = part_shape
535        +part_fill = part_fill
536        +part_workers = part_workers
537        Tensors.with_dense(~Element,~Tensors.Tensor<Element>,blank(~Element,Tensors.count_of(padded),padded,value,part_fill,part_workers),
538          target => target_shape => target_fill => target_status => target_workers =>
539            result_of(~Element,place_status(~Element,"pad",target_status,part_status,interior(before,part_shape,Tensors.view_of(padded),0),
540              target,padded,target_fill,part,part_shape,part_fill,part_workers))))

Uses (11)

Used by (1)