Skip to content

Commit a94863a

Browse files
committed
Simplify default key for root tensors.
1 parent 5a5f1fd commit a94863a

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

tfdeploy.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -153,9 +153,10 @@ def add(self, tensor, tf_sess=None, key=None, **kwargs):
153153
tensor = Tensor(tensor, tf_sess, **kwargs)
154154

155155
if key is None:
156-
key = len(self.roots)
157-
while key in self.roots:
158-
key += 1
156+
if len(self.roots) == 0:
157+
key = 0
158+
else:
159+
key = max(self.roots.keys()) + 1
159160

160161
self.roots[key] = tensor
161162

0 commit comments

Comments
 (0)