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

add doctsring to profiler #34

Merged
merged 1 commit into from
Jun 3, 2024
Merged
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
13 changes: 12 additions & 1 deletion transformer_nuggets/utils/benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,18 @@ def profiler(
profile_memory: bool = False,
with_stack: bool = True,
):
"""Thin wrapper around torch.profiler"""
"""Thin wrapper around torch.profiler

Args:
path: The path to save the trace file to
record_shapes: Record shapes of tensors
profile_memory: Profile memory usage
with_stack: Record stack traces

Usage:
with profiler(Path("trace.json")):
# code to profile
"""
assert path.is_file(), f"{path} is not a file."
path = path.with_suffix(".json")
# make parent dir if it doesn't exist
Expand Down
Loading