Class TensorRtHostMemory
- Namespace
- JYPPX.TensorRtSharp
- Assembly
- JYPPX.TensorRtSharp.dll
Managed wrapper around TensorRT host memory. TensorRT host memory 的托管封装。
public sealed class TensorRtHostMemory : IDisposable
- Inheritance
-
TensorRtHostMemory
- Implements
- Inherited Members
Properties
DataType
Gets the TensorRT data type reported for this host-memory block. 获取该 host-memory 内存块由 TensorRT 报告的数据类型。
public TensorRtDataType DataType { get; }
Property Value
Remarks
This metadata endpoint is available for TensorRT 8, TensorRT 10, and TensorRT 11 adapters. 当前该属性通过 TensorRT 8、TensorRT 10 和 TensorRT 11 适配线接入,只复制标量数据类型,不暴露 host-memory 指针。
Line
Gets the TensorRT API line that produced this host memory. 获取生成当前 host memory 的 TensorRT API line。
public TensorRtApiLine Line { get; }
Property Value
SizeInBytes
Gets the serialized payload size in bytes. 获取序列化负载大小,单位为字节。
public ulong SizeInBytes { get; }
Property Value
Methods
CopyTo(Stream)
Copies the TensorRT host-memory payload into a managed stream. 将 TensorRT host memory 负载复制到托管 stream。
public void CopyTo(Stream destination)
Parameters
destinationStreamThe writable destination stream. 可写目标 stream。
Remarks
The payload is first copied into a managed byte array, so no borrowed TensorRT pointer escapes this wrapper. 负载会先复制到托管字节数组,因此不会从当前封装泄露 borrowed TensorRT 指针。
Dispose()
Releases the TensorRT host-memory handle. 释放 TensorRT host memory 句柄。
public void Dispose()
OpenRead()
Opens a read-only managed stream over a copied TensorRT host-memory payload. 基于 TensorRT host memory 负载副本打开只读托管 stream。
public MemoryStream OpenRead()
Returns
- MemoryStream
A read-only managed memory stream containing a copied payload. 包含负载副本的只读托管内存流。
Remarks
The returned stream owns an independent managed copy and remains valid after this host-memory object is disposed. 返回的 stream 持有独立托管副本,因此当前 host memory 对象释放后仍然有效。
SaveToFile(string)
Saves the TensorRT host-memory payload to a file. 将 TensorRT host memory 负载保存到文件。
public void SaveToFile(string filePath)
Parameters
filePathstringThe destination file path. 目标文件路径。
ToArray()
Copies the TensorRT host-memory payload into a managed byte array. 将 TensorRT host memory 负载复制到托管字节数组中。
public byte[] ToArray()
Returns
- byte[]
A managed byte-array copy of the payload. 负载的托管字节数组副本。