Class TensorRtAllocatorCallbackOwner
- Namespace
- JYPPX.TensorRtSharp
- Assembly
- JYPPX.TensorRtSharp.dll
Managed skeleton and native dry-run diagnostic surface for a future TensorRT allocator callback owner. 未来 TensorRT allocator callback owner 的托管骨架与 native dry-run 诊断表面。
public sealed class TensorRtAllocatorCallbackOwner : IDisposable
- Inheritance
-
TensorRtAllocatorCallbackOwner
- Implements
- Inherited Members
Remarks
This owner is currently dry-run only. It keeps managed callback state alive, records invocation/failure diagnostics, and swallows handler exceptions into LastCallbackException and a failed TensorRtAllocatorDryRunResult. It can create a short-lived native diagnostic owner through RunNativeDryRunDiagnostic(TensorRtApiLine, TensorRtAllocatorDryRunRequest), but it is not attached to TensorRT, does not call allocator callbacks, and does not return or own device pointers. 当前 owner 仅用于 dry-run。它会保持托管回调状态存活、记录调用/失败诊断,并把 handler 异常吞吐到 LastCallbackException 与失败的 TensorRtAllocatorDryRunResult 中。它可以通过 RunNativeDryRunDiagnostic(TensorRtApiLine, TensorRtAllocatorDryRunRequest) 创建短生命周期 native 诊断 owner,但不会绑定到 TensorRT,不会调用 allocator callback,也不会返回或拥有 device pointer。
Constructors
TensorRtAllocatorCallbackOwner(TensorRtAllocatorDryRunHandler)
Creates a dry-run allocator callback owner. 创建 dry-run allocator callback owner。
public TensorRtAllocatorCallbackOwner(TensorRtAllocatorDryRunHandler handler)
Parameters
handlerTensorRtAllocatorDryRunHandlerThe managed dry-run handler. 托管 dry-run 处理器。
Remarks
The handler is kept alive by this owner until Dispose(). No TensorRT object borrows this owner in the current stage, so IsAttached always remains false. handler 会由当前 owner 保持存活直到 Dispose()。当前阶段没有 TensorRT 对象借用该 owner, 因此 IsAttached 始终为 false。
Properties
CallbackFailureCount
Gets the number of managed handler exceptions swallowed by this owner. 获取当前 owner 吞吐的托管 handler 异常次数。
public long CallbackFailureCount { get; }
Property Value
CallbackInvocationCount
Gets the number of dry-run callback invocations observed by this owner. 获取当前 owner 观察到的 dry-run 回调调用次数。
public long CallbackInvocationCount { get; }
Property Value
IsAttached
Gets whether this owner is currently attached to a TensorRT object. 获取当前 owner 是否正绑定到 TensorRT 对象。
public bool IsAttached { get; }
Property Value
Remarks
The dry-run skeleton never attaches to TensorRT. This property is present so later native owner work can keep the same diagnostics shape without exposing borrowed pointers. dry-run 骨架不会绑定到 TensorRT。保留该属性是为了后续 native owner 工作延续同一诊断形状,同时不暴露 borrowed pointer。
IsDisposed
Gets whether this owner has been disposed. 获取当前 owner 是否已释放。
public bool IsDisposed { get; }
Property Value
LastCallbackException
Gets the last exception thrown by the dry-run handler, if any. 获取 dry-run handler 最近一次抛出的异常。
public Exception? LastCallbackException { get; }
Property Value
LastDiagnostic
Gets the last diagnostic message observed by this owner. 获取当前 owner 最近一次观察到的诊断消息。
public string LastDiagnostic { get; }
Property Value
Methods
Dispose()
Releases the managed callback state keep-alive handle. 释放托管回调状态的 keep-alive 句柄。
public void Dispose()
~TensorRtAllocatorCallbackOwner()
Releases callback owner resources if Dispose() was not called. 如果调用方未调用 Dispose(),则释放 callback owner 资源。
protected ~TensorRtAllocatorCallbackOwner()
GetSnapshot(string)
Gets a copied lifecycle snapshot of the current allocator callback owner state. 获取当前 allocator callback owner 状态的复制生命周期快照。
public TensorRtAllocatorCallbackOwnerSnapshot GetSnapshot(string operation = "snapshot")
Parameters
operationstringA copied operation label. 复制出的操作标签。
Returns
- TensorRtAllocatorCallbackOwnerSnapshot
A copied lifecycle snapshot with no native handle or device pointer. 不包含 native handle 或 device pointer 的生命周期快照。
Remarks
This method can be called after Dispose() to verify release-hook and keep-alive cleanup diagnostics. It is still not proof that TensorRT invoked an allocator callback. 该方法可在 Dispose() 后调用,用于验证 release hook 与 keep-alive 清理诊断;它仍然不证明 TensorRT 已调用 allocator callback。
RunDryRunDiagnostic(TensorRtAllocatorDryRunRequest)
Runs the managed allocator dry-run diagnostic. 执行托管 allocator dry-run 诊断。
public TensorRtAllocatorDryRunResult RunDryRunDiagnostic(TensorRtAllocatorDryRunRequest request)
Parameters
requestTensorRtAllocatorDryRunRequestThe dry-run request. dry-run 请求。
Returns
- TensorRtAllocatorDryRunResult
A copied diagnostic result that never contains a device pointer. 不包含 device pointer 的诊断结果副本。
Remarks
This method does not call TensorRT, CUDA, or a native allocator trampoline. It is intended to validate managed callback lifetime, exception capture, and package-consumer surface before real allocator callbacks are unlocked. 该方法不会调用 TensorRT、CUDA 或 native allocator trampoline。它用于在解锁真实 allocator callback 前验证托管 回调生命周期、异常捕获与 package-consumer API 表面。
RunLifecycleDiagnostic(TensorRtAllocatorDryRunRequest)
Runs a pointer-free lifecycle diagnostic through the managed allocator callback owner prototype. 通过托管 allocator callback owner prototype 执行无 pointer 的生命周期诊断。
public TensorRtAllocatorCallbackOwnerSnapshot RunLifecycleDiagnostic(TensorRtAllocatorDryRunRequest request)
Parameters
requestTensorRtAllocatorDryRunRequestThe copied dry-run request. 复制出的 dry-run 请求。
Returns
- TensorRtAllocatorCallbackOwnerSnapshot
A copied lifecycle snapshot with no native handle or device pointer. 不包含 native handle 或 device pointer 的生命周期快照。
Remarks
This method exercises the managed keep-alive and exception-to-status path used by the allocator owner prototype.
It does not register the owner with TensorRT, does not call setGpuAllocator, and does not implement
IGpuAllocator::allocate/free/deallocate/reallocate.
该方法会触发 allocator owner prototype 使用的托管 keep-alive 与 exception-to-status 路径。它不会把 owner 注册到
TensorRT,不会调用 setGpuAllocator,也不会实现 IGpuAllocator::allocate/free/deallocate/reallocate。
RunNativeDryRunDiagnostic(TensorRtApiLine, TensorRtAllocatorDryRunRequest)
Runs the native allocator owner dry-run C ABI diagnostic. 执行 native allocator owner dry-run C ABI 诊断。
public TensorRtAllocatorNativeDryRunResult RunNativeDryRunDiagnostic(TensorRtApiLine line, TensorRtAllocatorDryRunRequest request)
Parameters
lineTensorRtApiLineThe TensorRT API line to probe. 要探测的 TensorRT API line。
requestTensorRtAllocatorDryRunRequestThe dry-run request. dry-run 请求。
Returns
- TensorRtAllocatorNativeDryRunResult
Copied native dry-run diagnostics without any native handle or device pointer. 不包含 native handle 或 device pointer 的诊断副本。
Remarks
This method creates a short-lived native diagnostic owner, emits one dry-run diagnostic, copies counters/status
back to managed memory, and immediately releases the native handle. It does not attach to TensorRT, does not call
setGpuAllocator, and does not implement IGpuAllocator::allocate/free/deallocate/reallocate.
该方法会创建一个短生命周期 native 诊断 owner,发出一次 dry-run 诊断,将计数与状态复制回托管内存,然后立即释放
native 句柄。它不会绑定 TensorRT,不会调用 setGpuAllocator,也不会实现
IGpuAllocator::allocate/free/deallocate/reallocate。
RunNativeStateLedgerDryRunDiagnostic(TensorRtApiLine, TensorRtAllocatorDryRunRequest, string, ulong)
Runs the synthetic native owner state ledger dry-run sequence. 执行 synthetic native owner 状态 ledger dry-run 序列。
public TensorRtAllocatorOwnerStateDryRunResult RunNativeStateLedgerDryRunDiagnostic(TensorRtApiLine line, TensorRtAllocatorDryRunRequest request, string targetKind = "IGpuAllocator", ulong streamValue = 0)
Parameters
lineTensorRtApiLineThe TensorRT API line to probe. 要探测的 TensorRT API line。
requestTensorRtAllocatorDryRunRequestThe dry-run request. dry-run 请求。
targetKindstringThe copied target kind label. 复制的目标类型标签。
streamValueulongThe synthetic stream value copied into the ledger. 复制到 ledger 的合成 stream value。
Returns
- TensorRtAllocatorOwnerStateDryRunResult
A copied native owner state snapshot with no handle or device pointer. 不包含 handle 或 device pointer 的 native owner 状态副本。
Remarks
This method creates a short-lived native diagnostic owner, records synthetic attach/allocation/release/detach
intents, copies the final state snapshot, and immediately releases the native handle. It does not attach to
TensorRT, does not call setGpuAllocator, and does not implement any allocator callback trampoline.
该方法会创建短生命周期 native 诊断 owner,记录合成的 attach/allocation/release/detach intent,复制最终状态快照,
然后立即释放 native 句柄。它不会绑定 TensorRT,不会调用 setGpuAllocator,也不会实现任何 allocator callback trampoline。