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

Method __init__

backends/mlx/llm/switch.py:188–218  ·  view source on GitHub ↗
(
        self,
        hidden_size: int,
        intermediate_size: int,
        num_experts: int,
        activation=None,
        bias: bool = False,
        fuse_gate_up: bool = False,
    )

Source from the content-addressed store, hash-verified

186 """
187
188 def __init__(
189 self,
190 hidden_size: int,
191 intermediate_size: int,
192 num_experts: int,
193 activation=None,
194 bias: bool = False,
195 fuse_gate_up: bool = False,
196 ):
197 super().__init__()
198 if activation is None:
199 activation = nn.functional.silu
200 self.activation = activation
201 self.num_experts = num_experts
202 self.intermediate_size = intermediate_size
203 self.fuse_gate_up = fuse_gate_up
204
205 if fuse_gate_up:
206 self.gate_up_proj = SwitchLinear(
207 hidden_size, 2 * intermediate_size, num_experts, bias=bias
208 )
209 else:
210 self.gate_proj = SwitchLinear(
211 hidden_size, intermediate_size, num_experts, bias=bias
212 )
213 self.up_proj = SwitchLinear(
214 hidden_size, intermediate_size, num_experts, bias=bias
215 )
216 self.down_proj = SwitchLinear(
217 intermediate_size, hidden_size, num_experts, bias=bias
218 )
219
220 def forward(
221 self,

Callers 1

__init__Method · 0.45

Calls 1

SwitchLinearClass · 0.85

Tested by

no test coverage detected