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

Method floor_test

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

Source from the content-addressed store, hash-verified

2882 self.ceil_test(gpu_dev)
2883
2884 def floor_test(self,dev):
2885 X = np.array([-1.9,1.2]).astype(np.float32)
2886 DY = np.ones((2),dtype=np.float32)
2887 y = np.floor(X)
2888 x = tensor.from_numpy(X)
2889 dy = tensor.from_numpy(DY)
2890 x.to_device(dev)
2891 dy.to_device(dev)
2892
2893 result = autograd.floor(x)
2894 dx = result.creator.backward(dy.data)
2895 DX = np.zeros((2),dtype=np.float32)
2896 np.testing.assert_array_almost_equal(tensor.to_numpy(result),y,decimal=5)
2897 np.testing.assert_array_almost_equal(tensor.to_numpy(tensor.from_raw_tensor(dx)),DX,decimal=5)
2898
2899 def test_floor_cpu(self):
2900 self.floor_test(cpu_dev)

Callers 2

test_floor_cpuMethod · 0.95
test_floor_gpuMethod · 0.95

Calls 2

to_deviceMethod · 0.45
backwardMethod · 0.45

Tested by

no test coverage detected