| 1407 | self._min_helper(gpu_dev) |
| 1408 | |
| 1409 | def _shape_helper(self, dev): |
| 1410 | x = np.array([0.1, -1.0, 0.4, 4.0, -0.9, |
| 1411 | 9.0]).reshape(3, 2).astype(np.float32) |
| 1412 | x = tensor.from_numpy(x) |
| 1413 | x.to_device(dev) |
| 1414 | |
| 1415 | y = autograd.shape(x) |
| 1416 | |
| 1417 | # frontend |
| 1418 | model = sonnx.to_onnx([x], [y]) |
| 1419 | # print('The model is:\n{}'.format(model)) |
| 1420 | |
| 1421 | # backend |
| 1422 | sg_ir = sonnx.prepare(model, device=dev) |
| 1423 | sg_ir.is_graph = True |
| 1424 | y_t = sg_ir.run([x]) |
| 1425 | |
| 1426 | np.testing.assert_array_almost_equal(tensor.to_numpy(y), |
| 1427 | tensor.to_numpy(y_t[0]), |
| 1428 | decimal=5) |
| 1429 | |
| 1430 | def test_shape_cpu(self): |
| 1431 | self._shape_helper(cpu_dev) |