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

Function generate_inputs

examples/pytorch/linear_backward/reference.py:3–10  ·  view source on GitHub ↗
(axes_and_scalars, device)

Source from the content-addressed store, hash-verified

1import torch
2
3def generate_inputs(axes_and_scalars, device):
4 M = axes_and_scalars['M']
5 N = axes_and_scalars['N']
6 K = axes_and_scalars['K']
7 grad_output = torch.randn(M, N, dtype=torch.float32, device=device) / N ** 0.5
8 x = torch.randn(M, K, dtype=torch.float32, device=device) / K ** 0.5
9 weight = torch.randn(N, K, dtype=torch.float32, device=device) / K ** 0.5
10 return {'grad_output': grad_output, 'x': x, 'weight': weight}
11
12@torch.no_grad()
13def run(grad_output, x, weight):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected