提交 2e4f6ea3 authored 作者: Arnaud Bergeron's avatar Arnaud Bergeron

Make sure the gpu part is only tested when we are actually running on a GPU.

上级 0faf7819
...@@ -2,7 +2,7 @@ import numpy ...@@ -2,7 +2,7 @@ import numpy
from nose.plugins.skip import SkipTest from nose.plugins.skip import SkipTest
from theano.sandbox.cuda.var import float32_shared_constructor as f32sc from theano.sandbox.cuda.var import float32_shared_constructor as f32sc
from theano.sandbox.cuda import CudaNdarrayType, cuda_available from theano.sandbox.cuda import CudaNdarrayType, cuda_available, cuda_enabled
import theano import theano
...@@ -17,11 +17,12 @@ def test_shared_pickle(): ...@@ -17,11 +17,12 @@ def test_shared_pickle():
v = numpy.array([1.0, 2.0], dtype='float32') v = numpy.array([1.0, 2.0], dtype='float32')
# This test will always be on the GPU # This test will always be on the GPU
assert isinstance(g, theano.tensor.basic.TensorVariable) if cuda_enabled:
assert isinstance(g.owner, theano.gof.graph.Apply) assert isinstance(g, theano.tensor.basic.TensorVariable)
assert isinstance(g.owner.op, theano.sandbox.cuda.HostFromGpu) assert isinstance(g.owner, theano.gof.graph.Apply)
assert isinstance(g.owner.inputs[0], CudaNdarrayType.SharedVariable) assert isinstance(g.owner.op, theano.sandbox.cuda.HostFromGpu)
assert (g.owner.inputs[0].get_value() == v).all() assert isinstance(g.owner.inputs[0], CudaNdarrayType.SharedVariable)
assert (g.owner.inputs[0].get_value() == v).all()
# Make sure it saves the same way (so that the tests before are not bogus) # Make sure it saves the same way (so that the tests before are not bogus)
s = theano.tensor.as_tensor_variable(theano.shared(v)) s = theano.tensor.as_tensor_variable(theano.shared(v))
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论