xnn.common.models.ops.SiLU#

class xnn.common.models.ops.SiLU(inplace=False)[source]#

Bases: SiLU

torch.nn.SiLU whose derivative stays the fused kernel under autograd.

Differentiated with a graph (the forces of a force loss), torch writes the derivative of silu as six recorded operations, each differentiated again for the parameter gradients. Here the derivative is the one silu_backward kernel torch uses without a graph, and its own derivative the closed form silu''(x) = s (1 - s) (2 + x (1 - 2 s)) with s = sigmoid(x). In training on inputs of at least FUSED_SLOPE_MIN_ELEMENTS (a force loss differentiates the derivative); otherwise, and under TorchScript, the values and derivatives are those of torch.nn.functional.silu(), the same numbers.

Parameters:

inplace (bool)

forward(x)[source]#

Runs the forward pass.

Parameters:

x (Tensor)

Return type:

Tensor