提交 4f4265ff authored 作者: Olivier Delalleau's avatar Olivier Delalleau

Fixed code according to comment

Not 100% sure of this fix, but it seems sensible and the test passes.
上级 22389ca2
...@@ -1773,19 +1773,10 @@ class Remove0Tester(utt.InferShapeTester): ...@@ -1773,19 +1773,10 @@ class Remove0Tester(utt.InferShapeTester):
if theano.config.mode not in ['FAST_COMPILE']: if theano.config.mode not in ['FAST_COMPILE']:
# list of apply nodes in the optimized graph. # list of apply nodes in the optimized graph.
nodes = f.maker.fgraph.toposort() nodes = f.maker.fgraph.toposort()
v = [True for node in nodes] for node in nodes:
# In python 3, list comprehention variables do not leak if isinstance(node.op, Remove0):
# in the outside scope, so we bind node varible below assert node.op.inplace, ('Inplace optimization should '
# to make the code behave the same under all 'have been applied.')
# versions. However, the logic here does not look
# right: the length of v is always the same as that of
# nodes and the only result of the assert is to check
# that nodes is not empty. The intent was probably to
# keep if clause inside the [] and check every node.
node = nodes[-1]
if isinstance(node.op, Remove0) and node.op.inplace:
assert len(v), \
'Inplacing optimization should have been applied.'
# checking # checking
# makes sense to change its name # makes sense to change its name
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论