(self, dev)
| 797 | self._SeLu_helper(gpu_dev) |
| 798 | |
| 799 | def _ELu_helper(self, dev): |
| 800 | x = np.array([-0.9, -0.3, -0.1, 0.1, 0.5, |
| 801 | 0.9]).reshape(3, 2).astype(np.float32) |
| 802 | #y = gamma * (alpha * e^x - alpha) for x <= 0, y = gamma * x for x > 0 |
| 803 | a = 1. |
| 804 | x = tensor.from_numpy(x) |
| 805 | x.to_device(dev) |
| 806 | |
| 807 | y = autograd.elu(x, a) |
| 808 | |
| 809 | # frontend |
| 810 | model = sonnx.to_onnx([x], [y]) |
| 811 | # print('The model is:\n{}'.format(model)) |
| 812 | |
| 813 | # backend |
| 814 | sg_ir = sonnx.prepare(model, device=dev) |
| 815 | sg_ir.is_graph = True |
| 816 | y_t = sg_ir.run([x]) |
| 817 | |
| 818 | np.testing.assert_array_almost_equal(tensor.to_numpy(y), |
| 819 | tensor.to_numpy(y_t[0]), |
| 820 | decimal=5) |
| 821 | |
| 822 | def test_ELu_cpu(self): |
| 823 | self._ELu_helper(cpu_dev) |
no test coverage detected