(self, dev)
| 454 | self._sum_helper(gpu_dev) |
| 455 | |
| 456 | def _Cos_helper(self, dev): |
| 457 | x = np.array([0.1, -1.0, 0.4, 4.0, -0.9, |
| 458 | 9.0]).reshape(3, 2).astype(np.float32) |
| 459 | x = tensor.from_numpy(x) |
| 460 | y = autograd.Cos()(x)[0] |
| 461 | |
| 462 | # frontend |
| 463 | model = sonnx.to_onnx([x], [y]) |
| 464 | # print('The model is:\n{}'.format(model)) |
| 465 | |
| 466 | # backend |
| 467 | sg_ir = sonnx.prepare(model, device=dev) |
| 468 | sg_ir.is_graph = True |
| 469 | y_t = sg_ir.run([x]) |
| 470 | |
| 471 | np.testing.assert_array_almost_equal(tensor.to_numpy(y), |
| 472 | tensor.to_numpy(y_t[0]), |
| 473 | decimal=5) |
| 474 | |
| 475 | def test_Cos_cpu(self): |
| 476 | self._Cos_helper(cpu_dev) |
no test coverage detected