提交 34239976 authored 作者: Marc-Alexandre Cote's avatar Marc-Alexandre Cote

Added more tests

上级 79f9288a
...@@ -33,75 +33,39 @@ class TestGpuCumsum(theano.tensor.tests.test_extra_ops.TestCumsumOp): ...@@ -33,75 +33,39 @@ class TestGpuCumsum(theano.tensor.tests.test_extra_ops.TestCumsumOp):
# Even number of elements # Even number of elements
a = np.random.random((18,)).astype(config.floatX) a = np.random.random((18,)).astype(config.floatX)
print "\nEven number of elements"
print f(a)
print np.cumsum(a)
assert np.allclose(np.cumsum(a), f(a)) assert np.allclose(np.cumsum(a), f(a))
# Odd number of elements # Odd number of elements
a = np.random.random((7,)).astype(config.floatX) a = np.random.random((7,)).astype(config.floatX)
print "\nOdd number of elements"
print f(a)
print np.cumsum(a)
assert np.allclose(np.cumsum(a), f(a)) assert np.allclose(np.cumsum(a), f(a))
# Use multiple GPU threadblocks # Use multiple GPU threadblocks
a = np.random.random((2048+1,)).astype(config.floatX) a = np.random.random((2048+1,)).astype(config.floatX)
print "\nUse multiple GPU threadblocks"
print f(a)
print np.cumsum(a)
assert np.allclose(np.cumsum(a), f(a)) assert np.allclose(np.cumsum(a), f(a))
# Use multiple GPU threadblocks # Use multiple GPU threadblocks
a = np.random.random((2048*80+1,)).astype(config.floatX) a = np.random.random((2048*75+1,)).astype(config.floatX)
print "\nUse multiple GPU threadblocks 2"
print f(a)
print np.cumsum(a)
assert np.allclose(np.cumsum(a), f(a)) assert np.allclose(np.cumsum(a), f(a))
# Use multiple GPU gridblocks # Use multiple GPU gridblocks
#a = (np.random.random((2048*2048+1,)).astype(config.floatX) - 0.5) * 10. a = np.ones((2048*2048+1,)).astype(config.floatX)
a = np.floor(np.random.random((2048*2048+1,)) * 10).astype(config.floatX)
#a = np.ones((2048*2048+1,)).astype(config.floatX)
print "\nUse multiple GPU gridblocks"
print f(a)
print np.cumsum(a)
assert np.allclose(np.cumsum(a), f(a)) assert np.allclose(np.cumsum(a), f(a))
# x = T.vector('x')
# f = theano.function([x], cumsum(x)) # Extensive testing
# a = (np.ones(0)+1).astype(config.floatX) i = 0;
# print "" while True:
# print f(a) a = np.ones((i,), dtype=config.floatX)
# print np.cumsum(a) fa = f(a)
# assert np.allclose(np.cumsum(a), f(a)) # Test axis=None npa = np.cumsum(a)
# return
if not np.allclose(npa, fa):
# #for i in range(3000-1,3000*2): print i, np.allclose(npa, fa) # Test axis=None
# #for i in range(3,2048*100,2048): print fa
# i = 150000; print npa
# import time assert False
# start = time.time()
# while True: if i % 1000 == 0:
# #a = np.random.random((i,)).astype(config.floatX) print i
# a = np.ones((i,), dtype=config.floatX)
i += 1
# fa = f(a)
# npa = np.cumsum(a)
# if not np.allclose(npa, fa):
# print i, np.allclose(npa, fa) # Test axis=None
# print fa
# print npa
# assert False
# if i % 1000 == 0:
# print i
# print time.time() - start
# start = time.time()
# #i-=1000
# if i == 80000:
# f = theano.function([x], cumsum(x))
# i += 1
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论