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

Method _matmul_helper

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

Source from the content-addressed store, hash-verified

236 self._concat_helper(gpu_dev)
237
238 def _matmul_helper(self, dev):
239 X1 = np.random.randn(4, 5).astype(np.float32)
240 X2 = np.random.randn(5, 4).astype(np.float32)
241
242 x1 = tensor.from_numpy(X1)
243 x2 = tensor.from_numpy(X2)
244 x1.to_device(dev)
245 x2.to_device(dev)
246
247 y = autograd.Matmul()(x1, x2)[0]
248
249 # frontend
250 model = sonnx.to_onnx([x1, x2], [y])
251 # print('The model is:\n{}'.format(model))
252
253 # backend
254 sg_ir = sonnx.prepare(model, device=dev)
255 sg_ir.is_graph = True
256 y_t = sg_ir.run([x1, x2])
257
258 np.testing.assert_array_almost_equal(tensor.to_numpy(y),
259 tensor.to_numpy(y_t[0]),
260 decimal=5)
261
262 def test_matmul_cpu(self):
263 self._matmul_helper(cpu_dev)

Callers 2

test_matmul_cpuMethod · 0.95
test_matmul_gpuMethod · 0.95

Calls 3

prepareMethod · 0.80
to_deviceMethod · 0.45
runMethod · 0.45

Tested by

no test coverage detected