提交 7bb08f51 authored 作者: Benjamin Scellier's avatar Benjamin Scellier 提交者: Nicolas Ballas

file theano/gof/tests/test_vm.py

上级 d159de11
...@@ -5,7 +5,7 @@ import time ...@@ -5,7 +5,7 @@ import time
import unittest import unittest
from nose.plugins.skip import SkipTest from nose.plugins.skip import SkipTest
import numpy import numpy as np
from six import itervalues from six import itervalues
from theano import function from theano import function
...@@ -92,7 +92,7 @@ def test_speed(): ...@@ -92,7 +92,7 @@ def test_speed():
def time_numpy(): def time_numpy():
steps_a = 5 steps_a = 5
steps_b = 100 steps_b = 100
x = numpy.asarray([2.0, 3.0], dtype=theano.config.floatX) x = np.asarray([2.0, 3.0], dtype=theano.config.floatX)
numpy_version(x, steps_a) numpy_version(x, steps_a)
t0 = time.time() t0 = time.time()
...@@ -195,7 +195,6 @@ def test_speed_lazy(): ...@@ -195,7 +195,6 @@ def test_speed_lazy():
def test_partial_function(): def test_partial_function():
import numpy as np
from theano.tests import unittest_tools as utt from theano.tests import unittest_tools as utt
def check_partial_function(linker_name): def check_partial_function(linker_name):
...@@ -234,7 +233,7 @@ def test_partial_function_with_updates(): ...@@ -234,7 +233,7 @@ def test_partial_function_with_updates():
def check_updates(linker_name): def check_updates(linker_name):
x = tensor.lscalar('input') x = tensor.lscalar('input')
y = theano.shared(numpy.asarray(1, 'int64'), name='global') y = theano.shared(np.asarray(1, 'int64'), name='global')
f = theano.function([x], [x, x + 34], updates=[(y, x + 1)], mode=Mode( f = theano.function([x], [x, x + 34], updates=[(y, x + 1)], mode=Mode(
optimizer=None, linker=linker_name)) optimizer=None, linker=linker_name))
g = theano.function([x], [x - 6], updates=[(y, y + 3)], mode=Mode( g = theano.function([x], [x - 6], updates=[(y, y + 3)], mode=Mode(
...@@ -283,7 +282,7 @@ if run_memory_usage_tests: ...@@ -283,7 +282,7 @@ if run_memory_usage_tests:
def test_leak2(): def test_leak2():
import theano.sandbox.cuda as cuda import theano.sandbox.cuda as cuda
for i in xrange(1000000): for i in xrange(1000000):
n = numpy.asarray([2.3, 4.5], dtype='f') n = np.asarray([2.3, 4.5], dtype='f')
c = sys.getrefcount(n) c = sys.getrefcount(n)
a = cuda.CudaNdarray(n) a = cuda.CudaNdarray(n)
a.sum() a.sum()
...@@ -338,7 +337,7 @@ if run_memory_usage_tests: ...@@ -338,7 +337,7 @@ if run_memory_usage_tests:
f_a = function([x], a, f_a = function([x], a,
mode=Mode(optimizer=None, mode=Mode(optimizer=None,
linker=linker())) linker=linker()))
inp = numpy.random.rand(1000000) inp = np.random.rand(1000000)
for i in xrange(100): for i in xrange(100):
f_a(inp) f_a(inp)
if 0: # this doesn't seem to work, prints 0 for everything if 0: # this doesn't seem to work, prints 0 for everything
...@@ -375,7 +374,7 @@ if run_memory_usage_tests: ...@@ -375,7 +374,7 @@ if run_memory_usage_tests:
f_a = function([x], a, f_a = function([x], a,
mode=Mode(optimizer=None, mode=Mode(optimizer=None,
linker=linker())) linker=linker()))
inp = numpy.random.rand(1000000) inp = np.random.rand(1000000)
for i in xrange(500): for i in xrange(500):
f_a(inp) f_a(inp)
print(1) print(1)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论