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
lineTensorRtApiLineThe TensorRT API line. TensorRT API 版本线。
handlerTensorRtProgressMonitorHandlerThe 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
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
CallbackInvocationCount
Gets the number of managed callback invocations observed by this monitor. 获取当前 monitor 观察到的托管回调调用次数。
public long CallbackInvocationCount { get; }
Property Value
InterfaceInfo
Gets copied TensorRT versioned-interface metadata for this progress monitor. 获取当前 progress monitor 的 TensorRT versioned-interface 元数据副本。
public TensorRtInterfaceInfo InterfaceInfo { get; }
Property Value
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
LastCallbackException
Gets the last exception thrown by the managed callback, if any. 获取托管回调最近一次抛出的异常。
public Exception? LastCallbackException { get; }
Property Value
Line
Gets the TensorRT API line used by this monitor. 获取当前 monitor 使用的 TensorRT API line。
public TensorRtApiLine Line { get; }
Property Value
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
kindTensorRtProgressMonitorEventKindThe event kind to emit. 要触发的事件类型。
phaseNamestringThe phase name copied to native UTF-8 memory. 复制到 native UTF-8 内存的阶段名称。
parentPhasestringThe optional parent phase. 可选父阶段。
stepintThe completed step index for step-complete events. step-complete 事件的完成步骤索引。
stepCountintThe 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
apiLanguageTensorRtApiLanguageThe 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
apiLanguageTensorRtApiLanguageThe copied API language when the query succeeds. 查询成功时复制出的 API language。
diagnosticstringA 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
interfaceInfoTensorRtInterfaceInfoThe 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
interfaceInfoTensorRtInterfaceInfoThe copied interface metadata when the query succeeds. 查询成功时复制出的 interface 元数据。
diagnosticstringA short diagnostic string describing success or the reason for failure. 描述成功或失败原因的简短诊断。
Returns
- bool
true when interface metadata is available for this TensorRT line. 当前 TensorRT 版本线支持该元数据时返回 true。