Elementwise.scalar: def of bendtorch-core@0.1.0.0 Import: import bendtorch-core@0.1.0.0/src/tensor/elementwise.bend as Elementwise Lines 85-118 of bendtorch-core@0.1.0.0/src/tensor/elementwise.bend: https://jend.leeeet.dev/read.txt?path=bendtorch-core@0.1.0.0/src/tensor/elementwise.bend&start_line=85&end_line=118 import Base def scalar(operation: Operation, left: F32, right: F32) -> F32: match operation: case Add{}: F32.add(left, right) case Sub{}: F32.sub(left, right) case Mul{}: F32.mul(left, right) case KeepLeft{}: left case NegateLeft{}: F32.neg(left) case ReluLeft{}: relu(left) case ReluBackward{}: relu_backward(left, right) case Divide{}: F32.div(left, right) case ExpLeft{}: F32.exp(left) case LogLeft{}: F32.log(left) case Matches{}: zero_if(Bool.not(U32.is_eq(bits(left), bits(right))), 1.0) case PickNegated{}: zero_if(Bool.not(is_one(right)), F32.neg(left)) case MseGrad{+scale}: F32.mul(F32.mul(scale, right), left) case OneHotGrad{+count}: zero_if(Bool.not(is_one(right)), target_gradient(left, count)) case SoftmaxGrad{+count, +single}: F32.neg(F32.mul(F32.exp(right), row_sum(single, target_gradient(left, count)))) case Descend{lr}: F32.sub(left, F32.mul(lr, right)) Uses (18): https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Bool.not https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=F32 https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=F32.add https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=F32.div https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=F32.exp https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=F32.log https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=F32.mul https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=F32.neg https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=F32.sub https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32.is_eq https://jend.leeeet.dev/definition.txt?path=bendtorch-core@0.1.0.0/src/tensor/elementwise.bend&name=Operation https://jend.leeeet.dev/definition.txt?path=bendtorch-core@0.1.0.0/src/tensor/elementwise.bend&name=bits https://jend.leeeet.dev/definition.txt?path=bendtorch-core@0.1.0.0/src/tensor/elementwise.bend&name=is_one https://jend.leeeet.dev/definition.txt?path=bendtorch-core@0.1.0.0/src/tensor/elementwise.bend&name=relu https://jend.leeeet.dev/definition.txt?path=bendtorch-core@0.1.0.0/src/tensor/elementwise.bend&name=relu_backward https://jend.leeeet.dev/definition.txt?path=bendtorch-core@0.1.0.0/src/tensor/elementwise.bend&name=row_sum https://jend.leeeet.dev/definition.txt?path=bendtorch-core@0.1.0.0/src/tensor/elementwise.bend&name=target_gradient https://jend.leeeet.dev/definition.txt?path=bendtorch-core@0.1.0.0/src/tensor/elementwise.bend&name=zero_if