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

Function test_removeAxis

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

Source from the content-addressed store, hash-verified

502
503
504def test_removeAxis():
505 x_np = np.random.rand(3, 3, 1, 1).astype("float32")
506 x = mge.Tensor(x_np)
507
508 with Grad() as grad:
509 grad.wrt(x, callback=save_to(x))
510 refs = {}
511
512 def f(x):
513 x = x * 1
514 y = F.squeeze(x, [2, 3])
515 refs["x"] = TensorWeakRef(x)
516 return y
517
518 y = f(x)
519 for _, r in refs.items():
520 assert r() is None
521 grad(y, F.ones_like(y))
522
523 np.testing.assert_equal(np.ones((3, 3, 1, 1), dtype=np.float32), x.grad.numpy())
524
525
526def test_dot():

Callers

nothing calls this directly

Calls 11

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

Tested by

no test coverage detected