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

Function test_reduce

imperative/python/test/unit/core/test_tensor_wrapper.py:82–97  ·  view source on GitHub ↗
(is_varnode)

Source from the content-addressed store, hash-verified

80
81@pytest.mark.parametrize("is_varnode", [True, False])
82def test_reduce(is_varnode):
83 if is_varnode:
84 network = Network()
85 else:
86 network = None
87
88 def test_x(x_np):
89 for m in ["sum", "prod", "min", "max", "mean"]:
90 x = make_tensor(x_np, network)
91 y = getattr(x, m)(axis=-1, keepdims=True)
92 np.testing.assert_almost_equal(y.numpy(), getattr(x_np, m)(-1), decimal=6)
93
94 test_x((10 * np.random.rand(10) + 1).astype("int32"))
95 test_x(np.random.rand(10).astype("float32"))
96 test_x(np.array([True, True, True]))
97 test_x(np.array([True, False, True]))
98
99
100@pytest.mark.parametrize("is_varnode", [True, False])

Callers

nothing calls this directly

Calls 4

NetworkClass · 0.90
test_xFunction · 0.85
arrayMethod · 0.80
astypeMethod · 0.45

Tested by

no test coverage detected