(self, dev)
| 1343 | self._transpose_helper(gpu_dev) |
| 1344 | |
| 1345 | def _max_helper(self, dev): |
| 1346 | X0 = np.array([0.1, 0.2, 2.0, 0.0, 0.1, |
| 1347 | 0.2]).reshape(3, 2).astype(np.float32) |
| 1348 | X1 = np.array([1.0, 2.0, 1.0, 2.1, 0.0, |
| 1349 | 2.0]).reshape(3, 2).astype(np.float32) |
| 1350 | x0 = tensor.from_numpy(X0) |
| 1351 | x1 = tensor.from_numpy(X1) |
| 1352 | x0.to_device(dev) |
| 1353 | x1.to_device(dev) |
| 1354 | |
| 1355 | y = autograd.max(x0, x1) |
| 1356 | |
| 1357 | # frontend |
| 1358 | model = sonnx.to_onnx([x0, x1], [y]) |
| 1359 | # print('The model is:\n{}'.format(model)) |
| 1360 | |
| 1361 | # backend |
| 1362 | sg_ir = sonnx.prepare(model, device=dev) |
| 1363 | sg_ir.is_graph = True |
| 1364 | y_t = sg_ir.run([x0, x1]) |
| 1365 | |
| 1366 | np.testing.assert_array_almost_equal(tensor.to_numpy(y), |
| 1367 | tensor.to_numpy(y_t[0]), |
| 1368 | decimal=5) |
| 1369 | |
| 1370 | def test_max_cpu(self): |
| 1371 | self._max_helper(cpu_dev) |
no test coverage detected