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

Print only once per compilation the warning.

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