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

Function test_dot

imperative/python/test/unit/core/test_autodiff.py:526–541  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

524
525
526def test_dot():
527 x = np.random.rand(2, 2).astype("float32")
528 x = mge.Tensor(x)
529 u = F.ones((2,))
530 v = F.ones((2,))
531
532 with Grad() as grad:
533 grad.wrt(x, callback=save_to(x))
534
535 def f(x):
536 return F.dot(u, F.matmul(x, v))
537
538 y = f(x)
539 grad(y, F.ones_like(y))
540
541 np.testing.assert_equal(np.ones((2, 2), dtype=np.float32), x.grad.numpy())
542
543
544def test_pixel_shuffle():

Callers

nothing calls this directly

Calls 10

GradClass · 0.90
save_toFunction · 0.85
gradFunction · 0.85
onesMethod · 0.80
wrtMethod · 0.80
assert_equalMethod · 0.80
fFunction · 0.70
astypeMethod · 0.45
TensorMethod · 0.45
numpyMethod · 0.45

Tested by

no test coverage detected