(self, dev)
| 1589 | self._negative_helper(gpu_dev) |
| 1590 | |
| 1591 | def _reciprocal_helper(self, dev): |
| 1592 | X = np.array([0.1, 0, 0.4, 1. - 4, 0.9, |
| 1593 | -2.0]).reshape(3, 2).astype(np.float32) |
| 1594 | x = tensor.from_numpy(X) |
| 1595 | x.to_device(cpu_dev) |
| 1596 | |
| 1597 | y = autograd.reciprocal(x) |
| 1598 | # frontend |
| 1599 | model = sonnx.to_onnx([x], [y]) |
| 1600 | # print('The model is:\n{}'.format(model)) |
| 1601 | |
| 1602 | # backend |
| 1603 | sg_ir = sonnx.prepare(model, device=dev) |
| 1604 | sg_ir.is_graph = True |
| 1605 | y_t = sg_ir.run([x]) |
| 1606 | |
| 1607 | np.testing.assert_array_almost_equal(tensor.to_numpy(y), |
| 1608 | tensor.to_numpy(y_t[0]), |
| 1609 | decimal=5) |
| 1610 | |
| 1611 | def test_reciprocal_cpu(self): |
| 1612 | self._reciprocal_helper(cpu_dev) |
no test coverage detected