(self, dev)
| 1435 | self._shape_helper(gpu_dev) |
| 1436 | |
| 1437 | def _and_helper(self, dev): |
| 1438 | x0 = np.array([0, -0.3, -0.1, 0.1, 0.5, |
| 1439 | 0.9]).reshape(3, 2).astype(np.float32) |
| 1440 | x1 = np.array([0, -0.3, 0, 0.1, 0.5, 0.9]).reshape(3, |
| 1441 | 2).astype(np.float32) |
| 1442 | |
| 1443 | x0 = tensor.from_numpy(x0) |
| 1444 | x1 = tensor.from_numpy(x1) |
| 1445 | x0.to_device(dev) |
| 1446 | x1.to_device(dev) |
| 1447 | |
| 1448 | y = autograd._and(x0, x1) |
| 1449 | |
| 1450 | # frontend |
| 1451 | model = sonnx.to_onnx([x0, x1], [y]) |
| 1452 | # print('The model is:\n{}'.format(model)) |
| 1453 | |
| 1454 | # backend |
| 1455 | sg_ir = sonnx.prepare(model, device=dev) |
| 1456 | sg_ir.is_graph = True |
| 1457 | y_t = sg_ir.run([x0, x1]) |
| 1458 | |
| 1459 | np.testing.assert_array_almost_equal(tensor.to_numpy(y), |
| 1460 | tensor.to_numpy(y_t[0]), |
| 1461 | decimal=5) |
| 1462 | |
| 1463 | def test_and_cpu(self): |
| 1464 | self._and_helper(cpu_dev) |
no test coverage detected