gelu¶
- nvtripy.gelu(input: Tensor) Tensor [source]¶
Applies a Gaussian Error Linear Unit (GELU) function to each element of the input tensor:
\(\text{gelu}(x) = x * \phi(x)\)
where \(\phi(x)\) is the Cumulative Distribution Function (CDF) of a Gaussian distribution.
- Parameters:
input (Tensor) – [dtype=T1] The input tensor.
- Returns:
[dtype=T1] A tensor of the same shape as the input.
- Return type:
Example
1input = tp.Tensor([1.0, 2.0, 3.0, 4.0], dtype=tp.float32) 2output = tp.gelu(input)
Local Variables¶>>> input tensor([1, 2, 3, 4], dtype=float32, loc=cpu:0, shape=(4,)) >>> output tensor([0.841345, 1.9545, 2.99595, 3.99987], dtype=float32, loc=gpu:0, shape=(4,))