(self, dev)
| 1500 | self._or_helper(gpu_dev) |
| 1501 | |
| 1502 | def _xor_helper(self, dev): |
| 1503 | x0 = np.array([0, -0.3, -0.1, 0.1, 0.5, |
| 1504 | 9.0]).reshape(3, 2).astype(np.float32) |
| 1505 | x1 = np.array([0, -0.3, 0, 0.1, 0, 0.9]).reshape(3, |
| 1506 | 2).astype(np.float32) |
| 1507 | |
| 1508 | x0 = tensor.from_numpy(x0) |
| 1509 | x1 = tensor.from_numpy(x1) |
| 1510 | x0.to_device(dev) |
| 1511 | x1.to_device(dev) |
| 1512 | |
| 1513 | y = autograd._xor(x0, x1) |
| 1514 | |
| 1515 | # frontend |
| 1516 | model = sonnx.to_onnx([x0, x1], [y]) |
| 1517 | # print('The model is:\n{}'.format(model)) |
| 1518 | |
| 1519 | # backend |
| 1520 | sg_ir = sonnx.prepare(model, device=dev) |
| 1521 | sg_ir.is_graph = True |
| 1522 | y_t = sg_ir.run([x0, x1]) |
| 1523 | |
| 1524 | np.testing.assert_array_almost_equal(tensor.to_numpy(y), |
| 1525 | tensor.to_numpy(y_t[0]), |
| 1526 | decimal=5) |
| 1527 | |
| 1528 | def test_xor_cpu(self): |
| 1529 | self._xor_helper(cpu_dev) |
no test coverage detected