MCPcopy Create free account
hub / github.com/pytorch/examples / __init__

Method __init__

distributed/tensor_parallelism/llama2_model.py:248–264  ·  view source on GitHub ↗
(
        self,
        dim: int,
        hidden_dim: int,
        multiple_of: int,
        ffn_dim_multiplier: Optional[float],
    )

Source from the content-addressed store, hash-verified

246 """
247
248 def __init__(
249 self,
250 dim: int,
251 hidden_dim: int,
252 multiple_of: int,
253 ffn_dim_multiplier: Optional[float],
254 ):
255 super().__init__()
256 hidden_dim = int(2 * hidden_dim / 3)
257 # custom dim factor multiplier
258 if ffn_dim_multiplier is not None:
259 hidden_dim = int(ffn_dim_multiplier * hidden_dim)
260 hidden_dim = multiple_of * ((hidden_dim + multiple_of - 1) // multiple_of)
261
262 self.w1 = nn.Linear(dim, hidden_dim, bias=False)
263 self.w2 = nn.Linear(hidden_dim, dim, bias=False)
264 self.w3 = nn.Linear(dim, hidden_dim, bias=False)
265
266 def forward(self, x):
267 return self.w2(F.silu(self.w1(x)) * self.w3(x))

Callers

nothing calls this directly

Calls 1

__init__Method · 0.45

Tested by

no test coverage detected