Skip to content

Commit

Permalink
[Minor,Feature] Add prefix arg to timeit.todict
Browse files Browse the repository at this point in the history
ghstack-source-id: f1ff685caf6e8950d02dfc44ad2c1eb496495ad1
Pull Request resolved: #2576
  • Loading branch information
vmoens committed Nov 18, 2024
1 parent b875979 commit 7bc84d1
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions torchrl/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,15 @@ def print(prefix=None) -> str: # noqa: T202
return "\n".join(string)

@classmethod
def todict(cls, percall=True):
def todict(cls, percall=True, prefix=None):
def _make_key(key):
if prefix:
return f"{prefix}/{key}"
return key

if percall:
return {key: val[0] for key, val in cls._REG.items()}
return {key: val[1] for key, val in cls._REG.items()}
return {_make_key(key): val[0] for key, val in cls._REG.items()}
return {_make_key(key): val[1] for key, val in cls._REG.items()}

@staticmethod
def erase():
Expand Down

0 comments on commit 7bc84d1

Please sign in to comment.