提交 578ad4fd authored 作者: Frederic Bastien's avatar Frederic Bastien

Don't let scan AllocEmpty cause false alarm by NanGuardMode

上级 e088e2a8
......@@ -322,8 +322,9 @@ class NanGuardMode(Mode):
do_check_on(x[0], node, fn, True)
fn()
outputs = fn.outputs
for x in outputs:
do_check_on(x[0], node, fn, False)
for x, var in zip(outputs, node.outputs):
if getattr(var, 'nan_guard_mode_check', True):
do_check_on(x[0], node, fn, False)
wrap_linker = theano.gof.WrapLinker([theano.gof.OpWiseCLinker()],
nan_check)
......
......@@ -620,7 +620,9 @@ def expand_empty(tensor_var, size):
new_shape = [size + shapes[0]] + shapes[1:]
empty = tensor.AllocEmpty(tensor_var.dtype)(*new_shape)
return tensor.set_subtensor(empty[:shapes[0]], tensor_var)
ret = tensor.set_subtensor(empty[:shapes[0]], tensor_var)
ret.nan_guard_mode_check = False
return ret
def equal_computations(xs, ys, in_xs=None, in_ys=None):
......
......@@ -6238,6 +6238,11 @@ class AllocEmpty(gof.Op):
# The outut can contain nan/inf. output.type is a new
# instance, so we can do this only for that variable.
output.type.filter_checks_isfinite = False
# We can't reuse filter_checks_isfinite as by default it is
# False and it is set to true only in DebugMode.
# We can't set it in the type as other make_node can reuse the type.
output.nan_guard_mode_check = False
return Apply(self, shape, [output])
def perform(self, node, inputs, out_):
......
......@@ -3076,6 +3076,9 @@ def local_inplace_setsubtensor(node):
set_instead_of_inc=node.op.set_instead_of_inc,
destroyhandler_tolerate_aliased=dta)
new_node = new_op(*node.inputs)
# Keep the information needed for NanGuardMode.
new_node.nan_guard_mode_check = getattr(
node.op, 'nan_guard_mode_check', True)
# Copy stacktrace from original outputs to new outputs.
# This is sensible, because the new operation is the
# same as the old one, but now with different attributes.
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论