Class TensorRtProfiler
- Namespace
- JYPPX.TensorRtSharp
- Assembly
- JYPPX.TensorRtSharp.dll
Managed owner for a TensorRT profiler callback object. TensorRT profiler 回调对象的托管 owner。
public sealed class TensorRtProfiler : IDisposable
- Inheritance
-
TensorRtProfiler
- Implements
- Inherited Members
Constructors
TensorRtProfiler(TensorRtApiLine, TensorRtProfilerHandler)
Creates a profiler that forwards TensorRT layer timing callbacks to managed code. 创建一个会把 TensorRT layer timing 回调转发给托管代码的 profiler。
public TensorRtProfiler(TensorRtApiLine line, TensorRtProfilerHandler handler)
Parameters
lineTensorRtApiLineThe TensorRT API line. TensorRT API 版本线。
handlerTensorRtProfilerHandlerThe managed profiling handler. 托管 profiling 处理器。
Remarks
TensorRT borrows the native profiler pointer when it is attached to an execution context. Keep the profiler alive until ClearProfiler() or context disposal detaches it. Managed exceptions are swallowed by the trampoline, counted, and converted to a non-OK status; they never cross the native ABI boundary. 当 profiler 绑定到 execution context 时,TensorRT 只借用 native profiler 指针。请让 profiler 至少存活到 ClearProfiler() 或 context dispose 解除绑定之后。托管异常会被 trampoline 吞吐、计数并转为非 OK 状态,不会跨 native ABI 边界抛出。
Properties
ApiLanguage
Gets copied TensorRT versioned-interface API language metadata for this profiler on TensorRT 11. 获取 TensorRT 11 profiler 的 versioned-interface API language 元数据副本。
public TensorRtApiLanguage ApiLanguage { get; }
Property Value
Remarks
The native bridge returns the scalar enum value and does not expose the profiler pointer. TensorRT 8 and TensorRT 10 profilers are not versioned interfaces in the NVIDIA headers used by this bridge. native bridge 只返回标量 enum 值,不暴露 profiler 指针。TensorRT 8 和 TensorRT 10 的 profiler 在当前 bridge 使用的 NVIDIA 头文件中不是 versioned interface。
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 profiler. 获取当前 profiler 观察到的托管回调调用次数。
public long CallbackInvocationCount { get; }
Property Value
InterfaceInfo
Gets copied TensorRT versioned-interface metadata for this profiler on TensorRT 11. 获取 TensorRT 11 profiler 的 versioned-interface 元数据副本。
public TensorRtInterfaceInfo InterfaceInfo { get; }
Property Value
Remarks
TensorRT 8 and TensorRT 10 profilers are not versioned interfaces in the NVIDIA headers used by this bridge. TensorRT 8 和 TensorRT 10 的 profiler 在当前 bridge 使用的 NVIDIA 头文件中不是 versioned interface。
IsAttached
Gets whether this profiler is currently borrowed by at least one execution context wrapper. 获取当前 profiler 是否正被至少一个 execution context 托管封装借用。
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 profiler. 获取当前 profiler 使用的 TensorRT API line。
public TensorRtApiLine Line { get; }
Property Value
Methods
Dispose()
Releases this profiler after all execution context attachments have been cleared. 在所有 execution context 绑定解除后释放当前 profiler。
public void Dispose()
EmitDiagnostic(string, float)
Synchronously emits a diagnostic profiler record through the native profiler object. 通过 native profiler 对象同步发送一条诊断 profiler 记录。
public bool EmitDiagnostic(string layerName, float milliseconds)
Parameters
layerNamestringThe layer name copied to native UTF-8 memory. 复制到 native UTF-8 内存的 layer 名称。
millisecondsfloatThe diagnostic elapsed time in milliseconds. 诊断耗时,单位毫秒。
Returns
- bool
true when the callback completed without a managed exception or non-OK status. 回调未发生托管异常或非 OK 状态时返回 true。
Remarks
This method is intended for diagnostics and smoke tests. It does not expose the native profiler pointer and does not attach the profiler to an execution context. 该方法用于诊断和 smoke 测试;它不会暴露 native profiler 指针,也不会把 profiler 绑定到 execution context。
~TensorRtProfiler()
Releases profiler callback resources if Dispose() was not called. 如果调用方未调用 Dispose(),则释放 profiler callback 资源。
protected ~TensorRtProfiler()
GetInterfaceMetadataSnapshot()
Gets a pointer-free aggregate of the profiler interface metadata probes. 获取 profiler interface metadata 查询的无指针聚合副本。
public TensorRtProfilerInterfaceMetadataSnapshot GetInterfaceMetadataSnapshot()
Returns
Remarks
TensorRT 11 performs the native copied-state queries. TensorRT 8 and TensorRT 10 retain controlled unsupported diagnostics because their profiler interfaces are not versioned interfaces in this bridge. 该快照只聚合 copied state;不代表 real-model-runtime、package-consumer-runtime 或 release proof。
TryGetApiLanguage(out TensorRtApiLanguage)
Tries to get copied TensorRT API language metadata for this profiler without exposing the native pointer. 尝试获取当前 profiler 的 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 profiler without exposing the native pointer. 尝试获取当前 profiler 的 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 profiler without exposing the native pointer. 尝试获取当前 profiler 的 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 profiler without exposing the native pointer. 尝试获取当前 profiler 的 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。