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

Method _kint_float

test/python/test_tensor.py:545–553  ·  view source on GitHub ↗
(self, dev=gpu_dev)

Source from the content-addressed store, hash-verified

543 self._kfloat32_int(cpu_dev)
544
545 def _kint_float(self, dev=gpu_dev):
546 np.random.seed(0)
547 x_val = np.random.randint(0, 10, (2, 3))
548 x = tensor.from_numpy(x_val)
549 x.to_device(dev)
550 scalar = random.random() * 100
551 y = x + scalar
552 self.assertEqual(y.dtype, tensor.float32)
553 np.testing.assert_array_almost_equal(tensor.to_numpy(y), x_val + scalar, 5)
554
555 @unittest.skipIf(not singa_api.USE_CUDA, 'CUDA is not enabled')
556 def test_kint_float_gpu(self):

Callers 2

test_kint_float_gpuMethod · 0.95
test_kint_float_cpuMethod · 0.95

Calls 1

to_deviceMethod · 0.45

Tested by

no test coverage detected