Table of Contents

Class TensorRtOnnxParser

Namespace
JYPPX.TensorRtSharp
Assembly
JYPPX.TensorRtSharp.dll

Parses ONNX models into a TensorRT network definition. 将 ONNX 模型解析到 TensorRT network definition。

public sealed class TensorRtOnnxParser : IDisposable
Inheritance
TensorRtOnnxParser
Implements
Inherited Members

Constructors

TensorRtOnnxParser(TensorRtLogger, TensorRtNetworkDefinition)

Creates an ONNX parser for the specified TensorRT logger and network. 使用指定的 TensorRT logger 和 network 创建 ONNX parser。

public TensorRtOnnxParser(TensorRtLogger logger, TensorRtNetworkDefinition network)

Parameters

logger TensorRtLogger

The TensorRT logger used by the parser. Parser 使用的 TensorRT logger。

network TensorRtNetworkDefinition

The target TensorRT network definition. 目标 TensorRT network definition。

Remarks

TensorRT borrows the logger pointer. This parser keeps the managed logger attached until the parser is disposed. TensorRT 只借用 logger 指针;当前 parser 会保持托管 logger 借用关系直到 parser 释放。

Properties

ErrorCount

Gets the number of parser errors currently reported by TensorRT. 获取 TensorRT 当前报告的 parser 错误数量。

public int ErrorCount { get; }

Property Value

int

Flags

Gets or sets the ONNX parser flag bitmask. 获取或设置 ONNX parser 标志位掩码。

public TensorRtOnnxParserFlags Flags { get; set; }

Property Value

TensorRtOnnxParserFlags

HasBuilderConfigAttached

Gets whether this parser currently retains a successful TensorRT 11 builder-config attachment. 获取当前 parser 是否保留了成功建立的 TensorRT 11 builder-config 关联。

public bool HasBuilderConfigAttached { get; }

Property Value

bool

Line

Gets the TensorRT API line used by this parser. 获取当前 parser 使用的 TensorRT API 版本线。

public TensorRtApiLine Line { get; }

Property Value

TensorRtApiLine

Methods

CheckModelSupport(ArraySegment<byte>, string?)

Checks whether TensorRT reports support for the serialized ONNX model in a managed byte-array segment. 检查 TensorRT 是否报告支持托管字节数组片段中的已序列化 ONNX 模型。

public TensorRtOnnxModelSupportReport CheckModelSupport(ArraySegment<byte> modelData, string? modelPath = null)

Parameters

modelData ArraySegment<byte>

Serialized ONNX model byte segment. 已序列化 ONNX 模型字节片段。

modelPath string

Optional model path used by TensorRT diagnostics. TensorRT 诊断信息使用的可选模型路径。

Returns

TensorRtOnnxModelSupportReport

A support report containing the full-model result and parser subgraphs. 包含完整模型结果和 parser 子图的支持性报告。

Remarks

The segment is copied into an exact managed byte array before native interop. 调用 native interop 前会将片段复制为精确长度的托管字节数组。

CheckModelSupport(byte[], string?)

Checks whether TensorRT reports support for the serialized ONNX model. 检查 TensorRT 是否报告支持指定的已序列化 ONNX 模型。

public TensorRtOnnxModelSupportReport CheckModelSupport(byte[] modelData, string? modelPath = null)

Parameters

modelData byte[]

Serialized ONNX model bytes. 已序列化的 ONNX 模型字节。

modelPath string

Optional model path used by TensorRT diagnostics. TensorRT 诊断信息使用的可选模型路径。

Returns

TensorRtOnnxModelSupportReport

A support report containing the full-model result and parser subgraphs. 包含完整模型结果和 parser 子图的支持性报告。

CheckModelSupport(Stream, string?)

Checks whether TensorRT reports support for the serialized ONNX model in a managed stream. 检查 TensorRT 是否报告支持托管 stream 中的已序列化 ONNX 模型。

public TensorRtOnnxModelSupportReport CheckModelSupport(Stream modelStream, string? modelPath = null)

Parameters

modelStream Stream

The readable stream containing serialized ONNX model bytes. 包含已序列化 ONNX 模型字节的可读 stream。

modelPath string

Optional model path used by TensorRT diagnostics. TensorRT 诊断信息使用的可选模型路径。

Returns

TensorRtOnnxModelSupportReport

A support report containing the full-model result and parser subgraphs. 包含完整模型结果和 parser 子图的支持性报告。

Remarks

The stream is copied into managed memory before native interop; this does not use TensorRT model-proto ownership APIs. 调用 native interop 前会将 stream 内容复制到托管内存;该入口不使用 TensorRT model proto ownership API。

CheckModelSupport(ReadOnlySpan<byte>, string?)

Checks whether TensorRT reports support for the serialized ONNX model in a managed read-only span. 检查 TensorRT 是否报告支持托管只读 span 中的已序列化 ONNX 模型。

public TensorRtOnnxModelSupportReport CheckModelSupport(ReadOnlySpan<byte> modelData, string? modelPath = null)

Parameters

modelData ReadOnlySpan<byte>

Serialized ONNX model bytes. 已序列化 ONNX 模型字节。

modelPath string

Optional model path used by TensorRT diagnostics. TensorRT 诊断信息使用的可选模型路径。

Returns

TensorRtOnnxModelSupportReport

A support report containing the full-model result and parser subgraphs. 包含完整模型结果和 parser 子图的支持性报告。

Remarks

The span is copied into a managed byte array before native interop, and TensorRT does not retain caller-owned memory. 调用 native interop 前会将 span 复制到托管字节数组,TensorRT 不会保留调用方拥有的内存。

ClearErrors()

Clears parser errors stored by TensorRT. 清理 TensorRT 保存的 parser 错误。

public void ClearErrors()

ClearFlag(TensorRtOnnxParserFlag)

Clears a single ONNX parser flag. 清除单个 ONNX parser 标志。

public void ClearFlag(TensorRtOnnxParserFlag flag)

Parameters

flag TensorRtOnnxParserFlag

The parser flag to clear. 要清除的 parser 标志。

Dispose()

Releases the native ONNX parser handle. 释放原生 ONNX parser 句柄。

public void Dispose()

GetDiagnostic(int)

Gets one detailed parser diagnostic by index. 按索引获取一条详细解析器诊断信息。

public TensorRtOnnxParserDiagnostic GetDiagnostic(int index)

Parameters

index int

Zero-based parser error index. 从零开始的解析器错误索引。

Returns

TensorRtOnnxParserDiagnostic

The detailed parser diagnostic. 详细解析器诊断信息。

Remarks

This path reads variable-length strings from the native bridge and avoids truncating long parser messages. 该路径从原生桥接读取可变长度字符串,可避免长解析错误消息被固定结构体截断。

GetDiagnosticSnapshot()

Captures copied ONNX parser diagnostics and plugin-library inventory without exposing native parser-owned pointers. 捕获已复制的 ONNX parser 诊断和 plugin-library inventory,不暴露原生 parser 拥有的指针。

public TensorRtOnnxParserDiagnosticSnapshot GetDiagnosticSnapshot()

Returns

TensorRtOnnxParserDiagnosticSnapshot

A pointer-free parser diagnostic snapshot. 无指针逃逸的 parser 诊断快照。

GetDiagnosticSummary()

Builds a readable parser diagnostic summary for logs and deployment troubleshooting. 为日志和部署排障生成可读的解析器诊断摘要。

public string GetDiagnosticSummary()

Returns

string

A parser diagnostic summary string. 解析器诊断摘要字符串。

GetDiagnostics()

Gets all detailed parser diagnostics currently reported by TensorRT. 获取 TensorRT 当前报告的全部详细解析器诊断信息。

public IReadOnlyList<TensorRtOnnxParserDiagnostic> GetDiagnostics()

Returns

IReadOnlyList<TensorRtOnnxParserDiagnostic>

The detailed parser diagnostics. 详细解析器诊断信息列表。

GetError(int)

Gets one parser error by index. 按索引获取一个 parser 错误。

public TensorRtParserErrorInfo GetError(int index)

Parameters

index int

Zero-based parser error index. 从零开始的 parser 错误索引。

Returns

TensorRtParserErrorInfo

The parser error information. Parser 错误信息。

GetErrorSummary()

Builds a readable parser error summary for logs and diagnostics. 为日志和诊断生成可读的 parser 错误摘要。

public string GetErrorSummary()

Returns

string

A parser error summary string. Parser 错误摘要字符串。

GetErrors()

Gets all parser errors currently reported by TensorRT. 获取 TensorRT 当前报告的全部 parser 错误。

public IReadOnlyList<TensorRtParserErrorInfo> GetErrors()

Returns

IReadOnlyList<TensorRtParserErrorInfo>

The parser error list. Parser 错误列表。

GetFlag(TensorRtOnnxParserFlag)

Gets a single ONNX parser flag. 获取单个 ONNX parser 标志。

public bool GetFlag(TensorRtOnnxParserFlag flag)

Parameters

flag TensorRtOnnxParserFlag

The parser flag to query. 要查询的 parser 标志。

Returns

bool

true when the flag is enabled. 标志启用时返回 true。

GetLayerOutputTensorMetadata(string, long)

Gets copied metadata for one ONNX layer output tensor without exposing the parser-owned tensor pointer. 获取一个 ONNX layer 输出 tensor 的复制元数据,不暴露 parser 拥有的 tensor 指针。

public TensorRtOnnxLayerOutputTensorMetadata GetLayerOutputTensorMetadata(string layerName, long outputIndex = 0)

Parameters

layerName string

The ONNX layer name. ONNX layer 名称。

outputIndex long

The zero-based output index. 从零开始的输出索引。

Returns

TensorRtOnnxLayerOutputTensorMetadata

Pointer-free copied tensor metadata. 无指针逃逸的 tensor 复制元数据。

Exceptions

KeyNotFoundException

The layer or output index was not found. 找不到 layer 或输出索引。

GetUsedVCPluginLibraries()

Gets VC plugin libraries used by the most recent ONNX parser operation. 获取最近一次 ONNX parser 操作使用的 VC plugin library 列表。

public IReadOnlyList<string> GetUsedVCPluginLibraries()

Returns

IReadOnlyList<string>

Parser-owned library paths copied into managed strings. 已复制到托管字符串中的 parser library 路径。

IsSubgraphSupported(long)

Returns whether TensorRT reports the ONNX subgraph at the specified index as supported. 返回 TensorRT 是否报告指定索引处的 ONNX subgraph 受支持。

public bool IsSubgraphSupported(long index)

Parameters

index long

Zero-based subgraph index. 从零开始的 subgraph 索引。

Returns

bool

true when TensorRT reports the subgraph as supported. TensorRT 报告该 subgraph 受支持时返回 true。

Remarks

This is a copied scalar query over the native parser state. The native bridge keeps TensorRT version guards in place and does not expose a borrowed parser pointer. 这是对 native parser 状态的标量只读查询;native bridge 保留 TensorRT 版本保护,不暴露 borrowed parser 指针。

LayerOutputTensorExists(string, long)

Returns whether a parsed ONNX layer output tensor exists without exposing the native tensor pointer. 判断已解析 ONNX layer 的输出 tensor 是否存在,同时不暴露原生 tensor 指针。

public bool LayerOutputTensorExists(string layerName, long outputIndex = 0)

Parameters

layerName string

The ONNX layer name to query. 要查询的 ONNX layer 名称。

outputIndex long

Zero-based output index. 从零开始的输出索引。

Returns

bool

true when TensorRT returns a non-null tensor pointer. TensorRT 返回非空 tensor 指针时为 true。

LoadInitializer(string, ArraySegment<byte>)

Loads an external ONNX initializer from a byte-array segment into the TensorRT 11 parser. 从托管字节数组片段加载外部 ONNX initializer 到 TensorRT 11 parser。

public bool LoadInitializer(string name, ArraySegment<byte> data)

Parameters

name string

Initializer name. initializer 名称。

data ArraySegment<byte>

Initializer data segment. initializer 数据片段。

Returns

bool

true when TensorRT accepts the initializer. TensorRT 接受 initializer 时返回 true。

LoadInitializer(string, byte[])

Loads an external ONNX initializer into the TensorRT 11 parser. 将外部 ONNX initializer 加载到 TensorRT 11 parser。

public bool LoadInitializer(string name, byte[] data)

Parameters

name string

Initializer name. initializer 名称。

data byte[]

Initializer data. initializer 数据。

Returns

bool

true when TensorRT accepts the initializer. TensorRT 接受 initializer 时返回 true。

Remarks

The initializer data is copied into an owned managed array and pinned until this parser is disposed, matching TensorRT's lifetime requirement. initializer 数据会复制到当前 parser 拥有的托管数组,并 pin 到 parser 释放为止,以满足 TensorRT 生命周期要求。

LoadInitializer(string, Stream)

Loads an external ONNX initializer from a stream into the TensorRT 11 parser. 从 stream 加载外部 ONNX initializer 到 TensorRT 11 parser。

public bool LoadInitializer(string name, Stream dataStream)

Parameters

name string

Initializer name. initializer 名称。

dataStream Stream

Readable stream containing initializer data. 包含 initializer 数据的可读 stream。

Returns

bool

true when TensorRT accepts the initializer. TensorRT 接受 initializer 时返回 true。

LoadInitializer(string, ReadOnlySpan<byte>)

Loads an external ONNX initializer from a read-only span into the TensorRT 11 parser. 从只读 span 加载外部 ONNX initializer 到 TensorRT 11 parser。

public bool LoadInitializer(string name, ReadOnlySpan<byte> data)

Parameters

name string

Initializer name. initializer 名称。

data ReadOnlySpan<byte>

Initializer data. initializer 数据。

Returns

bool

true when TensorRT accepts the initializer. TensorRT 接受 initializer 时返回 true。

LoadModelProto(ArraySegment<byte>, string?)

Loads serialized ONNX model-proto bytes from a byte-array segment into the TensorRT 11 parser. 从托管字节数组片段加载 ONNX model proto 到 TensorRT 11 parser。

public bool LoadModelProto(ArraySegment<byte> modelData, string? modelPath = null)

Parameters

modelData ArraySegment<byte>

Serialized ONNX model-proto byte segment. 已序列化 ONNX model proto 字节片段。

modelPath string

Optional model path used by TensorRT diagnostics. TensorRT 诊断信息使用的可选模型路径。

Returns

bool

true when TensorRT accepts the model proto. TensorRT 接受 model proto 时返回 true。

LoadModelProto(byte[], string?)

Loads serialized ONNX model-proto bytes into the TensorRT 11 parser without parsing immediately. 将已序列化 ONNX model proto 字节加载到 TensorRT 11 parser,但暂不立即解析。

public bool LoadModelProto(byte[] modelData, string? modelPath = null)

Parameters

modelData byte[]

Serialized ONNX model-proto bytes. 已序列化的 ONNX model proto 字节。

modelPath string

Optional model path used by TensorRT diagnostics. TensorRT 诊断信息使用的可选模型路径。

Returns

bool

true when TensorRT accepts the model proto. TensorRT 接受 model proto 时返回 true。

Remarks

TensorRT 11 does not retain the model-proto byte buffer after this call returns; the managed buffer is pinned only for the native call. TensorRT 11 在该调用返回后不会继续持有 model-proto 字节缓冲区;托管缓冲区仅在 native 调用期间短期 pin。

LoadModelProto(Stream, string?)

Loads serialized ONNX model-proto bytes from a stream into the TensorRT 11 parser. 从 stream 加载 ONNX model proto 到 TensorRT 11 parser。

public bool LoadModelProto(Stream modelStream, string? modelPath = null)

Parameters

modelStream Stream

Readable stream containing serialized ONNX model-proto bytes. 包含已序列化 ONNX model proto 字节的可读 stream。

modelPath string

Optional model path used by TensorRT diagnostics. TensorRT 诊断信息使用的可选模型路径。

Returns

bool

true when TensorRT accepts the model proto. TensorRT 接受 model proto 时返回 true。

LoadModelProto(ReadOnlySpan<byte>, string?)

Loads serialized ONNX model-proto bytes from a read-only span into the TensorRT 11 parser. 从只读 span 加载 ONNX model proto 到 TensorRT 11 parser。

public bool LoadModelProto(ReadOnlySpan<byte> modelData, string? modelPath = null)

Parameters

modelData ReadOnlySpan<byte>

Serialized ONNX model-proto bytes. 已序列化 ONNX model proto 字节。

modelPath string

Optional model path used by TensorRT diagnostics. TensorRT 诊断信息使用的可选模型路径。

Returns

bool

true when TensorRT accepts the model proto. TensorRT 接受 model proto 时返回 true。

Parse(ArraySegment<byte>, string?)

Parses ONNX model bytes from a managed byte-array segment into the target network. 将托管字节数组片段中的 ONNX 模型解析到目标 network。

public bool Parse(ArraySegment<byte> modelData, string? modelPath = null)

Parameters

modelData ArraySegment<byte>

Serialized ONNX model byte segment. 已序列化 ONNX 模型字节片段。

modelPath string

Optional model path used by TensorRT diagnostics. TensorRT 诊断信息使用的可选模型路径。

Returns

bool

true when parsing succeeds. 解析成功时返回 true。

Remarks

The segment is copied into an exact managed byte array before native interop. 调用 native interop 前会将片段复制为精确长度的托管字节数组。

Parse(byte[], string?)

Parses ONNX model bytes into the target network. 将 ONNX 模型字节解析到目标 network。

public bool Parse(byte[] modelData, string? modelPath = null)

Parameters

modelData byte[]

Serialized ONNX model bytes. 已序列化的 ONNX 模型字节。

modelPath string

Optional model path used by TensorRT diagnostics. TensorRT 诊断信息使用的可选模型路径。

Returns

bool

true when parsing succeeds. 解析成功时返回 true。

Parse(Stream, string?)

Parses ONNX model bytes from a managed stream into the target network. 从托管 stream 读取 ONNX 模型字节并解析到目标 network。

public bool Parse(Stream modelStream, string? modelPath = null)

Parameters

modelStream Stream

The readable stream containing serialized ONNX model bytes. 包含已序列化 ONNX 模型字节的可读 stream。

modelPath string

Optional model path used by TensorRT diagnostics. TensorRT 诊断信息使用的可选模型路径。

Returns

bool

true when parsing succeeds. 解析成功时返回 true。

Remarks

The stream is copied into managed memory before native interop; this is not a TensorRT model-proto or external-initializer lifetime bridge. 调用 native interop 前会将 stream 内容复制到托管内存;该入口不是 TensorRT model proto 或 external initializer 生命周期桥。

Parse(ReadOnlySpan<byte>, string?)

Parses ONNX model bytes from a managed read-only span into the target network. 将托管只读 span 中的 ONNX 模型字节解析到目标 network。

public bool Parse(ReadOnlySpan<byte> modelData, string? modelPath = null)

Parameters

modelData ReadOnlySpan<byte>

Serialized ONNX model bytes. 已序列化 ONNX 模型字节。

modelPath string

Optional model path used by TensorRT diagnostics. TensorRT 诊断信息使用的可选模型路径。

Returns

bool

true when parsing succeeds. 解析成功时返回 true。

Remarks

The span is copied into a managed byte array before native interop, and TensorRT does not retain caller-owned memory. 调用 native interop 前会将 span 复制到托管字节数组,TensorRT 不会保留调用方拥有的内存。

ParseFromFile(string, int)

Parses an ONNX model from a file path into the target network. 从文件路径解析 ONNX 模型到目标 network。

public bool ParseFromFile(string filePath, int verbosity = 1)

Parameters

filePath string

The ONNX model path. ONNX 模型路径。

verbosity int

TensorRT parser verbosity level. TensorRT parser 日志详细级别。

Returns

bool

true when parsing succeeds. 解析成功时返回 true。

ParseLoadedModel()

Parses the model proto previously loaded through LoadModelProto(byte[], string?). 解析先前通过 LoadModelProto(byte[], string?) 加载的 model proto。

public bool ParseLoadedModel()

Returns

bool

true when parsing succeeds. 解析成功时返回 true。

ParseWithWeightDescriptors(byte[])

Parses serialized ONNX model bytes through TensorRT's legacy weight-descriptor entry. 通过 TensorRT legacy weight-descriptor 入口解析已序列化 ONNX 模型字节。

public bool ParseWithWeightDescriptors(byte[] modelData)

Parameters

modelData byte[]

Serialized ONNX model bytes copied and pinned only for the vendor call. 仅在 vendor 调用期间复制并 pin 的 ONNX 模型字节。

Returns

bool

true when TensorRT reports a successful parse. TensorRT 报告解析成功时返回 true。

Exceptions

BridgeProbeException

Thrown for TensorRT 11, where this vendor method was removed. TensorRT 11 已移除该 vendor 方法。

SetBuilderConfig(TensorRtBuilderConfig)

Attaches a TensorRT 11 builder configuration to this ONNX parser. 将 TensorRT 11 builder 配置关联到当前 ONNX parser。

public bool SetBuilderConfig(TensorRtBuilderConfig config)

Parameters

config TensorRtBuilderConfig

The builder configuration borrowed by TensorRT. TensorRT 借用的 builder 配置。

Returns

bool

true when TensorRT accepts the configuration. TensorRT 接受该配置时返回 true。

Remarks

The parser keeps the configuration's native owner alive until another configuration is accepted or the parser is disposed. 在另一个配置被成功接受或 parser 被释放前,当前 parser 会保持该配置的 native owner 有效。

SetFlag(TensorRtOnnxParserFlag)

Enables a single ONNX parser flag. 启用单个 ONNX parser 标志。

public void SetFlag(TensorRtOnnxParserFlag flag)

Parameters

flag TensorRtOnnxParserFlag

The parser flag to enable. 要启用的 parser 标志。

SupportsOperator(string)

Returns whether the selected TensorRT parser reports support for an ONNX operator. 返回当前 TensorRT parser 是否报告支持指定 ONNX operator。

public bool SupportsOperator(string operatorName)

Parameters

operatorName string

The ONNX operator name, for example Identity. ONNX operator 名称,例如 Identity。

Returns

bool

true when TensorRT reports support for the operator. TensorRT 报告支持该 operator 时返回 true。

TryGetLayerOutputTensorMetadata(string, long, out TensorRtOnnxLayerOutputTensorMetadata?)

Tries to copy metadata for one ONNX layer output tensor without exposing the parser-owned tensor pointer. 尝试复制一个 ONNX layer 输出 tensor 的元数据,不暴露 parser 拥有的 tensor 指针。

public bool TryGetLayerOutputTensorMetadata(string layerName, long outputIndex, out TensorRtOnnxLayerOutputTensorMetadata? metadata)

Parameters

layerName string

The ONNX layer name. ONNX layer 名称。

outputIndex long

The zero-based output index. 从零开始的输出索引。

metadata TensorRtOnnxLayerOutputTensorMetadata

The copied metadata when found; otherwise null. 找到时返回复制元数据,否则为 null。

Returns

bool

true when the layer output exists. 当 layer 输出存在时返回 true。

Remarks

TensorRT 10 and 11 are supported. TensorRT 8 does not expose IParser::getLayerOutputTensor. 支持 TensorRT 10 和 11;TensorRT 8 未提供 IParser::getLayerOutputTensor。

TryParse(byte[], out IReadOnlyList<TensorRtOnnxParserDiagnostic>)

Attempts to parse ONNX model bytes and returns copied TensorRT parser diagnostics. 尝试解析 ONNX 模型字节并返回已复制的 TensorRT parser 诊断信息。

public bool TryParse(byte[] modelData, out IReadOnlyList<TensorRtOnnxParserDiagnostic> diagnostics)

Parameters

modelData byte[]

Serialized ONNX model bytes. 已序列化 ONNX 模型字节。

diagnostics IReadOnlyList<TensorRtOnnxParserDiagnostic>

Copied parser diagnostics collected after the parse attempt. 解析尝试后收集到的 parser 诊断信息副本。

Returns

bool

true when parsing succeeds. 解析成功时返回 true。

TryParse(byte[], string?, out IReadOnlyList<TensorRtOnnxParserDiagnostic>)

Attempts to parse ONNX model bytes and returns copied TensorRT parser diagnostics. 尝试解析 ONNX 模型字节并返回已复制的 TensorRT parser 诊断信息。

public bool TryParse(byte[] modelData, string? modelPath, out IReadOnlyList<TensorRtOnnxParserDiagnostic> diagnostics)

Parameters

modelData byte[]

Serialized ONNX model bytes. 已序列化 ONNX 模型字节。

modelPath string

Optional model path used by TensorRT diagnostics. TensorRT 诊断信息使用的可选模型路径。

diagnostics IReadOnlyList<TensorRtOnnxParserDiagnostic>

Copied parser diagnostics collected after the parse attempt. 解析尝试后收集到的 parser 诊断信息副本。

Returns

bool

true when parsing succeeds. 解析成功时返回 true。

TryParse(Stream, out IReadOnlyList<TensorRtOnnxParserDiagnostic>)

Attempts to parse ONNX model bytes from a managed stream and returns copied TensorRT parser diagnostics. 尝试从托管 stream 解析 ONNX 模型字节并返回已复制的 TensorRT parser 诊断信息。

public bool TryParse(Stream modelStream, out IReadOnlyList<TensorRtOnnxParserDiagnostic> diagnostics)

Parameters

modelStream Stream

The readable stream containing serialized ONNX model bytes. 包含已序列化 ONNX 模型字节的可读 stream。

diagnostics IReadOnlyList<TensorRtOnnxParserDiagnostic>

Copied parser diagnostics collected after the parse attempt. 解析尝试后收集到的 parser 诊断信息副本。

Returns

bool

true when parsing succeeds. 解析成功时返回 true。

TryParse(Stream, string?, out IReadOnlyList<TensorRtOnnxParserDiagnostic>)

Attempts to parse ONNX model bytes from a managed stream and returns copied TensorRT parser diagnostics. 尝试从托管 stream 解析 ONNX 模型字节并返回已复制的 TensorRT parser 诊断信息。

public bool TryParse(Stream modelStream, string? modelPath, out IReadOnlyList<TensorRtOnnxParserDiagnostic> diagnostics)

Parameters

modelStream Stream

The readable stream containing serialized ONNX model bytes. 包含已序列化 ONNX 模型字节的可读 stream。

modelPath string

Optional model path used by TensorRT diagnostics. TensorRT 诊断信息使用的可选模型路径。

diagnostics IReadOnlyList<TensorRtOnnxParserDiagnostic>

Copied parser diagnostics collected after the parse attempt. 解析尝试后收集到的 parser 诊断信息副本。

Returns

bool

true when parsing succeeds. 解析成功时返回 true。

TryParseWithWeightDescriptors(byte[], out IReadOnlyList<TensorRtOnnxParserDiagnostic>)

Attempts the legacy weight-descriptor parse and returns copied diagnostics. 尝试 legacy weight-descriptor 解析并返回已复制诊断。

public bool TryParseWithWeightDescriptors(byte[] modelData, out IReadOnlyList<TensorRtOnnxParserDiagnostic> diagnostics)

Parameters

modelData byte[]
diagnostics IReadOnlyList<TensorRtOnnxParserDiagnostic>

Returns

bool