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

Method round_helper

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

Source from the content-addressed store, hash-verified

3506 self.rounde_helper(gpu_dev)
3507
3508 def round_helper(self, dev):
3509 X = np.array([
3510 0.1, 0.5, 0.9, 1.2, 1.5, 1.8, 2.3, 2.5, 2.7, -1.1, -1.5, -1.9, -2.2,
3511 -2.5, -2.8
3512 ]).astype(np.float32)
3513 x = tensor.from_numpy(X)
3514 x.to_device(dev)
3515
3516 y_t = np.array(
3517 [0., 1., 1., 1., 2., 2., 2., 3., 3., -1., -2., -2., -2., -3.,
3518 -3.]).astype(np.float32)
3519 dy = tensor.from_numpy(y_t)
3520 dy.to_device(dev)
3521
3522 y = autograd.round(x)
3523 np.testing.assert_array_almost_equal(tensor.to_numpy(y), y_t)
3524
3525 def test_round_cpu(self):
3526 self.round_helper(cpu_dev)

Callers 2

test_round_cpuMethod · 0.95
test_round_gpuMethod · 0.95

Calls 1

to_deviceMethod · 0.45

Tested by

no test coverage detected