提交 3e0b10c4 authored 作者: Frederic Bastien's avatar Frederic Bastien

clean up.

上级 f5b24c1a
...@@ -3478,7 +3478,7 @@ class Composite(ScalarOp): ...@@ -3478,7 +3478,7 @@ class Composite(ScalarOp):
if name: if name:
out.name = name out.name = name
else: else:
name = getattr(out, 'name', None) name = out.name
super(Composite, out).__init__(output_types_preference, name) super(Composite, out).__init__(output_types_preference, name)
return out return out
...@@ -3561,34 +3561,19 @@ class Composite(ScalarOp): ...@@ -3561,34 +3561,19 @@ class Composite(ScalarOp):
Return a readable string representation of self.fgraph. Return a readable string representation of self.fgraph.
""" """
try: rval = self.name
rval = self.name if rval is None:
if rval is None: for i, r in enumerate(self.fgraph.inputs):
raise AttributeError r.name = 'i%i' % i
except AttributeError: for i, r in enumerate(self.fgraph.outputs):
if 0: r.name = 'o%i' % i
l = [] io = set(self.fgraph.inputs + self.fgraph.outputs)
for n in self.fgraph.toposort(): for i, r in enumerate(self.fgraph.variables):
if hasattr(n.op, "name") and n.op.name is not None: if r not in io and len(r.clients) > 1:
v = n.op.name r.name = 't%i' % i
if v.startswith("Composite"): rval = "Composite{%s}" % ', '.join([pprint(output) for output
v = v[len("Composite"):] in self.fgraph.outputs])
else: self.name = rval
v = n.op.__class__.__name__
l.append(v)
rval = "Composite{" + ",".join(l) + "}"
else:
for i, r in enumerate(self.fgraph.inputs):
r.name = 'i%i' % i
for i, r in enumerate(self.fgraph.outputs):
r.name = 'o%i' % i
io = set(self.fgraph.inputs + self.fgraph.outputs)
for i, r in enumerate(self.fgraph.variables):
if r not in io and len(r.clients) > 1:
r.name = 't%i' % i
rval = "Composite{%s}" % ', '.join([pprint(output) for output
in self.fgraph.outputs])
self.name = rval
def init_fgraph(self): def init_fgraph(self):
# The clone done by FunctionGraph is needed as we don't want # The clone done by FunctionGraph is needed as we don't want
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论