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

Method _kfloat32_int

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

Source from the content-addressed store, hash-verified

526 x.gaussian(0, 1)
527
528 def _kfloat32_int(self, dev=gpu_dev):
529 np.random.seed(0)
530 x_val = np.random.random((2, 3)).astype(np.float32) * 10
531 x = tensor.from_numpy(x_val)
532 x.to_device(dev)
533 scalar = np.random.random((1,))[0] * 100
534 y = x + scalar
535 self.assertEqual(y.dtype, tensor.float32)
536 np.testing.assert_array_almost_equal(tensor.to_numpy(y), x_val + scalar)
537
538 @unittest.skipIf(not singa_api.USE_CUDA, 'CUDA is not enabled')
539 def test_kfloat32_int_gpu(self):

Callers 2

test_kfloat32_int_gpuMethod · 0.95
test_kfloat32_int_cpuMethod · 0.95

Calls 1

to_deviceMethod · 0.45

Tested by

no test coverage detected