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

Function mlp_forward

tests/dump_phase7_reference.py:261–268  ·  view source on GitHub ↗
(x: torch.Tensor, weights: Dict[str, torch.Tensor], prefix: str, num_layers: int)

Source from the content-addressed store, hash-verified

259
260
261def mlp_forward(x: torch.Tensor, weights: Dict[str, torch.Tensor], prefix: str, num_layers: int) -> torch.Tensor:
262 for i in range(num_layers):
263 w = weights[f"{prefix}.layers.{i}.weight"].float()
264 b = weights[f"{prefix}.layers.{i}.bias"].float()
265 x = F.linear(x, w, b)
266 if i < num_layers - 1:
267 x = F.relu(x)
268 return x
269
270
271def build_no_point_prompt_encoder_outputs(prompt_weights: Dict[str, torch.Tensor]) -> tuple[torch.Tensor, torch.Tensor, torch.Tensor]:

Callers 1

run_sam_decoderFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected