提交 b931d52f authored 作者: James Bergstra's avatar James Bergstra

MakeVector.perform - optimization. modifying to skip asarray() when output space…

MakeVector.perform - optimization. modifying to skip asarray() when output space is already allocated.
上级 69ec8fcb
...@@ -224,7 +224,12 @@ class MakeVector(T.Op): ...@@ -224,7 +224,12 @@ class MakeVector(T.Op):
def __str__(self): def __str__(self):
return self.__class__.__name__ return self.__class__.__name__
def perform(self, node, inputs, (out,)): def perform(self, node, inputs, (out,)):
# not calling theano._asarray as optimization
if out[0] is None:
out[0] = theano._asarray(inputs, dtype=node.outputs[0].dtype) out[0] = theano._asarray(inputs, dtype=node.outputs[0].dtype)
else:
# assume that out has correct dtype. there is no cheap way to check
out[0][...] = inputs
make_vector = MakeVector() make_vector = MakeVector()
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论