cupyx.profiler.time_range#

class cupyx.profiler.time_range(message=None, color_id=None, argb_color=None, sync=False)[源代码][源代码]#

使用 NVTX/rocTX 标记带有范围的函数调用。此对象可以作为装饰器或上下文管理器使用。

当用作装饰器时,装饰的函数调用会被标记为范围:

>>> from cupyx.profiler import time_range
>>> @time_range()
... def function_to_profile():
...     pass

当用作上下文管理器时,它将封闭的块描述为嵌套范围:

>>> from cupyx.profiler import time_range
>>> with time_range('some range in green', color_id=0):
...    # do something you want to measure
...    pass

标记的范围在分析器(如 nvvp、nsys-ui 等)的时间轴中可见。

参数:
  • message (str) – 范围的名称。当用作装饰器时,默认值为 func.__name__

  • color_id – 范围颜色 ID

  • argb_color – ARGB 中的范围颜色(例如,绿色为 0xFF00FF00)

  • sync (bool) – 如果 True,在调用 cupy.cuda.nvtx.RangePush()cupy.cuda.nvtx.RangePop() 之前,等待所有未完成的 GPU 处理完成。

方法

__call__(func)[源代码][源代码]#

作为函数调用自身。

__enter__()[源代码][源代码]#
__exit__(exc_type, exc_value, traceback)[源代码][源代码]#
__eq__(value, /)#

返回 self==value。

__ne__(value, /)#

返回 self!=value。

__lt__(value, /)#

返回 self<value。

__le__(value, /)#

返回 self<=value。

__gt__(value, /)#

返回 self>value。

__ge__(value, /)#

返回 self>=value。