Skip to content

Commit

Permalink
Merge pull request #37 from MayDomine/main
Browse files Browse the repository at this point in the history
add __iter__ to make TransformerBlockList Iterable
  • Loading branch information
a710128 authored Jul 8, 2022
2 parents e6ba031 + bbe73a4 commit 3ed3e3c
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion bmtrain/block_layer.py
Original file line number Diff line number Diff line change
Expand Up @@ -831,7 +831,8 @@ def __init__(self, modules: Iterable[CheckpointBlock], sqrt=False) -> None:

def __len__(self) -> int:
return len(self._modules)

def __iter__(self) -> Iterator[CheckpointBlock]:
return iter(self._modules.values())
def __getitem__(self, index: Union[int, str]) -> CheckpointBlock:
return self._modules[str(index)]

Expand Down

0 comments on commit 3ed3e3c

Please sign in to comment.