(self, dev)
| 1777 | self._unsqueeze_helper(gpu_dev) |
| 1778 | |
| 1779 | def _slice_helper(self, dev): |
| 1780 | X = np.random.randn(20, 10, 5).astype(np.float32) |
| 1781 | starts, ends, axes, steps = [0, 0], [3, 10], [0, 1], [1, 1] |
| 1782 | x = tensor.from_numpy(X) |
| 1783 | x.to_device(dev) |
| 1784 | y = autograd.slice(x, starts, ends, axes, steps) |
| 1785 | |
| 1786 | # frontend |
| 1787 | model = sonnx.to_onnx([x], [y]) |
| 1788 | # print('The model is:\n{}'.format(model)) |
| 1789 | |
| 1790 | # backend |
| 1791 | sg_ir = sonnx.prepare(model, device=dev) |
| 1792 | sg_ir.is_graph = True |
| 1793 | y_t = sg_ir.run([x]) |
| 1794 | |
| 1795 | np.testing.assert_array_almost_equal( |
| 1796 | tensor.to_numpy(y).shape, |
| 1797 | tensor.to_numpy(y_t[0]).shape) |
| 1798 | |
| 1799 | def test_slice_cpu(self): |
| 1800 | self._slice_helper(cpu_dev) |
no test coverage detected