(self, dev)
| 951 | self._Div_helper(gpu_dev) |
| 952 | |
| 953 | def _Sub_helper(self, dev): |
| 954 | x0 = np.array([-0.9, -0.3, -0.1, 0.1, 0.5, |
| 955 | 0.9]).reshape(3, 2).astype(np.float32) |
| 956 | x1 = np.array([0, -0.3, 0, 0.1, 0, 0.9]).reshape(3, |
| 957 | 2).astype(np.float32) |
| 958 | x0 = tensor.from_numpy(x0) |
| 959 | x1 = tensor.from_numpy(x1) |
| 960 | x0.to_device(dev) |
| 961 | x1.to_device(dev) |
| 962 | |
| 963 | y = autograd.sub(x0, x1) |
| 964 | |
| 965 | # frontend |
| 966 | model = sonnx.to_onnx([x0, x1], [y]) |
| 967 | # print('The model is:\n{}'.format(model)) |
| 968 | |
| 969 | # backend |
| 970 | sg_ir = sonnx.prepare(model, device=dev) |
| 971 | sg_ir.is_graph = True |
| 972 | y_t = sg_ir.run([x0, x1]) |
| 973 | |
| 974 | np.testing.assert_array_almost_equal(tensor.to_numpy(y), |
| 975 | tensor.to_numpy(y_t[0]), |
| 976 | decimal=5) |
| 977 | |
| 978 | def test_Sub_cpu(self): |
| 979 | self._Sub_helper(cpu_dev) |
no test coverage detected