提交 7cf5b30d authored 作者: Reyhane Askari's avatar Reyhane Askari

outputgruard check added to debugmode

上级 2e62dd59
......@@ -27,7 +27,8 @@ from theano.compile.function_module import (
FunctionMaker, Function, infer_reuse_pattern,
SymbolicOutput, Supervisor, std_fgraph)
from theano.compile.mode import Mode, register_mode
from theano.compile.ops import OutputGuard
from theano.compile.ops import OutputGuard, _output_guard
__docformat__ = "restructuredtext en"
_logger = logging.getLogger("theano.compile.debugmode")
......@@ -2311,6 +2312,17 @@ class _Maker(FunctionMaker): # inheritance buys a few helper functions
"of", len(li), "events was stable.",
file=sys.stderr)
self.fgraph = fgraph
for o in fgraph.outputs:
try:
fgraph.replace_validate(o, _output_guard(o), reason='output_guard')
raise Exception("Output variable %s required output_guard, "
"how was this output left unprotected against "
"destructive operations?" % o)
except gof.InconsistencyError:
# This output is already impossible to destroy.
# No guard necessary
pass
linker = _Linker(self)
......
......@@ -118,9 +118,9 @@ class AddDestroyHandler(gof.Optimizer):
supervisor_added = True
break
if not supervisor_added:
warnings.warn("WARNING: Supervisor is not added. Please do not"
"use some_op.optimize(fgraph). Instead use theano.function"
"to add the optimiztions.",
warnings.warn("WARNING: Supervisor is not added. Please build a FunctionGraph"
"via theano.compile.function_module.std_graph()"
"or add the Supervisor class manually.",
stacklevel=3)
def add_requirements(self, fgraph):
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论