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

Function test_matmul

imperative/python/test/unit/core/test_tensor_wrapper.py:48–62  ·  view source on GitHub ↗
(is_varnode, shape_a, shape_b)

Source from the content-addressed store, hash-verified

46 "shape_a, shape_b", [((4,), (4,)), ((10, 4), (4, 10)), ((3, 10, 4), (3, 4, 10)),],
47)
48def test_matmul(is_varnode, shape_a, shape_b):
49 if is_varnode:
50 network = Network()
51 else:
52 network = None
53
54 A = make_tensor(np.random.rand(*shape_a).astype("float32"), network)
55 B = make_tensor(np.random.rand(*shape_b).astype("float32"), network)
56 C = A @ B
57 if is_varnode:
58 np.testing.assert_almost_equal(
59 get_var_value(C), get_var_value(A) @ get_var_value(B), decimal=6
60 )
61 else:
62 np.testing.assert_almost_equal(C.numpy(), A.numpy() @ B.numpy(), decimal=6)
63
64
65@pytest.mark.parametrize("is_varnode", [True, False])

Callers

nothing calls this directly

Calls 5

NetworkClass · 0.90
make_tensorFunction · 0.90
get_var_valueFunction · 0.90
astypeMethod · 0.45
numpyMethod · 0.45

Tested by

no test coverage detected