(self, dev)
| 1750 | self._squeeze_helper(gpu_dev) |
| 1751 | |
| 1752 | def _unsqueeze_helper(self, dev): |
| 1753 | X = np.random.randn(3, 2) |
| 1754 | |
| 1755 | x = tensor.from_numpy(X) |
| 1756 | x.to_device(dev) |
| 1757 | y = autograd.unsqueeze(x, [2, 4, 5]) |
| 1758 | |
| 1759 | # frontend |
| 1760 | model = sonnx.to_onnx([x], [y]) |
| 1761 | # print('The model is:\n{}'.format(model)) |
| 1762 | |
| 1763 | # backend |
| 1764 | sg_ir = sonnx.prepare(model, device=dev) |
| 1765 | sg_ir.is_graph = True |
| 1766 | y_t = sg_ir.run([x]) |
| 1767 | |
| 1768 | np.testing.assert_array_almost_equal( |
| 1769 | tensor.to_numpy(y).shape, |
| 1770 | tensor.to_numpy(y_t[0]).shape) |
| 1771 | |
| 1772 | def test_unsqueeze_cpu(self): |
| 1773 | self._unsqueeze_helper(cpu_dev) |
no test coverage detected