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

Merge pull request #2707 from abergeron/relative_import

Relative import
......@@ -26,9 +26,9 @@ AddConfigVar('gpuarray.sync',
in_c_key=True)
# This is for documentation not to depend on the availability of pygpu
from type import (GpuArrayType, GpuArrayVariable, GpuArrayConstant,
from .type import (GpuArrayType, GpuArrayVariable, GpuArrayConstant,
GpuArraySharedVariable, gpuarray_shared_constructor)
import opt
from . import opt
def init_dev(dev):
......
......@@ -20,7 +20,7 @@ try:
except ImportError:
pass
from type import GpuArrayType
from .type import GpuArrayType
def as_gpuarray_variable(x):
......
from theano import Op, Apply, config
from theano.tensor.blas import Dot22, Gemv, Gemm, Ger
from theano.sandbox.gpuarray.basic_ops import (HideC, as_gpuarray_variable)
from .basic_ops import HideC, as_gpuarray_variable
try:
import pygpu
......
......@@ -3,9 +3,9 @@ import os
import theano
from theano import config, gof
from theano.sandbox.gpuarray.comp import NVCC_compiler
from theano.sandbox.gpuarray.type import GpuArrayType
from theano.sandbox.gpuarray.basic_ops import as_gpuarray_variable
from .comp import NVCC_compiler
from .type import GpuArrayType
from .basic_ops import as_gpuarray_variable
class GpuConv(gof.Op):
......
......@@ -7,9 +7,9 @@ import numpy
import theano
from theano import Apply, scalar, config
from theano import scalar as scal
from theano.gof.utils import MethodNotDefined
from theano.scalar import Scalar
from theano.tensor.elemwise import (Elemwise, DimShuffle, CAReduceDtype)
from theano.sandbox.gpuarray.comp import NVCC_compiler
try:
import pygpu
......@@ -21,11 +21,11 @@ try:
except ImportError:
pass
from theano.sandbox.gpuarray.basic_ops import (as_gpuarray_variable, HideC,
GpuKernelBase, Kernel)
from theano.sandbox.gpuarray.type import GpuArrayType
from .basic_ops import (as_gpuarray_variable, HideC,
GpuKernelBase, Kernel)
from .comp import NVCC_compiler
from .type import GpuArrayType
from theano.gof.utils import MethodNotDefined
def _is_scalar(v):
......
""" Helper routines for generating gpu kernels for nvcc.
"""
def nvcc_kernel(name, params, body):
"""Return the c code of a kernel function.
......
......@@ -11,12 +11,11 @@ try:
except ImportError:
pass
from theano.sandbox.gpuarray.basic_ops import (as_gpuarray_variable,
host_from_gpu, gpu_from_host)
from theano.sandbox.gpuarray.opt import register_opt as register_gpu_opt
from theano.sandbox.gpuarray.opt import op_lifter as op_lifter
from theano.sandbox.gpuarray.type import GpuArrayType
from theano.sandbox.gpuarray.comp import NVCC_compiler
from .basic_ops import (as_gpuarray_variable,
host_from_gpu, gpu_from_host)
from .opt import register_opt as register_gpu_opt, op_lifter
from .type import GpuArrayType
from .comp import NVCC_compiler
class GpuImages2Neibs(Images2Neibs, Op):
......
......@@ -2,8 +2,6 @@ import numpy
from theano import Op, Apply, config
from theano.compat.six import StringIO
from theano.sandbox.gpuarray.comp import NVCC_compiler
try:
import pygpu
......@@ -11,11 +9,12 @@ try:
except ImportError:
pass
from theano.sandbox.gpuarray.basic_ops import as_gpuarray_variable
from theano.sandbox.gpuarray.type import GpuArrayType
from theano.sandbox.gpuarray.kernel_codegen import (nvcc_kernel,
inline_softmax,
inline_softmax_fixed_shared)
from .basic_ops import as_gpuarray_variable
from .comp import NVCC_compiler
from .type import GpuArrayType
from .kernel_codegen import (nvcc_kernel,
inline_softmax,
inline_softmax_fixed_shared)
class GpuCrossentropySoftmaxArgmax1HotWithBias(Op):
......
......@@ -18,26 +18,23 @@ from theano.scan_module import scan_utils, scan_op, scan_opt
from theano.compat.python2x import all, any
from theano.tensor.nnet.conv import ConvOp
from theano.sandbox.gpuarray.type import GpuArrayType
from theano.sandbox.gpuarray.basic_ops import (
host_from_gpu, gpu_from_host, HostFromGpu, GpuFromHost,
GpuSplit,
gpu_alloc, GpuAlloc, GpuReshape, GpuEye, gpu_join, GpuJoin,
)
from theano.sandbox.gpuarray.blas import gpu_dot22, GpuGemv, GpuGemm, GpuGer
from theano.sandbox.gpuarray.conv import GpuConv
from theano.sandbox.gpuarray.nnet import (
GpuCrossentropySoftmaxArgmax1HotWithBias,
GpuCrossentropySoftmax1HotWithBiasDx,
GpuSoftmaxWithBias, GpuSoftmax
)
from theano.sandbox.gpuarray.elemwise import (GpuElemwise, _is_scalar,
GpuDimShuffle, GpuCAReduceCuda,
GpuCAReduceCPY)
from theano.sandbox.gpuarray.subtensor import (GpuIncSubtensor, GpuSubtensor,
GpuAdvancedIncSubtensor1,
GpuAdvancedIncSubtensor1_dev20)
from theano.sandbox.gpuarray.type import GpuArrayConstant
from .type import GpuArrayType, GpuArrayConstant
from .basic_ops import (host_from_gpu, gpu_from_host,
HostFromGpu, GpuFromHost,
GpuSplit,
gpu_alloc, GpuAlloc, GpuReshape,
GpuEye, gpu_join, GpuJoin)
from .blas import gpu_dot22, GpuGemv, GpuGemm, GpuGer
from .conv import GpuConv
from .nnet import (GpuCrossentropySoftmaxArgmax1HotWithBias,
GpuCrossentropySoftmax1HotWithBiasDx,
GpuSoftmaxWithBias, GpuSoftmax)
from .elemwise import (GpuElemwise, _is_scalar,
GpuDimShuffle, GpuCAReduceCuda,
GpuCAReduceCPY)
from .subtensor import (GpuIncSubtensor, GpuSubtensor,
GpuAdvancedIncSubtensor1,
GpuAdvancedIncSubtensor1_dev20)
gpu_optimizer = EquilibriumDB()
gpu_cut_copies = EquilibriumDB()
......
......@@ -14,10 +14,10 @@ try:
except ImportError:
pass
from theano.sandbox.gpuarray.type import GpuArrayType
from theano.sandbox.gpuarray.basic_ops import as_gpuarray_variable, HideC
from theano.sandbox.gpuarray.elemwise import GpuElemwise
from theano.sandbox.gpuarray.comp import NVCC_compiler
from .type import GpuArrayType
from .basic_ops import as_gpuarray_variable, HideC
from .elemwise import GpuElemwise
from .comp import NVCC_compiler
class GpuSubtensor(HideC, Subtensor):
......
......@@ -34,16 +34,16 @@ if cuda_ndarray.cuda_available and not theano.sandbox.gpuarray.pygpu_activated:
if not theano.sandbox.gpuarray.pygpu_activated:
raise SkipTest("pygpu disabled")
from theano.sandbox.gpuarray.type import (GpuArrayType,
gpuarray_shared_constructor)
from theano.sandbox.gpuarray.basic_ops import (
from ..type import (GpuArrayType,
gpuarray_shared_constructor)
from ..basic_ops import (
host_from_gpu, gpu_from_host,
gpu_alloc, GpuAlloc,
gpu_from_cuda,
cuda_from_gpu, HostFromGpu,
GpuFromHost, GpuReshape,
gpu_join, GpuJoin, GpuSplit, GpuEye, gpu_contiguous)
from theano.sandbox.gpuarray.subtensor import GpuSubtensor
from ..subtensor import GpuSubtensor
from theano.tests import unittest_tools as utt
utt.seed_rng()
......
......@@ -8,14 +8,14 @@ from theano.tensor.blas import (gemv_inplace, gemm_inplace, ger_destructive,
_dot22)
from theano.tensor.tests.test_blas import TestGer, BaseGemv
from theano.sandbox.gpuarray import gpuarray_shared_constructor
from theano.sandbox.gpuarray.tests.test_basic_ops import (makeTester, rand,
mode_with_gpu)
from theano.sandbox.gpuarray.blas import (gpugemv_inplace, gpugemv_no_inplace,
gpugemm_inplace, gpugemm_no_inplace,
gpuger_inplace, gpuger_no_inplace,
GpuGer, gpu_dot22)
from .. import gpuarray_shared_constructor
from .test_basic_ops import (makeTester, rand,
mode_with_gpu)
from ..blas import (gpugemv_inplace, gpugemv_no_inplace,
gpugemm_inplace, gpugemm_no_inplace,
gpuger_inplace, gpuger_no_inplace,
GpuGer, gpu_dot22)
GpuGemvTester = makeTester('GpuGemvTester',
......
......@@ -22,10 +22,10 @@ from theano.compat.python2x import any
from theano.tests.unittest_tools import seed_rng
# We let that import do the init of the back-end if needed.
from theano.sandbox.gpuarray.tests.test_basic_ops import (mode_with_gpu,
mode_without_gpu)
from theano.sandbox.gpuarray.type import GpuArrayType
from theano.sandbox.gpuarray.conv import GpuConv
from .test_basic_ops import (mode_with_gpu,
mode_without_gpu)
from ..type import GpuArrayType
from ..conv import GpuConv
import pygpu
gftensor4 = GpuArrayType('float32', [False] * 4)
......
......@@ -6,11 +6,10 @@ from theano.tests.unittest_tools import SkipTest
from theano.tensor.tests.test_elemwise import (test_Broadcast, test_DimShuffle,
test_CAReduce, T_reduce_dtype)
from theano.sandbox.gpuarray.tests.test_basic_ops import (mode_with_gpu,
rand_gpuarray)
from theano.sandbox.gpuarray.elemwise import (GpuElemwise, GpuDimShuffle,
GpuCAReduceCuda, GpuCAReduceCPY)
from theano.sandbox.gpuarray.type import GpuArrayType
from .test_basic_ops import mode_with_gpu, rand_gpuarray
from ..elemwise import (GpuElemwise, GpuDimShuffle,
GpuCAReduceCuda, GpuCAReduceCPY)
from ..type import GpuArrayType
from pygpu.array import gpuarray
......
import unittest
from theano.tensor.nnet.tests import test_neighbours
# We let that import do the init of the back-end if needed.
from theano.sandbox.gpuarray.tests.test_basic_ops import (mode_with_gpu,
mode_without_gpu)
from .test_basic_ops import (mode_with_gpu,
mode_without_gpu)
import theano.tensor.nnet.tests.test_neighbours
from theano.sandbox.gpuarray.neighbours import GpuImages2Neibs
from ..neighbours import GpuImages2Neibs
class T_GpuImages2Neibs(theano.tensor.nnet.tests.test_neighbours.T_Images2Neibs):
class T_GpuImages2Neibs(test_neighbours.T_Images2Neibs):
mode = mode_with_gpu
op = GpuImages2Neibs
dtypes = ['int64', 'float32', 'float64']
......
......@@ -9,12 +9,13 @@ import theano.tests.unittest_tools as utt
from theano.sandbox import gpuarray
# We let that import do the init of the back-end if needed.
from theano.sandbox.gpuarray.tests.test_basic_ops import (mode_with_gpu,
mode_without_gpu)
from .test_basic_ops import (mode_with_gpu,
mode_without_gpu)
from theano.sandbox.gpuarray.nnet import (
from ..nnet import (
GpuCrossentropySoftmaxArgmax1HotWithBias,
GpuCrossentropySoftmax1HotWithBiasDx)
GpuCrossentropySoftmax1HotWithBiasDx,
GpuSoftmaxWithBias, GpuSoftmax)
def test_GpuCrossentropySoftmaxArgmax1HotWithBias():
......@@ -203,7 +204,7 @@ def softmax_with_bias_unittest_template(dtypeInput, dtypeBias):
f_gpu = theano.function([x], z, mode=mode_with_gpu)
assert f.maker.fgraph.toposort()[-1].op == T.nnet.softmax_with_bias
assert isinstance(f_gpu.maker.fgraph.toposort()[-2].op,
theano.sandbox.gpuarray.nnet.GpuSoftmaxWithBias)
GpuSoftmaxWithBias)
def cmp(n, m):
# print "test_softmax",n,m
......@@ -261,7 +262,7 @@ def softmax_unittest_template(dtypeInput):
f_gpu = theano.function([x], z, mode=mode_with_gpu)
assert f.maker.fgraph.toposort()[-1].op == T.nnet.softmax
assert isinstance(f_gpu.maker.fgraph.toposort()[-2].op,
theano.sandbox.gpuarray.nnet.GpuSoftmax)
GpuSoftmax)
def cmp(n, m):
if dtypeInput == 'float32':
......
......@@ -3,19 +3,16 @@ import numpy
import theano
from theano import tensor
from theano.tests import unittest_tools as utt
import theano.sandbox.gpuarray
from theano.sandbox.gpuarray.type import (
GpuArrayType, gpuarray_shared_constructor)
from theano.sandbox.gpuarray.basic_ops import (
GpuAlloc, GpuReshape, gpu_alloc, gpu_from_host, host_from_gpu)
from theano.sandbox.gpuarray.elemwise import (
GpuCAReduceCuda, GpuCAReduceCPY, GpuElemwise)
from theano.sandbox.gpuarray.subtensor import GpuSubtensor
from theano.sandbox.gpuarray.tests.test_basic_ops import (
rand_gpuarray, mode_with_gpu, mode_without_gpu
)
from theano.tests.unittest_tools import SkipTest
from theano.tensor.tests.test_basic import TestSpecifyShape
from theano.tensor.tests import test_basic
import theano.sandbox.gpuarray
from ..type import GpuArrayType, gpuarray_shared_constructor
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
def test_local_assert():
......@@ -135,10 +132,9 @@ def test_rebroadcast():
assert isinstance(rebr.outputs[0].type, GpuArrayType)
class TestSpecifyShape(TestSpecifyShape):
class TestSpecifyShape(test_basic.TestSpecifyShape):
mode = mode_with_gpu
input_type = GpuArrayType
pass
def test_print_op():
......@@ -146,9 +142,6 @@ def test_print_op():
b = tensor.fmatrix()
f = theano.function([b], theano.printing.Print()(b) * 2,
mode=mode_with_gpu)
theano.printing.debugprint(f)
# print f.maker.fgraph.toposort()
#[GpuFromHost(<TensorType(float32, matrix)>), <theano.printing.Print object at 0x3581210>(GpuFromHost.0), GpuElemwise{mul}(CudaNdarray{[[ 2.]]}, <theano.printing.Print object at 0x3581210>.0), HostFromGpu(GpuElemwise{mul}.0)]
topo = f.maker.fgraph.toposort()
assert topo[0].op == gpu_from_host
assert isinstance(topo[1].op, theano.printing.Print)
......
......@@ -5,12 +5,10 @@ import theano
from theano.tests import unittest_tools as utt
import theano.sandbox.rng_mrg
from theano.sandbox.gpuarray.basic_ops import (
gpu_from_host, GpuFromHost, HostFromGpu
)
from theano.sandbox.gpuarray.elemwise import GpuElemwise
from ..basic_ops import gpu_from_host, GpuFromHost, HostFromGpu
from ..elemwise import GpuElemwise
from theano.sandbox.gpuarray.tests.test_basic_ops import mode_with_gpu
from .test_basic_ops import mode_with_gpu
class T_Scan(TestCase):
......
import numpy
import theano
from theano.tensor.tests.test_subtensor import T_subtensor
from theano.sandbox.gpuarray.basic_ops import (HostFromGpu, GpuFromHost)
from theano.sandbox.gpuarray.subtensor import (GpuIncSubtensor, GpuSubtensor,
GpuAdvancedIncSubtensor1)
from theano import tensor
from theano.compile import DeepCopyOp
from theano.sandbox.gpuarray.type import gpuarray_shared_constructor
from theano.tensor.tests.test_subtensor import T_subtensor
from theano.sandbox.gpuarray.tests.test_basic_ops import mode_with_gpu
from ..basic_ops import HostFromGpu, GpuFromHost
from ..subtensor import (GpuIncSubtensor, GpuSubtensor,
GpuAdvancedIncSubtensor1)
from ..type import gpuarray_shared_constructor
from theano.compile import DeepCopyOp
from .test_basic_ops import mode_with_gpu
from theano import tensor
class G_subtensor(T_subtensor):
......
......@@ -5,9 +5,9 @@ import numpy
import theano
from theano.compile import DeepCopyOp
from theano.sandbox.gpuarray.tests.test_basic_ops import rand_gpuarray
from .test_basic_ops import rand_gpuarray
from theano.sandbox.gpuarray.type import GpuArrayType
from ..type import GpuArrayType
def test_deep_copy():
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论