提交 3625c701 authored 作者: Ian Goodfellow's avatar Ian Goodfellow

implemented connection_pattern for elemwise

上级 b33e939b
...@@ -1548,7 +1548,7 @@ class Second(BinaryScalarOp): ...@@ -1548,7 +1548,7 @@ class Second(BinaryScalarOp):
def c_code(self, node, name, (x, y), (z, ), sub): def c_code(self, node, name, (x, y), (z, ), sub):
return "%(z)s = %(y)s;" % locals() return "%(z)s = %(y)s;" % locals()
def connection_pattern(self): def connection_pattern(self, node):
# x is never connected because its elements are never used # x is never connected because its elements are never used
# y is connected because its elements are copied over # y is connected because its elements are copied over
......
...@@ -618,6 +618,14 @@ class Elemwise(Op): ...@@ -618,6 +618,14 @@ class Elemwise(Op):
return rval return rval
def connection_pattern(self, node):
if hasattr(self.scalar_op, 'connection_pattern'):
return self.scalar_op.connection_pattern(node)
return [[True for output in node.outputs] for ipt in node.inputs]
def grad(self, inputs, ograds): def grad(self, inputs, ograds):
#compute grad with respect to broadcasted input #compute grad with respect to broadcasted input
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论