提交 3d25229a authored 作者: Arnaud Bergeron's avatar Arnaud Bergeron

Fix bug in Composite.

上级 dd0d4274
...@@ -3711,8 +3711,7 @@ class Composite(ScalarOp): ...@@ -3711,8 +3711,7 @@ class Composite(ScalarOp):
raise NotImplementedError("grad is not implemented for Composite") raise NotImplementedError("grad is not implemented for Composite")
def c_code(self, node, nodename, inames, onames, sub): def c_code(self, node, nodename, inames, onames, sub):
if not hasattr(self, '_c_code'): self.init_c_code()
self.init_c_code()
d = dict(chain(izip(("i%i" % i for i in xrange(len(inames))), inames), d = dict(chain(izip(("i%i" % i for i in xrange(len(inames))), inames),
izip(("o%i" % i for i in xrange(len(onames))), izip(("o%i" % i for i in xrange(len(onames))),
...@@ -3746,6 +3745,7 @@ class Composite(ScalarOp): ...@@ -3746,6 +3745,7 @@ class Composite(ScalarOp):
return "\n".join(sorted(set(rval))) return "\n".join(sorted(set(rval)))
def c_support_code_apply(self, node, name): def c_support_code_apply(self, node, name):
self.init_c_code()
rval = [] rval = []
for subnode, subnodename in zip(self.fgraph.toposort(), self.nodenames): for subnode, subnodename in zip(self.fgraph.toposort(), self.nodenames):
try: try:
...@@ -3771,13 +3771,11 @@ class Composite(ScalarOp): ...@@ -3771,13 +3771,11 @@ class Composite(ScalarOp):
return False return False
# see __hash__ for comment on why there is no mention of fgraph # see __hash__ for comment on why there is no mention of fgraph
# or module cache key here. # or module cache key here.
if not hasattr(self, '_c_code'): self.init_c_code() # self._c_code and self.nodenames
self.init_c_code() # self._c_code and self.nodenames
return (self._c_code == other._c_code) return (self._c_code == other._c_code)
def __hash__(self): def __hash__(self):
if not hasattr(self, '_c_code'): self.init_c_code() # self._c_code and self.nodenames
self.init_c_code() # self._c_code and self.nodenames
rval = hash((type(self), rval = hash((type(self),
self.nin, self.nin,
self.nout, self.nout,
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论