MCPcopy Create free account
hub / github.com/PABannier/sam3.cpp / mlp_forward

Function mlp_forward

tests/dump_phase5_reference.py:86–94  ·  view source on GitHub ↗

Forward through MLP layers from state dict.

(x, sd, prefix, num_layers, activation="relu")

Source from the content-addressed store, hash-verified

84
85
86def mlp_forward(x, sd, prefix, num_layers, activation="relu"):
87 """Forward through MLP layers from state dict."""
88 for i in range(num_layers):
89 w = sd[f"{prefix}.layers.{i}.weight"]
90 b = sd[f"{prefix}.layers.{i}.bias"]
91 x = F.linear(x, w, b)
92 if i < num_layers - 1:
93 x = F.relu(x)
94 return x
95
96
97def multihead_attention_forward(query, key, value, w_q, b_q, w_k, b_k, w_v, b_v,

Callers 1

mainFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected