提交 d2240bdd authored 作者: Olivier Delalleau's avatar Olivier Delalleau

Merge pull request #574 from nouiz/gpu_setsubtensor

Gpu setsubtensor
...@@ -2,6 +2,7 @@ import logging ...@@ -2,6 +2,7 @@ import logging
_logger = logging.getLogger('theano.sandbox.cuda.opt') _logger = logging.getLogger('theano.sandbox.cuda.opt')
import sys import sys
import warnings
import numpy import numpy
...@@ -747,8 +748,22 @@ def local_gpu_advanced_incsubtensor1(node): ...@@ -747,8 +748,22 @@ def local_gpu_advanced_incsubtensor1(node):
host_input.owner.op.__class__ is tensor.AdvancedIncSubtensor1: host_input.owner.op.__class__ is tensor.AdvancedIncSubtensor1:
x, y = host_input.owner.inputs[0:2] x, y = host_input.owner.inputs[0:2]
coords = host_input.owner.inputs[2:] coords = host_input.owner.inputs[2:]
return [GpuAdvancedIncSubtensor1()(gpu_from_host(x), set_instead_of_inc = host_input.owner.op.set_instead_of_inc
gpu_from_host(y), *coords)] if set_instead_of_inc and config.warn.gpu_set_subtensor1:
warnings.warn(
'Although your current code is fine, please note that '
'Theano versions prior to 0.6 (more specifically, '
'prior to commit XXXX on DATE) may have '
'yielded an incorrect result. To remove this warning, '
'either set the `warn.gpu_set_subtensor1` config '
'option to False, or `warn.ignore_bug_before` to at '
'least \'0.6\'.')
if set_instead_of_inc:
return
gpu_op = GpuAdvancedIncSubtensor1(
set_instead_of_inc=set_instead_of_inc)
return [gpu_op(gpu_from_host(x), gpu_from_host(y), *coords)]
# Should not execute for GpuAdvancedIncSubtensor1 # Should not execute for GpuAdvancedIncSubtensor1
if node.op.__class__ is tensor.AdvancedIncSubtensor1 and \ if node.op.__class__ is tensor.AdvancedIncSubtensor1 and \
...@@ -767,8 +782,21 @@ def local_gpu_advanced_incsubtensor1(node): ...@@ -767,8 +782,21 @@ def local_gpu_advanced_incsubtensor1(node):
else: else:
gpu_y = gpu_from_host(y) gpu_y = gpu_from_host(y)
if go_gpu: if go_gpu:
return [host_from_gpu(GpuAdvancedIncSubtensor1()( set_instead_of_inc = node.op.set_instead_of_inc
gpu_x, gpu_y, *coords))] if set_instead_of_inc and config.warn.gpu_set_subtensor1:
warnings.warn(
'Although your current code is fine, please note that '
'Theano versions prior to 0.6 (more specifically, '
'prior to commit XXXX on DATE) may have '
'yielded an incorrect result. To remove this warning, '
'either set the `warn.gpu_set_subtensor1` config '
'option to False, or `warn.ignore_bug_before` to at '
'least \'0.6\'.', stacklevel=1)
if set_instead_of_inc:
return
gpu_op = GpuAdvancedIncSubtensor1(
set_instead_of_inc=set_instead_of_inc)
return [host_from_gpu(gpu_op(gpu_x, gpu_y, *coords))]
return False return False
......
...@@ -887,7 +887,9 @@ class T_subtensor(theano.tensor.tests.test_basic.T_subtensor): ...@@ -887,7 +887,9 @@ class T_subtensor(theano.tensor.tests.test_basic.T_subtensor):
mode = mode_with_gpu mode = mode_with_gpu
dtype = 'float32' dtype = 'float32'
ignore_topo = (B.HostFromGpu, B.GpuFromHost) ignore_topo = (B.HostFromGpu, B.GpuFromHost)
fast_compile = theano.config.mode == 'FAST_COMPILE' fast_compile = False
ops = (cuda.GpuSubtensor, cuda.GpuIncSubtensor,
cuda.GpuAdvancedSubtensor1, cuda.GpuAdvancedIncSubtensor1)
def __init__(self, name): def __init__(self, name):
return super(theano.tensor.tests.test_basic.T_subtensor, return super(theano.tensor.tests.test_basic.T_subtensor,
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论