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

Speed up ifelse by not calling filter. We can suppose the inputs is of the right type

上级 dd478b4e
...@@ -246,10 +246,9 @@ class IfElse(PureOp): ...@@ -246,10 +246,9 @@ class IfElse(PureOp):
for out, outtype, t in izip(outputs, outtypes, ts): for out, outtype, t in izip(outputs, outtypes, ts):
compute_map[out][0] = 1 compute_map[out][0] = 1
if self.as_view: if self.as_view:
oval = outtype.filter(storage_map[t][0]) oval = storage_map[t][0]
else: else:
oval = outtype.filter( oval = deepcopy(storage_map[t][0])
deepcopy(storage_map[t][0]))
storage_map[out][0] = oval storage_map[out][0] = oval
return [] return []
else: else:
...@@ -262,8 +261,7 @@ class IfElse(PureOp): ...@@ -262,8 +261,7 @@ class IfElse(PureOp):
compute_map[out][0] = 1 compute_map[out][0] = 1
# can't view both outputs unless destroyhandler # can't view both outputs unless destroyhandler
# improves # improves
oval = outtype.filter( oval = deepcopy(storage_map[f][0])
deepcopy(storage_map[f][0]))
storage_map[out][0] = oval storage_map[out][0] = oval
return [] return []
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论