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

Method _mul_helper

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

Source from the content-addressed store, hash-verified

1283 self._prelu_helper(gpu_dev)
1284
1285 def _mul_helper(self, dev):
1286 x = np.array([0.1, -1.0, 0.4, 4.0, -0.9,
1287 9.0]).reshape(3, 2).astype(np.float32)
1288 x1 = np.array([0.1, 1.0, 0.4, 4.0, 0.9,
1289 9.0]).reshape(3, 2).astype(np.float32)
1290 x = tensor.from_numpy(x)
1291 x1 = tensor.from_numpy(x1)
1292 x.to_device(dev)
1293 x1.to_device(dev)
1294 y = autograd.mul(x, x1)
1295
1296 # frontend
1297 model = sonnx.to_onnx([x, x1], [y])
1298 # print('The model is:\n{}'.format(model))
1299
1300 # backend
1301 sg_ir = sonnx.prepare(model, device=dev)
1302 sg_ir.is_graph = True
1303 y_t = sg_ir.run([x, x1])
1304
1305 np.testing.assert_array_almost_equal(tensor.to_numpy(y),
1306 tensor.to_numpy(y_t[0]),
1307 decimal=5)
1308
1309 def test_mul_cpu(self):
1310 self._mul_helper(cpu_dev)

Callers 2

test_mul_cpuMethod · 0.95
test_mul_gpuMethod · 0.95

Calls 4

prepareMethod · 0.80
reshapeMethod · 0.45
to_deviceMethod · 0.45
runMethod · 0.45

Tested by

no test coverage detected