tvm.runtime.profiling#

Registration of profiling objects in python.

class tvm.runtime.profiling.Count(count: int)[源代码]#

A integer count of something

class tvm.runtime.profiling.DeviceWrapper(dev: Device)[源代码]#

Wraps a tvm.runtime.Device

class tvm.runtime.profiling.Duration(duration: float)[源代码]#

A duration of something

class tvm.runtime.profiling.MetricCollector[源代码]#

Interface for user defined profiling metric collection.

class tvm.runtime.profiling.Percent(percent: float)[源代码]#

A Percent of something

class tvm.runtime.profiling.Ratio(ratio: float)[源代码]#

A Ratio of two things

class tvm.runtime.profiling.Report(calls: Sequence[Dict[str, Object]], device_metrics: Dict[str, Dict[str, Object]], configuration: Dict[str, Object])[源代码]#

A container for information gathered during a profiling run.

calls#

Per-call profiling metrics (function name, runtime, device, ...).

Type:

Array[Dict[str, Object]]

device_metrics#

Per-device metrics collected over the entire run.

Type:

Dict[Device, Dict[str, Object]]

csv()[源代码]#

Convert this profiling report into CSV format.

This only includes calls and not overall metrics.

返回:

csv -- calls in CSV format.

返回类型:

str

classmethod from_json(s)[源代码]#

Deserialize a report from JSON.

参数:

s (str) -- Report serialize via json().

返回:

report -- The deserialized report.

返回类型:

Report

json()[源代码]#

Convert this profiling report into JSON format.

Example output:

返回:

json -- Formatted JSON

返回类型:

str

table(sort=True, aggregate=True, col_sums=True)[源代码]#

Generate a human-readable table

参数:
  • sort (bool) -- If aggregate is true, whether to sort call frames by descending duration. If aggregate is False, whether to sort frames by order of appearancei n the program.

  • aggregate (bool) -- Whether to join multiple calls to the same op into a single line.

  • col_sums (bool) -- Whether to include the sum of each column.

返回:

table -- A human-readable table

返回类型:

str

tvm.runtime.profiling.profile_function(mod, dev, collectors, func_name=None, warmup_iters=10)[源代码]#

Collect performance information of a function execution. Usually used with a compiled PrimFunc.

This information can include performance counters like cache hits and FLOPs that are useful in debugging performance issues of individual PrimFuncs. Different metrics can be collected depending on which MetricCollector is used.

示例

参数:
  • mod (Module) -- Module containing the function to profile.

  • dev (Device) -- Device to run the function on.

  • collectors (List[MetricCollector]) -- MetricCollector which will collect performance information.

  • func_name (Optional[str]) -- Name of the function in mod to profile. Defaults to the entry_name of mod.

  • warmup_iters (int) -- Number of iterations to run the function before collecting performance information. Recommended to set this larger than 0 for consistent cache effects. Defaults to 10.

返回:

prof -- PackedFunc which takes the same arguments as the mod[func_name] and returns performance metrics as a Dict[str, ObjectRef] where values can be CountNode, DurationNode, PercentNode.

返回类型:

PackedFunc[args, Dict[str, ObjectRef]]