提交 6dc2aac4 authored 作者: Arnaud Bergeron's avatar Arnaud Bergeron

Move off the device and mode config to a separate file.

上级 3cb88534
from nose.plugins.skip import SkipTest
import theano.sandbox.gpuarray
if theano.sandbox.gpuarray.pygpu is None:
raise SkipTest("pygpu not installed")
if not theano.sandbox.gpuarray.pygpu_activated:
import theano.sandbox.cuda as cuda_ndarray
if cuda_ndarray.cuda_available:
cuda_ndarray.use('gpu', default_to_move_computation_to_gpu=False,
move_shared_float32_to_gpu=False,
enable_cuda=False)
theano.sandbox.gpuarray.init_dev('cuda')
if not theano.sandbox.gpuarray.pygpu_activated:
raise SkipTest("pygpu disabled")
test_ctx_name = None
if theano.config.mode == 'FAST_COMPILE':
mode_with_gpu = theano.compile.mode.get_mode('FAST_RUN').including('gpuarray').excluding('gpu')
mode_without_gpu = theano.compile.mode.get_mode('FAST_RUN').excluding('gpuarray')
else:
mode_with_gpu = theano.compile.mode.get_default_mode().including('gpuarray').excluding('gpu')
mode_without_gpu = theano.compile.mode.get_default_mode().excluding('gpuarray')
......@@ -13,7 +13,6 @@ from theano.tensor.basic import alloc
from theano.tensor.tests import test_basic
from theano.tensor.tests.test_basic import rand, safe_make_node
from theano.tests import unittest_tools as utt
from theano.tests.unittest_tools import SkipTest
import theano.sandbox.gpuarray
......@@ -25,41 +24,16 @@ from ..basic_ops import (
gpu_join, GpuJoin, GpuSplit, GpuEye, gpu_contiguous)
from ..subtensor import GpuSubtensor
import theano.sandbox.cuda as cuda_ndarray
from .config import mode_with_gpu, mode_without_gpu
try:
from pygpu import gpuarray
except:
pass
if theano.sandbox.gpuarray.pygpu is None:
raise SkipTest("pygpu not installed")
# If you are writing a new test file, don't copy this code, but rather
# import stuff from this file (like mode_with_gpu) to reuse it.
if cuda_ndarray.cuda_available and not theano.sandbox.gpuarray.pygpu_activated:
if not cuda_ndarray.use.device_number:
# We should not enable all the use like the flag device=gpu,
# as many tests don't work in that setup.
cuda_ndarray.use('gpu',
default_to_move_computation_to_gpu=False,
move_shared_float32_to_gpu=False,
enable_cuda=False)
theano.sandbox.gpuarray.init_dev('cuda')
if not theano.sandbox.gpuarray.pygpu_activated:
raise SkipTest("pygpu disabled")
utt.seed_rng()
rng = numpy.random.RandomState(seed=utt.fetch_seed())
if theano.config.mode == 'FAST_COMPILE':
mode_with_gpu = theano.compile.mode.get_mode('FAST_RUN').including('gpuarray').excluding('gpu')
mode_without_gpu = theano.compile.mode.get_mode('FAST_RUN').excluding('gpuarray')
else:
mode_with_gpu = theano.compile.mode.get_default_mode().including('gpuarray').excluding('gpu')
mode_without_gpu = theano.compile.mode.get_default_mode().excluding('gpuarray')
def inplace_func(inputs, outputs, mode=None, allow_input_downcast=False,
on_unused_input='raise', name=None):
......@@ -114,6 +88,7 @@ def makeTester(name, op, gpu_op, cases, checks=None, mode_gpu=mode_with_gpu,
def test_all(self):
if skip:
from nose.plugins.skip import SkipTest
raise SkipTest(skip)
for testname, inputs in iteritems(cases):
......
......@@ -10,8 +10,8 @@ from theano.tensor.blas import gemv_inplace, gemm_inplace, _dot22
from theano.tensor.tests.test_blas import TestGer, BaseGemv
from .. import gpuarray_shared_constructor
from .test_basic_ops import (makeTester, rand,
mode_with_gpu)
from .config import mode_with_gpu
from .test_basic_ops import makeTester, rand
from ..blas import (gpugemv_inplace, gpugemv_no_inplace,
gpugemm_inplace,
......
......@@ -14,7 +14,7 @@ from theano import tensor
from theano.tests.unittest_tools import seed_rng
# We let that import do the init of the back-end if needed.
from .test_basic_ops import mode_with_gpu
from .config import mode_with_gpu
from ..type import GpuArrayType
from ..conv import GpuConv
from theano.sandbox.gpuarray import dnn
......
......@@ -15,7 +15,7 @@ from theano.tensor.signal.downsample import MaxPoolGrad, AveragePoolGrad
from .. import dnn
from ..basic_ops import GpuAllocEmpty
from .test_basic_ops import mode_with_gpu, mode_without_gpu
from .config import mode_with_gpu, mode_without_gpu
from . import test_nnet
......
......@@ -7,7 +7,8 @@ from theano.tests.unittest_tools import SkipTest, assert_allclose
from theano.tensor.tests.test_elemwise import (test_Broadcast, test_DimShuffle,
test_CAReduce, T_reduce_dtype)
from .test_basic_ops import mode_with_gpu, rand_gpuarray
from .config import mode_with_gpu
from .test_basic_ops import rand_gpuarray
from ..elemwise import (GpuElemwise, GpuDimShuffle,
GpuCAReduceCuda, GpuCAReduceCPY)
from ..type import GpuArrayType
......
from theano.tensor.nnet.tests import test_neighbours
# We let that import do the init of the back-end if needed.
from .test_basic_ops import mode_with_gpu
from .config import mode_with_gpu
from ..neighbours import GpuImages2Neibs
......
......@@ -6,7 +6,7 @@ from theano import function
from theano.tests import unittest_tools as utt
from theano.tensor import vector, matrix, dot
from .test_basic_ops import mode_with_gpu
from .config import mode_with_gpu
from ..nerv import Gemm16, nerv
......
......@@ -7,9 +7,7 @@ import theano
import theano.tensor as T
import theano.tests.unittest_tools as utt
# We let that import do the init of the back-end if needed.
from .test_basic_ops import (mode_with_gpu,
mode_without_gpu)
from .config import mode_with_gpu, mode_without_gpu
from ..nnet import (
GpuCrossentropySoftmaxArgmax1HotWithBias,
GpuCrossentropySoftmax1HotWithBiasDx,
......
......@@ -14,7 +14,9 @@ from ..basic_ops import (GpuAlloc, GpuReshape, gpu_alloc,
gpu_from_host, host_from_gpu)
from ..elemwise import GpuCAReduceCuda, GpuCAReduceCPY, GpuElemwise
from ..subtensor import GpuSubtensor
from .test_basic_ops import rand_gpuarray, mode_with_gpu, mode_without_gpu
from .config import mode_with_gpu, mode_without_gpu
from .test_basic_ops import rand_gpuarray
def test_local_assert():
......
......@@ -9,7 +9,7 @@ import theano.sandbox.rng_mrg
from ..basic_ops import gpu_from_host, GpuFromHost, HostFromGpu
from ..elemwise import GpuElemwise
from .test_basic_ops import mode_with_gpu
from .config import mode_with_gpu
class T_Scan(TestCase):
......
......@@ -11,8 +11,7 @@ from ..subtensor import (GpuIncSubtensor, GpuSubtensor,
GpuAdvancedIncSubtensor1)
from ..type import gpuarray_shared_constructor
from .test_basic_ops import mode_with_gpu
from .config import mode_with_gpu
class G_subtensor(test_subtensor.T_subtensor):
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论