(self, dev)
| 1561 | self._not_helper(gpu_dev) |
| 1562 | |
| 1563 | def _negative_helper(self, dev): |
| 1564 | X = np.array([0.1, 0, 0.4, 1. - 4, 0.9, |
| 1565 | -2.0]).reshape(3, 2).astype(np.float32) |
| 1566 | x = tensor.from_numpy(X) |
| 1567 | x.to_device(dev) |
| 1568 | |
| 1569 | y = autograd.negative(x) |
| 1570 | |
| 1571 | # frontend |
| 1572 | model = sonnx.to_onnx([x], [y]) |
| 1573 | # print('The model is:\n{}'.format(model)) |
| 1574 | |
| 1575 | # backend |
| 1576 | sg_ir = sonnx.prepare(model, device=dev) |
| 1577 | sg_ir.is_graph = True |
| 1578 | y_t = sg_ir.run([x]) |
| 1579 | |
| 1580 | np.testing.assert_array_almost_equal(tensor.to_numpy(y), |
| 1581 | tensor.to_numpy(y_t[0]), |
| 1582 | decimal=5) |
| 1583 | |
| 1584 | def test_negative_cpu(self): |
| 1585 | self._negative_helper(cpu_dev) |
no test coverage detected