(self, dev)
| 1100 | self._identity_helper(gpu_dev) |
| 1101 | |
| 1102 | def _softplus_helper(self, dev): |
| 1103 | x = np.array([-0.9, -0.3, -0.1, 0.1, 0.5, |
| 1104 | 0.9]).reshape(3, 2).astype(np.float32) |
| 1105 | x = tensor.from_numpy(x) |
| 1106 | x.to_device(dev) |
| 1107 | |
| 1108 | y = autograd.softplus(x) |
| 1109 | |
| 1110 | # frontend |
| 1111 | model = sonnx.to_onnx([x], [y]) |
| 1112 | # print('The model is:\n{}'.format(model)) |
| 1113 | |
| 1114 | # backend |
| 1115 | sg_ir = sonnx.prepare(model, device=dev) |
| 1116 | sg_ir.is_graph = True |
| 1117 | y_t = sg_ir.run([x]) |
| 1118 | |
| 1119 | np.testing.assert_array_almost_equal(tensor.to_numpy(y), |
| 1120 | tensor.to_numpy(y_t[0]), |
| 1121 | decimal=5) |
| 1122 | |
| 1123 | def test_softplus_cpu(self): |
| 1124 | self._softplus_helper(cpu_dev) |
no test coverage detected