提交 abe49e6c authored 作者: Pascal Lamblin's avatar Pascal Lamblin

Do not constant-fold Alloc if it is the output

Also fix an optimization bug in that case.
上级 daf7d9c9
......@@ -2005,13 +2005,18 @@ class GpuAlloc(Op):
return (3,)
def do_constant_folding(self, node):
if any([isinstance(client[0].op, (
for client in node.outputs[0].clients:
if client[0] == 'output':
# If the output is a constant, it will have to be deepcopied
# each time the function is called. So we do not fold.
return False
elif (not isinstance(client[0], basestring)
and isinstance(client[0].op, (
tensor.IncSubtensor,
tensor.AdvancedIncSubtensor1,
GpuIncSubtensor,
GpuAdvancedIncSubtensor1
))
for client in node.outputs[0].clients]):
))):
return False
return True
......
......@@ -2617,11 +2617,17 @@ class Alloc(gof.Op):
return self.make_node(eval_points[0], *inputs[1:]).outputs
def do_constant_folding(self, node):
if python_any([isinstance(client[0].op, (IncSubtensor,
for client in node.outputs[0].clients:
if client[0] == 'output':
# If the output is a constant, it will have to be deepcopied
# each time the function is called. So we do not fold.
return False
elif (not isinstance(client[0], basestring)
and isinstance(client[0].op, (
IncSubtensor,
AdvancedIncSubtensor1,
AdvancedIncSubtensor,
))
for client in node.outputs[0].clients]):
))):
return False
return True
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论