MCPcopy Create free account
hub / github.com/apache/singa / _linear_helper

Method _linear_helper

test/python/test_onnx.py:339–356  ·  view source on GitHub ↗
(self, dev)

Source from the content-addressed store, hash-verified

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)

Callers 2

test_linear_cpuMethod · 0.95
test_linear_gpuMethod · 0.95

Calls 5

gaussianMethod · 0.95
cloneMethod · 0.95
TensorMethod · 0.80
prepareMethod · 0.80
runMethod · 0.45

Tested by

no test coverage detected