提交 aa2a430b authored 作者: Frederic Bastien's avatar Frederic Bastien

Add Theano flag scan.debug=False.

上级 70e866cd
...@@ -239,6 +239,14 @@ import theano and print the config variable, as in: ...@@ -239,6 +239,14 @@ import theano and print the config variable, as in:
``False``, then we will gc the inner of scan after all ``False``, then we will gc the inner of scan after all
iterations. This is the default. iterations. This is the default.
.. attribute:: config.scan.debug
Bool value, either ``True`` or ``False``
Default: ``False``
If True, we will print extra scan debug information.
.. attribute:: openmp .. attribute:: openmp
Bool value: either True or False Bool value: either True or False
......
...@@ -1427,6 +1427,11 @@ AddConfigVar('scan.allow_output_prealloc', ...@@ -1427,6 +1427,11 @@ AddConfigVar('scan.allow_output_prealloc',
BoolParam(True), BoolParam(True),
in_c_key=False) in_c_key=False)
AddConfigVar('scan.debug',
"If True, enable extra verbose output related to scan",
BoolParam(False),
in_c_key=False)
AddConfigVar('pycuda.init', AddConfigVar('pycuda.init',
"""If True, always initialize PyCUDA when Theano want to """If True, always initialize PyCUDA when Theano want to
initilize the GPU. Currently, we must always initialize initilize the GPU. Currently, we must always initialize
......
...@@ -304,6 +304,9 @@ class ReplaceValidate(History, Validator): ...@@ -304,6 +304,9 @@ class ReplaceValidate(History, Validator):
chk = fgraph.checkpoint() chk = fgraph.checkpoint()
if verbose is None: if verbose is None:
verbose = config.optimizer_verbose verbose = config.optimizer_verbose
if config.scan.debug:
nb = len([n for n in fgraph.apply_nodes if isinstance(n.op, theano.scan_module.scan_op.Scan)])
for r, new_r in replacements: for r, new_r in replacements:
try: try:
fgraph.replace(r, new_r, reason=reason, verbose=False) fgraph.replace(r, new_r, reason=reason, verbose=False)
...@@ -337,6 +340,12 @@ class ReplaceValidate(History, Validator): ...@@ -337,6 +340,12 @@ class ReplaceValidate(History, Validator):
if verbose: if verbose:
print("validate failed on node %s.\n Reason: %s, %s" % (r, reason, e)) print("validate failed on node %s.\n Reason: %s, %s" % (r, reason, e))
raise raise
if config.scan.debug:
nb2 = len([n for n in fgraph.apply_nodes if isinstance(n.op, theano.scan_module.scan_op.Scan)])
if nb2 > nb:
print("Extra scan introduced", nb, nb2, getattr(reason, 'name', reason), r, new_r)
elif nb2 < nb:
print("Scan removed", nb, nb2, getattr(reason, 'name', reason), r, new_r)
if verbose: if verbose:
print(reason, r, new_r) print(reason, r, new_r)
# The return is needed by replace_all_validate_remove # The return is needed by replace_all_validate_remove
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论