tvm.runtime.profiling#

Registration of profiling objects in python.

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

A integer count of something

参数:

count (int)

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

Wraps a tvm.runtime.Device

参数:

dev (Device)

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

A duration of something

参数:

duration (float)

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

Interface for user defined profiling metric collection.

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

A Percent of something

参数:

percent (float)

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

A Ratio of two things

参数:

ratio (float)

class tvm.runtime.profiling.Report(calls, device_metrics, configuration)[源代码]#

A container for information gathered during a profiling run.

Attributes#

callsArray[Dict[str, Object]]

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

device_metricsDict[Device, Dict[str, Object]]

Per-device metrics collected over the entire run.

__init__(calls, device_metrics, configuration)[源代码]#

Construct a profiling report from a list of metrics and per-device metrics.

Parameters#

callsSequence[Dict[str, Object]]

Per function call metrics.

device_metricsDict[str, Dict[str, Object]]

Per device metrics.

configurationDict[str, Object]

Configuration of TVM for this profiling run. Includes number of threads, executor.

参数:
csv()[源代码]#

Convert this profiling report into CSV format.

This only includes calls and not overall metrics.

Returns#

csvstr

calls in CSV format.

classmethod from_json(s)[源代码]#

Deserialize a report from JSON.

Parameters#

sstr

Report serialize via json().

Returns#

reportReport

The deserialized report.

json()[源代码]#

Convert this profiling report into JSON format.

Example output:

Returns#

jsonstr

Formatted JSON

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

Generate a human-readable table

Parameters#

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.

Returns#

table : str

A human-readable table

参数:
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.

Example#

Parameters#

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.

Returns#

prof: PackedFunc[args, Dict[str, ObjectRef]]

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.