Function
mlp_forward
(x: torch.Tensor, weights: Dict[str, torch.Tensor], prefix: str, num_layers: int)
Source from the content-addressed store, hash-verified
| 259 | |
| 260 | |
| 261 | def 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 | |
| 271 | def build_no_point_prompt_encoder_outputs(prompt_weights: Dict[str, torch.Tensor]) -> tuple[torch.Tensor, torch.Tensor, torch.Tensor]: |
Tested by
no test coverage detected