示例#1
0
def test_computation_convenience(thr):

    size = 10000
    batch = 101

    ref = UniformIntegerHelper(0, 511)
    rng = CBRNG.uniform_integer(Type(numpy.int32, shape=(batch, size)), 1,
        sampler_kwds=dict(low=ref.extent[0], high=ref.extent[1]))
    check_computation(thr, rng, ref)
示例#2
0
def test_computation_convenience(thr):

    size = 10000
    batch = 101

    extent = (0, 511)
    mean, std = uniform_discrete_mean_and_std(*extent)
    rng = CBRNG.uniform_integer(Type(numpy.int32, shape=(batch, size)), 1,
        sampler_kwds=dict(low=extent[0], high=extent[1] + 1))
    check_computation(thr, rng, extent=extent, mean=mean, std=std)
示例#3
0
def test_computation_convenience(thr):

    size = 10000
    batch = 101

    extent = (0, 511)
    mean, std = uniform_discrete_mean_and_std(*extent)
    rng = CBRNG.uniform_integer(Type(numpy.int32, shape=(batch, size)),
                                1,
                                sampler_kwds=dict(low=extent[0],
                                                  high=extent[1] + 1))
    check_computation(thr, rng, extent=extent, mean=mean, std=std)
示例#4
0
 def randint(self, array, minval, maxval, seed=None):
     kernel_cache, thread = self.kernel_cache, self.thread
     key = (self.randint, array.shape, array.dtype, minval, maxval, thread)
         
     if key not in kernel_cache.keys():
         log.info("compiling " + str(key))
 
         rng = CBRNG.uniform_integer(Type(array.dtype, shape=array.shape), len(array.shape),  # @UndefinedVariable
         sampler_kwds=dict(low=numpy.int32(minval), high=numpy.int32(maxval)), seed=seed)
 
         counters = thread.to_device(rng.create_counters())
 
         kernel_cache[key] = (rng.compile(thread), counters)
 
     (rng, counters) = kernel_cache[key]
 
     rng(counters, array)
示例#5
0
    def randint(self, array, minval, maxval, seed=None):
        kernel_cache, thread = self.kernel_cache, self.thread
        key = (self.randint, array.shape, array.dtype, minval, maxval, thread)

        if key not in kernel_cache.keys():
            log.info("compiling " + str(key))

            rng = CBRNG.uniform_integer(
                Type(array.dtype, shape=array.shape),
                len(array.shape),  # @UndefinedVariable
                sampler_kwds=dict(low=numpy.int32(minval),
                                  high=numpy.int32(maxval)),
                seed=seed)

            counters = thread.to_device(rng.create_counters())

            kernel_cache[key] = (rng.compile(thread), counters)

        (rng, counters) = kernel_cache[key]

        rng(counters, array)