def test_timer(): if gpu.lib.pt_clusterNet == gpu.lib.pt_clusterNetCPU: return t = gpu.Timer() A = gpu.rand(100,100) B = gpu.rand(100,100) C = gpu.rand(100,100) time = 0 t.tick() for i in range(10): gpu.dot(A,B,C) time = t.tock() assert time > 0 time = 0 t.tick("Timer test") gpu.dot(A,B,C) time = t.tock("Timer test") assert time > 0 accumulative_time = 0 for i in range(100): t.tick('cumulative') gpu.dot(A,B,C) t.tick('cumulative') accumulative_time = t.tock('cumulative') assert accumulative_time > 5*time
def test_timer(): if gpu.lib.pt_clusterNet == gpu.lib.pt_clusterNetCPU: return t = gpu.Timer() A = gpu.rand(100, 100) B = gpu.rand(100, 100) C = gpu.rand(100, 100) time = 0 t.tick() for i in range(10): gpu.dot(A, B, C) time = t.tock() assert time > 0 time = 0 t.tick("Timer test") gpu.dot(A, B, C) time = t.tock("Timer test") assert time > 0 accumulative_time = 0 for i in range(100): t.tick('cumulative') gpu.dot(A, B, C) t.tick('cumulative') accumulative_time = t.tock('cumulative') assert accumulative_time > 5 * time
def test_rand(): A = gpu.rand(100, 100) B = A.tocpu() assert np.mean(B) > 0.45 and np.mean(B) < 0.55 assert np.var(B) > 0.08 and np.var(B) < 0.085 gpu.setRandomState(1234) A1 = gpu.rand(1000, 1000) gpu.setRandomState(1234) A2 = gpu.rand(1000, 1000) B1 = A1.tocpu() B2 = A2.tocpu() t.assert_array_equal(B1, B2, "Seed not working!")
def test_rand(): A = gpu.rand(100,100) B = A.tocpu() assert np.mean(B) > 0.45 and np.mean(B) < 0.55 assert np.var(B) > 0.08 and np.var(B) < 0.085 gpu.setRandomState(1234) A1 = gpu.rand(1000,1000) gpu.setRandomState(1234) A2 = gpu.rand(1000,1000) B1 = A1.tocpu() B2 = A2.tocpu() t.assert_array_equal(B1, B2, "Seed not working!")
@author: tim ''' import cluster_net as gpu import cudanet as gpu2 t = gpu.Timer() dim1 = 16 dim_inner = 1024 dim_outer = 1024 batch_first_mode = True if batch_first_mode: input = gpu.rand(dim1,dim_inner) W = gpu.rand(dim_inner,dim_outer) output = gpu.rand(dim1,dim_outer) input2 = gpu2.random.rand(dim1,dim_inner) W2 = gpu2.random.rand(dim_inner,dim_outer) output2 = gpu2.random.rand(dim1,dim_outer) else: input = gpu.rand(dim_inner,dim1) W = gpu.rand(dim_outer,dim_inner) output = gpu.rand(dim_outer,dim1) input2 = gpu2.random.rand(dim_inner,dim1) W2 = gpu2.random.rand(dim_outer,dim_inner) output2 = gpu2.random.rand(dim_outer,dim1)
''' Created on Dec 31, 2015 @author: tim ''' import cluster_net as gpu import time t = gpu.Timer() dim1 = 128 dim_inner = 32 dim_outer = 256 for i in range(1000): dim_inner += 32 A = gpu.rand(dim1, dim_inner) B = gpu.rand(dim_inner, dim_outer) C = gpu.rand(dim1, dim_outer) if dim_inner > 0: iters = 1000 if dim_inner > 100: iters = 100 if dim_inner > 1000: iters = 10 if dim_inner > 3000: iters = 4 #warmup for j in range(2): gpu.dot(A, B, C) t.tick(str(dim_inner)) for j in range(iters): gpu.dot(A, B, C) sec = t.tock(str(dim_inner)) / 1000. tilesA = (dim1 / 16) * ((dim_inner / 64) +
outputreated on Jan 3, 2016 @author: tim ''' import cluster_net as gpu import cudanet as gpu2 t = gpu.Timer() dim1 = 16 dim_inner = 1024 dim_outer = 1024 batch_first_mode = True if batch_first_mode: input = gpu.rand(dim1, dim_inner) W = gpu.rand(dim_inner, dim_outer) output = gpu.rand(dim1, dim_outer) input2 = gpu2.random.rand(dim1, dim_inner) W2 = gpu2.random.rand(dim_inner, dim_outer) output2 = gpu2.random.rand(dim1, dim_outer) else: input = gpu.rand(dim_inner, dim1) W = gpu.rand(dim_outer, dim_inner) output = gpu.rand(dim_outer, dim1) input2 = gpu2.random.rand(dim_inner, dim1) W2 = gpu2.random.rand(dim_outer, dim_inner) output2 = gpu2.random.rand(dim_outer, dim1) mean_time = 0
''' Created on Dec 31, 2015 @author: tim ''' import cluster_net as gpu import time t = gpu.Timer() dim1 = 128 dim_inner = 32 dim_outer = 256 for i in range(1000): dim_inner += 32 A = gpu.rand(dim1,dim_inner) B = gpu.rand(dim_inner,dim_outer) C = gpu.rand(dim1,dim_outer) if dim_inner > 0: iters = 1000 if dim_inner > 100: iters = 100 if dim_inner > 1000: iters = 10 if dim_inner > 3000: iters = 4 #warmup for j in range(2): gpu.dot(A,B,C) t.tick(str(dim_inner)) for j in range(iters): gpu.dot(A,B,C) sec = t.tock(str(dim_inner))/1000. tilesA = (dim1/16)*((dim_inner/64) + (1 if dim_inner % 64 > 0 else 0))