FeedForward¶
- class torchtune.modules.FeedForward(*, gate_proj: Module, down_proj: Module, up_proj: Module, activation: Module = SiLU())[source]¶
This class implements the feed-forward network derived from Llama2.
- Parameters:
gate_proj (nn.Module) – Projection from input dim to hidden dim, fed through activation and multiplied by up_proj.
down_proj (nn.Module) – Final projection to output dim.
up_proj (nn.Module) – Projection from input dim to hidden dim, multiplied by activation(gate_proj).
activation (nn.Module) – Activation function to use. Default is nn.SiLU().
- forward(x: Tensor) Tensor [source]¶
Define the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Module
instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.