Ensure dtypes are respected
@@ -681,11 +681,11 @@ class RandomState(object):
else:
dtype = mx.dtype
if dtype == cupy.int32 or dtype == cupy.uint32:
- dtype = numpy.uint32
+ dtype = numpy.int32
mx = mx.astype(dtype, copy=False)
upper_limit = _UINT32_MAX - (_UINT32_MAX - mx) % (mx + 1)
elif dtype == cupy.int64 or dtype == cupy.uint64:
- dtype = numpy.uint64
+ dtype = numpy.int64
mx = mx.astype(dtype, copy=False)
upper_limit = _UINT64_MAX - (_UINT64_MAX - mx) % (mx + 1)
else:
@@ -1185,8 +1185,10 @@ class RandomState(object):
diff = hi - lo
total_elems = functools.reduce(operator.mul, size, 1)
out = self._interval(diff.flatten(), total_elems)
+ out = out.astype(dtype)
out = cupy.reshape(out, size)
- return out + lo
+ cupy.add(out, lo, out=out)
+ return out
else:
if high is None:
lo = 0
