Table of Contents

Class TensorRtProgressMonitor

Namespace
JYPPX.TensorRtSharp
Assembly
JYPPX.TensorRtSharp.dll

Managed owner for a TensorRT progress monitor callback object. TensorRT progress monitor 回调对象的托管 owner。

public sealed class TensorRtProgressMonitor : IDisposable
Inheritance
TensorRtProgressMonitor
Implements
Inherited Members

Constructors

TensorRtProgressMonitor(TensorRtApiLine, TensorRtProgressMonitorHandler)

Creates a progress monitor that forwards TensorRT build progress callbacks to managed code. 创建一个会把 TensorRT 构建进度回调转发给托管代码的 progress monitor。

public TensorRtProgressMonitor(TensorRtApiLine line, TensorRtProgressMonitorHandler handler)

Parameters

line TensorRtApiLine

The TensorRT API line. TensorRT API 版本线。

handler TensorRtProgressMonitorHandler

The managed progress handler. 托管 progress 处理器。

Remarks

TensorRT 10 and TensorRT 11 support progress monitors. TensorRT 8 does not expose this callback interface. Attach this monitor to a builder config with SetProgressMonitor(TensorRtProgressMonitor) and detach it before disposing the monitor. If Dispose() is called while a config still borrows the monitor, the native handle is released only after the config clears or disposes its attachment. Managed exceptions are swallowed by the trampoline, counted, and converted to a non-OK status; they never cross the native ABI boundary. TensorRT 10 和 TensorRT 11 支持 progress monitor;TensorRT 8 不暴露该回调接口。请用 SetProgressMonitor(TensorRtProgressMonitor) 绑定到 builder config,并在释放 monitor 前先解除绑定。 如果 config 仍在借用时调用 Dispose(),native 句柄会延迟到 config clear/dispose 后释放。托管异常会被 trampoline 吞吐、计数并转为非 OK 状态,不会跨 native ABI 边界抛出。

Properties

ApiLanguage

Gets copied TensorRT versioned-interface API language metadata for this progress monitor. 获取当前 progress monitor 的 TensorRT versioned-interface API language 元数据副本。

public TensorRtApiLanguage ApiLanguage { get; }

Property Value

TensorRtApiLanguage

Remarks

TensorRT 10 and TensorRT 11 expose progress monitors as versioned interfaces. The native bridge returns the scalar enum value and does not expose the monitor pointer. TensorRT 10 和 TensorRT 11 将 progress monitor 暴露为 versioned interface。native bridge 只返回标量 enum 值, 不暴露 monitor 指针。

CallbackFailureCount

Gets the number of managed callback exceptions swallowed at the ABI boundary. 获取在 ABI 边界被吞吐的托管回调异常次数。

public long CallbackFailureCount { get; }

Property Value

long

CallbackInvocationCount

Gets the number of managed callback invocations observed by this monitor. 获取当前 monitor 观察到的托管回调调用次数。

public long CallbackInvocationCount { get; }

Property Value

long

InterfaceInfo

Gets copied TensorRT versioned-interface metadata for this progress monitor. 获取当前 progress monitor 的 TensorRT versioned-interface 元数据副本。

public TensorRtInterfaceInfo InterfaceInfo { get; }

Property Value

TensorRtInterfaceInfo

Remarks

TensorRT 10 and TensorRT 11 expose progress monitors as versioned interfaces. TensorRT 10 和 TensorRT 11 将 progress monitor 暴露为 versioned interface。

IsAttached

Gets whether this monitor is currently borrowed by at least one TensorRT builder config wrapper. 获取当前 monitor 是否正被至少一个 TensorRT builder config 托管封装借用。

public bool IsAttached { get; }

Property Value

bool

LastCallbackException

Gets the last exception thrown by the managed callback, if any. 获取托管回调最近一次抛出的异常。

public Exception? LastCallbackException { get; }

Property Value

Exception

Line

Gets the TensorRT API line used by this monitor. 获取当前 monitor 使用的 TensorRT API line。

public TensorRtApiLine Line { get; }

Property Value

TensorRtApiLine

Methods

Dispose()

Releases this progress monitor after all builder config attachments have been cleared. 在所有 builder config 绑定解除后释放当前 progress monitor。

public void Dispose()

EmitDiagnostic(TensorRtProgressMonitorEventKind, string, string?, int, int)

Synchronously emits a diagnostic progress monitor event through the native monitor object. 通过 native monitor 对象同步发送一条诊断 progress 事件。

public TensorRtProgressMonitorDiagnosticResult EmitDiagnostic(TensorRtProgressMonitorEventKind kind, string phaseName, string? parentPhase = null, int step = -1, int stepCount = 0)

Parameters

kind TensorRtProgressMonitorEventKind

The event kind to emit. 要触发的事件类型。

phaseName string

The phase name copied to native UTF-8 memory. 复制到 native UTF-8 内存的阶段名称。

parentPhase string

The optional parent phase. 可选父阶段。

step int

The completed step index for step-complete events. step-complete 事件的完成步骤索引。

stepCount int

The phase step count for phase-start events. phase-start 事件的总步骤数。

Returns

TensorRtProgressMonitorDiagnosticResult

The diagnostic result reported by the native bridge. native bridge 返回的诊断结果。

Remarks

This method is intended for diagnostics and smoke tests. It does not expose the native monitor pointer and does not attach the monitor to a builder config. 该方法用于诊断和 smoke 测试;它不会暴露 native monitor 指针,也不会把 monitor 绑定到 builder config。

~TensorRtProgressMonitor()

Releases progress monitor callback resources if Dispose() was not called. 如果调用方未调用 Dispose(),则释放 progress monitor callback 资源。

protected ~TensorRtProgressMonitor()

TryGetApiLanguage(out TensorRtApiLanguage)

Tries to get copied TensorRT API language metadata for this progress monitor without exposing the native pointer. 尝试获取当前 progress monitor 的 TensorRT API language 元数据副本;不会暴露 native 指针。

public bool TryGetApiLanguage(out TensorRtApiLanguage apiLanguage)

Parameters

apiLanguage TensorRtApiLanguage

The copied API language when the query succeeds. 查询成功时复制出的 API language。

Returns

bool

true when API language metadata is available for this TensorRT line. 当前 TensorRT 版本线支持该元数据时返回 true。

TryGetApiLanguage(out TensorRtApiLanguage, out string)

Tries to get copied TensorRT API language metadata for this progress monitor without exposing the native pointer. 尝试获取当前 progress monitor 的 TensorRT API language 元数据副本;不会暴露 native 指针。

public bool TryGetApiLanguage(out TensorRtApiLanguage apiLanguage, out string diagnostic)

Parameters

apiLanguage TensorRtApiLanguage

The copied API language when the query succeeds. 查询成功时复制出的 API language。

diagnostic string

A short diagnostic string describing success or the reason for failure. 描述成功或失败原因的简短诊断。

Returns

bool

true when API language metadata is available for this TensorRT line. 当前 TensorRT 版本线支持该元数据时返回 true。

TryGetInterfaceInfo(out TensorRtInterfaceInfo)

Tries to get copied TensorRT versioned-interface metadata for this progress monitor without exposing the native pointer. 尝试获取当前 progress monitor 的 TensorRT versioned-interface 元数据副本;不会暴露 native 指针。

public bool TryGetInterfaceInfo(out TensorRtInterfaceInfo interfaceInfo)

Parameters

interfaceInfo TensorRtInterfaceInfo

The copied interface metadata when the query succeeds. 查询成功时复制出的 interface 元数据。

Returns

bool

true when interface metadata is available for this TensorRT line. 当前 TensorRT 版本线支持该元数据时返回 true。

TryGetInterfaceInfo(out TensorRtInterfaceInfo, out string)

Tries to get copied TensorRT versioned-interface metadata for this progress monitor without exposing the native pointer. 尝试获取当前 progress monitor 的 TensorRT versioned-interface 元数据副本;不会暴露 native 指针。

public bool TryGetInterfaceInfo(out TensorRtInterfaceInfo interfaceInfo, out string diagnostic)

Parameters

interfaceInfo TensorRtInterfaceInfo

The copied interface metadata when the query succeeds. 查询成功时复制出的 interface 元数据。

diagnostic string

A short diagnostic string describing success or the reason for failure. 描述成功或失败原因的简短诊断。

Returns

bool

true when interface metadata is available for this TensorRT line. 当前 TensorRT 版本线支持该元数据时返回 true。

Remarks

TensorRT 10 and TensorRT 11 expose progress monitors as versioned interfaces. Unsupported or unavailable adapters return false with a diagnostic. TensorRT 10 和 TensorRT 11 将 progress monitor 暴露为 versioned interface;不支持或不可用的 adapter 会返回 false 并给出诊断。