MCPcopy Create free account
hub / github.com/OpenSparseLLMs/MoM / f

Function f

benchmarks/ops/benchmark.py:54–59  ·  view source on GitHub ↗
(*inputs, y, grad)

Source from the content-addressed store, hash-verified

52 raise RuntimeError("Grad shape does not match output shape")
53
54 def f(*inputs, y, grad):
55 # Set .grad to None to avoid extra operation of gradient accumulation
56 for x in inputs:
57 if isinstance(x, torch.Tensor):
58 x.grad = None
59 y.backward(grad, retain_graph=True)
60
61 t = benchmark.Timer(
62 stmt="f(*inputs, y=y, grad=grad)",

Callers 1

applyMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected