ONNX intermediate representation spec - IR

清疚 2023-01-05 12:03 228阅读 0赞

ONNX intermediate representation spec - IR

Open Neural Network Exchange (ONNX) - github
https://github.com/onnx/onnx

ONNX intermediate representation spec
https://github.com/onnx/onnx/blob/master/docs/IR.md

docs/IR.md
https://github.com/onnx/onnx/blob/master/docs/IR.md

docs
https://github.com/onnx/onnx/tree/master/docs

docs/Operators.md
https://github.com/onnx/onnx/blob/master/docs/Operators.md

1. Open Neural Network Exchange (ONNX) IR

the normative specification of the semantics of ONNX.
ONNX 语义的标准规范。

  1. normative ['nɔː(r)mətɪv]:adj. 规范的,标准的

The .proto and .proto3 files found under the onnx folder form the normative specification of its syntax authored in the Protocol Buffers definition language. Commentary found in the .proto and .proto3 files are intended to improve readability of those files, but are not normative if they conflict with this document. Such conflicts should be reported as documentation bugs.
onnx 文件夹下找到的 .proto and .proto3 文件构成了在 Protocol Buffers 中定义语言中编写的其语法标准规范。

Notes on model validation
A tool is available to perform general validation of models against this specification. It is implemented in C++ with Python command-line wrapper.
有一个工具可以根据此规范对模型进行常规验证。它是使用 Python 命令行包装程序在 C++ 中实现的。

  1. The use of SHOULD, MUST, MAY and so on in this document is consistent with RFC 2119.
  2. The use of list shall denote an ordered collection of items, set shall denote an unordered collection of unique elements, and bag an unordered collection of possibly non-unique elements.
    使用 list 表示元素的有序集合,set 表示唯一元素的无序集合,而 bag 表示可能不是唯一元素的无序集合。

2. Components

ONNX is an open specification that consists of the following components:

  1. A definition of an extensible computation graph model. 可扩展计算图模型的定义。
  2. Definitions of standard data types. 标准数据类型的定义。
  3. Definitions of built-in operators. 内置运算符的定义。

Of these, #1 and #2 are covered herein; the built-in operators are covered separately in documents listed at the end of this. Specifically, built-in operators are divided into a set of primitive operators and functions. A function is an operator whose semantics is formally expressed via expansion into a sub-graph (called the function body) using other operators (and functions). Functionality-wise, an ONNX compatible framework or runtime may inline a function body to execute it if it does not have corresponding implementation of the function.
其中 #1 and #2 在此涵盖,内置运算符在本文末尾列出的文档中单独介绍。具体而言,内置运算符分为一组 primitive operators and functions。函数是一个运算符,其语义是通过使用其他运算符 (和函数) 扩展为子图 (称为函数主体) 来正式表达的。在功能方面,如果 ONNX 兼容的框架或运行时没有相应的函数实现,则可以内联函数体以执行它。

There are two official ONNX variants; the main distinction between the two is found in the supported types and the default operator sets. The neural-network-only ONNX variant recognizes only tensors as input and output types, while the Classical Machine Learning extension, ONNX-ML, also recognizes sequences and maps. ONNX-ML extends the ONNX operator set with ML algorithms that are not based on neural networks.
有两种官方的 ONNX 变体:两者之间的主要区别在于支持的类型和默认的运算符集。仅神经网络的 ONNX 变体仅将张量识别为输入和输出类型,而经典机器学习扩展 ONNX-ML 还识别序列和图。ONNX-ML 使用不基于神经网络的 ML 算法扩展了 ONNX 运算符集。

Upto IR version 6, the ONNX specification and model format addressed only inference (also known as scoring). Starting from IR version 7, the ONNX specification and model format has been extended to support training. An ONNX training-model itself is an extension of the inference-model and allows an inference-only runtime to ignore the training-related extensions and run inference. In typical usage scenarios, however, an inference-only model may enable a more optimized model-representation (for inference purposes) than a training-model.
在 IR 版本 6 之前,ONNX 规范和模型格式仅解决推理 (也称为 scoring)。从 IR 版本 7 开始,ONNX 规范和模型格式已扩展为支持训练。ONNX 训练模型本身是推理模型的扩展,并且允许仅推理的运行时忽略与训练相关的扩展并运行推理。但是,在典型的使用场景中,仅推理模型可以实现比训练模型更好的模型表示 (出于推理目的)。

3. Runtime Agnostic - 运行时不可知

ONNX does not pre-suppose or imply any particular method of runtime implementation.
ONNX 不预设或暗示任何特定的运行时实现方法。

For example, an implementation may consist of a rich runtime which interprets the model; it may be a code generator that translates the model in its entirety to executable code for some target programming language; it may be a hardware implementation; it may be a combination of two or three of those.
它可能是一个代码生成器,可以将模型整体转换为某种目标编程语言的可执行代码。它可能是硬件实现。它可能是其中两个或三个的组合。

Nothing in this specification should be construed as advocating one implementation approach over any other; any comments on the inner workings of concrete implementations are to be interpreted as examples.
本规范中的任何内容都不应解释为主张一种实现方法胜过任何其他实现方法。 对具体实现的内部运作的任何评论都应解释为示例。

  1. construe [kən'struː]:n. 解释,语法分析,分析练习句,直译 v. 理解,领会
  2. advocate ['ædvəkət]:v. 提倡,拥护,支持 n. 拥护者,支持者,辩护律师,提倡者

发表评论

表情:
评论列表 (有 0 条评论,228人围观)

还没有评论,来说两句吧...

相关阅读

    相关 ONNX简介

    ONNX简介 Open Neural Network Exchange(ONNX,开放神经网络交换)格式,是一个用于表示深度学习模型的标准,可使模型在不同框架之间进行转移

    相关 ONNX初探

    0x0. 背景 最近看了一些ONNX的资料,一个最大的感受就是这些资料太凌乱了。大多数都是在介绍ONNX模型转换中碰到的坑点以及解决办法。很少有文章可以系统的介绍ONNX

    相关 ONNX初探

    0x0. 背景 最近看了一些ONNX的资料,一个最大的感受就是这些资料太凌乱了。大多数都是在介绍ONNX模型转换中碰到的坑点以及解决办法。很少有文章可以系统的介绍ONNX