Table of Contents

Class TensorRtTensor

Namespace
JYPPX.TensorRtSharp
Assembly
JYPPX.TensorRtSharp.dll

Represents a TensorRT network tensor handle. 表示一个 TensorRT 网络张量句柄。

public sealed class TensorRtTensor : IDisposable
Inheritance
TensorRtTensor
Implements
Inherited Members

Properties

AllowedFormats

Gets or sets the allowed tensor memory formats bitmask. 获取或设置允许的张量内存格式位掩码。

public TensorRtTensorFormats AllowedFormats { get; set; }

Property Value

TensorRtTensorFormats

BroadcastAcrossBatch

Gets or sets TensorRT's legacy broadcast-across-batch flag for this tensor. 获取或设置 TensorRT 针对此张量的旧版 broadcast-across-batch 标志。

public bool BroadcastAcrossBatch { get; set; }

Property Value

bool

Remarks

This flag is deprecated in modern explicit-batch workflows, but it is still exposed for version coverage and model compatibility. 该标志在现代 explicit-batch 流程中已不推荐使用;这里保留它是为了版本覆盖和模型兼容。

DataType

Gets or sets the tensor element data type. 获取或设置张量元素数据类型。

public TensorRtDataType DataType { get; set; }

Property Value

TensorRtDataType

DynamicRangeMaximum

Gets the maximum dynamic range value currently reported by TensorRT. 获取 TensorRT 当前报告的 dynamic range 最大值。

public float DynamicRangeMaximum { get; }

Property Value

float

DynamicRangeMinimum

Gets the minimum dynamic range value currently reported by TensorRT. 获取 TensorRT 当前报告的 dynamic range 最小值。

public float DynamicRangeMinimum { get; }

Property Value

float

IsDynamicRangeSet

Gets whether an explicit dynamic range is set on this tensor. 获取此张量是否已经设置显式 dynamic range。

public bool IsDynamicRangeSet { get; }

Property Value

bool

Remarks

TensorRT 8 and 10 expose this query. TensorRT 11 removed the corresponding public query, so this property throws BridgeProbeException for TensorRT 11. TensorRT 8 和 10 提供该查询;TensorRT 11 已移除对应公开查询,因此该属性在 TensorRT 11 下会抛出 BridgeProbeException

IsExecutionTensor

Gets whether TensorRT reports this network tensor as an execution tensor. 获取 TensorRT 是否将当前网络张量识别为 execution tensor。

public bool IsExecutionTensor { get; }

Property Value

bool

Remarks

This query helps diagnose dynamic-shape graphs where a tensor may participate only in shape calculation. 该查询可用于诊断动态 shape 图中张量是否只参与 shape 计算。

IsNetworkInput

Gets whether TensorRT reports this tensor as a network input tensor. 获取 TensorRT 是否将当前张量报告为 network input tensor。

public bool IsNetworkInput { get; }

Property Value

bool

Remarks

This query is useful when validating direct network construction and layer wiring. 该查询适合验证直接构图和 layer 连接关系。

IsNetworkOutput

Gets whether TensorRT reports this tensor as a network output tensor. 获取 TensorRT 是否将当前张量报告为 network output tensor。

public bool IsNetworkOutput { get; }

Property Value

bool

Remarks

Marked network outputs should report true after the network output has been configured. 完成输出标记后,network output 通常应返回 true

IsShapeTensor

Gets whether TensorRT reports this network tensor as a shape tensor. 获取 TensorRT 是否将当前网络张量识别为 shape tensor。

public bool IsShapeTensor { get; }

Property Value

bool

Remarks

The result is most reliable after network construction is complete. 该结果在网络构建完成后最可靠。

Line

Gets the TensorRT adapter line that owns this tensor. 获取拥有此张量的 TensorRT 适配线。

public TensorRtApiLine Line { get; }

Property Value

TensorRtApiLine

Location

Gets or sets whether the tensor is expected in device or host memory. 获取或设置张量应位于设备内存还是主机内存。

public TensorRtTensorLocation Location { get; set; }

Property Value

TensorRtTensorLocation

Name

Gets or sets the tensor name. 获取或设置张量名称。

public string Name { get; set; }

Property Value

string

Shape

Gets or sets the tensor shape using TensorRT's classic 32-bit dimensions. 使用 TensorRT 经典 32 位维度获取或设置张量形状。

public TensorRtDims Shape { get; set; }

Property Value

TensorRtDims

Shape64

Gets the TensorRT 11 tensor shape with 64-bit dimension extents. 获取 TensorRT 11 张量形状,并保留 64 位维度 extent。

public TensorRtDims64 Shape64 { get; }

Property Value

TensorRtDims64

Remarks

This API is available only for the TensorRT 11 adapter line. It keeps unknown-rank shapes and large extents intact. 该 API 仅适用于 TensorRT 11 适配线;它会保留 unknown-rank shape 和大维度 extent。

Methods

ClearDimensionName(int)

Clears the symbolic name assigned to one tensor dimension. 清除指定张量维度的符号名称。

public void ClearDimensionName(int dimensionIndex)

Parameters

dimensionIndex int

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

Dispose()

Releases the managed wrapper for the TensorRT tensor handle. 释放 TensorRT 张量句柄的托管包装。

public void Dispose()

GetDimensionExtent64(int)

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

public long GetDimensionExtent64(int dimensionIndex)

Parameters

dimensionIndex int

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

Returns

long

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

GetDimensionName(int)

Gets the symbolic name assigned to one tensor dimension. 获取指定张量维度的符号名称。

public string GetDimensionName(int dimensionIndex)

Parameters

dimensionIndex int

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

Returns

string

The symbolic dimension name, or an empty string when no name is assigned. 返回维度符号名;未设置时返回空字符串。

ResetDynamicRange()

Clears the explicit dynamic range on the tensor. 清除张量上的显式 dynamic range。

public void ResetDynamicRange()

SetDimensionName(int, string)

Assigns a symbolic name to one tensor dimension. 为指定张量维度设置符号名称。

public void SetDimensionName(int dimensionIndex, string name)

Parameters

dimensionIndex int

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

name string

The symbolic dimension name. 维度符号名称。

Remarks

Dimension names can express runtime equality constraints and improve diagnostic readability in dynamic-shape networks. 维度名称可表达运行时维度相等约束,并提升动态 shape 网络的诊断可读性。

SetDynamicRange(float, float)

Sets an explicit dynamic range on the tensor. 为张量设置显式 dynamic range。

public void SetDynamicRange(float minimum, float maximum)

Parameters

minimum float

The lower bound. 下界。

maximum float

The upper bound. 上界。