提交 eeb7c04a authored 作者: Frédéric Bastien's avatar Frédéric Bastien

Merge pull request #2436 from sebastien-j/faster_tests

Faster tests
import unittest import unittest
import numpy import numpy
import copy
import theano import theano
from theano.tests import unittest_tools as utt from theano.tests import unittest_tools as utt
...@@ -188,8 +189,12 @@ class TestConv3dFFT(unittest.TestCase): ...@@ -188,8 +189,12 @@ class TestConv3dFFT(unittest.TestCase):
pad_last_dim = pad) pad_last_dim = pad)
conv_fft = conv_fft.dimshuffle(0, 2, 3, 4, 1) conv_fft = conv_fft.dimshuffle(0, 2, 3, 4, 1)
f_ref = theano.function([], conv_ref) ref_mode = copy.copy(theano.compile.get_default_mode())
f_fft = theano.function([], conv_fft, mode=mode_with_gpu) ref_mode.check_py_code = False
f_ref = theano.function([], conv_ref, mode=ref_mode)
mode = mode_with_gpu
mode.check_py_code = False
f_fft = theano.function([], conv_fft, mode=mode)
res_ref = f_ref() res_ref = f_ref()
res_fft = f_fft() res_fft = f_fft()
...@@ -251,9 +256,12 @@ class TestConv3dFFT(unittest.TestCase): ...@@ -251,9 +256,12 @@ class TestConv3dFFT(unittest.TestCase):
conv = theano.tensor.nnet.conv3D(V=inputs, W=filters, conv = theano.tensor.nnet.conv3D(V=inputs, W=filters,
b=bias, d=(1,1,1)) b=bias, d=(1,1,1))
ref_mode = copy.copy(theano.compile.get_default_mode())
ref_mode.check_py_code = False
mode = mode_with_gpu.including('conv3d_fft') mode = mode_with_gpu.including('conv3d_fft')
mode.check_py_code = False
f_ref = theano.function([], conv) f_ref = theano.function([], conv, mode=ref_mode)
f_fft = theano.function([], conv, mode=mode) f_fft = theano.function([], conv, mode=mode)
# make sure we inserted the fft trickery # make sure we inserted the fft trickery
...@@ -281,9 +289,12 @@ class TestConv3dFFT(unittest.TestCase): ...@@ -281,9 +289,12 @@ class TestConv3dFFT(unittest.TestCase):
conv = theano.tensor.nnet.convGrad3D(V=inputs, dCdH=dCdH, conv = theano.tensor.nnet.convGrad3D(V=inputs, dCdH=dCdH,
WShape=filters_shape, WShape=filters_shape,
d=(1,1,1)) d=(1,1,1))
ref_mode = copy.copy(theano.compile.get_default_mode())
ref_mode.check_py_code = False
mode = mode_with_gpu.including('convgrad3d_fft') mode = mode_with_gpu.including('convgrad3d_fft')
mode.check_py_code = False
f_ref = theano.function([], conv) f_ref = theano.function([], conv, mode=ref_mode)
f_fft = theano.function([], conv, mode=mode) f_fft = theano.function([], conv, mode=mode)
# make sure we inserted the fft trickery # make sure we inserted the fft trickery
......
import unittest import unittest
import numpy import numpy
import copy
import theano import theano
from theano.tests import unittest_tools as utt from theano.tests import unittest_tools as utt
...@@ -172,8 +173,11 @@ class TestCorr3DMM(unittest.TestCase): ...@@ -172,8 +173,11 @@ class TestCorr3DMM(unittest.TestCase):
conv = theano.tensor.nnet.conv3D(V=inputs, W=filters, conv = theano.tensor.nnet.conv3D(V=inputs, W=filters,
b=bias, d=(1, 1, 1)) b=bias, d=(1, 1, 1))
mode = mode_with_gpu.including('conv3d_gemm') mode = mode_with_gpu.including('conv3d_gemm')
mode.check_py_code = False
ref_mode = copy.copy(theano.compile.get_default_mode())
ref_mode.check_py_code = False
f_ref = theano.function([], conv) f_ref = theano.function([], conv, mode=ref_mode)
f_gemm = theano.function([], conv, mode=mode) f_gemm = theano.function([], conv, mode=mode)
# make sure we inserted the gemm trickery # make sure we inserted the gemm trickery
......
import os import os
import sys import sys
import time import time
import copy
import numpy import numpy
import theano import theano
...@@ -322,7 +323,8 @@ def test_GPU_nstreams_limit(): ...@@ -322,7 +323,8 @@ def test_GPU_nstreams_limit():
if theano.config.mode == "FAST_COMPILE": if theano.config.mode == "FAST_COMPILE":
mode = "FAST_RUN" mode = "FAST_RUN"
else: else:
mode = None mode = copy.copy(theano.compile.get_default_mode())
mode.check_py_code = False
out = R.uniform(size=size, nstreams=nstreams, dtype='float32') out = R.uniform(size=size, nstreams=nstreams, dtype='float32')
f = theano.function([], out, mode=mode) f = theano.function([], out, mode=mode)
return f() return f()
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论