TensorRT-LLMs/tests/unittest/trt/model_api/profile_utils.py
xiweny 6979afa6f2
test: reorganize tests folder hierarchy (#2996)
1. move TRT path tests to 'trt' folder
2. optimize some import usage
2025-03-27 12:07:53 +08:00

27 lines
526 B
Python

from contextlib import contextmanager
from functools import wraps
from tensorrt_llm import profiler
def profile(tag):
@contextmanager
def profile_range(tag):
profiler.start(tag)
yield
profiler.stop(tag)
def inner_decorator(func):
@wraps(func)
def wrapper(*args, **kwargs):
"""A wrapper function"""
with profile_range(tag):
func(*args, **kwargs)
profiler.summary()
return wrapper
return inner_decorator