Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Refactor] Rename and move scoped profiler info under ti.profiler #4165

Merged
merged 2 commits into from
Jan 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion python/taichi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,12 @@
from taichi import aot # isort:skip
from taichi._testing import * # isort:skip

__deprecated_names__ = {'SOA': 'Layout.SOA', 'AOS': 'Layout.AOS'}
__deprecated_names__ = {
'SOA': 'Layout.SOA',
'AOS': 'Layout.AOS',
'print_profile_info': 'profiler.print_scoped_profiler_info',
'clear_profile_info': 'profiler.clear_scoped_profiler_info'
}

if sys.version_info.minor < 7:
for name, alter in __deprecated_names__.items():
Expand Down
1 change: 1 addition & 0 deletions python/taichi/profiler/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from taichi.profiler.kernelprofiler import \
KernelProfiler # import for docstring-gen
from taichi.profiler.kernelprofiler import get_default_kernel_profiler
from taichi.profiler.scoped_profiler import *
34 changes: 34 additions & 0 deletions python/taichi/profiler/scoped_profiler.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
from taichi._lib import core as _ti_core


def print_scoped_profiler_info():
"""Print time elapsed on the host tasks in a hierarchical format.

This profiler is automatically on.

Call function imports from C++ : _ti_core.print_profile_info()

Example::

>>> import taichi as ti
>>> ti.init(arch=ti.cpu)
>>> var = ti.field(ti.f32, shape=1)
>>> @ti.kernel
>>> def compute():
>>> var[0] = 1.0
>>> print("Setting var[0] =", var[0])
>>> compute()
>>> ti.profiler.print_scoped_profiler_info()
"""
_ti_core.print_profile_info()


def clear_scoped_profiler_info():
"""Clear profiler's records about time elapsed on the host tasks.

Call function imports from C++ : _ti_core.clear_profile_info()
"""
_ti_core.clear_profile_info()


__all__ = ['print_scoped_profiler_info', 'clear_scoped_profiler_info']
2 changes: 0 additions & 2 deletions python/taichi/tools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,4 @@
'get_kernel_stats',
'get_traceback',
'set_gdb_trigger',
'print_profile_info',
'clear_profile_info',
]
30 changes: 0 additions & 30 deletions python/taichi/tools/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,36 +129,6 @@ def set_gdb_trigger(on=True):
_ti_core.set_core_trigger_gdb_when_crash(on)


def print_profile_info():
"""Print time elapsed on the host tasks in a hierarchical format.

This profiler is automatically on.

Call function imports from C++ : _ti_core.print_profile_info()

Example::

>>> import taichi as ti
>>> ti.init(arch=ti.cpu)
>>> var = ti.field(ti.f32, shape=1)
>>> @ti.kernel
>>> def compute():
>>> var[0] = 1.0
>>> print("Setting var[0] =", var[0])
>>> compute()
>>> ti.print_profile_info()
"""
_ti_core.print_profile_info()


def clear_profile_info():
"""Clear profiler's records about time elapsed on the host tasks.

Call function imports from C++ : _ti_core.clear_profile_info()
"""
_ti_core.clear_profile_info()


def dump_dot(filepath=None, rankdir=None, embed_states_threshold=0):
d = _ti_core.dump_dot(rankdir, embed_states_threshold)
if filepath is not None:
Expand Down