TensorF32.activate: def of stelliferous@0.0.2.0 Import: import stelliferous@0.0.2.0/tensor_f32.bend as TensorF32 Lines 231-247 of stelliferous@0.0.2.0/tensor_f32.bend: https://jend.leeeet.dev/read.txt?path=stelliferous@0.0.2.0/tensor_f32.bend&start_line=231&end_line=247 import Base import stelliferous@0.0.2.0/math_activation.bend as Activations import stelliferous@0.0.2.0/tensor.bend as Tensors import stelliferous@0.0.2.0/tensor_operations.bend as Operations # Activations: Act.silu() and the other values of lib/math_activation.bend # carry their own planner cost. activate applies one to a tensor; relu, silu, # ... below are its shorthands. Custom carries only a cost; its function # reaches conv2d_custom or apply, and activate fails on it. def activate(tensor: Tensor(),+activation: Activations.Activation) -> Tensor(): match activation: case Activations.Identity{}: tensor case Activations.ReLU{}: Tensors.apply(~F32,~Operations.mapped(~F32,~Activations.relu_value),"relu",Activations.operations(Activations.ReLU{}),tensor) case Activations.ReLU6{}: Tensors.apply(~F32,~Operations.mapped(~F32,~Activations.relu6_value),"relu6",Activations.operations(Activations.ReLU6{}),tensor) case Activations.LeakyReLU{+slope}: Tensors.combine_scalar(~F32,~Activations.leaky_relu_value,"leaky_relu",Activations.operations(Activations.LeakyReLU{slope}),tensor,slope) case Activations.Sigmoid{}: Tensors.apply(~F32,~Operations.mapped_lanes(~Activations.sigmoid_value),"sigmoid",Activations.operations(Activations.Sigmoid{}),tensor) case Activations.SiLU{}: Tensors.apply(~F32,~Operations.mapped_lanes(~Activations.silu_value),"silu",Activations.operations(Activations.SiLU{}),tensor) case Activations.Tanh{}: Tensors.apply(~F32,~Operations.mapped_lanes(~Activations.tanh_value),"tanh",Activations.operations(Activations.Tanh{}),tensor) case Activations.HardSigmoid{}: Tensors.apply(~F32,~Operations.mapped(~F32,~Activations.hard_sigmoid_value),"hard_sigmoid",Activations.operations(Activations.HardSigmoid{}),tensor) case Activations.HardSwish{}: Tensors.apply(~F32,~Operations.mapped(~F32,~Activations.hard_swish_value),"hard_swish",Activations.operations(Activations.HardSwish{}),tensor) case Activations.GELUTanh{}: Tensors.apply(~F32,~Operations.mapped_lanes(~Activations.gelu_tanh_value),"gelu_tanh",Activations.operations(Activations.GELUTanh{}),tensor) case Activations.Custom{count}: Tensors.rejected(~F32,"activate",tensor) Uses (18): https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=F32 https://jend.leeeet.dev/definition.txt?path=stelliferous@0.0.2.0/math_activation.bend&name=Activation https://jend.leeeet.dev/definition.txt?path=stelliferous@0.0.2.0/math_activation.bend&name=gelu_tanh_value https://jend.leeeet.dev/definition.txt?path=stelliferous@0.0.2.0/math_activation.bend&name=hard_sigmoid_value https://jend.leeeet.dev/definition.txt?path=stelliferous@0.0.2.0/math_activation.bend&name=hard_swish_value https://jend.leeeet.dev/definition.txt?path=stelliferous@0.0.2.0/math_activation.bend&name=leaky_relu_value https://jend.leeeet.dev/definition.txt?path=stelliferous@0.0.2.0/math_activation.bend&name=operations https://jend.leeeet.dev/definition.txt?path=stelliferous@0.0.2.0/math_activation.bend&name=relu6_value https://jend.leeeet.dev/definition.txt?path=stelliferous@0.0.2.0/math_activation.bend&name=relu_value https://jend.leeeet.dev/definition.txt?path=stelliferous@0.0.2.0/math_activation.bend&name=sigmoid_value https://jend.leeeet.dev/definition.txt?path=stelliferous@0.0.2.0/math_activation.bend&name=silu_value https://jend.leeeet.dev/definition.txt?path=stelliferous@0.0.2.0/math_activation.bend&name=tanh_value https://jend.leeeet.dev/definition.txt?path=stelliferous@0.0.2.0/tensor.bend&name=apply https://jend.leeeet.dev/definition.txt?path=stelliferous@0.0.2.0/tensor.bend&name=combine_scalar https://jend.leeeet.dev/definition.txt?path=stelliferous@0.0.2.0/tensor.bend&name=rejected https://jend.leeeet.dev/definition.txt?path=stelliferous@0.0.2.0/tensor_f32.bend&name=Tensor https://jend.leeeet.dev/definition.txt?path=stelliferous@0.0.2.0/tensor_operations.bend&name=mapped https://jend.leeeet.dev/definition.txt?path=stelliferous@0.0.2.0/tensor_operations.bend&name=mapped_lanes