(self, dev)
| 76 | self._conv2d_helper(gpu_dev) |
| 77 | |
| 78 | def _relu_helper(self, dev): |
| 79 | X = np.array([0.8, -1.2, 3.3, -3.6, -0.5, |
| 80 | 0.5]).reshape(3, 2).astype(np.float32) |
| 81 | XT = np.array([0.8, 0, 3.3, 0, 0, 0.5]).reshape(3, 2).astype(np.float32) |
| 82 | x = tensor.from_numpy(X) |
| 83 | x.to_device(dev) |
| 84 | y = autograd.ReLU()(x)[0] |
| 85 | |
| 86 | # frontend |
| 87 | model = sonnx.to_onnx([x], [y]) |
| 88 | # print('The model is:\n{}'.format(model)) |
| 89 | |
| 90 | # backend |
| 91 | sg_ir = sonnx.prepare(model, device=dev) |
| 92 | sg_ir.is_graph = True |
| 93 | y_t = sg_ir.run([x]) |
| 94 | np.testing.assert_array_almost_equal(tensor.to_numpy(y), |
| 95 | tensor.to_numpy(y_t[0]), |
| 96 | decimal=5) |
| 97 | |
| 98 | def test_relu_cpu(self): |
| 99 | self._relu_helper(cpu_dev) |
no test coverage detected