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

Method _reduceSum_helper

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

Source from the content-addressed store, hash-verified

1669 self._dropout_helper(gpu_dev)
1670
1671 def _reduceSum_helper(self, dev):
1672 X = np.random.randn(3, 4, 5).astype(np.float32)
1673
1674 x = tensor.from_numpy(X)
1675 x.to_device(dev)
1676 y = autograd.reduce_sum(x, None, 1)
1677
1678 # frontend
1679 model = sonnx.to_onnx([x], [y])
1680 # print('The model is:\n{}'.format(model))
1681
1682 # backend
1683 sg_ir = sonnx.prepare(model, device=dev)
1684 sg_ir.is_graph = True
1685 y_t = sg_ir.run([x])
1686
1687 np.testing.assert_array_almost_equal(
1688 tensor.to_numpy(y).shape,
1689 tensor.to_numpy(y_t[0]).shape)
1690
1691 def test_reduceSum_cpu(self):
1692 self._reduceSum_helper(cpu_dev)

Callers 2

test_reduceSum_cpuMethod · 0.95
test_reduceSum_gpuMethod · 0.95

Calls 3

prepareMethod · 0.80
to_deviceMethod · 0.45
runMethod · 0.45

Tested by

no test coverage detected