算法选择器

模块:polygraphy.backend.trt

警告

算法选择器在 TensorRT 10.8 中已弃用。请在 ITimingCache 中使用可编辑模式。

class TensorInfo(dtype, strides, vectorized_dim, components_per_element)[source]

基类:object

跟踪关于张量的信息,例如格式和数据类型。

参数:
  • dtype (trt.DataType) – 数据类型。

  • strides (Sequence[int]) – 步幅。

  • vectorized_dim (int) – 向量化维度的索引。

  • components_per_element (int) – 每个元素的组件数。

static from_trt(io_info)[source]

从 TensorRT IAlgorithmIOInfo 创建 Polygraphy TensorInfo 实例。

参数:

io_info (trt.IAlgorithmIOInfo) – 算法 I/O 信息。

返回值:

TensorInfo

class Algorithm(implementation, tactic, inputs, outputs)[source]

基类:object

表示 TensorRT 算法变体,它可以由实现 ID、策略 ID 和 I/O 张量信息唯一表示。

参数:
  • implementation (int) – 此算法的实现。

  • tactic (int) – 此算法的策略。

  • inputs (Sequence[TensorInfo]) – 每个输入的 TensorInfo 序列。

  • outputs (Sequence[TensorInfo]) – 每个输出的 TensorInfo 序列。

static from_trt(context, algorithm)[source]

从 TensorRT IAlgorithmContextIAlgorithm 创建 Polygraphy Algorithm 实例。

参数:
  • context (trt.IAlgorithmContext) – 与层对应的算法上下文。

  • algorithm (trt.IAlgorithm) – TensorRT 提供的算法变体。

返回值:

算法

class TacticReplayData(dct=None)[source]

基类:Interface

将层名称映射到相应的策略。更具体地说,它是一个 OrderedDict[str, Algorithm]

add(name, algorithm)[source]

向策略回放数据中添加条目。

参数:
  • name (str) – 层的名称

  • algorithm (Algorithm) – 用于该层的算法。

返回值:

self,以允许方法链式调用。

返回类型:

TacticReplayData

static from_json(src)

解码 JSON 对象并创建此类的实例。

参数:

src (str) – 对象的 JSON 表示

返回值:

解码后的实例

返回类型:

TacticReplayData

Raises:

PolygraphyException – 如果 JSON 无法解码为 TacticReplayData 的实例

static load(src)

从 JSON 文件加载此类的实例。

参数:

src (Union[str, file-like]) – 要从中读取的路径或类文件对象。

返回值:

解码后的实例

返回类型:

TacticReplayData

Raises:

PolygraphyException – 如果 JSON 无法解码为 TacticReplayData 的实例

save(dest)

将此实例编码为 JSON 对象并将其保存到指定的路径或类文件对象。

参数:

dest (Union[str, file-like]) – 要写入的路径或类文件对象。

to_json()

将此实例编码为 JSON 对象。

返回值:

此实例的 JSON 表示。

返回类型:

str

TacticRecorder(*args, **kwargs)

已弃用:请使用 None 代替

TacticReplayer(*args, **kwargs)

已弃用:请使用 None 代替