提交 6d2b7054 authored 作者: James Bergstra's avatar James Bergstra

fixed mistake in constant_folding that would make all constants TensorConstants

上级 087b430b
......@@ -1038,12 +1038,8 @@ def constant_folding(node):
return False
storage = [[None] for output in node.outputs]
node.op.perform(node, [x.data for x in node.inputs], storage)
cls = gof.Constant
if isinstance(output.type, T.Tensor):
#TODO: think about how to extend to more types
cls = T.TensorConstant
return [cls(output.type, s[0]) for s, output in zip(storage, node.outputs)]
#TODO: think about how to extend to more types
return [(T.TensorConstant if isinstance(s[0], (N.ndarray,int,float)) else gof.Constant)(output.type, s[0]) for s, output in zip(storage, node.outputs)]
register_canonicalize(constant_folding)
register_specialize(constant_folding)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论