MCPcopy
hub / github.com/tinygrad/tinygrad / step

Function step

test/backend/test_optim.py:36–44  ·  view source on GitHub ↗
(tensor, optim, steps=1, teeny=False, **kwargs)

Source from the content-addressed store, hash-verified

34 return out
35
36def step(tensor, optim, steps=1, teeny=False, **kwargs):
37 net = TeenyNet(tensor) if teeny else TinyNet(tensor)
38 optim = optim([net.x, net.W], **kwargs)
39 for _ in range(steps):
40 out = net.forward()
41 optim.zero_grad()
42 out.backward()
43 optim.step()
44 return net.x.detach().numpy(), net.W.detach().numpy()
45
46@slow
47class TestOptim(unittest.TestCase):

Callers 2

_test_optimMethod · 0.70

Calls 8

TeenyNetClass · 0.85
detachMethod · 0.80
TinyNetClass · 0.70
forwardMethod · 0.45
zero_gradMethod · 0.45
backwardMethod · 0.45
stepMethod · 0.45
numpyMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…