提交 6872ae43 authored 作者: Frederic's avatar Frederic

Disable GpuAdvancedIncSubtensor1 when set_instead_of_inc is True and warn about it.

上级 fbb70262
...@@ -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
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论