def activated

stelliferous@0.0.2.0 · kernel_pipeline.bend:47

import stelliferous@0.0.2.0/kernel_pipeline.bend as KernelPipeline
import Base
import stelliferous@0.0.2.0/storage_buffer.bend as Storage
import stelliferous@0.0.2.0/math_activation.bend as Activations

47# One tight pass over each finished leaf while it is still in cache; applying
48# the activation inside the store measured about twice as slow. The built-in
49# is chosen once per leaf, so each pass is specialized; the identity skips it.
50# Sigmoid, SiLU, tanh and GELU pass their values through tiles.
51def activated(~custom: F32 -> F32,activation: Activations.Activation,+count: U32,buffer: Storage.Buffer<F32>) -> Storage.Buffer<F32>:
52  match activation:
53    case Activations.Identity{}: buffer
54    case Activations.ReLU{}: unit_mapped(~Activations.relu_value,count,buffer)
55    case Activations.ReLU6{}: unit_mapped(~Activations.relu6_value,count,buffer)
56    case Activations.LeakyReLU{slope}: mapped(~F32,~leaky_relu_value,count,slope,buffer)
57    case Activations.Sigmoid{}: unit_lanes(~Activations.sigmoid_value,count,buffer)
58    case Activations.SiLU{}: unit_lanes(~Activations.silu_value,count,buffer)
59    case Activations.Tanh{}: unit_lanes(~Activations.tanh_value,count,buffer)
60    case Activations.HardSigmoid{}: unit_mapped(~Activations.hard_sigmoid_value,count,buffer)
61    case Activations.HardSwish{}: unit_mapped(~Activations.hard_swish_value,count,buffer)
62    case Activations.GELUTanh{}: unit_lanes(~Activations.gelu_tanh_value,count,buffer)
63    case Activations.Custom{operations}: unit_mapped(~custom,count,buffer)

Uses (16)

Used by (1)