提交 49e0964c authored 作者: Frederic Bastien's avatar Frederic Bastien

By default, do not put scalar shared variable on the GPU to do like what the optimizer do.

上级 06addd9c
...@@ -60,6 +60,20 @@ def test_filter_float(): ...@@ -60,6 +60,20 @@ def test_filter_float():
del theano.compile.sharedvalue.shared.constructors[-1] del theano.compile.sharedvalue.shared.constructors[-1]
def test_gpuarray_shared_scalar():
# By default, we don't put scalar as shared variable on the GPU
try:
gpuarray_shared_constructor(np.asarray(1, dtype='float32'))
except TypeError:
pass
else:
assert False, "Expected an error"
# But we can force that
gpuarray_shared_constructor(np.asarray(1, dtype='float32'),
target=test_ctx_name)
def test_unpickle_gpuarray_as_numpy_ndarray_flag0(): def test_unpickle_gpuarray_as_numpy_ndarray_flag0():
""" Test when pygpu isn't there for unpickle are in test_pickle.py""" """ Test when pygpu isn't there for unpickle are in test_pickle.py"""
oldflag = config.experimental.unpickle_gpu_on_cpu oldflag = config.experimental.unpickle_gpu_on_cpu
......
...@@ -667,6 +667,8 @@ def gpuarray_shared_constructor(value, name=None, strict=False, ...@@ -667,6 +667,8 @@ def gpuarray_shared_constructor(value, name=None, strict=False,
if target is notset: if target is notset:
target = None target = None
if not gpu_supported(value): if not gpu_supported(value):
raise TypeError('The GPU do not support that value.')
if not move_to_gpu(value):
raise TypeError('We do not move that data by default to the GPU') raise TypeError('We do not move that data by default to the GPU')
try: try:
get_context(target) get_context(target)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论