Skip to content

Commit

Permalink
Split PPE methods
Browse files Browse the repository at this point in the history
  • Loading branch information
KantaTamura committed Aug 26, 2024
1 parent cb533c8 commit e6c128c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 23 deletions.
21 changes: 21 additions & 0 deletions pfio/v2/_profiler.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
try:
from pytorch_pfn_extras.profiler import record, record_iterable

except ImportError:

class _DummyRecord:
def __init__(self):
pass

def __enter__(self):
pass

def __exit__(self, exc_type, exc_value, traceback):
pass

# IF PPE is not available, wrap with noop
def record(tag, trace, *args): # type: ignore # NOQA
return _DummyRecord()

def record_iterable(tag, iter, trace, *args): # type: ignore # NOQA
yield from iter
24 changes: 1 addition & 23 deletions pfio/v2/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,7 @@
import shutil
from typing import Optional

try:
from pytorch_pfn_extras.profiler import record, record_iterable

except ImportError:

class _DummyRecord:
def __init__(self):
pass

def __enter__(self):
pass

def __exit__(self, exc_type, exc_value, traceback):
pass

# IF PPE is not available, wrap with noop
def record(tag, trace, *args): # type: ignore # NOQA
return _DummyRecord()

def record_iterable(tag, iter, trace, *args): # type: ignore # NOQA
yield from iter


from ._profiler import record, record_iterable
from .fs import FS, FileStat, format_repr


Expand Down

0 comments on commit e6c128c

Please sign in to comment.