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

Function layer_norm_2d

tests/dump_phase7_reference.py:147–151  ·  view source on GitHub ↗
(x: torch.Tensor, weight: torch.Tensor, bias: torch.Tensor, eps: float = 1e-6)

Source from the content-addressed store, hash-verified

145
146
147def layer_norm_2d(x: torch.Tensor, weight: torch.Tensor, bias: torch.Tensor, eps: float = 1e-6) -> torch.Tensor:
148 u = x.mean(1, keepdim=True)
149 s = (x - u).pow(2).mean(1, keepdim=True)
150 x = (x - u) / torch.sqrt(s + eps)
151 return weight[:, None, None] * x + bias[:, None, None]
152
153
154def sinusoidal_pe(h: int, w: int, d_model: int) -> torch.Tensor:

Callers 2

run_sam_decoderFunction · 0.70
run_memory_encoderFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected