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

Method _min_1inputs_helper

test/python/test_operation.py:1822–1843  ·  view source on GitHub ↗
(self, dev)

Source from the content-addressed store, hash-verified

1820 self._min_3inputs_helper(gpu_dev)
1821
1822 def _min_1inputs_helper(self, dev):
1823 data_0 = np.array([3, 2, 1]).astype(np.float32)
1824 XT = np.array([3, 2, 1]).astype(np.float32)
1825
1826 DY = np.array([1, 1, 1]).astype(np.float32)
1827 x0 = tensor.from_numpy(data_0)
1828 dy = tensor.from_numpy(DY)
1829 x0.to_device(dev)
1830 dy.to_device(dev)
1831
1832 result = autograd.min(x0)
1833 dx0 = result.creator.backward(dy.data)
1834
1835 DX0 = np.array([1, 1, 1]).astype(np.float32)
1836
1837 np.testing.assert_array_almost_equal(tensor.to_numpy(result),
1838 XT,
1839 decimal=5)
1840 np.testing.assert_array_almost_equal(tensor.to_numpy(
1841 tensor.from_raw_tensor(dx0)),
1842 DX0,
1843 decimal=5)
1844
1845 def test_min_1inputs_cpu(self):
1846 self._min_1inputs_helper(cpu_dev)

Callers 2

test_min_1inputs_cpuMethod · 0.95
test_min_1inputs_gpuMethod · 0.95

Calls 2

to_deviceMethod · 0.45
backwardMethod · 0.45

Tested by

no test coverage detected