Table of Contents

Class TensorRtOptimizationProfile

Namespace
JYPPX.TensorRtSharp
Assembly
JYPPX.TensorRtSharp.dll

Wraps a TensorRT optimization profile used to describe dynamic input ranges during engine building. 封装 TensorRT 优化配置文件,用于在构建引擎时描述动态输入的 min/opt/max 范围。

public sealed class TensorRtOptimizationProfile : IDisposable
Inheritance
TensorRtOptimizationProfile
Implements
Inherited Members

Properties

ExtraMemoryTarget

Gets or sets the extra memory target fraction for this profile. 获取或设置该 profile 允许 TensorRT 为额外 profile 分配的额外内存比例。

public float ExtraMemoryTarget { get; set; }

Property Value

float

Remarks

TensorRT uses this value as a build-time hint. Valid values are vendor-defined and may vary by TensorRT line. TensorRT 会把该值作为构建期提示;可接受范围由 TensorRT 版本决定。

IsValid

Gets a value indicating whether TensorRT considers this profile complete and internally valid. 获取 TensorRT 是否认为该 profile 已完整配置且内部状态有效。

public bool IsValid { get; }

Property Value

bool

Line

Gets the TensorRT API line that owns this profile. 获取创建该 profile 的 TensorRT API 版本线。

public TensorRtApiLine Line { get; }

Property Value

TensorRtApiLine

Methods

Dispose()

Releases the native optimization profile handle. 释放原生 optimization profile 句柄。

public void Dispose()

GetShape(string, TensorRtOptimizationProfileSelector)

Gets one min/opt/max dimension selector from this optimization profile. 从该优化 profile 中读取某一个 min/opt/max selector 的维度。

public TensorRtDims GetShape(string inputName, TensorRtOptimizationProfileSelector selector)

Parameters

inputName string

Network input tensor name. 网络输入张量名称。

selector TensorRtOptimizationProfileSelector

Profile selector to query. 要查询的 profile selector。

Returns

TensorRtDims

The TensorRT dimensions stored for the selector. 该 selector 保存的 TensorRT 维度。

GetShape64(string, TensorRtOptimizationProfileSelector)

Gets one TensorRT 11 min/opt/max dimension selector with 64-bit extents. 以 64 位 extent 获取 TensorRT 11 某个 min/opt/max selector 的维度。

public TensorRtDims64 GetShape64(string inputName, TensorRtOptimizationProfileSelector selector)

Parameters

inputName string

Network input tensor name. 网络输入张量名称。

selector TensorRtOptimizationProfileSelector

Profile selector to query. 要查询的 profile selector。

Returns

TensorRtDims64

The TensorRT 11 dimensions stored for the selector. 该 selector 保存的 TensorRT 11 维度。

GetShapeDimensionExtent64(string, TensorRtOptimizationProfileSelector, int)

Gets one dimension extent from a TensorRT 11 profile selector as a 64-bit value. 以 64 位整数获取 TensorRT 11 profile selector 的单个维度 extent。

public long GetShapeDimensionExtent64(string inputName, TensorRtOptimizationProfileSelector selector, int dimensionIndex)

Parameters

inputName string

Network input tensor name. 网络输入张量名称。

selector TensorRtOptimizationProfileSelector

Profile selector to query. 要查询的 profile selector。

dimensionIndex int

The zero-based dimension index. 从零开始的维度索引。

Returns

long

The profile dimension extent reported by TensorRT. TensorRT 报告的 profile 维度 extent。

GetShapeRange(string)

Gets the complete min/opt/max dimension range for an input tensor. 获取输入张量完整的 min/opt/max 维度范围。

public TensorRtOptimizationProfileShapeRange GetShapeRange(string inputName)

Parameters

inputName string

Network input tensor name. 网络输入张量名称。

Returns

TensorRtOptimizationProfileShapeRange

The complete profile shape range. 完整的 profile 形状范围。

GetShapeRange64(string)

Gets the complete TensorRT 11 min/opt/max dimension range using 64-bit extents. 使用 64 位 extent 获取 TensorRT 11 完整的 min/opt/max 维度范围。

public TensorRtOptimizationProfileShapeRange64 GetShapeRange64(string inputName)

Parameters

inputName string

Network input tensor name. 网络输入张量名称。

Returns

TensorRtOptimizationProfileShapeRange64

The complete 64-bit profile shape range. 完整的 64 位 profile shape 范围。

GetShapeValueCount(string)

Gets the number of integer values configured for a TensorRT shape tensor input. 获取 TensorRT shape tensor 输入已配置的整数取值数量。

public int GetShapeValueCount(string inputName)

Parameters

inputName string

Shape tensor input name. shape tensor 输入名称。

Returns

int

The number of configured shape values, or a vendor-defined negative value when not configured. 已配置取值数量;未配置时可能返回 TensorRT 定义的负数。

GetShapeValueCountV2(string)

Gets the number of 64-bit shape values configured for a TensorRT shape tensor input. 获取 TensorRT shape tensor 输入已配置的 64 位 shape 值数量。

public int GetShapeValueCountV2(string inputName)

Parameters

inputName string

Shape tensor input name. Shape tensor 输入名称。

Returns

int

The number of configured values, or a TensorRT-defined negative value when unset. 已配置数量;未配置时可能返回 TensorRT 定义的负数。

GetShapeValueRange(string)

Gets the complete min/opt/max value range for a TensorRT shape tensor input. 获取 TensorRT shape tensor 输入完整的 min/opt/max 取值范围。

public TensorRtOptimizationProfileShapeValueRange GetShapeValueRange(string inputName)

Parameters

inputName string

Shape tensor input name. shape tensor 输入名称。

Returns

TensorRtOptimizationProfileShapeValueRange

The configured shape-value range. 已配置的 shape-value 范围。

GetShapeValueRangeV2(string)

Gets the complete min/opt/max 64-bit value range for a TensorRT shape tensor input. 获取 TensorRT shape tensor 输入完整的 min/opt/max 64 位取值范围。

public TensorRtOptimizationProfileShapeValueRangeV2 GetShapeValueRangeV2(string inputName)

Parameters

inputName string

Shape tensor input name. Shape tensor 输入名称。

Returns

TensorRtOptimizationProfileShapeValueRangeV2

The configured 64-bit shape-value range. 已配置的 64 位 shape-value 范围。

GetShapeValues(string, TensorRtOptimizationProfileSelector)

Gets one min/opt/max value selector for a TensorRT shape tensor input. 获取 TensorRT shape tensor 输入在某一个 min/opt/max selector 下的取值。

public IReadOnlyList<int> GetShapeValues(string inputName, TensorRtOptimizationProfileSelector selector)

Parameters

inputName string

Shape tensor input name. shape tensor 输入名称。

selector TensorRtOptimizationProfileSelector

Profile selector to query. 要查询的 profile selector。

Returns

IReadOnlyList<int>

The configured shape values. 已配置的 shape 取值。

GetShapeValuesV2(string, TensorRtOptimizationProfileSelector)

Gets one min/opt/max 64-bit value selector for a TensorRT shape tensor input. 获取 TensorRT shape tensor 输入在某个 min/opt/max selector 下的 64 位取值。

public IReadOnlyList<long> GetShapeValuesV2(string inputName, TensorRtOptimizationProfileSelector selector)

Parameters

inputName string

Shape tensor input name. Shape tensor 输入名称。

selector TensorRtOptimizationProfileSelector

Profile selector to query. 要查询的 profile selector。

Returns

IReadOnlyList<long>

The configured 64-bit shape values. 已配置的 64 位 shape 值。

SetShape(string, TensorRtDims, TensorRtDims, TensorRtDims)

Sets the complete min/opt/max dimension range for a dynamic input tensor. 一次性设置动态输入张量完整的 min/opt/max 维度范围。

public void SetShape(string inputName, TensorRtDims min, TensorRtDims opt, TensorRtDims max)

Parameters

inputName string

Network input tensor name. 网络输入张量名称。

min TensorRtDims

Minimum supported shape. 最小支持形状。

opt TensorRtDims

Optimization target shape. 优化目标形状。

max TensorRtDims

Maximum supported shape. 最大支持形状。

SetShape(string, TensorRtOptimizationProfileSelector, TensorRtDims)

Sets one min/opt/max dimension selector for a dynamic input tensor. 设置动态输入张量在某一个 min/opt/max selector 下的维度。

public void SetShape(string inputName, TensorRtOptimizationProfileSelector selector, TensorRtDims dims)

Parameters

inputName string

Network input tensor name. 网络输入张量名称。

selector TensorRtOptimizationProfileSelector

Profile selector to set. 要设置的 profile selector。

dims TensorRtDims

Tensor dimensions for the selector. 该 selector 对应的张量维度。

SetShapeValues(string, TensorRtOptimizationProfileSelector, IReadOnlyList<int>)

Sets one min/opt/max value selector for a TensorRT shape tensor input. 设置 TensorRT shape tensor 输入在某一个 min/opt/max selector 下的取值。

public void SetShapeValues(string inputName, TensorRtOptimizationProfileSelector selector, IReadOnlyList<int> values)

Parameters

inputName string

Shape tensor input name. shape tensor 输入名称。

selector TensorRtOptimizationProfileSelector

Profile selector to set. 要设置的 profile selector。

values IReadOnlyList<int>

Integer shape values for the selector. 该 selector 对应的整数 shape 值。

SetShapeValues(string, TensorRtOptimizationProfileSelector, params int[])

Sets one min/opt/max value selector for a TensorRT shape tensor input. 设置 TensorRT shape tensor 输入在某一个 min/opt/max selector 下的取值。

public void SetShapeValues(string inputName, TensorRtOptimizationProfileSelector selector, params int[] values)

Parameters

inputName string

Shape tensor input name. shape tensor 输入名称。

selector TensorRtOptimizationProfileSelector

Profile selector to set. 要设置的 profile selector。

values int[]

Integer shape values for the selector. 该 selector 对应的整数 shape 值。

SetShapeValues(string, IReadOnlyList<int>, IReadOnlyList<int>, IReadOnlyList<int>)

Sets the complete min/opt/max value range for a TensorRT shape tensor input. 一次性设置 TensorRT shape tensor 输入完整的 min/opt/max 取值范围。

public void SetShapeValues(string inputName, IReadOnlyList<int> min, IReadOnlyList<int> opt, IReadOnlyList<int> max)

Parameters

inputName string

Shape tensor input name. shape tensor 输入名称。

min IReadOnlyList<int>

Minimum values. 最小取值。

opt IReadOnlyList<int>

Optimization target values. 优化目标取值。

max IReadOnlyList<int>

Maximum values. 最大取值。

SetShapeValuesV2(string, TensorRtOptimizationProfileSelector, IReadOnlyList<long>)

Sets one min/opt/max 64-bit value selector for a TensorRT shape tensor input. 为 TensorRT shape tensor 输入设置某个 min/opt/max selector 下的 64 位整数取值。

public bool SetShapeValuesV2(string inputName, TensorRtOptimizationProfileSelector selector, IReadOnlyList<long> values)

Parameters

inputName string

Shape tensor input name. Shape tensor 输入名称。

selector TensorRtOptimizationProfileSelector

Profile selector to set. 要设置的 profile selector。

values IReadOnlyList<long>

64-bit integer shape values for the selector. 该 selector 对应的 64 位整数 shape 值。

Returns

bool

true when TensorRT accepts the values. 当 TensorRT 接受该取值时返回 true

SetShapeValuesV2(string, TensorRtOptimizationProfileSelector, params long[])

Sets one min/opt/max 64-bit value selector for a TensorRT shape tensor input. 为 TensorRT shape tensor 输入设置某个 min/opt/max selector 下的 64 位整数取值。

public bool SetShapeValuesV2(string inputName, TensorRtOptimizationProfileSelector selector, params long[] values)

Parameters

inputName string

Shape tensor input name. Shape tensor 输入名称。

selector TensorRtOptimizationProfileSelector

Profile selector to set. 要设置的 profile selector。

values long[]

64-bit integer shape values for the selector. 该 selector 对应的 64 位整数 shape 值。

Returns

bool

true when TensorRT accepts the values. 当 TensorRT 接受该取值时返回 true

SetShapeValuesV2(string, IReadOnlyList<long>, IReadOnlyList<long>, IReadOnlyList<long>)

Sets the complete min/opt/max 64-bit value range for a TensorRT shape tensor input. 一次性设置 TensorRT shape tensor 输入完整的 min/opt/max 64 位取值范围。

public void SetShapeValuesV2(string inputName, IReadOnlyList<long> min, IReadOnlyList<long> opt, IReadOnlyList<long> max)

Parameters

inputName string

Shape tensor input name. Shape tensor 输入名称。

min IReadOnlyList<long>

Minimum values. 最小取值。

opt IReadOnlyList<long>

Optimization target values. 优化目标取值。

max IReadOnlyList<long>

Maximum values. 最大取值。