Beispiel #1
0
    def check_normal(self, curand_func, dtype):
        shape = cupy._get_size(self.size)
        exp_size = six.moves.reduce(operator.mul, shape, 1)
        if exp_size % 2 == 1:
            exp_size += 1

        curand_func.return_value = cupy.zeros(exp_size, dtype=dtype)
        out = self.rs.normal(self.args[0], self.args[1], self.size, dtype)
        gen, _, size, loc, scale = curand_func.call_args[0]
        self.assertIs(gen, self.rs._generator)
        self.assertEqual(size, exp_size)
        self.assertIs(loc, self.args[0])
        self.assertIs(scale, self.args[1])
        self.assertEqual(out.shape, shape)
Beispiel #2
0
    def check_normal(self, curand_func, dtype):
        shape = cupy._get_size(self.size)
        exp_size = six.moves.reduce(operator.mul, shape, 1)
        if exp_size % 2 == 1:
            exp_size += 1

        curand_func.return_value = cupy.zeros(exp_size, dtype=dtype)
        out = self.rs.normal(self.args[0], self.args[1], self.size, dtype)
        gen, _, size, loc, scale = curand_func.call_args[0]
        self.assertIs(gen, self.rs._generator)
        self.assertEqual(size, exp_size)
        self.assertIs(loc, self.args[0])
        self.assertIs(scale, self.args[1])
        self.assertEqual(out.shape, shape)
Beispiel #3
0
 def _generate_normal(self, func, size, dtype, *args):
     # curand funcitons below don't support odd size.
     # * curand.generateNormal
     # * curand.generateNormalDouble
     # * curand.generateLogNormal
     # * curand.generateLogNormalDouble
     size = cupy._get_size(size)
     element_size = six.moves.reduce(operator.mul, size, 1)
     if element_size % 2 == 0:
         out = cupy.empty(size, dtype=dtype)
         func(self._generator, out.data.ptr, out.size, *args)
         return out
     else:
         out = cupy.empty((element_size + 1,), dtype=dtype)
         func(self._generator, out.data.ptr, out.size, *args)
         return out[:element_size].reshape(size)
Beispiel #4
0
 def _generate_normal(self, func, size, dtype, *args):
     # curand funcitons below don't support odd size.
     # * curand.generateNormal
     # * curand.generateNormalDouble
     # * curand.generateLogNormal
     # * curand.generateLogNormalDouble
     size = cupy._get_size(size)
     element_size = six.moves.reduce(operator.mul, size, 1)
     if element_size % 2 == 0:
         out = cupy.empty(size, dtype=dtype)
         func(self._generator, out.data.ptr, out.size, *args)
         return out
     else:
         out = cupy.empty((element_size + 1,), dtype=dtype)
         func(self._generator, out.data.ptr, out.size, *args)
         return out[:element_size].reshape(size)
Beispiel #5
0
 def check_collection(self, a):
     self.assertEqual(cupy._get_size(a), tuple(a))
Beispiel #6
0
 def test_none(self):
     self.assertEqual(cupy._get_size(None), ())
Beispiel #7
0
 def test_float(self):
     with self.assertRaises(ValueError):
         cupy._get_size(1.0)
Beispiel #8
0
 def test_int(self):
     self.assertEqual(cupy._get_size(1), (1, ))
Beispiel #9
0
 def test_none(self):
     self.assertEqual(cupy._get_size(None), ())
Beispiel #10
0
 def test_float(self):
     with self.assertRaises(ValueError):
         cupy._get_size(1.0)
Beispiel #11
0
 def test_int(self):
     self.assertEqual(cupy._get_size(1), (1,))
Beispiel #12
0
 def check_collection(self, a):
     self.assertEqual(cupy._get_size(a), tuple(a))