Skip to content

Commit f75c26a

Browse files
committed
fix unique parameters
1 parent 2dc161a commit f75c26a

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

python/jittor/__init__.py

+13-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
# This file is subject to the terms and conditions defined in
88
# file 'LICENSE.txt', which is part of this source code package.
99
# ***************************************************************
10-
__version__ = '1.1.7.8'
10+
__version__ = '1.1.7.9'
1111
from . import lock
1212
with lock.lock_scope():
1313
from . import compiler
@@ -404,6 +404,16 @@ def load(path):
404404
model_dict = pickle.load(pkl_file)
405405
return model_dict
406406

407+
def _uniq(x):
408+
a = set()
409+
b = []
410+
for i in x:
411+
j = id(i)
412+
if j not in a:
413+
a.add(j)
414+
b.append(i)
415+
return b
416+
407417
class Module:
408418
def __init__(self, *args, **kw):
409419
pass
@@ -463,15 +473,15 @@ def callback(parents, k, v, n):
463473
def callback_leave(parents, k, v, n):
464474
stack.pop()
465475
self.dfs([], None, callback, callback_leave)
466-
return ps
476+
return _uniq(ps)
467477

468478
def modules(self):
469479
ms = []
470480
def callback(parents, k, v, n):
471481
if isinstance(v, Module):
472482
ms.append(v)
473483
self.dfs([], None, callback, None)
474-
return ms
484+
return _uniq(ms)
475485

476486
def children(self):
477487
cd = []

0 commit comments

Comments
 (0)