Function dfdx::tensor_ops::fast_gelu
source · pub fn fast_gelu<S: Shape, E: Dtype, D: UnaryKernel<FastGeLUKernelOp, E>, T: Tape<E, D>>(
t: Tensor<S, E, D, T>
) -> Tensor<S, E, D, T>
Expand description
Fast Gaussian Linear Unit (GeLU). A fast version of the gaussiane linear unit calculated by
0.5 * x * (1 + tanh(sqrt(2 / pi) * (x + 0.044715 * x^3)))
See also accurate_gelu for the more accurate version.
Examples:
let t = dev.tensor([-1.0, 0.0, 1.0, 2.0]);
let r = t.gelu();