()
| 59 | |
| 60 | |
| 61 | def 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 | |
| 77 | def test_exception(): |
nothing calls this directly
no test coverage detected