[go: up one dir, main page]

CN116560674A - A method and device for exporting a deep learning model compatible with multiple frameworks to ONNX - Google Patents

A method and device for exporting a deep learning model compatible with multiple frameworks to ONNX Download PDF

Info

Publication number
CN116560674A
CN116560674A CN202310473450.1A CN202310473450A CN116560674A CN 116560674 A CN116560674 A CN 116560674A CN 202310473450 A CN202310473450 A CN 202310473450A CN 116560674 A CN116560674 A CN 116560674A
Authority
CN
China
Prior art keywords
model
layer
onnx
target
node
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202310473450.1A
Other languages
Chinese (zh)
Inventor
董豪
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Peking University
Original Assignee
Peking University
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Peking University filed Critical Peking University
Priority to CN202310473450.1A priority Critical patent/CN116560674A/en
Publication of CN116560674A publication Critical patent/CN116560674A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/60Software deployment
    • G06F8/61Installation
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/04Architecture, e.g. interconnection topology
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02TCLIMATE CHANGE MITIGATION TECHNOLOGIES RELATED TO TRANSPORTATION
    • Y02T10/00Road transport of goods or passengers
    • Y02T10/10Internal combustion engine [ICE] based vehicles
    • Y02T10/40Engine management systems

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Artificial Intelligence (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • Health & Medical Sciences (AREA)
  • Biomedical Technology (AREA)
  • Biophysics (AREA)
  • Computational Linguistics (AREA)
  • Data Mining & Analysis (AREA)
  • Evolutionary Computation (AREA)
  • General Health & Medical Sciences (AREA)
  • Molecular Biology (AREA)
  • Computing Systems (AREA)
  • Mathematical Physics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

本申请实施例公开了一种兼容多框架的深度学习模型导出至ONNX的方法和装置,其方法包括:获取目标模型的每个层的层信息,以及广度优先搜索规则,目标模型为深度学习统一编程框架模型,目标模型能够兼容多个采用不同转换规则的框架;根据目标模型的每个层的层信息,以及广度优先遍历规则,对目标深度学习模型的每个层依序进行层遍历,得到对应的模型拓扑结构;根据模型拓扑结构,对目标模型的每个层依序进行映射,以将模型节点映射至开放神经网络交换ONNX;以及根据将模型节点映射到ONNX的映射结果和多个关键函数,通过创建ONNX计算图和创建ONNX模型,生成包括ONNX模型的模型文件。

The embodiment of the present application discloses a method and device for exporting a deep learning model compatible with multiple frameworks to ONNX. The method includes: obtaining layer information of each layer of the target model, and breadth-first search rules. The target model is a unified deep learning model. The programming framework model, the target model can be compatible with multiple frameworks using different conversion rules; according to the layer information of each layer of the target model and the breadth-first traversal rules, each layer of the target deep learning model is traversed sequentially to obtain The corresponding model topology; according to the model topology, map each layer of the target model in order to map the model node to the open neural network exchange ONNX; and according to the mapping result of mapping the model node to ONNX and multiple key Function to generate model files including ONNX models by creating ONNX calculation graphs and creating ONNX models.

Description

一种兼容多框架的深度学习模型导出至ONNX的方法和装置A method and device for exporting a deep learning model compatible with multiple frameworks to ONNX

技术领域technical field

本发明涉及计算机技术领域,具体涉及一种兼容多框架的深度学习模型导出至ONNX的方法和装置。The invention relates to the field of computer technology, in particular to a method and device for exporting a deep learning model compatible with multiple frameworks to ONNX.

背景技术Background technique

目前,深度学习模型部署大都采用转换为一个中间表示ONNX(Open NeuralNetwork Exchange,开放神经网络交换)来实现,然后通过推理引擎ONNX Runtime进行推理,也有通过TensorRT进行部署的。然而,ONNX已经占据深度学习部署的大部分市场,各个深度学习框架厂商纷纷将其所采用的的框架转换到ONNX。At present, the deployment of deep learning models is mostly implemented by converting to an intermediate representation ONNX (Open NeuralNetwork Exchange, Open Neural Network Exchange), and then inferring through the inference engine ONNX Runtime, and deploying it through TensorRT. However, ONNX has occupied most of the deep learning deployment market, and various deep learning framework manufacturers have switched their adopted frameworks to ONNX.

目前,用于将各个框架依次转换到ONNX的工具有很多,例如,ensorFlow2ONNX、Keras2ONNX、Paddle2ONNX。上述这些工具均具有对应于其特定的一套转换规则。例如,TensorFlow2ONNX是将TensorFlow算子一一对应到ONNX的算子,然后再将整个TensorFlow模型计算图转换为对应的ONNX的图,然后导出ONNX模型。Currently, there are many tools for sequentially converting each framework to ONNX, for example, ensorFlow2ONNX, Keras2ONNX, Paddle2ONNX. Each of the above-mentioned tools has a specific set of conversion rules corresponding to it. For example, TensorFlow2ONNX is to map TensorFlow operators to ONNX operators one by one, and then convert the entire TensorFlow model calculation graph into the corresponding ONNX graph, and then export the ONNX model.

由于各个框架之间算子、算子参数不尽相同,在将各个框架中的任意一个框架转换到ONNX时,都需要配置对应于该框架所采用的特定的一套转换规则。Since operators and operator parameters are different among different frameworks, when converting any framework in each framework to ONNX, it is necessary to configure a specific set of conversion rules corresponding to the framework.

目前,各个深度学习框架在模型部署方面,具有其对应的特定一套转换工具(例如,paddle有paddle2onnx转换工具,mindspore有mindspore2onnx转换工具)。由于上述各个深度学习框架具有其对应的特定的前端接口,且各个前端接口之间均存在差异,各个深度学习框架均有其对应的一套转换规则;因此,针对采用不同转换规则的不同深度学习框架,用户需要依次实现对应框架的代码,并通过对应框架的代码来进行模型的部署及迁移,这将使得模型的部署及迁移过程变得困难。At present, each deep learning framework has its corresponding specific set of conversion tools in terms of model deployment (for example, paddle has paddle2onnx conversion tool, mindspore has mindspore2onnx conversion tool). Since each of the above-mentioned deep learning frameworks has its corresponding specific front-end interface, and there are differences between each front-end interface, each deep learning framework has its corresponding set of conversion rules; therefore, for different deep learning with different conversion rules Framework, the user needs to implement the code of the corresponding framework in turn, and deploy and migrate the model through the code of the corresponding framework, which will make the deployment and migration process of the model difficult.

发明内容Contents of the invention

基于此,有必要针对现有的针对采用不同转换规则的不同深度学习框架,模型的部署及迁移过程是极其困难的问题,提供一种兼容多框架的深度学习模型导出至ONNX的方法、装置、存储介质、电子设备和计算机程序产品。Based on this, it is necessary to provide a method, device, Storage media, electronic devices and computer program products.

第一方面,本申请实施例提供了一种兼容多框架的深度学习模型导出至ONNX的方法,所述方法包括:In the first aspect, the embodiment of the present application provides a method for exporting a deep learning model compatible with multiple frameworks to ONNX, the method comprising:

获取目标模型的每个层的层信息,以及广度优先搜索规则,所述目标模型为深度学习统一编程框架模型,所述目标模型能够兼容多个采用不同转换规则的框架;Obtaining layer information and breadth-first search rules of each layer of the target model, the target model is a deep learning unified programming framework model, and the target model is compatible with multiple frameworks using different conversion rules;

根据所述目标模型的每个层的层信息,以及广度优先遍历规则,对所述目标深度学习模型的每个层依序进行层遍历,得到对应的模型拓扑结构;According to the layer information of each layer of the target model and the breadth-first traversal rule, each layer of the target deep learning model is sequentially traversed to obtain a corresponding model topology;

根据所述模型拓扑结构,对所述目标模型的每个层依序进行映射,以将模型节点映射至开放神经网络交换ONNX;According to the model topology, each layer of the target model is mapped in order to map the model nodes to the open neural network exchange ONNX;

根据将模型节点映射到ONNX的映射结果和多个关键函数,通过创建ONNX计算图和创建ONNX模型,生成包括所述ONNX模型的模型文件。According to the mapping result of mapping model nodes to ONNX and multiple key functions, by creating an ONNX calculation graph and creating an ONNX model, a model file including the ONNX model is generated.

在一种实施方式中,所述获取目标模型的每个层的层信息,包括:In one embodiment, the obtaining layer information of each layer of the target model includes:

获取模块节点的各项属性信息,模块节点的各项属性信息包括神经网络层、当前层神经网络层输入节点、当前层神经网络层输出节点、当前层神经网络层输入值、当前层神经网络层输出值、以及当前网络层节点名称;Obtain the attribute information of the module node. The attribute information of the module node includes the neural network layer, the input node of the neural network layer of the current layer, the output node of the neural network layer of the current layer, the input value of the neural network layer of the current layer, the neural network layer of the current layer Output value, and the name of the current network layer node;

通过调用所述模块节点执行一次前向传播,获取目标模型的每个层的层信息,所述目标模型的每个层的层信息包括目标神经网络层、任意一层作为当前层所对应当前层神经网络层输入节点、任意一层作为当前层所对应的当前层神经网络层输出节点、任意一层作为当前层所对应的当前层神经网络层输入值、任意一层作为当前层所对应的当前层神经网络层输出值和任意一层作为当前层所对应的当前网络层节点名称。By calling the module node to perform a forward propagation, obtain the layer information of each layer of the target model, the layer information of each layer of the target model includes the target neural network layer, any layer as the current layer corresponding to the current layer Neural network layer input node, any layer as the current layer neural network layer output node corresponding to the current layer, any layer as the current layer neural network layer input value corresponding to the current layer, any layer as the current layer corresponding to the current layer Layer neural network layer output value and any layer as the current network layer node name corresponding to the current layer.

在一种实施方式中,所述根据所述模型拓扑结构,对所述目标模型的每个层依序进行映射,以将模型节点映射至开放神经网络交换ONNX,包括:In one embodiment, according to the model topology, each layer of the target model is sequentially mapped to map model nodes to ONNX, including:

获取所述模型拓扑结构;Obtain the model topology;

根据所述模型拓扑结构确定对应的拓扑排序方式;determining a corresponding topological sorting manner according to the model topology;

根据拓扑排序方式,依序对每个层进行映射处理,得到对应的ONNX算子组合,以将模型节点映射至ONNX。According to the topological sorting method, each layer is mapped sequentially to obtain the corresponding ONNX operator combination to map the model nodes to ONNX.

在一种实施方式中,所述多个关键函数至少包括用于创建ONNX计算图的第一函数和用于创建ONNX模型的第二函数,所述根据将模型节点映射到ONNX的映射结果和多个关键函数,通过创建ONNX计算图和创建ONNX模型,生成包括所述ONNX模型的模型文件,包括:In one embodiment, the plurality of key functions at least include a first function for creating an ONNX calculation graph and a second function for creating an ONNX model, and according to the mapping result of mapping model nodes to ONNX and multiple A key function, by creating an ONNX calculation graph and creating an ONNX model, a model file including the ONNX model is generated, including:

获取将模型节点映射到ONNX的所述映射结果;Obtain the mapping result of mapping model nodes to ONNX;

根据所述映射结果、所述第一函数和所述第二函数,创建对应的ONNX计算图和对应的ONNX模型;Create a corresponding ONNX calculation graph and a corresponding ONNX model according to the mapping result, the first function and the second function;

验证所述ONNX模型是否为有效模型,并在验证所述ONNX模型有效的情况下,生成包括所述ONNX模型的模型文件。Verify whether the ONNX model is an effective model, and generate a model file including the ONNX model under the valid situation of verifying the ONNX model.

在一种实施方式中,所述验证所述ONNX模型是否为有效模型,包括:In one implementation, the verification of whether the ONNX model is an effective model includes:

在从TensorLayerX所使用的每一层均能映射到ONNX统一格式的情况下,验证所述ONNX模型为有效模型。In the case that each layer used from TensorLayerX can be mapped to the ONNX unified format, verify that the ONNX model is a valid model.

在一种实施方式中,所述验证所述ONNX模型是否为有效模型,还包括:In one embodiment, the verification of whether the ONNX model is an effective model also includes:

在所述TensorLayerX中至少包括一个不能映射到ONNX统一格式的层的情况下,验证所述ONNX模型为无效模型。In the case where the TensorLayerX includes at least one layer that cannot be mapped to the ONNX unified format, verify that the ONNX model is an invalid model.

在一种实施方式中,所述目标模型能够兼容的多个采用不同转换规则的框架包括以下至少一项:In one embodiment, the plurality of frameworks using different conversion rules compatible with the target model include at least one of the following:

TneosFlow、MindSpore、PaddlePaddle和PyTorch。TneosFlow, MindSpore, PaddlePaddle, and PyTorch.

第二方面,本申请实施例提供了一种兼容多框架的深度学习模型导出至ONNX的装置,所述装置包括:In the second aspect, the embodiment of the present application provides a device for exporting a deep learning model compatible with multiple frameworks to ONNX, and the device includes:

获取模块,用于获取目标模型的每个层的层信息,以及广度优先搜索规则,所述目标模型为深度学习统一编程框架模型,所述目标模型能够兼容多个采用不同转换规则的框架;An acquisition module, configured to acquire layer information of each layer of the target model, and breadth-first search rules, the target model is a deep learning unified programming framework model, and the target model can be compatible with multiple frameworks using different conversion rules;

遍历模块,用于根据所述目标模型的每个层的层信息,以及广度优先遍历规则,对所述目标深度学习模型的每个层依序进行层遍历,得到对应的模型拓扑结构;A traversal module, configured to sequentially perform layer traversal on each layer of the target deep learning model to obtain a corresponding model topology according to the layer information of each layer of the target model and the breadth-first traversal rule;

映射模块,用于根据所述模型拓扑结构,对所述目标模型的每个层依序进行映射,以将模型节点映射至开放神经网络交换ONNX;The mapping module is used to map each layer of the target model in sequence according to the model topology, so as to map the model nodes to the open neural network exchange ONNX;

生成模块,用于根据将模型节点映射到ONNX的映射结果和多个关键函数,通过创建ONNX计算图和创建ONNX模型,生成包括所述ONNX模型的模型文件。The generation module is used to generate a model file including the ONNX model by creating an ONNX calculation graph and creating an ONNX model according to the mapping result of mapping the model nodes to ONNX and a plurality of key functions.

第三方面,本申请实施例提供一种计算机可读存储介质,所述计算机可读存储介质存储有计算机程序,所述计算机程序用于执行上述的方法步骤。In a third aspect, the embodiments of the present application provide a computer-readable storage medium, where the computer-readable storage medium stores a computer program, and the computer program is used to execute the above method steps.

第四方面,本申请实施例提供一种电子设备,所述电子设备包括:In a fourth aspect, an embodiment of the present application provides an electronic device, and the electronic device includes:

处理器;processor;

用于存储所述处理器可执行指令的存储器;memory for storing said processor-executable instructions;

所述处理器,用于从所述存储器中读取所述可执行指令,并执行所述可执行指令以实现上述的方法步骤。The processor is configured to read the executable instruction from the memory, and execute the executable instruction to implement the above method steps.

第五方面,本申请实施例提供一种计算机程序产品,包括计算机程序,所述计算机程序在被处理器执行时实现上述的方法步骤。In a fifth aspect, the embodiments of the present application provide a computer program product, including a computer program, and when the computer program is executed by a processor, the above method steps are implemented.

在本申请实施例中,获取目标模型的每个层的层信息,以及广度优先搜索规则,目标模型为深度学习统一编程框架模型,目标模型能够兼容多个采用不同转换规则的框架;根据目标模型的每个层的层信息,以及广度优先遍历规则,对目标深度学习模型的每个层依序进行层遍历,得到对应的模型拓扑结构;根据模型拓扑结构,对目标模型的每个层依序进行映射,以将模型节点映射至开放神经网络交换ONNX;以及根据将模型节点映射到ONNX的映射结果和多个关键函数,通过创建ONNX计算图和创建ONNX模型,生成包括ONNX模型的模型文件。本申请实施例提供的兼容多框架的深度学习模型导出至ONNX的方法,由于目标模型为深度学习统一编程框架模型、且目标模型能够兼容多个采用不同转换规则的框架,从而兼容多框架的深度学习模型导出至ONNX的方法,能够支持多种深度学习框架后端(例如,paddle、mindspore、tensorflow、pytorch),通过切换后端就能改变计算引擎,因此,用户在模型部署迁移上就不需要实现对应框架代码来进行部署,只需切换后端即可。采用本申请实施例的兼容多框架的深度学习模型导出至ONNX的方法,能够做到:针对采用不同转换规则的不同深度学习框架,模型部署及迁移的过程与所使用的计算后端无关,从而避免了由于算子接口差异所导致的需要设计多个映射方法的问题。In the embodiment of the present application, the layer information of each layer of the target model and the breadth-first search rules are obtained, the target model is a deep learning unified programming framework model, and the target model can be compatible with multiple frameworks using different conversion rules; according to the target model The layer information of each layer of the target deep learning model and the breadth-first traversal rules are used to perform layer traversal on each layer of the target deep learning model in order to obtain the corresponding model topology; according to the model topology, each layer of the target model is sequenced Mapping is performed to map the model nodes to the open neural network exchange ONNX; and according to the mapping result and a plurality of key functions of mapping the model nodes to ONNX, by creating an ONNX calculation graph and creating an ONNX model, a model file including the ONNX model is generated. The method for exporting a deep learning model compatible with multiple frameworks to ONNX provided by the embodiment of the present application, since the target model is a unified programming framework model for deep learning, and the target model can be compatible with multiple frameworks using different conversion rules, it is compatible with the depth of multiple frameworks The method of exporting the learning model to ONNX can support a variety of deep learning framework backends (for example, paddle, mindspore, tensorflow, pytorch), and the computing engine can be changed by switching the backend. Therefore, users do not need to deploy and migrate models. Implement the corresponding framework code for deployment, just switch the backend. Using the method of exporting the deep learning model compatible with multiple frameworks to ONNX in the embodiment of the present application can achieve: for different deep learning frameworks using different conversion rules, the process of model deployment and migration has nothing to do with the computing backend used, thus This avoids the need to design multiple mapping methods due to differences in operator interfaces.

附图说明Description of drawings

通过参考下面的附图,可以更为完整地理解本发明的示例性实施方式。附图用来提供对本申请实施例的进一步理解,并且构成说明书的一部分,与本申请实施例一起用于解释本发明,并不构成对本发明的限制。在附图中,相同的参考标号通常代表相同部件或步骤。A more complete understanding of the exemplary embodiments of the present invention can be had by referring to the following drawings. The accompanying drawings are used to provide a further understanding of the embodiments of the present application, and constitute a part of the specification, and are used together with the embodiments of the present application to explain the present invention, and do not constitute limitations to the present invention. In the drawings, the same reference numerals generally represent the same components or steps.

图1为具体应用场景下的兼容多框架的深度学习模型导出至ONNX的整体设计示意图;Figure 1 is a schematic diagram of the overall design of a deep learning model compatible with multiple frameworks exported to ONNX in a specific application scenario;

图2为根据本申请一示例性实施例提供的兼容多框架的深度学习模型导出至ONNX的方法的流程图;Fig. 2 is the flow chart of the method for exporting the deep learning model of compatible multi-frame according to an exemplary embodiment of the present application to ONNX;

图3为具体应用场景下的通过ModuleNode类收集模型拓扑结构示意图;Figure 3 is a schematic diagram of the model topology collected through the ModuleNode class in a specific application scenario;

图4为具体应用场景下的模型节点映射到ONNX的示意图;Figure 4 is a schematic diagram of the mapping of model nodes to ONNX in specific application scenarios;

图5为具体应用场景下的ONNX构图和保存模型的示意图;Figure 5 is a schematic diagram of ONNX composition and storage models in specific application scenarios;

图6为根据本申请一示例性实施例提供的兼容多框架的深度学习模型导出至ONNX的装置600的结构示意图;FIG. 6 is a schematic structural diagram of a device 600 for exporting a multi-framework-compatible deep learning model to ONNX according to an exemplary embodiment of the present application;

图7示出了本申请一示例性实施例提供的一种电子设备的示意图;Fig. 7 shows a schematic diagram of an electronic device provided by an exemplary embodiment of the present application;

图8示出了本申请一示例性实施例提供的一种计算机可读介质的示意图。Fig. 8 shows a schematic diagram of a computer-readable medium provided by an exemplary embodiment of the present application.

具体实施方式Detailed ways

下面将参照附图更详细地描述本公开的示例性实施方式。虽然附图中显示了本公开的示例性实施方式,然而应当理解,可以以各种形式实现本公开而不应被这里阐述的实施方式所限制。相反,提供这些实施方式是为了能够更透彻地理解本公开,并且能够将本公开的范围完整的传达给本领域的技术人员。Exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although exemplary embodiments of the present disclosure are shown in the drawings, it should be understood that the present disclosure may be embodied in various forms and should not be limited by the embodiments set forth herein. Rather, these embodiments are provided for more thorough understanding of the present disclosure and to fully convey the scope of the present disclosure to those skilled in the art.

需要注意的是,除非另有说明,本申请使用的技术术语或者科学术语应当为本申请所属领域技术人员所理解的通常意义。It should be noted that, unless otherwise specified, technical terms or scientific terms used in this application shall have the usual meanings understood by those skilled in the art to which this application belongs.

另外,术语“第一”和“第二”等是用于区别不同对象,而不是用于描述特定顺序。此外,术语“包括”和“具有”以及它们任何变形,意图在于覆盖不排他的包含。例如包含了一系列步骤或单元的过程、方法、系统、产品或设备没有限定于已列出的步骤或单元,而是可选地还包括没有列出的步骤或单元,或可选地还包括对于这些过程、方法、产品或设备固有的其它步骤或单元。In addition, the terms "first" and "second", etc. are used to distinguish different objects, not to describe a specific order. Furthermore, the terms "include" and "have", as well as any variations thereof, are intended to cover a non-exclusive inclusion. For example, a process, method, system, product or device comprising a series of steps or units is not limited to the listed steps or units, but optionally also includes unlisted steps or units, or optionally further includes For other steps or units inherent in these processes, methods, products or apparatuses.

本申请实施例提供一种兼容多框架的深度学习模型导出至ONNX的方法及装置、一种电子设备以及计算机可读介质,下面结合附图进行说明。Embodiments of the present application provide a method and device for exporting a deep learning model compatible with multiple frameworks to ONNX, an electronic device, and a computer-readable medium, which will be described below with reference to the accompanying drawings.

如图1所示,为具体应用场景下的兼容多框架的深度学习模型导出至ONNX的整体设计示意图。As shown in Figure 1, it is a schematic diagram of the overall design of exporting a deep learning model compatible with multiple frameworks to ONNX in a specific application scenario.

如图1所示,基于深度学习统一编程框架所提供的高层次接口,可得到支持多计算后端的模型;给定模型一个输入进行一次前向传播,就能收集到所有高层次接口层的信息,然后利用广度优先搜索得到模型拓扑结构;遍历访问拓扑结构,依照映射一一将接口层的信息转换到ONNX算子信息;最后使用ONNX提供的make_graph函数、make_model函数来创建ONNX计算图,使用check_model检验ONNX模型,检验通过后保存模型就得到了model.onnx文件;此时,就可以将模型部署到目标设备进行推理。As shown in Figure 1, based on the high-level interface provided by the deep learning unified programming framework, a model that supports multiple computing backends can be obtained; given a model with one input and one forward propagation, all the information of the high-level interface layer can be collected , and then use breadth-first search to obtain the model topology; traverse the access topology, and convert the interface layer information to ONNX operator information one by one according to the mapping; finally use the make_graph function and make_model function provided by ONNX to create the ONNX calculation graph, and use check_model Check the ONNX model, save the model after passing the test and get the model.onnx file; at this point, you can deploy the model to the target device for inference.

需要说明的是,上述计算图是用来描述运算的有向无环图,计算图有两个主要元素:结点Node和边Edge;结点表示数据,如向量、矩阵、张量。边表示运算,如加减乘除卷积等。It should be noted that the above calculation graph is a directed acyclic graph used to describe operations. The calculation graph has two main elements: node Node and edge Edge; nodes represent data, such as vectors, matrices, and tensors. Edges represent operations, such as addition, subtraction, multiplication, division, convolution, etc.

如图1所示的整体设计图所展示的流程主要包括了四个部分,四个部分具体如下所述:The process shown in the overall design diagram shown in Figure 1 mainly includes four parts, and the details of the four parts are as follows:

模型拓扑结构(用于遍历访问,然后将统一框架的神经网络层映射到ONNX算子)、模型节点映射到ONNX(用于生成ONNX算子信息)、ONNX构图和ONNX模型(依据ONNX算子信息导出ONNX文件)。Model topology (for traversal access, and then map the neural network layer of the unified framework to ONNX operators), model node mapping to ONNX (for generating ONNX operator information), ONNX composition and ONNX model (according to ONNX operator information export ONNX file).

请参考图2,其示出了本申请的一些实施方式所提供的一种兼容多框架的深度学习模型导出至ONNX的方法的流程图,如图2所示,兼容多框架的深度学习模型导出至ONNX的方法可以包括以下步骤:Please refer to FIG. 2 , which shows a flowchart of a method for exporting a multi-framework-compatible deep learning model to ONNX provided by some embodiments of the present application. As shown in FIG. 2 , a multi-framework-compatible deep learning model export A method to ONNX may include the following steps:

步骤S201:获取目标模型的每个层的层信息,以及广度优先搜索规则,目标模型为深度学习统一编程框架模型,目标模型能够兼容多个采用不同转换规则的框架。Step S201: Obtain layer information and breadth-first search rules of each layer of the target model. The target model is a deep learning unified programming framework model, and the target model can be compatible with multiple frameworks using different conversion rules.

在本申请实施例提供的兼容多框架的深度学习模型导出至ONNX的方法中,目标模型能够兼容的多个采用不同转换规则的框架包括以下至少一项:TneosFlow、MindSpore、PaddlePaddle和PyTorch。In the method for exporting a multi-framework compatible deep learning model to ONNX provided in the embodiment of the present application, the target model is compatible with multiple frameworks using different conversion rules including at least one of the following: TneosFlow, MindSpore, PaddlePaddle, and PyTorch.

在一种可能的实现方式中,获取目标模型的每个层的层信息,包括以下步骤:In a possible implementation manner, obtaining layer information of each layer of the target model includes the following steps:

获取模块节点的各项属性信息,模块节点的各项属性信息包括神经网络层、当前层神经网络层输入节点、当前层神经网络层输出节点、当前层神经网络层输入值、当前层神经网络层输出值、以及当前网络层节点名称;Obtain the attribute information of the module node. The attribute information of the module node includes the neural network layer, the input node of the neural network layer of the current layer, the output node of the neural network layer of the current layer, the input value of the neural network layer of the current layer, the neural network layer of the current layer Output value, and the name of the current network layer node;

通过调用模块节点执行一次前向传播,获取目标模型的每个层的层信息,目标模型的每个层的层信息包括目标神经网络层、任意一层作为当前层所对应当前层神经网络层输入节点、任意一层作为当前层所对应的当前层神经网络层输出节点、任意一层作为当前层所对应的当前层神经网络层输入值、任意一层作为当前层所对应的当前层神经网络层输出值和任意一层作为当前层所对应的当前网络层节点名称。By calling the module node to perform a forward propagation, the layer information of each layer of the target model is obtained. The layer information of each layer of the target model includes the target neural network layer, and any layer is used as the input of the current layer neural network layer corresponding to the current layer. Node, any layer as the current layer neural network layer output node corresponding to the current layer, any layer as the current layer neural network layer input value corresponding to the current layer, any layer as the current layer neural network layer corresponding to the current layer The output value and any layer are used as the current network layer node name corresponding to the current layer.

步骤S202:根据目标模型的每个层的层信息,以及广度优先遍历规则,对目标深度学习模型的每个层依序进行层遍历,得到对应的模型拓扑结构。Step S202: According to the layer information of each layer of the target model and the breadth-first traversal rule, each layer of the target deep learning model is traversed sequentially to obtain the corresponding model topology.

如图3所示,为具体应用场景下的通过ModuleNode类收集模型拓扑结构示意图。As shown in Figure 3, it is a schematic diagram of the model topology collected through the ModuleNode class in a specific application scenario.

如图3所示,构建ModuleNode对象,这其中包含了当前层节点信息,当前层的输入输出层节点信息以及输入输出数据。因为深度学习模型是由一个个神经网络组件Layer构建组成,因此,将ModuleNode模块节点类封装到函数中,在每个Layer的前向传播方法中调用ModuleNode来收集每个Layer的信息。因为输入输出是有方向的,因此,只要执行一次前向传播就能收集到所有的节点信息;最后将每个Node节点的信息进行广度优先访问就能得到一个深度学习模型的模型拓扑结构。As shown in Figure 3, the ModuleNode object is constructed, which contains the current layer node information, the current layer input and output layer node information, and input and output data. Because the deep learning model is composed of layers of neural network components, the ModuleNode module node class is encapsulated into a function, and ModuleNode is called in the forward propagation method of each Layer to collect the information of each Layer. Because the input and output are directional, all node information can be collected as long as one forward propagation is performed; finally, the model topology of a deep learning model can be obtained by breadth-first access to the information of each Node node.

如图3所示,通过调用ModuleNode来收集每个层的信息的具体过程如下所述:As shown in Figure 3, the specific process of collecting information of each layer by calling ModuleNode is as follows:

如图3所示,ModuleNode类在最左边类图里展示了ModuleNode的属性和方法。其中,属性包括layer(神经网络层)、in_nodes(当前层神经网络层输入节点)、out_nodes(当前层神经网络层输出节点)、in_tensors(当前层神经网络层输入值)、out_tensors(当前层神经网络层输出值)、以及node_name(当前网络层节点名称);其中,所采用的方法是layer(inputs),即执行一次前向传播。As shown in Figure 3, the ModuleNode class shows the properties and methods of ModuleNode in the leftmost class diagram. Among them, the attributes include layer (neural network layer), in_nodes (current layer neural network layer input node), out_nodes (current layer neural network layer output node), in_tensors (current layer neural network layer input value), out_tensors (current layer neural network layer layer output value), and node_name (current network layer node name); wherein, the method adopted is layer(inputs), that is, a forward propagation is performed.

如图3所示,图3的第二个模块为深度学习模型。深度学习模型是通过一个个Layer堆叠连接起来的网络结构。在每个Layer的前向传播方法中调用了ModuleNode,那么,当模型执行前向传播时,每个Layer都会调用一次ModuleNode,此时,就能够记录每个Layer的信息,即ModuleNode描述的属性:layer、in_nodes、out_nodes、in_tensors、out_tensors、node_name。由此,得到了图3中的第三个模块:模型所有节点信息。As shown in Figure 3, the second module in Figure 3 is a deep learning model. The deep learning model is a network structure connected by Layer stacking. ModuleNode is called in the forward propagation method of each Layer. Then, when the model performs forward propagation, each Layer will call ModuleNode once. At this time, the information of each Layer can be recorded, that is, the attributes described by ModuleNode: layer, in_nodes, out_nodes, in_tensors, out_tensors, node_name. Thus, the third module in Figure 3 is obtained: all node information of the model.

在本申请实施例提供的兼容多框架的深度学习模型导出至ONNX的方法中,根据目标模型的每个层的层信息,以及广度优先遍历规则,对目标深度学习模型的每个层依序进行层遍历,得到对应的模型拓扑结构具体如下所述:In the method for exporting a multi-framework-compatible deep learning model to ONNX provided in the embodiment of this application, each layer of the target deep learning model is sequentially processed according to the layer information of each layer of the target model and the breadth-first traversal rule Through layer traversal, the corresponding model topology structure is obtained as follows:

上述广度优先遍历规则就是层次遍历。首先遍历第1层,然后遍历第2层,同一层次按照从左到右的顺序访问,直到遍历最后一层。图3中已获知模型所有的节点信息。The above breadth-first traversal rules are hierarchical traversals. Firstly, the first layer is traversed, and then the second layer is traversed, and the same layer is visited in order from left to right until the last layer is traversed. In Figure 3, all node information of the model has been known.

例如:layer=Layer1、in_nodes=[input]、out_nodes=[layer1_node]、in_tensors=[a]、out_tensors=[b]、node_name=layer1;For example: layer=Layer1, in_nodes=[input], out_nodes=[layer1_node], in_tensors=[a], out_tensors=[b], node_name=layer1;

layer=Layer2、in_nodes=[input]、out_nodes=[layer2_node]、in_tensors=[a]、out_tensors=[c]、node_name=layer2;layer=Layer2, in_nodes=[input], out_nodes=[layer2_node], in_tensors=[a], out_tensors=[c], node_name=layer2;

layer=Layer3、in_nodes=[layer1_node、layer2_node]、out_nodes=[layer3_node]、in_tensors=[b,c]、out_tensors=[d]、node_name=layer3;layer=Layer3, in_nodes=[layer1_node, layer2_node], out_nodes=[layer3_node], in_tensors=[b,c], out_tensors=[d], node_name=layer3;

layer=Layer4、in_nodes=[layer3_node]、out_nodes=[layer4_node]、in_tensors=[d]、out_tensors=[output]、node_name=layer4;layer=Layer4, in_nodes=[layer3_node], out_nodes=[layer4_node], in_tensors=[d], out_tensors=[output], node_name=layer4;

采用上述广度优先遍历规则进行遍历为:按照层次进行遍历,具体为:第一层有layerl和layer2,那么,从左往右layer2,layer1(其输入是input,输出是b,c)。第二层只有layer3(其输入是b,c的node,输出是d)。第三层是layer4(其输入是d,输出是output)。检查到输出flag是output,遍历结束。上述经由广度优先遍历所得到的模型拓扑结构为:a->[b,c]->[d]->[e]->[output]。Traversing using the breadth-first traversal rule above is: traversing according to the level, specifically: the first layer has layer1 and layer2, then, from left to right layer2, layer1 (the input is input, the output is b, c). The second layer has only layer3 (its input is the node of b, c, and the output is d). The third layer is layer4 (its input is d and its output is output). Check that the output flag is output, and the traversal ends. The model topology obtained through breadth-first traversal above is: a->[b, c]->[d]->[e]->[output].

步骤S203:根据模型拓扑结构,对目标模型的每个层依序进行映射,以将模型节点映射至开放神经网络交换ONNX。Step S203: according to the model topology, each layer of the target model is sequentially mapped, so as to map the model nodes to ONNX.

如图4所示,为具体应用场景下的模型节点映射到ONNX的示意图。有了上述如图3所示的模型拓扑结构后,只需按照拓扑排序,依次将每个Layer转换到ONNX算子组合,就能完成模型节点映射了。As shown in Figure 4, it is a schematic diagram of the mapping of model nodes to ONNX in specific application scenarios. With the above-mentioned model topology shown in Figure 3, it is only necessary to convert each Layer to ONNX operator combination in turn according to the topology sorting, and then the model node mapping can be completed.

在实际应用场景中,模型节点映射到ONNX所采用的映射规则是根据ONNX提供的标准(一种表示深度学习模型的开放格式,定义了一套独立于环境和平台的标准格式。)In the actual application scenario, the mapping rules adopted by the model node mapping to ONNX are based on the standard provided by ONNX (an open format for expressing deep learning models, which defines a set of standard formats independent of the environment and platform.)

例如,2d卷积层:在tensorlayerx中是conv2d,那么,映射到onnx需要用onnx的格式来描述。如果Layer中检测到是conv2d,那么,需要映射为onnx的写法,使用make_node('Transpose')转换输入,再调用make_node(‘Conv’)执行卷积。For example, 2d convolution layer: conv2d in tensorlayerx, then, mapping to onnx needs to be described in onnx format. If conv2d is detected in Layer, then it needs to be mapped to onnx, use make_node('Transpose') to convert the input, and then call make_node('Conv') to perform convolution.

线性层:在tensorlayerx中是linear,那么,映射到onnx需要用onnx的格式来描述。如果Layer中检测到是linear这个操作,不能直接映射,需要拆分成乘法和加法。那么,需要映射为onnx的写法,使用make_node(‘matmul’)执行乘法,再调用make_node(‘add’)执行加法。Linear layer: It is linear in tensorlayerx, so mapping to onnx needs to be described in onnx format. If the linear operation is detected in the Layer, it cannot be directly mapped and needs to be split into multiplication and addition. Then, it needs to be mapped to onnx, use make_node('matmul') to perform multiplication, and then call make_node('add') to perform addition.

上述ONNX提供的'Transpose'、‘Conv’、‘matmul’、以及‘add’都是标准格式。The 'Transpose', 'Conv', 'matmul', and 'add' provided by ONNX mentioned above are all standard formats.

在一种可能的实现方式中,根据模型拓扑结构,对目标模型的每个层依序进行映射,以将模型节点映射至开放神经网络交换ONNX,包括以下步骤:In a possible implementation, each layer of the target model is sequentially mapped according to the model topology, so as to map the model nodes to the open neural network exchange ONNX, including the following steps:

获取模型拓扑结构;Get model topology;

根据模型拓扑结构确定对应的拓扑排序方式;Determine the corresponding topological sorting method according to the model topology;

根据拓扑排序方式,依序对每个层进行映射处理,得到对应的ONNX算子组合,以将模型节点映射至ONNX。According to the topological sorting method, each layer is mapped sequentially to obtain the corresponding ONNX operator combination to map the model nodes to ONNX.

步骤S204:根据将模型节点映射到ONNX的映射结果和多个关键函数,通过创建ONNX计算图和创建ONNX模型,生成包括ONNX模型的模型文件。Step S204: According to the mapping result of mapping model nodes to ONNX and multiple key functions, by creating an ONNX calculation graph and creating an ONNX model, a model file including the ONNX model is generated.

在一种可能的实现方式中,多个关键函数至少包括用于创建ONNX计算图的第一函数和用于创建ONNX模型的第二函数,根据将模型节点映射到ONNX的映射结果和多个关键函数,通过创建ONNX计算图和创建ONNX模型,生成包括ONNX模型的模型文件,包括以下步骤:In a possible implementation, the multiple key functions include at least a first function for creating an ONNX calculation graph and a second function for creating an ONNX model, according to the mapping result of mapping model nodes to ONNX and multiple key The function generates a model file including an ONNX model by creating an ONNX calculation graph and creating an ONNX model, including the following steps:

获取将模型节点映射到ONNX的映射结果;Obtain the mapping result of mapping model nodes to ONNX;

根据映射结果、第一函数和第二函数,创建对应的ONNX计算图和对应的ONNX模型;According to the mapping result, the first function and the second function, create the corresponding ONNX calculation graph and the corresponding ONNX model;

验证ONNX模型是否为有效模型,并在验证ONNX模型有效的情况下,生成包括ONNX模型的模型文件。Verify whether the ONNX model is a valid model, and generate a model file including the ONNX model if the ONNX model is verified to be valid.

在实际应用场景中,多个关键函数除了包括用于创建ONNX计算图的第一函数和用于创建ONNX模型的第二函数之外,还包括:用于校验模型是否有效的第三函数。In the actual application scenario, in addition to the first function for creating ONNX calculation graph and the second function for creating ONNX model, the multiple key functions also include: the third function for verifying whether the model is valid.

如图5所示,为具体应用场景下的ONNX构图和保存模型的示意图。得到如图4所示的将模型节点映射到ONNX的映射结果之后,利用ONNX自带的函数来完成ONNX构图和ONNX导出。上述过程使用make_graph(第一函数)、make_model(第二函数)函数来创建ONNX计算图,使用check_model(第三函数)检验模型,检验通过后,保存模型就得到了model.onnx文件。As shown in Figure 5, it is a schematic diagram of ONNX composition and saving models in specific application scenarios. After obtaining the mapping result of mapping model nodes to ONNX as shown in Figure 4, use the functions that come with ONNX to complete ONNX composition and ONNX export. The above process uses the make_graph (first function) and make_model (second function) functions to create the ONNX calculation graph, and uses check_model (the third function) to check the model. After the check is passed, save the model to get the model.onnx file.

在实际应用场景中,根据将模型节点映射到ONNX的映射结果和多个关键函数(第一函数和第二函数),创建ONNX计算图的过程如下所述:In the actual application scenario, according to the mapping result of mapping model nodes to ONNX and multiple key functions (the first function and the second function), the process of creating ONNX calculation graph is as follows:

如图3所示,模型拓扑结构a->[b,c]->[d]->[e]->[output];As shown in Figure 3, the model topology a->[b,c]->[d]->[e]->[output];

layer=linear、in_nodes=[input]、out_nodes=[layer1_node]、in_tensors=[a]、out_tensors=[b]、node_name=linear 1;layer=linear, in_nodes=[input], out_nodes=[layer1_node], in_tensors=[a], out_tensors=[b], node_name=linear1;

layer=linear、in_nodes=[input]、out_nodes=[layer2_node]、in_tensors=[a]、out_tensors=[c]、node_name=linear 2;layer=linear, in_nodes=[input], out_nodes=[layer2_node], in_tensors=[a], out_tensors=[c], node_name=linear2;

layer=linear、in_nodes=[layer1_node,layer2_node]、out_nodes=[layer3_node]、in_tensors=[b,c]、out_tensors=[d]、node_name=linear 3;layer=linear, in_nodes=[layer1_node, layer2_node], out_nodes=[layer3_node], in_tensors=[b,c], out_tensors=[d], node_name=linear3;

layer=linear、in_nodes=[layer3_node]、out_nodes=[layer4_node]、in_tensors=[d]、out_tensors=[output]、node_name=linear 4;layer=linear, in_nodes=[layer3_node], out_nodes=[layer4_node], in_tensors=[d], out_tensors=[output], node_name=linear4;

由此,模型拓扑结构可以描述为:input->[linear 1,linear 2]->[linear 3]->[linear4]->[output]。Thus, the model topology can be described as: input->[linear 1, linear 2]->[linear 3]->[linear4]->[output].

由此获知:输入给到线性层1和线性层2;线性层1和线性层2的结果给到线性层3;线性层3的结果给线性层4;最后输出。上述线性层都能用ONNX提供的统一格式来表示。From this we know: the input is given to linear layer 1 and linear layer 2; the results of linear layer 1 and linear layer 2 are given to linear layer 3; the results of linear layer 3 are given to linear layer 4; and finally output. The above linear layers can be expressed in a unified format provided by ONNX.

在一种可能的实现方式中,验证ONNX模型是否为有效模型,包括以下步骤:In a possible implementation, verifying whether the ONNX model is a valid model includes the following steps:

在从TensorLayerX所使用的每一层均能映射到ONNX统一格式的情况下,验证ONNX模型为有效模型。In the case that each layer used from TensorLayerX can be mapped to the ONNX unified format, verify that the ONNX model is a valid model.

在一种可能的实现方式中,验证ONNX模型是否为有效模型,还包括以下步骤:In a possible implementation, verifying whether the ONNX model is a valid model also includes the following steps:

在TensorLayerX中至少包括一个不能映射到ONNX统一格式的层的情况下,验证ONNX模型为无效模型。Validate an ONNX model as an invalid model when TensorLayerX includes at least one layer that cannot be mapped to the ONNX unified format.

在实际应用场景中,检验是通过check_model来检验,为ONNX所提供的一个函数。当从tensorlayerx所使用的Layer都能映射到ONNX统一格式时,则检验通过。In the actual application scenario, the check is checked by check_model, which is a function provided by ONNX. When the Layer used from tensorlayerx can be mapped to the ONNX unified format, the test is passed.

检验不通过的情况,例如,tensorlayerx中有一个layer叫Attention。由于Attention在ONNX无法像linear一样通过乘法加法组合表示映射到ONNX。那么,有Attention的layer所构建的网络就不能通过检验。If the test fails, for example, there is a layer called Attention in tensorlayerx. Because Attention cannot be mapped to ONNX through multiplication and addition in ONNX like linear. Then, the network constructed by the layer with Attention cannot pass the inspection.

本申请实施例提供的兼容多框架的深度学习模型导出至ONNX的方法,由于目标模型为深度学习统一编程框架模型、且目标模型能够兼容多个采用不同转换规则的框架,从而兼容多框架的深度学习模型导出至ONNX的方法,能够支持多种深度学习框架后端(例如,paddle、mindspore、tensorflow、pytorch),通过切换后端就能改变计算引擎,因此,用户在模型部署迁移上就不需要实现对应框架代码来进行部署,只需切换后端即可。采用本申请实施例的兼容多框架的深度学习模型导出至ONNX的方法,能够做到:针对采用不同转换规则的不同深度学习框架,模型部署及迁移的过程与所使用的计算后端无关,从而避免了由于算子接口差异所导致的需要设计多个映射方法的问题。此外,上述方法更具通用性。再者,上述方法提供了作为高层次深度学习库模型导出至ONNX的一种实现方式。The method of exporting the deep learning model compatible with multiple frameworks to ONNX provided by the embodiment of the present application, because the target model is a unified programming framework model for deep learning, and the target model can be compatible with multiple frameworks using different conversion rules, thus compatible with the depth of multiple frameworks The method of exporting the learning model to ONNX can support a variety of deep learning framework backends (for example, paddle, mindspore, tensorflow, pytorch), and the computing engine can be changed by switching the backend. Therefore, users do not need to deploy and migrate models. Implement the corresponding framework code for deployment, just switch the backend. Using the method of exporting the deep learning model compatible with multiple frameworks to ONNX in the embodiment of the present application can achieve: for different deep learning frameworks using different conversion rules, the process of model deployment and migration has nothing to do with the computing backend used, thus This avoids the need to design multiple mapping methods due to differences in operator interfaces. In addition, the above method is more general. Furthermore, the above method provides an implementation way to export to ONNX as a high-level deep learning library model.

在上述的实施例中,提供了一种兼容多框架的深度学习模型导出至ONNX的方法,与之相对应的,本申请还提供一种兼容多框架的深度学习模型导出至ONNX的装置。本申请实施例提供的兼容多框架的深度学习模型导出至ONNX的装置可以实施上述兼容多框架的深度学习模型导出至ONNX的方法,该兼容多框架的深度学习模型导出至ONNX的装置可以通过软件、硬件或软硬结合的方式来实现。例如,该兼容多框架的深度学习模型导出至ONNX的装置可以包括集成的或分开的功能模块或单元来执行上述各方法中的对应步骤。In the above embodiments, a method for exporting a multi-framework-compatible deep learning model to ONNX is provided. Correspondingly, the present application also provides a device for exporting a multi-framework-compatible deep learning model to ONNX. The device for exporting a multi-framework-compatible deep learning model to ONNX provided in the embodiment of the present application can implement the above-mentioned method for exporting a multi-framework-compatible deep learning model to ONNX, and the device for exporting a multi-framework-compatible deep learning model to ONNX can use software , hardware or a combination of hardware and software. For example, the device for exporting the multi-framework-compatible deep learning model to ONNX may include integrated or separate functional modules or units to perform corresponding steps in the above-mentioned methods.

请参考图6,其示出了本申请的一些实施方式所提供的一种兼容多框架的深度学习模型导出至ONNX的装置的示意图。由于装置实施例基本相似于方法实施例,所以描述得比较简单,相关之处参见方法实施例的部分说明即可。下述描述的装置实施例仅仅是示意性的。Please refer to FIG. 6 , which shows a schematic diagram of a device for exporting a multi-framework compatible deep learning model to ONNX provided by some embodiments of the present application. Since the device embodiment is basically similar to the method embodiment, the description is relatively simple, and for relevant parts, refer to the part of the description of the method embodiment. The device embodiments described below are illustrative only.

如图6所示,兼容多框架的深度学习模型导出至ONNX的装置600可以包括:As shown in Figure 6, the device 600 for exporting the deep learning model compatible with multiple frameworks to ONNX may include:

获取模块601,用于获取目标模型的每个层的层信息,以及广度优先搜索规则,目标模型为深度学习统一编程框架模型,目标模型能够兼容多个采用不同转换规则的框架;The obtaining module 601 is used to obtain the layer information of each layer of the target model and the breadth-first search rule. The target model is a deep learning unified programming framework model, and the target model can be compatible with multiple frameworks using different conversion rules;

遍历模块602,用于根据目标模型的每个层的层信息,以及广度优先遍历规则,对目标深度学习模型的每个层依序进行层遍历,得到对应的模型拓扑结构;The traversal module 602 is used to perform layer traversal on each layer of the target deep learning model in order according to the layer information of each layer of the target model and the breadth-first traversal rule to obtain the corresponding model topology;

映射模块603,用于根据模型拓扑结构,对目标模型的每个层依序进行映射,以将模型节点映射至开放神经网络交换ONNX;The mapping module 603 is used to map each layer of the target model in sequence according to the model topology, so as to map the model nodes to the open neural network exchange ONNX;

生成模块604,用于根据将模型节点映射到ONNX的映射结果和多个关键函数,通过创建ONNX计算图和创建ONNX模型,生成包括ONNX模型的模型文件。The generating module 604 is configured to generate a model file including an ONNX model by creating an ONNX calculation graph and creating an ONNX model according to the mapping result of mapping model nodes to ONNX and multiple key functions.

在本申请实施例的一些实施方式中,获取模块601具体用于:In some implementations of the embodiments of this application, the acquisition module 601 is specifically used to:

获取模块节点的各项属性信息,模块节点的各项属性信息包括神经网络层、当前层神经网络层输入节点、当前层神经网络层输出节点、当前层神经网络层输入值、当前层神经网络层输出值、以及当前网络层节点名称;Obtain the attribute information of the module node. The attribute information of the module node includes the neural network layer, the input node of the neural network layer of the current layer, the output node of the neural network layer of the current layer, the input value of the neural network layer of the current layer, the neural network layer of the current layer Output value, and the name of the current network layer node;

通过调用模块节点执行一次前向传播,获取目标模型的每个层的层信息,目标模型的每个层的层信息包括目标神经网络层、任意一层作为当前层所对应当前层神经网络层输入节点、任意一层作为当前层所对应的当前层神经网络层输出节点、任意一层作为当前层所对应的当前层神经网络层输入值、任意一层作为当前层所对应的当前层神经网络层输出值和任意一层作为当前层所对应的当前网络层节点名称。By calling the module node to perform a forward propagation, the layer information of each layer of the target model is obtained. The layer information of each layer of the target model includes the target neural network layer, and any layer is used as the input of the current layer neural network layer corresponding to the current layer. Node, any layer as the current layer neural network layer output node corresponding to the current layer, any layer as the current layer neural network layer input value corresponding to the current layer, any layer as the current layer neural network layer corresponding to the current layer The output value and any layer are used as the current network layer node name corresponding to the current layer.

在本申请实施例的一些实施方式中,映射模块603具体用于:In some implementations of the embodiments of the present application, the mapping module 603 is specifically used to:

获取模型拓扑结构;Get model topology;

根据模型拓扑结构确定对应的拓扑排序方式;Determine the corresponding topological sorting method according to the model topology;

根据拓扑排序方式,依序对每个层进行映射处理,得到对应的ONNX算子组合,以将模型节点映射至ONNX。According to the topological sorting method, each layer is mapped sequentially to obtain the corresponding ONNX operator combination to map the model nodes to ONNX.

在本申请实施例的一些实施方式中,多个关键函数至少包括用于创建ONNX计算图的第一函数和用于创建ONNX模型的第二函数,生成模块604用于:In some implementations of the embodiments of the present application, the multiple key functions include at least a first function for creating an ONNX calculation graph and a second function for creating an ONNX model, and the generation module 604 is used for:

获取将模型节点映射到ONNX的映射结果;Obtain the mapping result of mapping model nodes to ONNX;

根据映射结果、第一函数和第二函数,创建对应的ONNX计算图和对应的ONNX模型;According to the mapping result, the first function and the second function, create the corresponding ONNX calculation graph and the corresponding ONNX model;

验证ONNX模型是否为有效模型,并在验证ONNX模型有效的情况下,生成包括ONNX模型的模型文件。Verify whether the ONNX model is a valid model, and generate a model file including the ONNX model if the ONNX model is verified to be valid.

在本申请实施例的一些实施方式中,生成模块604具体用于:In some implementations of the embodiments of the present application, the generation module 604 is specifically used to:

在从TensorLayerX所使用的每一层均能映射到ONNX统一格式的情况下,验证ONNX模型为有效模型。In the case that each layer used from TensorLayerX can be mapped to the ONNX unified format, verify that the ONNX model is a valid model.

在本申请实施例的一些实施方式中,生成模块604具体还用于:In some implementations of the embodiments of the present application, the generating module 604 is specifically further configured to:

在TensorLayerX中至少包括一个不能映射到ONNX统一格式的层的情况下,验证ONNX模型为无效模型。Validate an ONNX model as an invalid model when TensorLayerX includes at least one layer that cannot be mapped to the ONNX unified format.

在本申请实施例的一些实施方式中,目标模型能够兼容的多个采用不同转换规则的框架包括以下至少一项:TneosFlow、MindSpore、PaddlePaddle和PyTorch。In some implementations of the embodiments of the present application, the multiple frameworks using different conversion rules that the target model is compatible with include at least one of the following: TneosFlow, MindSpore, PaddlePaddle, and PyTorch.

在本申请实施例的一些实施方式中本申请实施例提供的兼容多框架的深度学习模型导出至ONNX的装置600,与本申请前述实施例提供的兼容多框架的深度学习模型导出至ONNX的方法出于相同的发明构思,具有相同的有益效果。In some implementations of the embodiments of the present application, the device 600 for exporting the multi-framework-compatible deep learning model to ONNX provided by the embodiment of the present application is the same as the method for exporting the multi-framework-compatible deep learning model to ONNX provided by the previous embodiments of the present application Based on the same inventive concept, they have the same beneficial effects.

本申请实施方式还提供一种与前述实施方式所提供的兼容多框架的深度学习模型导出至ONNX的装置对应的电子设备,电子设备可以是用于服务端的电子设备,例如服务器,包括独立的服务器和分布式服务器集群等,以执行上述兼容多框架的深度学习模型导出至ONNX的方法;电子设备也可以是用于客户端的电子设备,例如手机、笔记本电脑、平板电脑、台式机电脑等,以执行上述兼容多框架的深度学习模型导出至ONNX的方法。The embodiment of the present application also provides an electronic device corresponding to the device for exporting the multi-framework-compatible deep learning model to ONNX provided in the foregoing embodiment. The electronic device can be an electronic device for the server, such as a server, including an independent server And distributed server clusters, etc., to implement the above method of exporting the deep learning model compatible with multiple frameworks to ONNX; the electronic device can also be an electronic device for the client, such as a mobile phone, a notebook computer, a tablet computer, a desktop computer, etc. Execute the method of exporting the above-mentioned deep learning model compatible with multiple frameworks to ONNX.

请参考图7,其示出了本申请的一些实施方式所提供的一种电子设备的示意图。如图7所示,电子设备70包括:处理器700,存储器701,总线702和通信接口703,处理器700、通信接口703和存储器701通过总线702连接;存储器701中存储有可在处理器700上运行的计算机程序,处理器700运行计算机程序时执行本申请前述的兼容多框架的深度学习模型导出至ONNX的方法。Please refer to FIG. 7 , which shows a schematic diagram of an electronic device provided by some embodiments of the present application. As shown in Figure 7, electronic equipment 70 comprises: processor 700, memory 701, bus 702 and communication interface 703, processor 700, communication interface 703 and memory 701 are connected by bus 702; When the processor 700 runs the computer program, it executes the method for exporting the multi-framework-compatible deep learning model to ONNX described above in this application.

其中,存储器701可能包含高速随机存取存储器(RAM:Random Access Memory),也可能还包括非不稳定的存储器(non-volatile memory),例如至少一个磁盘存储器。通过至少一个通信接口703(可以是有线或者无线)实现该系统网元与至少一个其他网元之间的通信连接,可以使用互联网、广域网、本地网、城域网等。Wherein, the memory 701 may include a high-speed random access memory (RAM: Random Access Memory), and may also include a non-volatile memory (non-volatile memory), such as at least one disk memory. The communication connection between the system network element and at least one other network element is realized through at least one communication interface 703 (which may be wired or wireless), and the Internet, wide area network, local network, metropolitan area network, etc. can be used.

总线702可以是ISA总线、PCI总线或EISA总线等。总线可以分为地址总线、数据总线、控制总线等。其中,存储器701用于存储程序,处理器700在接收到执行指令后,执行所述程序,前述本申请实施例任一实施方式揭示的兼容多框架的深度学习模型导出至ONNX的方法可以应用于处理器700中,或者由处理器700实现。The bus 702 may be an ISA bus, a PCI bus, or an EISA bus, etc. The bus can be divided into address bus, data bus, control bus and so on. Wherein, the memory 701 is used to store the program, and the processor 700 executes the program after receiving the execution instruction. The method for exporting the compatible multi-framework deep learning model to ONNX disclosed in any implementation mode of the foregoing embodiments of the present application can be applied to In the processor 700, or implemented by the processor 700.

处理器700可能是一种集成电路芯片,具有信号的处理能力。在实现过程中,上述方法的各步骤可以通过处理器700中的硬件的集成逻辑电路或者软件形式的指令完成。上述的处理器700可以是通用处理器,包括中央处理器(Central Processing Unit,简称CPU)、网络处理器(Network Processor,简称NP)等;还可以是数字信号处理器(DSP)、专用集成电路(ASIC)、现成可编程门阵列(FPGA)或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件。可以实现或者执行本申请实施例中的公开的各方法、步骤及逻辑框图。通用处理器可以是微处理器或者该处理器也可以是任何常规的处理器等。结合本申请实施例所公开的方法的步骤可以直接体现为硬件译码处理器执行完成,或者用译码处理器中的硬件及软件模块组合执行完成。软件模块可以位于随机存储器,闪存、只读存储器,可编程只读存储器或者电可擦写可编程存储器、寄存器等本领域成熟的存储介质中。该存储介质位于存储器701,处理器700读取存储器701中的信息,结合其硬件完成上述方法的步骤。The processor 700 may be an integrated circuit chip with signal processing capability. In the implementation process, each step of the above method may be implemented by an integrated logic circuit of hardware in the processor 700 or an instruction in the form of software. The above-mentioned processor 700 can be a general-purpose processor, including a central processing unit (Central Processing Unit, referred to as CPU), a network processor (Network Processor, referred to as NP), etc.; it can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), off-the-shelf programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components. Various methods, steps, and logic block diagrams disclosed in the embodiments of the present application may be implemented or executed. A general-purpose processor may be a microprocessor, or the processor may be any conventional processor, or the like. The steps of the method disclosed in connection with the embodiments of the present application may be directly implemented by a hardware decoding processor, or implemented by a combination of hardware and software modules in the decoding processor. The software module can be located in a mature storage medium in the field such as random access memory, flash memory, read-only memory, programmable read-only memory or electrically erasable programmable memory, register. The storage medium is located in the memory 701, and the processor 700 reads the information in the memory 701, and completes the steps of the above method in combination with its hardware.

本申请实施例提供的电子设备与本申请实施例提供的兼容多框架的深度学习模型导出至ONNX的方法出于相同的发明构思,具有与其采用、运行或实现的方法相同的有益效果。The electronic device provided by the embodiment of the present application is based on the same inventive concept as the method for exporting the multi-framework-compatible deep learning model to ONNX provided by the embodiment of the present application, and has the same beneficial effect as the method adopted, operated or implemented.

本申请实施方式还提供一种与前述实施方式所提供的兼容多框架的深度学习模型导出至ONNX的方法对应的计算机可读介质,请参考图8,其示出的计算机可读存储介质为光盘80,其上存储有计算机程序(即程序产品),所述计算机程序在被处理器运行时,会执行前述兼容多框架的深度学习模型导出至ONNX的方法。The embodiment of the present application also provides a computer-readable medium corresponding to the method of exporting the multi-framework-compatible deep learning model to ONNX provided in the foregoing embodiment. Please refer to FIG. 8, the computer-readable storage medium shown in it is an optical disc 80, a computer program (ie, a program product) is stored thereon, and when the computer program is run by the processor, it will execute the method for exporting the aforementioned deep learning model compatible with multiple frameworks to ONNX.

需要说明的是,所述计算机可读存储介质的例子还可以包括,但不限于相变内存(PRAM)、静态随机存取存储器(SRAM)、动态随机存取存储器(DRAM)、其他类型的随机存取存储器(RAM)、只读存储器(ROM)、电可擦除可编程只读存储器(EEPROM)、快闪记忆体或其他光学、磁性存储介质,在此不再一一赘述。It should be noted that examples of the computer-readable storage medium may also include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random Access memory (RAM), read only memory (ROM), electrically erasable programmable read only memory (EEPROM), flash memory or other optical and magnetic storage media will not be repeated here.

本申请的上述实施例提供的计算机可读存储介质与本申请实施例提供的兼容多框架的深度学习模型导出至ONNX的方法出于相同的发明构思,具有与其存储的应用程序所采用、运行或实现的方法相同的有益效果。The computer-readable storage medium provided by the above-mentioned embodiments of the present application is based on the same inventive concept as the method for exporting the deep learning model compatible with multiple frameworks to ONNX provided by the embodiments of the present application. The method for realizing the same beneficial effect.

需要说明的是,附图中的流程图和框图显示了根据本申请的多个实施例的系统、方法和计算机程序产品的可能实现的体系架构、功能和操作。在这点上,流程图或框图中的每个方框可以代表一个模块、程序段或代码的一部分,所述模块、程序段或代码的一部分包含一个或多个用于实现规定的逻辑功能的可执行指令。也应当注意,在有些作为替换的实现中,方框中所标注的功能也可以以不同于附图中所标注的顺序发生。例如,两个连续的方框实际上可以基本并行地执行,它们有时也可以按相反的顺序执行,这依所涉及的功能而定。也要注意的是,框图和/或流程图中的每个方框、以及框图和/或流程图中的方框的组合,可以用执行规定的功能或动作的专用的基于硬件的系统来实现,或者可以用专用硬件与计算机指令的组合来实现。It should be noted that the flowcharts and block diagrams in the accompanying drawings show the architecture, functions and operations of possible implementations of systems, methods and computer program products according to multiple embodiments of the present application. In this regard, each block in a flowchart or block diagram may represent a module, program segment, or part of code that includes one or more Executable instructions. It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks in succession may, in fact, be executed substantially concurrently, or they may sometimes be executed in the reverse order, depending upon the functionality involved. It should also be noted that each block of the block diagrams and/or flowchart illustrations, and combinations of blocks in the block diagrams and/or flowchart illustrations, can be implemented by a dedicated hardware-based system that performs the specified function or action , or may be implemented by a combination of dedicated hardware and computer instructions.

所属领域的技术人员可以清楚地了解到,为描述的方便和简洁,上述描述的系统、装置和单元的具体工作过程,可以参考前述方法实施例中的对应过程,在此不再赘述。Those skilled in the art can clearly understand that for the convenience and brevity of the description, the specific working process of the above-described system, device and unit can refer to the corresponding process in the foregoing method embodiment, which will not be repeated here.

在本申请所提供的几个实施例中,应该理解到,所揭露的装置和方法,可以通过其它的方式实现。以上所描述的装置实施例仅仅是示意性的,例如,所述单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,又例如,多个单元或组件可以结合或者可以集成到另一个系统,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通信连接可以是通过一些通信接口,装置或单元的间接耦合或通信连接,可以是电性,机械或其它的形式。In the several embodiments provided in this application, it should be understood that the disclosed devices and methods may be implemented in other ways. The device embodiments described above are only illustrative. For example, the division of the units is only a logical function division. In actual implementation, there may be other division methods. For example, multiple units or components can be combined or May be integrated into another system, or some features may be ignored, or not implemented. In another point, the mutual coupling or direct coupling or communication connection shown or discussed may be through some communication interfaces, and the indirect coupling or communication connection of devices or units may be in electrical, mechanical or other forms.

所述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部单元来实现本实施例方案的目的。The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place, or may be distributed to multiple network units. Part or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.

另外,在本申请各个实施例中的各功能单元可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, each unit may exist separately physically, or two or more units may be integrated into one unit.

所述功能如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储介质中。基于这样的理解,本申请的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质中,包括若干指令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)执行本申请各个实施例所述方法的全部或部分步骤。而前述的存储介质包括:U盘、移动硬盘、只读存储器(ROM,Read-Only Memory)、随机存取存储器(RAM,Random Access Memory)、磁碟或者光盘等各种可以存储程序代码的介质。If the functions described above are realized in the form of software function units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art or the part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including Several instructions are used to make a computer device (which may be a personal computer, a server, or a network device, etc.) execute all or part of the steps of the methods described in the various embodiments of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), magnetic disk or optical disk and other media that can store program codes. .

最后应说明的是:以上各实施例仅用以说明本申请的技术方案,而非对其限制;尽管参照前述各实施例对本申请进行了详细的说明,本领域的普通技术人员应当理解:其依然可以对前述各实施例所记载的技术方案进行修改,或者对其中部分或者全部技术特征进行等同替换;而这些修改或者替换,并不使相应技术方案的本质脱离本申请各实施例技术方案的范围,其均应涵盖在本申请的权利要求和说明书的范围当中。Finally, it should be noted that: the above embodiments are only used to illustrate the technical solutions of the present application, rather than limiting them; although the application has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that: It is still possible to modify the technical solutions described in the foregoing embodiments, or perform equivalent replacements for some or all of the technical features; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the technical solutions of the various embodiments of the present application. All of them should be covered by the scope of the claims and description of the present application.

Claims (10)

1. A method of multi-framework compatible deep learning model export to ONNX, the method comprising:
acquiring layer information of each layer of a target model and breadth-first search rules, wherein the target model is a deep learning unified programming framework model, and can be compatible with a plurality of frameworks adopting different conversion rules;
according to the layer information of each layer of the target model and breadth-first traversing rules, sequentially traversing each layer of the target deep learning model to obtain a corresponding model topological structure;
according to the model topological structure, mapping each layer of the target model in sequence to map model nodes to an open neural network exchange ONNX;
and generating a model file comprising the ONNX model by creating an ONNX calculation graph and an ONNX model according to a mapping result of mapping the model node to the ONNX and a plurality of key functions.
2. The method of claim 1, wherein the obtaining layer information for each layer of the object model comprises:
acquiring various attribute information of a module node, wherein the various attribute information of the module node comprises a neural network layer, a current layer neural network layer input node, a current layer neural network layer output node, a current layer neural network layer input value, a current layer neural network layer output value and a current network layer node name;
And carrying out forward propagation once by calling the module node to acquire layer information of each layer of the target model, wherein the layer information of each layer of the target model comprises a target neural network layer, any layer serving as a current layer neural network layer input node corresponding to the current layer, any layer serving as a current layer neural network layer output node corresponding to the current layer, any layer serving as a current layer neural network layer input value corresponding to the current layer, any layer serving as a current layer neural network layer output value corresponding to the current layer and any layer serving as a current network layer node name corresponding to the current layer.
3. The method of claim 1, wherein the mapping each layer of the target model in order to map model nodes to open neural network exchanges ONNX according to the model topology comprises:
acquiring the model topological structure;
determining a corresponding topology ordering mode according to the model topology structure;
and according to the topological ordering mode, mapping each layer sequentially to obtain a corresponding ONNX operator combination so as to map the model nodes to the ONNX.
4. The method of claim 1, wherein the plurality of key functions includes at least a first function for creating an ONNX computation graph and a second function for creating an ONNX model, wherein the generating a model file including the ONNX model by creating the ONNX computation graph and creating the ONNX model based on a mapping result of mapping model nodes to the ONNX and the plurality of key functions comprises:
Obtaining the mapping result of mapping the model node to ONNX;
creating a corresponding ONNX calculation graph and a corresponding ONNX model according to the mapping result, the first function and the second function;
and verifying whether the ONNX model is a valid model, and generating a model file comprising the ONNX model under the condition that the ONNX model is verified to be valid.
5. The method of claim 4, wherein the verifying whether the ONNX model is a valid model comprises:
in case each layer used from TensorLayerX can be mapped to the ONNX unified format, the ONNX model is verified as a valid model.
6. The method of claim 5, wherein the verifying whether the ONNX model is a valid model further comprises:
and under the condition that the TensorLayerX at least comprises one layer which cannot be mapped to the ONNX unified format, verifying the ONNX model as an invalid model.
7. The method of claim 1, wherein the step of determining the position of the substrate comprises,
the multiple frameworks which can be compatible with the target model and adopt different conversion rules comprise at least one of the following:
TneosFlow, mindSpore, paddlePaddle and pyrerch.
8. An apparatus for multi-framework compatible deep learning model export to ONNX, the apparatus comprising:
the system comprises an acquisition module, a breadth-first search module and a breadth-first search module, wherein the acquisition module is used for acquiring layer information of each layer of a target model, the target model is a deep learning unified programming framework model, and the target model can be compatible with a plurality of frameworks adopting different conversion rules;
the traversing module is used for sequentially traversing each layer of the target deep learning model according to the layer information of each layer of the target model and breadth-first traversing rules to obtain a corresponding model topological structure;
the mapping module is used for sequentially mapping each layer of the target model according to the model topological structure so as to map model nodes to an open neural network exchange ONNX;
and the generating module is used for generating a model file comprising the ONNX model by creating an ONNX calculation graph and an ONNX model according to the mapping result of mapping the model node to the ONNX and a plurality of key functions.
9. A computer readable storage medium, characterized in that the computer readable storage medium stores a computer program for executing the method of any of the preceding claims 1 to 7.
10. An electronic device, the electronic device comprising:
a processor;
a memory for storing the processor-executable instructions;
the processor being configured to read the executable instructions from the memory and execute the executable instructions to implement the method of any one of the preceding claims 1 to 7.
CN202310473450.1A 2023-04-27 2023-04-27 A method and device for exporting a deep learning model compatible with multiple frameworks to ONNX Pending CN116560674A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310473450.1A CN116560674A (en) 2023-04-27 2023-04-27 A method and device for exporting a deep learning model compatible with multiple frameworks to ONNX

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310473450.1A CN116560674A (en) 2023-04-27 2023-04-27 A method and device for exporting a deep learning model compatible with multiple frameworks to ONNX

Publications (1)

Publication Number Publication Date
CN116560674A true CN116560674A (en) 2023-08-08

Family

ID=87495808

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310473450.1A Pending CN116560674A (en) 2023-04-27 2023-04-27 A method and device for exporting a deep learning model compatible with multiple frameworks to ONNX

Country Status (1)

Country Link
CN (1) CN116560674A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN119337922A (en) * 2024-11-01 2025-01-21 西安电子科技大学 Neural network model conversion method based on MXNet and ONNX

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN119337922A (en) * 2024-11-01 2025-01-21 西安电子科技大学 Neural network model conversion method based on MXNet and ONNX

Similar Documents

Publication Publication Date Title
CN113255258B (en) Logic synthesis method and device, electronic equipment and storage medium
US20210365253A1 (en) Heterogeneity-agnostic and topology-agnostic data plane programming
CN111249736B (en) Code processing method and device
CN106681903B (en) Method and device for generating test case
CN116341441B (en) Method for optimizing digital logic circuit and related equipment
CN113760751B (en) Method for generating test case, electronic device and storage medium
CN113918635A (en) Interface data format conversion method and device
CN113568598B (en) Yosys-based FPGA logic synthesis method and device for realizing summation operation
CN111399911B (en) A kind of artificial intelligence development method and device based on multi-core heterogeneous computing
CN115934346B (en) Automatic detection methods, devices, electronic equipment and media for operators
CN116089275A (en) Database testing method, database system, electronic equipment and storage medium
CN116107669A (en) Operator registration method, device and equipment of deep learning framework and storage medium
CN116560674A (en) A method and device for exporting a deep learning model compatible with multiple frameworks to ONNX
CN114692532A (en) Chip system integration method and device and computer readable storage medium
CN116341429B (en) Logical rewriting method and related equipment for logical network
CN116048731A (en) Code processing method, device, electronic device and storage medium
CN114595664A (en) Method, device and electronic device for generating form
CN114417754B (en) Formalized identification method of combinational logic unit and related equipment
CN110244953A (en) Interval Analysis Method and Device of Java Program
CN116029672A (en) Process development system, equipment and storage medium
CN116150527A (en) Component style isolation method, device, equipment, storage medium and product
CN110647568B (en) Method and device for converting graph database data into programming language data
CN113672518B (en) Test case construction method and related equipment
CN115470737B (en) Method for generating data flow graph, electronic equipment and storage medium
CN120822470A (en) Combinational logic circuit optimization method, device, equipment, medium and program product

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination