(self, dev)
| 1188 | self._mean_helper(gpu_dev) |
| 1189 | |
| 1190 | def _pow_helper(self, dev): |
| 1191 | x0 = np.array([7, 5, 0.2, 0.1, 0.3, 4]).reshape(3, 2).astype(np.float32) |
| 1192 | x1 = np.array([-1.0, 2.0, -1.0, -2.1, 1.0, |
| 1193 | -2.0]).reshape(3, 2).astype(np.float32) |
| 1194 | x0 = tensor.from_numpy(x0) |
| 1195 | x1 = tensor.from_numpy(x1) |
| 1196 | x0.to_device(dev) |
| 1197 | x1.to_device(dev) |
| 1198 | |
| 1199 | y = autograd.mean(x0, x1) |
| 1200 | |
| 1201 | # frontend |
| 1202 | model = sonnx.to_onnx([x0, x1], [y]) |
| 1203 | # print('The model is:\n{}'.format(model)) |
| 1204 | |
| 1205 | # backend |
| 1206 | sg_ir = sonnx.prepare(model, device=dev) |
| 1207 | sg_ir.is_graph = True |
| 1208 | y_t = sg_ir.run([x0, x1]) |
| 1209 | |
| 1210 | np.testing.assert_array_almost_equal(tensor.to_numpy(y), |
| 1211 | tensor.to_numpy(y_t[0]), |
| 1212 | decimal=5) |
| 1213 | |
| 1214 | def test_pow_cpu(self): |
| 1215 | self._pow_helper(cpu_dev) |
no test coverage detected