(self, dev)
| 425 | self._reshape_helper(gpu_dev) |
| 426 | |
| 427 | def _sum_helper(self, dev): |
| 428 | x = np.array([0.1, -1.0, 0.4, 4.0, -0.9, |
| 429 | 9.0]).reshape(3, 2).astype(np.float32) |
| 430 | x1 = np.array([0.1, 1.0, 0.4, 4.0, 0.9, |
| 431 | 9.0]).reshape(3, 2).astype(np.float32) |
| 432 | x = tensor.from_numpy(x) |
| 433 | x1 = tensor.from_numpy(x1) |
| 434 | y = autograd.Sum()(x, x1)[0] |
| 435 | |
| 436 | # frontend |
| 437 | model = sonnx.to_onnx([x, x1], [y]) |
| 438 | # print('The model is:\n{}'.format(model)) |
| 439 | |
| 440 | # backend |
| 441 | sg_ir = sonnx.prepare(model, device=dev) |
| 442 | sg_ir.is_graph = True |
| 443 | y_t = sg_ir.run([x, x1]) |
| 444 | |
| 445 | np.testing.assert_array_almost_equal(tensor.to_numpy(y), |
| 446 | tensor.to_numpy(y_t[0]), |
| 447 | decimal=5) |
| 448 | |
| 449 | def test_sum_cpu(self): |
| 450 | self._sum_helper(cpu_dev) |
no test coverage detected