MCPcopy Create free account
hub / github.com/NVIDIA/SOL-ExecBench / run

Function run

examples/cuda_cpp/rmsnorm/reference.py:4–14  ·  view source on GitHub ↗
(hidden_states, weight)

Source from the content-addressed store, hash-verified

2
3@torch.no_grad()
4def run(hidden_states, weight):
5 batch_size, hidden_size = hidden_states.shape
6 # Check constants
7 assert hidden_size == 4096
8
9 EPS = 1e-5
10
11 x = hidden_states.to(torch.float32)
12 inv_rms = torch.rsqrt(x.pow(2).mean(dim=-1, keepdim=True) + EPS)
13 y = (x * inv_rms) * weight.to(torch.float32)
14 return y.to(hidden_states.dtype)

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected