| 337 | self._batch_norm_helper(gpu_dev) |
| 338 | |
| 339 | def _linear_helper(self, dev): |
| 340 | x = tensor.Tensor(shape=(2, 20), device=dev) |
| 341 | x.gaussian(0.0, 1.0) |
| 342 | x1 = x.clone() |
| 343 | y = layer.Linear(20, 1, bias=False)(x) |
| 344 | |
| 345 | # frontend |
| 346 | model = sonnx.to_onnx([x], [y]) |
| 347 | # print('The model is:\n{}'.format(model)) |
| 348 | |
| 349 | # backend |
| 350 | sg_ir = sonnx.prepare(model, device=dev) |
| 351 | sg_ir.is_graph = True |
| 352 | y_t = sg_ir.run([x1]) |
| 353 | |
| 354 | np.testing.assert_array_almost_equal(tensor.to_numpy(y), |
| 355 | tensor.to_numpy(y_t[0]), |
| 356 | decimal=5) |
| 357 | |
| 358 | def test_linear_cpu(self): |
| 359 | self._linear_helper(cpu_dev) |