xnn.common.models.ops.GELU#

class xnn.common.models.ops.GELU(approximate='none')[source]#

Bases: GELU

torch.nn.GELU (exact form) whose derivative stays the fused kernel under autograd.

As SiLU: the derivative is the one gelu_backward kernel, its own derivative the closed form gelu''(x) = phi(x) (2 - x^2) with the standard normal density phi, under the same conditions. The "tanh" approximation and TorchScript use torch.nn.functional.gelu().

Parameters:

approximate (str)

forward(x)[source]#

Runs the forward pass.

Parameters:

x (Tensor)

Return type:

Tensor