提交 e436106d authored 作者: Frederic's avatar Frederic

Print only once per compilation the warning.

上级 262b0278
...@@ -147,7 +147,7 @@ class ReplaceValidate(History, Validator): ...@@ -147,7 +147,7 @@ class ReplaceValidate(History, Validator):
return chk return chk
def replace_all_validate_remove(self, env, replacements, def replace_all_validate_remove(self, env, replacements,
remove, reason=None): remove, reason=None, warn=True):
"""As replace_all_validate, revert the replacement if the ops """As replace_all_validate, revert the replacement if the ops
in the list remove are still in the graph. It also print a warning. in the list remove are still in the graph. It also print a warning.
...@@ -156,15 +156,16 @@ class ReplaceValidate(History, Validator): ...@@ -156,15 +156,16 @@ class ReplaceValidate(History, Validator):
for rm in remove: for rm in remove:
if rm in env.nodes or rm in env.variables: if rm in env.nodes or rm in env.variables:
env.revert(chk) env.revert(chk)
out = sys.stderr if warn:
print >> out, ( out = sys.stderr
"WARNING: An optimization wanted to replace a Variable" print >> out, (
" in the graph, but the replacement for it doesn't" "WARNING: An optimization wanted to replace a Variable"
" remove it. We disabled the optimization." " in the graph, but the replacement for it doesn't"
" Your function runs correctly, but it would be" " remove it. We disabled the optimization."
" appreciated if you submit this problem to the mailing" " Your function runs correctly, but it would be"
" list theano-users so that we can fix it.") " appreciated if you submit this problem to the"
print >> out, reason, replacements " mailing list theano-users so that we can fix it.")
print >> out, reason, replacements
raise ReplacementDidntRemovedError() raise ReplacementDidntRemovedError()
......
...@@ -1335,7 +1335,8 @@ class GemmOptimizer(Optimizer): ...@@ -1335,7 +1335,8 @@ class GemmOptimizer(Optimizer):
env.replace_all_validate_remove( env.replace_all_validate_remove(
zip(node.outputs, new_outputs), zip(node.outputs, new_outputs),
[old_dot22], [old_dot22],
reason='GemmOptimizer' reason='GemmOptimizer',
warn=nb_replacement_didn_t_remove == 0
) )
did_something = True did_something = True
break break
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论