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

Method _min_helper

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

Source from the content-addressed store, hash-verified

1375 self._max_helper(gpu_dev)
1376
1377 def _min_helper(self, dev):
1378 X0 = np.array([0.1, 0.2, 2.0, 0.0, 0.1,
1379 0.2]).reshape(3, 2).astype(np.float32)
1380 X1 = np.array([1.0, 2.0, 1.0, 2.1, 0.0,
1381 2.0]).reshape(3, 2).astype(np.float32)
1382 x0 = tensor.from_numpy(X0)
1383 x1 = tensor.from_numpy(X1)
1384 x0.to_device(dev)
1385 x1.to_device(dev)
1386
1387 y = autograd.min(x0, x1)
1388
1389 # frontend
1390 model = sonnx.to_onnx([x0, x1], [y])
1391 # print('The model is:\n{}'.format(model))
1392
1393 # backend
1394 sg_ir = sonnx.prepare(model, device=dev)
1395 sg_ir.is_graph = True
1396 y_t = sg_ir.run([x0, x1])
1397
1398 np.testing.assert_array_almost_equal(tensor.to_numpy(y),
1399 tensor.to_numpy(y_t[0]),
1400 decimal=5)
1401
1402 def test_min_cpu(self):
1403 self._min_helper(cpu_dev)

Callers 2

test_min_cpuMethod · 0.95
test_min_gpuMethod · 0.95

Calls 4

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

Tested by

no test coverage detected