(self, dev)
| 1907 | self._nonzero_helper(gpu_dev) |
| 1908 | |
| 1909 | def _cast_helper(self, dev): |
| 1910 | X = np.array([[1, 0], [1, 1]]).astype(np.float32) |
| 1911 | x = tensor.from_numpy(X) |
| 1912 | x.to_device(dev) |
| 1913 | y = autograd.cast(x, tensor.int32) |
| 1914 | |
| 1915 | # frontend |
| 1916 | model = sonnx.to_onnx([x], [y]) |
| 1917 | # print('The model is:\n{}'.format(model)) |
| 1918 | |
| 1919 | # backend |
| 1920 | sg_ir = sonnx.prepare(model, device=dev) |
| 1921 | sg_ir.is_graph = True |
| 1922 | y_t = sg_ir.run([x]) |
| 1923 | |
| 1924 | np.testing.assert_array_almost_equal( |
| 1925 | tensor.to_numpy(y).shape, |
| 1926 | tensor.to_numpy(y_t[0]).shape) |
| 1927 | |
| 1928 | def test_cast_cpu(self): |
| 1929 | self._cast_helper(cpu_dev) |
no test coverage detected