(self, dev)
| 1128 | self._softplus_helper(gpu_dev) |
| 1129 | |
| 1130 | def _softsign_helper(self, dev): |
| 1131 | x = np.array([-0.9, -0.3, -0.1, 0.1, 0.5, |
| 1132 | 0.9]).reshape(3, 2).astype(np.float32) |
| 1133 | x = tensor.from_numpy(x) |
| 1134 | x.to_device(dev) |
| 1135 | |
| 1136 | y = autograd.softsign(x) |
| 1137 | |
| 1138 | # frontend |
| 1139 | model = sonnx.to_onnx([x], [y]) |
| 1140 | # print('The model is:\n{}'.format(model)) |
| 1141 | |
| 1142 | # backend |
| 1143 | sg_ir = sonnx.prepare(model, device=dev) |
| 1144 | sg_ir.is_graph = True |
| 1145 | y_t = sg_ir.run([x]) |
| 1146 | |
| 1147 | np.testing.assert_array_almost_equal(tensor.to_numpy(y), |
| 1148 | tensor.to_numpy(y_t[0]), |
| 1149 | decimal=5) |
| 1150 | |
| 1151 | def test_softsign_cpu(self): |
| 1152 | self._softsign_helper(cpu_dev) |
no test coverage detected