MCPcopy Create free account
hub / github.com/MegEngine/MegEngine / func

Function func

imperative/python/test/integration/test_xla_dist_training.py:75–81  ·  view source on GitHub ↗
(model, optimizer, timage, tlabel)

Source from the content-addressed store, hash-verified

73 label = np.random.randint(0, 10, (3, 8,))
74
75 def func(model, optimizer, timage, tlabel):
76 with gm:
77 score = model(timage)
78 loss = F.nn.cross_entropy(score, tlabel)
79 gm.backward(loss)
80 optimizer.step().clear_grad()
81 return loss
82
83 if is_trace:
84 func = xla_trace(func, without_host=True, capture_as_const=True)

Callers 1

runnerFunction · 0.70

Calls 4

modelFunction · 0.85
backwardMethod · 0.45
clear_gradMethod · 0.45
stepMethod · 0.45

Tested by

no test coverage detected