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

Function test_op

imperative/python/test/unit/core/test_megbrain_graph.py:61–74  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

59
60
61def test_op():
62 g = mgb_graph.Graph()
63 x = Tensor(np.random.randn(10).astype("float32"), device="xpux")._dev_tensor()
64 v, _ = mgb_graph.input_callback(
65 lambda: x, device=x.comp_node, dtype=x.dtype, graph=g
66 )
67 neg = Elemwise(Elemwise.Mode.NEGATE)
68 v = mgb_graph.apply_normal_varnode(neg, v)[0]
69 y = Future()
70 v = mgb_graph.output_callback(y.set_result, v)
71 f = g.compile(v)
72 f()
73
74 np.testing.assert_equal(x.numpy(), -y.result().numpy())
75
76
77def test_exception():

Callers

nothing calls this directly

Calls 9

compileMethod · 0.95
TensorClass · 0.90
_dev_tensorMethod · 0.80
assert_equalMethod · 0.80
fFunction · 0.70
ElemwiseClass · 0.50
FutureClass · 0.50
astypeMethod · 0.45
numpyMethod · 0.45

Tested by

no test coverage detected