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

Function test_where

imperative/python/test/unit/functional/test_functional.py:30–58  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

28
29
30def test_where():
31 maskv0 = np.array([[1, 0], [0, 1]], dtype=np.bool_)
32 xv0 = np.array([[1, np.inf], [np.nan, 4]], dtype=np.float32)
33 yv0 = np.array([[5, 6], [7, 8]], dtype=np.float32)
34
35 maskv1 = np.array([[1, 0, 1], [1, 0, 0], [1, 1, 0]], dtype=np.bool_)
36 xv1 = np.array([[1, np.inf, 2], [0, np.nan, 4], [1, 5, 7]], dtype=np.float32)
37 yv1 = np.array([[5, 6, 9], [2, 7, 8], [2, 1, 9]], dtype=np.float32)
38
39 maskv2 = np.array([1, 1, 1], dtype=np.bool_)
40 xv2 = np.array([1, 3, 2], dtype=np.float32)
41 yv2 = np.array([5, 6, 9], dtype=np.float32)
42
43 maskv3 = np.array([0, 0, 0], dtype=np.bool_)
44 xv3 = np.array([1, 3, 2], dtype=np.float32)
45 yv3 = np.array([5, 6, 9], dtype=np.float32)
46
47 maskv4 = np.array(1, dtype=np.bool_)
48 xv4 = np.array(1, dtype=np.float32)
49 yv4 = np.array(0, dtype=np.float32)
50
51 cases = [
52 {"input": [maskv0, xv0, yv0]},
53 {"input": [maskv1, xv1, yv1]},
54 {"input": [maskv2, xv2, yv2]},
55 {"input": [maskv3, xv3, yv3]},
56 {"input": [maskv4, xv4, yv4]},
57 ]
58 opr_test(cases, F.where, ref_fn=np.where, test_trace=True)
59
60
61def test_dropout():

Callers

nothing calls this directly

Calls 2

opr_testFunction · 0.90
arrayMethod · 0.80

Tested by

no test coverage detected