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

Method ceil_test

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

Source from the content-addressed store, hash-verified

2853 self.slice_test(gpu_dev)
2854
2855 def ceil_test(self, dev):
2856 X = np.array([-1.5, 1.2]).astype(np.float32)
2857 DY = np.ones((2), dtype=np.float32)
2858 y = np.ceil(X)
2859
2860 x = tensor.from_numpy(X)
2861 dy = tensor.from_numpy(DY)
2862 x.to_device(dev)
2863 dy.to_device(dev)
2864
2865 result = autograd.ceil(x)
2866 dx = result.creator.backward(dy.data)
2867 DX = np.zeros((2), dtype=np.float32)
2868
2869 np.testing.assert_array_almost_equal(tensor.to_numpy(result),
2870 y,
2871 decimal=5)
2872 np.testing.assert_array_almost_equal(tensor.to_numpy(
2873 tensor.from_raw_tensor(dx)),
2874 DX,
2875 decimal=5)
2876
2877 def test_ceil_cpu(self):
2878 self.ceil_test(cpu_dev)

Callers 2

test_ceil_cpuMethod · 0.95
test_ceil_gpuMethod · 0.95

Calls 2

to_deviceMethod · 0.45
backwardMethod · 0.45

Tested by

no test coverage detected