(self, dev)
| 919 | self._Sign_helper(gpu_dev) |
| 920 | |
| 921 | def _Div_helper(self, dev): |
| 922 | x0 = np.array([-0.9, -0.3, -0.1, 0.1, 0.5, |
| 923 | 0.9]).reshape(3, 2).astype(np.float32) |
| 924 | x1 = np.array([0, -0.3, 0, 0.1, 0, 0.9]).reshape(3, |
| 925 | 2).astype(np.float32) |
| 926 | x0 = tensor.from_numpy(x0) |
| 927 | x1 = tensor.from_numpy(x1) |
| 928 | x0.to_device(dev) |
| 929 | x1.to_device(dev) |
| 930 | |
| 931 | y = autograd.div(x0, x1) |
| 932 | |
| 933 | # frontend |
| 934 | model = sonnx.to_onnx([x0, x1], [y]) |
| 935 | # print('The model is:\n{}'.format(model)) |
| 936 | |
| 937 | # backend |
| 938 | sg_ir = sonnx.prepare(model, device=dev) |
| 939 | sg_ir.is_graph = True |
| 940 | y_t = sg_ir.run([x0, x1]) |
| 941 | |
| 942 | np.testing.assert_array_almost_equal(tensor.to_numpy(y), |
| 943 | tensor.to_numpy(y_t[0]), |
| 944 | decimal=5) |
| 945 | |
| 946 | def test_Div_cpu(self): |
| 947 | self._Div_helper(cpu_dev) |
no test coverage detected