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

Method _squeeze_helper

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

Source from the content-addressed store, hash-verified

1723 self._reduceMean_helper(gpu_dev)
1724
1725 def _squeeze_helper(self, dev):
1726 X = np.random.randn(3, 1, 2, 1, 1)
1727
1728 x = tensor.from_numpy(X)
1729 x.to_device(dev)
1730 y = autograd.squeeze(x, [1, 3, 4])
1731
1732 # frontend
1733 model = sonnx.to_onnx([x], [y])
1734 # print('The model is:\n{}'.format(model))
1735
1736 # backend
1737 sg_ir = sonnx.prepare(model, device=dev)
1738 sg_ir.is_graph = True
1739 y_t = sg_ir.run([x])
1740
1741 np.testing.assert_array_almost_equal(
1742 tensor.to_numpy(y).shape,
1743 tensor.to_numpy(y_t[0]).shape)
1744
1745 def test_squeeze_cpu(self):
1746 self._squeeze_helper(cpu_dev)

Callers 2

test_squeeze_cpuMethod · 0.95
test_squeeze_gpuMethod · 0.95

Calls 3

prepareMethod · 0.80
to_deviceMethod · 0.45
runMethod · 0.45

Tested by

no test coverage detected