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

Method _reduceMean_helper

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

Source from the content-addressed store, hash-verified

1696 self._reduceSum_helper(gpu_dev)
1697
1698 def _reduceMean_helper(self, dev):
1699 X = np.random.randn(3, 4, 5).astype(np.float32)
1700
1701 x = tensor.from_numpy(X)
1702 x.to_device(dev)
1703 y = autograd.reduce_mean(x, None, 1)
1704
1705 # frontend
1706 model = sonnx.to_onnx([x], [y])
1707 # print('The model is:\n{}'.format(model))
1708
1709 # backend
1710 sg_ir = sonnx.prepare(model, device=dev)
1711 sg_ir.is_graph = True
1712 y_t = sg_ir.run([x])
1713
1714 np.testing.assert_array_almost_equal(
1715 tensor.to_numpy(y).shape,
1716 tensor.to_numpy(y_t[0]).shape)
1717
1718 def test_reduceMean_cpu(self):
1719 self._reduceMean_helper(cpu_dev)

Callers 2

test_reduceMean_cpuMethod · 0.95
test_reduceMean_gpuMethod · 0.95

Calls 3

prepareMethod · 0.80
to_deviceMethod · 0.45
runMethod · 0.45

Tested by

no test coverage detected