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

Method _unsqueeze_helper

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

Source from the content-addressed store, hash-verified

1750 self._squeeze_helper(gpu_dev)
1751
1752 def _unsqueeze_helper(self, dev):
1753 X = np.random.randn(3, 2)
1754
1755 x = tensor.from_numpy(X)
1756 x.to_device(dev)
1757 y = autograd.unsqueeze(x, [2, 4, 5])
1758
1759 # frontend
1760 model = sonnx.to_onnx([x], [y])
1761 # print('The model is:\n{}'.format(model))
1762
1763 # backend
1764 sg_ir = sonnx.prepare(model, device=dev)
1765 sg_ir.is_graph = True
1766 y_t = sg_ir.run([x])
1767
1768 np.testing.assert_array_almost_equal(
1769 tensor.to_numpy(y).shape,
1770 tensor.to_numpy(y_t[0]).shape)
1771
1772 def test_unsqueeze_cpu(self):
1773 self._unsqueeze_helper(cpu_dev)

Callers 2

test_unsqueeze_cpuMethod · 0.95
test_unsqueeze_gpuMethod · 0.95

Calls 3

prepareMethod · 0.80
to_deviceMethod · 0.45
runMethod · 0.45

Tested by

no test coverage detected