Skip to content

Commit

Permalink
Merge pull request #5 from opendilab/fix/walk
Browse files Browse the repository at this point in the history
fix(hansbug): fix uncompitable problem with walk
  • Loading branch information
HansBug authored Mar 3, 2022
2 parents 1e922e0 + 61f5e94 commit d664fb5
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
treevalue>=1.2.0
treevalue>=1.2.2
torch>=1.1.0,<=1.10.0
hbutils>=0.0.1
numpy
5 changes: 2 additions & 3 deletions treetensor/common/wrappers.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from functools import wraps
from operator import itemgetter

from treevalue import TreeValue, walk
from treevalue import TreeValue, flatten_values

__all__ = [
'ireduce',
Expand All @@ -17,7 +16,7 @@ def _decorator(func):
def _new_func(*args, **kwargs):
result = func(*args, **kwargs)
if isinstance(result, TreeValue):
it = map(itemgetter(1), walk(result, include_nodes=False))
it = flatten_values(result)
return rfunc(piter(it))
else:
return result
Expand Down

0 comments on commit d664fb5

Please sign in to comment.