解析 ONNX GraphProto

解析 ONNX GraphProto#

import set_env
from tvm.relay.frontend.onnx import GraphProto
GraphProto?
Init signature: GraphProto(shape, dtype, freeze_params=False, op_type_dict=None)
Docstring:     
A helper class for handling Relay expression copying from pb2.GraphProto.
Definition: https://github.com/onnx/onnx/blob/main/onnx/onnx.proto

    Parameters
----------
shape : dict of str to tuple, optional
    The input shape to the graph

dtype : str or dict of str to str
    The input types to the graph

freeze_params: bool
    If this parameter is true, the importer will take any provided
    onnx input values (weights, shapes, etc) and embed them into the relay model
    as Constants instead of variables. This allows more aggressive optimizations
    at compile time and helps in making models static if certain inputs represent
    attributes relay would traditionally consider compile-time constants.

op_type_dict: Dict[str, int]
    Dictionary for span filling usage. If the name property of op was not set
    op_type_dict will provide an alternative by combining literal op type with
    its presenting order
File:           /media/pc/data/lxw/ai/tvm/python/tvm/relay/frontend/onnx.py
Type:           type
Subclasses:

GraphProto 类是辅助类,用于处理从 pb2.GraphProto 复制到 Relay 表达式。

该类有以下参数:

  • shape:一个字典,表示图的输入形状。这是一个可选参数。

  • dtype:一个字符串或字典,表示图的输入类型。如果是一个字典,则键是输入名称,值是对应的数据类型。

  • freeze_params:一个布尔值。如果为 True,则导入器会将提供的任何 ONNX 输入值(权重、形状等)嵌入到 Relay 模型中作为常量而不是变量。这允许在编译时进行更积极的优化,并在特定输入表示传统上被视为编译时常量的属性时使模型静态化。

  • op_type_dict:一个字典,用于 span 跨度填充使用。如果算子的名称属性未设置,则 op_type_dict 将通过将文字算子类型与呈现顺序相结合来提供替代方案。