提交 de2fba8d authored 作者: Frederic Bastien's avatar Frederic Bastien

Small optimization. Usefull in DebugMode

上级 9989c686
...@@ -566,16 +566,15 @@ class ShapeFeature(object): ...@@ -566,16 +566,15 @@ class ShapeFeature(object):
sometimes Theano constants?? That would be confusing. sometimes Theano constants?? That would be confusing.
""" """
def shape_i(self, i): @staticmethod
def op_deco(r): def shape_ir(i, r):
if hasattr(r.type,"broadcastable") and r.type.broadcastable[i]: if hasattr(r.type,"broadcastable") and r.type.broadcastable[i]:
return self.lscalar_one return self.lscalar_one
else: else:
return Shape_i(i)(r) return Shape_i(i).make_node(r).outputs[0]
return op_deco
def shape_tuple(self, r): def shape_tuple(self, r):
return tuple([self.shape_i(i)(r) for i in xrange(r.ndim)]) return tuple([self.shape_ir(i,r) for i in xrange(r.ndim)])
def default_infer_shape(self, node, i_shapes): def default_infer_shape(self, node, i_shapes):
rval = [] rval = []
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论