Model platformization processing method and device

By obtaining and quantifying the node parameters of the model and generating compiled files with preset compilation templates, the problem that the hardware platform cannot load the AI model is solved, and the model is efficiently deployed and operated on hardware platforms such as MCU.

CN120373490APending Publication Date: 2025-07-25QINGDAO HAIER AIR CONDITIONING ELECTRONICS CO LTD +2
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510005070.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-01-02
Publication Date
2025-07-25

AI Technical Summary

Technical Problem

Due to the limitations of hardware platforms such as embedded chip microcontroller unit (MCU) hardware architecture and operating environment, it is impossible to directly parse and load AI models called or generated by PC or AI custom chips, these hardware platforms cannot apply AI models to actual task processing.

Method used

By obtaining the node parameters of the model to be loaded, performing quantitative processing, and combining the preset compilation template to generate the compiled file and loading it on the preset hardware platform to realize the localization of the model.

Benefits of technology

It improves the deployment efficiency and stability of the model on different hardware platforms, reduces the probability of errors during the deployment process, and enables the model to run smoothly and efficiently on the target hardware platform.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120373490A_ABST
    Figure CN120373490A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of computers, and provides a model platformization processing method and device.The method comprises the steps that node parameters of a to-be-loaded model are obtained, and the node parameters are used for representing parameters of a basic operation unit of the to-be-loaded model; quantizing the node parameters to obtain quantized parameters; according to the quantization parameters, generating a compiling file in combination with a preset compiling template, and loading the compiling file to a preset hardware platform to obtain a localized model; wherein the preset compiling template is firstly constructed based on a programming language determined by a preset hardware platform. According to the method, the defect that in the prior art, the AI model cannot be analyzed and loaded due to limitation of a hardware architecture and an operation environment is overcome, the model is gradually converted from the original state and successfully operates on the target hardware platform, and the whole model localization process is smoother and more efficient.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technologies, and in particular, to a method and device for model platform processing. Background Art

[0002] In today's era, model technologies have shown a rapid development trend. As a classic machine learning library, Sklearn is equipped with a large number of algorithms and tools for diverse machine learning tasks such as classification, regression, and clustering. These algorithms and tools have undergone long-term practical tests and optimizations, and have good stability and reliability. With its simple and easy-to-use interface design, Sklearn provides great convenience for PC computers or other AI custom chips dedicated to AI models, enabling the PC side or AI custom chips to easily call the corresponding AI models from it and quickly build an efficient machine learning application system, thereby efficiently coping with various complex data processing and analysis scenarios, and strongly promoting the wide application and in-depth development of machine learning technologies in practical fields.

[0003] Due to the limitations of some hardware platforms, such as the hardware architecture and operating environment of the embedded chip microcontroller unit (MCU for short), it is impossible to recognize the parameter and structure information of the AI model. Therefore, these hardware platforms cannot directly parse and load the AI models called or generated by the PC side or AI custom chips, making it basically impossible for the hardware platforms to apply the AI models to actual task processing. Summary of the Invention

[0004] The present invention provides a method and device for model platform processing to solve the defect in the prior art that it is impossible to parse and load the AI model due to the limitations of the hardware architecture and operating environment, and to realize the gradual conversion of the model from the original state and successfully run on the target hardware platform, making the entire process of model localization smoother and more efficient.

[0005] The present invention provides a method for model platform processing, including: obtaining the node parameters of the model to be loaded, where the node parameters are used to represent the parameters of the basic operation units of the model to be loaded; quantifying the node parameters to obtain quantization parameters; generating a compilation file according to the quantization parameters in combination with a preset compilation template, and loading the compilation file to a preset hardware platform to obtain a localized model; where the preset compilation template is constructed in advance based on a programming language determined by the preset hardware platform.

[0006] It should be noted that by obtaining the node parameters of the model to be loaded and focusing on the parameters representing the basic operation units of the model, the core components of the model can be accurately grasped, so as to quantize it, convert high-precision parameters into low-precision representations, facilitate the improvement of storage resources and computing performance, enable the model to better adapt to the resource conditions of different hardware platforms on the premise of meeting the basic accuracy requirements of the business, and further generate and load a compilation file according to the quantization parameters in combination with a preset compilation template, making the deployment of the model on different hardware platforms more standardized and convenient, reducing the error probability during the deployment process, improving the deployment efficiency, realizing the gradual conversion of the model from the original state and successfully running on the target hardware platform, and making the entire process of model localization smoother and more efficient.

[0007] According to the model platform processing method provided by the present invention, obtaining the node parameters of the model to be loaded includes: obtaining the model to be loaded, where the model to be loaded is a model previously converted based on a preset model format; according to the model to be loaded, searching a model structure knowledge base to obtain the nodes of the model to be loaded; wherein, the model structure knowledge base is previously constructed based on the model structure and the nodes corresponding to the model structure; according to the nodes of the model to be loaded, disassembling the model to be loaded to obtain the node parameters.

[0008] It should be noted that by searching the pre-constructed model structure knowledge base, the corresponding model structure and the corresponding node information can be quickly matched according to the model to be loaded, and further, according to the nodes obtained by the search, the model to be loaded is disassembled, so as to accurately obtain the parameters of each node, effectively avoiding situations such as omissions and misjudgments that may occur in manual disassembly or general parsing methods, ensuring that the obtained node parameters are complete and accurate, and providing a reliable data basis for the further quantization processing of the subsequent model.

[0009] According to the model platform processing method provided by the present invention, obtaining the model to be loaded includes: obtaining a trained machine learning model instance from the machine learning library Sklearn; based on a preset model format, performing model conversion on the machine learning instance to obtain the model to be loaded.

[0010] It should be noted that by obtaining the trained machine learning model instance from Sklearn, a variety of model types in Sklearn can be utilized, such as classification models (decision tree classifier, random forest classifier, etc.), regression models (linear regression, ridge regression, etc.), and clustering models (K-Means, etc.), which provides diverse choices for subsequent model applications, ensures that different task requirements are met, and further converts the model through a preset model format to convert the Sklearn model into a format that better meets the requirements of specific application scenarios or platforms, realizes the reconstruction of the AI model, better adapts to different deployment environments and application requirements, and broadens the scope of use of the model.

[0011] According to the model platform processing method provided by the present invention, after obtaining the node parameters of the model to be loaded, it includes: based on the number of nodes of the model to be loaded corresponding to the node parameters being greater than 1, determining whether there are nodes with the same structure among the nodes of the model to be loaded; based on there being nodes with the same structure among the nodes of the model to be loaded, determining whether the nodes with the same structure are duplicate nodes. If they are duplicate nodes, then retain the node parameters corresponding to any one of the duplicate nodes and share the retained node parameters to the node parameters corresponding to other duplicate nodes; otherwise, merge the nodes with the same structure and the corresponding node parameters.

[0012] It should be noted that when there are nodes with the same structure in the model to be loaded, further determine whether there are duplicate nodes to determine whether to share the node parameters of the duplicate nodes or merge the nodes with the same structure and their parameters, so as to effectively reduce the storage amount of node parameters, reduce duplicate or redundant node parameters, reduce memory occupancy, and avoid problems such as performance degradation or even program crashes caused by memory tension, enabling the model to run more stably and smoothly on various platforms.

[0013] According to the model platform processing method provided by the present invention, the node parameters include the input node parameters and output node parameters of the corresponding node. After obtaining the node parameters of the model to be loaded, it further includes: based on the number of nodes of the model to be loaded corresponding to the node parameters being greater than 1, determining whether the output node parameters of a node are the input node parameters of another node. If so, then merge the corresponding node and the node parameters of the corresponding node; otherwise, do not merge.

[0014] It should be noted that when the output node parameter of a node is exactly the input node parameter of another node, it means that there is a certain degree of information overlap and redundant transmission between these two nodes. Therefore, by identifying and merging the nodes and their parameters with input-output associations, the nodes with tight input-output dependencies are integrated together to avoid redundant parameter transmission, reduce unnecessary intermediate data storage and operations, simplify the data processing flow involved in the model, improve the overall compactness of the model, reduce the number of nodes and the complexity of the connections between them, and simplify the topological structure of the model to be loaded.

[0015] According to a model platform processing method provided by the present invention, after quantifying the node parameters, it further includes: determining whether there is a coefficient parameter in the node parameters; based on the existence of the coefficient parameter in the node parameters, determining the proportion of the coefficient parameter in the node parameters; determining whether the proportion is lower than a preset proportion threshold, and if the proportion is lower than the preset proportion threshold, deleting the corresponding coefficient parameter; otherwise, retaining the corresponding coefficient parameter.

[0016] It should be noted that by judging the proportion of the coefficient parameter in the node parameters, the coefficient parameters with proportions lower than the preset proportion threshold are deleted, avoiding calculation operations on these relatively unimportant coefficients, simplifying the calculation process, reducing the amount of calculation, enabling a significant improvement in the operation speed, and being able to reduce the storage space occupied by the model parameters, making the size of the model meet the capacity of the hardware platform, ensuring that the model can run on a hardware platform with a small capacity, and optimizing the allocation of hardware resources to improve the efficiency of the entire model operation.

[0017] According to a model platform processing method provided by the present invention, quantifying the node parameters to obtain quantization parameters includes: according to the node of the model to be loaded corresponding to the node parameters, searching the quantization knowledge base to determine the quantization strategy for the corresponding node; wherein, the quantization knowledge base is constructed in advance based on each node of the model and the quantization strategy corresponding to each node, and the quantization strategy is configured in advance for the corresponding model node and includes at least one quantization method; quantifying the corresponding node parameters according to the quantization strategy of the node to obtain the corresponding quantization parameters.

[0018] It should be noted that by searching the quantization knowledge base according to the node of the model to be loaded corresponding to the node parameters, a pre-configured quantization strategy can be accurately matched for each specific node, thereby ensuring that each node adopts the quantization strategy most suitable for its own characteristics, and then performing more accurate quantization operations, minimizing the impact of quantization on the model performance, saving a large amount of time and effort, and at the same time ensuring the reliability and quality of the quantization process. In addition, a quantization knowledge base is constructed based on each node of the model and the corresponding quantization strategy to centrally store all model nodes and their corresponding quantization strategies, facilitating unified management and maintenance.

[0019] The present invention also provides a model platform processing device, including: a parameter acquisition module, which acquires node parameters of a model to be loaded, and the node parameters are used to characterize parameters of basic operation units of the model to be loaded; a quantization module, which quantizes the node parameters to obtain quantization parameters; a model processing module, which generates a compilation file according to the quantization parameters and in combination with a preset compilation template, and loads the compilation file to a preset hardware platform to obtain a localized model; wherein the preset compilation template is constructed in advance based on a programming language determined for the preset hardware platform.

[0020] It should be noted that by acquiring the node parameters of the model to be loaded through the parameter acquisition module and focusing on the parameters characterizing the basic operation units of the model, the core components of the model can be accurately grasped, so that the quantization module can quantize them, thereby converting high-precision parameters into low-precision representations, which is convenient for improving storage resources and computing performance. This enables the model to better adapt to the resource conditions of different hardware platforms on the premise of meeting the basic accuracy requirements of the business. Further, through the model processing module, according to the quantization parameters and in combination with the preset compilation template, a compilation file is generated and loaded, making the deployment of models on different hardware platforms more standardized and convenient, reducing the error probability during the deployment process, improving the deployment efficiency, and realizing the gradual conversion of the model from the original state and successfully running on the target hardware platform, making the entire process of model localization smoother and more efficient.

[0021] The present invention also provides an electronic device, including a memory, a processor, and a computer program stored on the memory and executable on the processor. When the processor executes the computer program, the steps of the model platform processing method described in any one of the above are implemented.

[0022] The present invention also provides a non-transitory computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the model platform processing method described in any one of the above are implemented. BRIEF DESCRIPTION OF THE DRAWINGS

[0023] In order to more clearly illustrate the technical solutions in the present invention or the prior art, the following will briefly introduce the drawings required for use in the description of the embodiments or the prior art. Obviously, the drawings in the following description are some embodiments of the present invention. For those of ordinary skill in the art, without creative efforts, other drawings can also be obtained based on these drawings.

[0024] Figure 1 is a schematic flowchart of the model platform processing method provided by the present invention; Figure 2 is a schematic structural diagram of the model platform processing device provided by the present invention; Figure 3 is a schematic structural diagram of the electronic device provided by the present invention. Detailed implementation mode

[0025] To make the objectives, technical solutions and advantages of the present invention clearer, the technical solutions in the present invention will be clearly and completely described below with reference to the accompanying drawings in the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, rather than all of the embodiments. All other embodiments obtained by those of ordinary skill in the art based on the embodiments in the present invention without making creative efforts shall fall within the protection scope of the present invention.

[0026] Figure 1 A flow schematic diagram of a method for model platform processing according to the present invention is described. The method includes: S11. Obtain node parameters of the model to be loaded, where the node parameters are used to characterize the parameters of the basic operation units of the model to be loaded; S12. Quantify the node parameters to obtain quantization parameters; S13. According to the quantization parameters, combine with a preset compilation template to generate a compilation file and load it onto a preset hardware platform to obtain a localized model; wherein, the preset compilation template is constructed in advance based on a programming language determined by the preset hardware platform.

[0027] It should be noted that the step numbers "S1N" in this specification do not represent the sequence of the model platform processing method. The model platform processing method of the present invention will be specifically described below.

[0028] Step S11. Obtain node parameters of the model to be loaded, where the node parameters are used to characterize the parameters of the basic operation units of the model to be loaded.

[0029] In this embodiment, obtaining the node parameters of the model to be loaded includes: obtaining the model to be loaded, where the model to be loaded is a model that has been previously converted based on a preset model format; according to the model to be loaded, search a model structure knowledge base to obtain the nodes of the model to be loaded; wherein, the model structure knowledge base is constructed in advance based on the model structure and the nodes corresponding to the model structure; according to the nodes of the model to be loaded, disassemble the model to be loaded to obtain the node parameters.

[0030] It should be noted that by searching the pre-constructed model structure knowledge base, the corresponding model structure and the corresponding node information can be quickly matched according to the model to be loaded, and further, according to the nodes obtained by the search, the model to be loaded is disassembled, so as to accurately obtain the parameters of each node, effectively avoiding omissions, misjudgments, etc. that may occur in manual disassembly or general parsing methods, ensuring the integrity and accuracy of the obtained node parameters, and providing a reliable data basis for the further processing and quantization of the subsequent model.

[0031] In addition, by constructing a model structure knowledge base based on different types of model structures and corresponding nodes, after obtaining the node parameters of the model to be loaded, the nodes in the model can be quickly identified through pattern matching, and disassembled and analyzed in the way specified in the knowledge base. At the same time, the knowledge base is continuously updated to adapt to newly emerging model architectures.

[0032] Specifically, obtaining the model to be loaded includes: obtaining a trained machine learning model instance from the machine learning library (Scikit-learn, abbreviated as Sklearn); performing model conversion on the machine learning instance based on a preset model format to obtain the model to be loaded.

[0033] It should be noted that by obtaining a trained machine learning model instance from Sklearn, the rich model types in Sklearn can be utilized, such as classification models (decision tree classifier, random forest classifier, etc.), regression models (linear regression, ridge regression, etc.), and clustering models (K-Means, etc.), which provides diverse choices for subsequent model applications, ensures meeting different task requirements, and further performs model conversion through a preset model format to convert the Sklearn model into a format more in line with the requirements of a specific application scenario or platform, realizing the reconstruction of the AI model to better adapt to different deployment environments and application requirements and broaden the scope of use of the model.

[0034] In an alternative embodiment, after obtaining the model to be loaded, it includes: storing the model to be loaded in the target model library. Correspondingly, before obtaining a trained machine learning model instance from Sklearn, it includes: determining whether the corresponding model to be loaded is stored in the target model library. If it is stored, obtain the corresponding model to be loaded from the target model library; otherwise, obtain a trained machine learning model instance from Sklearn and perform model conversion based on a preset model format to obtain the model to be loaded.

[0035] Furthermore, before performing model conversion on the machine learning instance using Netron, it also includes: determining whether the machine learning model instance corresponding to the model to be loaded in Sklearn has been trained. If it has not been trained, train the corresponding machine learning model instance.

[0036] In an alternative embodiment, the preset model format is the Open Neural Network Exchange (ONNX) format, and the target model library is the ONNX library. Correspondingly, model conversion of the machine learning instance can be implemented using the open-source neural network model visualization tool Netron.

[0037] Further, before converting the machine learning instance using Netron, it includes: calling a preset command to install Scikit-learn, ONNX library, and skl2onnx library. It should be added that the skl2onnx library is a library used to convert Scikit-learn (Sklearn) models into ONNX (Open Neural Network Exchange) format for deployment and inference on other platforms or tools that support ONNX.

[0038] Correspondingly, converting the machine learning instance using Netron includes: using the skl2onnx library to convert the machine learning instance into ONNX format to obtain a model to be loaded.

[0039] In addition, after obtaining the model to be loaded, it includes: storing the model to be loaded in the ONNX library.

[0040] It should be added that the preset command can be installed using the pip command. For example, execute pip install scikit-learn onnx skl2onnx in the command line, and no further limitation is made here.

[0041] Step S12: Quantize the node parameters to obtain quantization parameters.

[0042] In this embodiment, quantizing the node parameters to obtain quantization parameters includes: according to the node of the model to be loaded corresponding to the node parameters, searching the quantization knowledge base to determine the quantization strategy for the corresponding node; wherein, the quantization knowledge base is previously constructed based on each node of the model and the quantization strategy corresponding to each node, and the quantization strategy is previously configured for the corresponding model node and includes at least one quantization method; quantize the corresponding node parameters according to the quantization strategy of the node to obtain the corresponding quantization parameters.

[0043] It should be noted that by searching the quantization knowledge base according to the node of the model to be loaded corresponding to the node parameters, a pre-configured quantization strategy can be accurately matched for each specific node, so as to ensure that each node adopts the quantization strategy most suitable for its own characteristics, and then perform the quantization operation more accurately, minimizing the impact of quantization on the model performance, saving a lot of time and effort, and at the same time ensuring the reliability and quality of the quantization process. In addition, a quantization knowledge base is constructed based on each node of the model and the corresponding quantization strategy to centrally store all model nodes and their corresponding quantization strategies, which is convenient for unified management and maintenance.

[0044] Furthermore, version control can be performed on the quantization knowledge base to record information such as changes in quantization strategies at different stages and adjustments to the applicable scope. This facilitates quickly locating and obtaining relevant materials in the knowledge base when problems occur or when it is necessary to trace back and view the basis for formulating the quantization strategy at a certain node, reducing management costs and the probability of errors.

[0045] In addition, the quantization method can refer to existing quantization means, such as amplification, rounding, etc. Since there are many specific quantization means, they are not listed one by one here. The specific quantization strategy can be configured according to the actual model nodes involved and the corresponding design requirements or prior experience of the nodes, and no further limitation is made here.

[0046] In an alternative embodiment, the quantization strategy can be to expand the parameter by a preset multiple and truncate and round it to discard the digits after the decimal point.

[0047] Step S13: According to the quantization parameters, in combination with a preset compilation template, generate a compilation file and load it onto a preset hardware platform to obtain a localized model; wherein, the preset compilation template is constructed in advance based on a programming language determined for the preset hardware platform.

[0048] In this embodiment, generating a compilation file according to the quantization parameters and in combination with a preset compilation template includes: according to the quantization parameters, extracting the values of each quantization parameter, the model type, and the nodes corresponding to the quantization parameters; according to the model type and the corresponding preset hardware platform, selecting a preset compilation template, and embedding the values of each quantization parameter into the preset compilation template according to the corresponding nodes to obtain a compilation file.

[0049] Furthermore, after extracting the values of each quantization parameter, the model type, and the nodes corresponding to the quantization parameters, it includes: performing data processing on the extracted parameters according to a preset data structure to extract the values of each quantization parameter, the model type, and the nodes corresponding to the quantization parameters. Correspondingly, before selecting a preset compilation template according to the model type and the corresponding preset hardware platform and embedding the values of each quantization parameter into the preset compilation template according to the corresponding nodes, it includes: checking whether the parameters after data processing conform to the format and value range required by the corresponding preset compilation template, and based on compliance, selecting a preset compilation template according to the model type and the corresponding preset hardware platform, and embedding the values of each quantization parameter into the preset compilation template according to the corresponding nodes.

[0050] In addition, before selecting a preset compilation template according to the model type and the corresponding preset hardware platform, it includes: according to the model type, determining the model structure, core algorithm, and model data flow mode; according to the preset hardware platform, determining the supported instruction set and programming model, and selecting a programming language; according to the model structure, core algorithm, and model data flow mode, using the selected programming language to construct a compilation template.

[0051] It should be noted that, in order for the generated compiled file to be recognized by the hardware platform, the programming language for constructing the preset compilation template needs to meet the usage requirements of the hardware platform. For example, if the hardware platform is a Microcontroller Unit (MCU) hardware platform, the programming language can be C language, a mixed programming of C language and Python, the Rust system programming language, etc. Another example is that if the hardware platform is a Field Programmable Gate Array (FPGA), the programming language can adopt the HDL hardware description language, and no further limitation is made here. In addition, when the hardware platform is an MCU, the corresponding template is compiled through embedded C language so that the general MCU can recognize and execute the corresponding model.

[0052] It should be noted that when the model to be loaded involves multiple nodes, the converted model may have a data volume that is too large to be loaded onto the MCU for operation. Therefore, the method of node merging can be considered to reduce unnecessary nodes so that the size of the merged model meets the capacity requirements.

[0053] In an alternative embodiment, after obtaining the node parameters of the model to be loaded, it includes: based on the number of nodes of the model to be loaded corresponding to the node parameters being greater than 1, determining whether there are nodes with the same structure among the nodes of the model to be loaded; based on there being nodes with the same structure among the nodes of the model to be loaded, determining whether the nodes with the same structure are duplicate nodes. If they are duplicate nodes, then retain the node parameters corresponding to any one of the duplicate nodes and share the retained node parameters to the node parameters corresponding to the other duplicate nodes; otherwise, merge the nodes with the same structure and the corresponding node parameters.

[0054] It should be noted that when there are nodes with the same structure in the model to be loaded, further determine whether there are duplicate nodes to determine whether to share the node parameters of the duplicate nodes or merge the nodes with the same structure and their parameters, so as to effectively reduce the storage amount of node parameters, reduce duplicate or redundant node parameters, reduce the memory occupancy, and avoid problems such as performance degradation or even program crashes caused by memory tension, enabling the model to run more stably and smoothly on various platforms.

[0055] In an alternative embodiment, the node parameters include the input node parameters and output node parameters of the corresponding node. After obtaining the node parameters of the model to be loaded, it further includes: based on the number of nodes of the model to be loaded corresponding to the node parameters being greater than 1, determining whether there is an output node parameter of a node that is an input node parameter of another node. If so, then merge the corresponding node and the node parameters of the corresponding node; otherwise, do not merge.

[0056] It should be noted that when the output node parameter of a node is exactly the input node parameter of another node, it means that there is a certain degree of information overlap and redundant transmission between these two nodes. Therefore, by identifying and merging the nodes and their parameters with input-output associations, the nodes with tight input-output dependencies are integrated together to avoid redundant parameter transmission, reduce unnecessary intermediate data storage and operations, simplify the data processing flow involved in the model, improve the overall compactness of the model, reduce the number of nodes and the complexity of the connections between them, and simplify the topological structure of the model to be loaded.

[0057] In an optional embodiment, after quantifying the node parameters, it further includes: determining whether there is a coefficient parameter in the node parameters; based on the existence of the coefficient parameter in the node parameters, determining the proportion of the coefficient parameter in the node parameters; determining whether the proportion is lower than a preset proportion threshold, and if the proportion is lower than the preset proportion threshold, deleting the corresponding coefficient parameter; otherwise, retaining the corresponding coefficient parameter.

[0058] It should be noted that by judging the proportion of the coefficient parameter in the node parameters, the coefficient parameters with proportions lower than the preset proportion threshold are deleted to avoid calculation operations on these relatively unimportant coefficients, simplify the calculation process, reduce the amount of calculation, significantly improve the operation speed, and reduce the storage space occupied by the model parameters, so that the size of the model meets the capacity of the hardware platform, ensure that the model can run on a hardware platform with a small capacity, and optimize the allocation of hardware resources to improve the efficiency of the entire model operation.

[0059] In summary, the embodiment of the present invention captures the node parameters of the model to be loaded, focuses on the parameters representing the basic operation units of the model, thereby accurately grasping the core components of the model, quantifying them, converting high-precision parameters into low-precision representations, facilitating the improvement of storage resources and computing performance, enabling the model to better adapt to the resource status of different hardware platforms on the premise of meeting the basic accuracy requirements of the business, and further generating and loading a compilation file according to the quantization parameters in combination with a preset compilation template, making the deployment of models on different hardware platforms more standardized and convenient, reducing the error probability during the deployment process, improving the deployment efficiency, realizing the gradual conversion of the model from the original state and successfully running on the target hardware platform, and making the entire process of model localization smoother and more efficient.

[0060] The model platform processing device provided by the present invention will be described below. The model platform processing device described below can be correspondingly referred to the model platform processing method described above.

[0061] Figure 2 A schematic structural diagram of a model platform processing device is shown. The device includes: A parameter acquisition module 21 acquires node parameters of a model to be loaded, where the node parameters are used to characterize the parameters of the basic computing units of the model to be loaded. A quantization module 22 quantizes the node parameters to obtain quantized parameters. A model processing module 23 generates a compilation file according to the quantized parameters and in combination with a preset compilation template, and loads the compilation file to a preset hardware platform to obtain a localized model; wherein, the preset compilation template is constructed in advance based on a programming language determined by the preset hardware platform.

[0062] In this embodiment, the parameter acquisition module 21 includes: a model acquisition unit that acquires a model to be loaded, where the model to be loaded is a model obtained by converting in advance based on a preset model format; a node search unit that searches a model structure knowledge base according to the model to be loaded to obtain the nodes of the model to be loaded; wherein, the model structure knowledge base is constructed in advance based on the model structure and the nodes corresponding to the model structure; a model processing unit that disassembles the model to be loaded according to the nodes of the model to be loaded to obtain node parameters.

[0063] Specifically, the model acquisition unit includes: a model acquisition subunit that acquires a trained machine learning model instance from a machine learning library (Scikit-learn, abbreviated as Sklearn); a model conversion subunit that performs model conversion on the machine learning instance based on a preset model format to obtain a model to be loaded.

[0064] In an alternative embodiment, the parameter acquisition module 21 further includes: a storage unit that stores the model to be loaded in a target model library after obtaining the model to be loaded. Correspondingly, the parameter acquisition module 21 further includes: a judgment unit that determines whether the target model library stores a corresponding model to be loaded before acquiring a trained machine learning model instance from Sklearn. If it is stored, the corresponding model to be loaded is acquired from the target model library; otherwise, a trained machine learning model instance is acquired from Sklearn and model conversion is performed based on a preset model format to obtain a model to be loaded.

[0065] Further, the parameter acquisition module 21 further includes: a training judgment unit that determines whether the machine learning model instance corresponding to the model to be loaded in Sklearn has been trained before performing model conversion on the machine learning instance using Netron. If it has not been trained, the corresponding machine learning model instance is trained.

[0066] In an alternative embodiment, the preset model format is the Open Neural Network Exchange (ONNX) format, and the target model library is the ONNX library. Correspondingly, the model conversion of the machine learning instance can be implemented by using the open-source neural network model visualization tool Netron.

[0067] Furthermore, the parameter acquisition module 21 further includes: a command invocation unit that invokes a preset command to install Sklearn, the ONNX library, and the skl2onnx library before converting the machine learning instance using Netron.

[0068] Correspondingly, the model conversion subunit is configured to: use the skl2onnx library to convert the machine learning instance into the ONNX format to obtain a model to be loaded.

[0069] In addition, the storage unit is configured to: after obtaining the model to be loaded, store the model to be loaded in the ONNX library.

[0070] In this embodiment, the quantization module 22 includes: a quantization lookup unit that looks up a quantization knowledge base according to the nodes of the model to be loaded corresponding to the node parameters to determine the quantization strategy for the corresponding nodes; wherein the quantization knowledge base is previously constructed based on each node of the model and the quantization strategy corresponding to each node, and the quantization strategy is previously configured for the corresponding model node and includes at least one quantization method; a quantization unit that quantizes the corresponding node parameters according to the quantization strategy of the nodes to obtain corresponding quantized parameters.

[0071] In addition, the model processing module 23 includes: a parameter extraction unit that extracts the values of each quantized parameter, the model type, and the nodes corresponding to the quantized parameters according to the quantized parameters; a compilation unit that selects a preset compilation template according to the model type and the corresponding preset hardware platform, and embeds the values of each quantized parameter into the preset compilation template according to the corresponding nodes to obtain a compilation file.

[0072] Furthermore, the model processing module 23 further includes: a data processing unit that, after extracting the values of each quantized parameter, the model type, and the nodes corresponding to the quantized parameters, processes the extracted parameters according to a preset data structure to extract the values of each quantized parameter, the model type, and the nodes corresponding to the quantized parameters. Correspondingly, the model processing module 23 further includes: a verification unit that, before selecting a preset compilation template according to the model type and the corresponding preset hardware platform and embedding the values of each quantized parameter into the preset compilation template according to the corresponding nodes, checks whether the parameters after data processing meet the format and value range requirements corresponding to the preset compilation template, and based on compliance, selects a preset compilation template according to the model type and the corresponding preset hardware platform, and embeds the values of each quantized parameter into the preset compilation template according to the corresponding nodes.

[0073] In addition, the model processing module 23 further includes: a model information determination unit, which determines the model structure, core algorithm, and model data flow mode according to the model type before selecting a preset compilation template based on the model type and the corresponding preset hardware platform; a language selection unit, which determines the supported instruction set and programming model according to the preset hardware platform and selects a programming language; and a root template creation unit, which constructs a compilation template using the selected programming language according to the model structure, core algorithm, and model data flow mode.

[0074] In an alternative embodiment, the apparatus further includes: a structure judgment module, which, after obtaining the node parameters of the model to be loaded, determines whether there is the same structure among the nodes of the model to be loaded based on the number of nodes of the model to be loaded corresponding to the node parameters being greater than 1; a node judgment module, which, based on the existence of the same structure among the nodes of the model to be loaded, determines whether the nodes with the same structure are duplicate nodes. If they are duplicate nodes, a parameter sharing module retains the node parameters corresponding to any one of the duplicate nodes and shares the retained node parameters to the node parameters corresponding to the other duplicate nodes; otherwise, a first parameter merging module merges the nodes with the same structure and the corresponding node parameters.

[0075] In an alternative embodiment, the node parameters include the input node parameters and output node parameters of the corresponding node. The apparatus further includes: a node relationship determination module, which, after obtaining the node parameters of the model to be loaded, determines whether there is an output node parameter of a node that is an input node parameter of another node based on the number of nodes of the model to be loaded corresponding to the node parameters being greater than 1. If so, a second parameter merging module merges the corresponding nodes and the node parameters of the corresponding nodes; otherwise, no merging is performed.

[0076] In an alternative embodiment, the apparatus further includes: a coefficient acquisition module, which determines whether there are coefficient parameters in the node parameters after quantifying the node parameters; a proportion determination module, which determines the proportion of the coefficient parameters in the node parameters based on the existence of the coefficient parameters in the node parameters; and a coefficient processing module, which determines whether the proportion is lower than a preset proportion threshold. If the proportion is lower than the preset proportion threshold, the corresponding coefficient parameters are deleted; otherwise, the corresponding coefficient parameters are retained.

[0077] In summary, in the embodiments of the present invention, the node parameters of the model to be loaded are obtained through the parameter acquisition module, and the focus is placed on the parameters representing the basic operation units of the model, so as to accurately capture the core components of the model, and then the quantization module is used to quantize them, so as to convert the high-precision parameters into low-precision representations, which is convenient for improving storage resources and computing performance. On the premise that the model meets the basic accuracy requirements of the business, it can better adapt to the resource conditions of different hardware platforms. Further, the model processing module generates and loads a compilation file according to the quantization parameters in combination with a preset compilation template, making the model deployment on different hardware platforms more standardized and convenient, reducing the error probability during the deployment process, improving the deployment efficiency, realizing the gradual conversion of the model from the original state and successfully running on the target hardware platform, and making the entire model localization process smoother and more efficient.

[0078] Figure 3 FIG. shows a schematic physical structure diagram of an electronic device, such as Figure 3 shown, the electronic device may include: a processor 310, a communication interface 320, a memory 330, and a communication bus 340. Among them, the processor 310, the communication interface 320, and the memory 330 complete mutual communication through the communication bus 340. The processor 310 can call the logical instructions in the memory 330 to execute the model platform processing method, and the method includes: obtaining the node parameters of the model to be loaded, where the node parameters are used to represent the parameters of the basic operation units of the model to be loaded; quantizing the node parameters to obtain quantization parameters; generating and loading a compilation file to a preset hardware platform according to the quantization parameters to obtain a localized model; where the preset compilation template is constructed in advance based on the programming language determined by the preset hardware platform.

[0079] In addition, when the logical instructions in the above-mentioned memory 330 can be implemented in the form of software functional units and sold or used as an independent product, they can be stored in a computer-readable storage medium. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or a part of this technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods in the various embodiments of the present invention. The foregoing storage medium includes: various media such as a USB flash drive, a mobile hard disk, a read-only memory (ROM, Read-Only Memory), a random access memory (RAM, Random Access Memory), a magnetic disk, or an optical disc that can store program codes.

[0080] On the other hand, the present invention also provides a computer program product. The computer program product includes a computer program stored on a non-transitory computer-readable storage medium. The computer program includes program instructions. When the program instructions are executed by a computer, the computer can execute the model platforming processing method provided by each of the above methods. The method includes: obtaining node parameters of a model to be loaded, where the node parameters are used to characterize parameters of basic operation units of the model to be loaded; quantifying the node parameters to obtain quantified parameters; and generating a compilation file according to the quantified parameters in combination with a preset compilation template and loading the compilation file to a preset hardware platform to obtain a localized model, where the preset compilation template is constructed in advance based on a programming language determined for the preset hardware platform.

[0081] In another aspect, the present invention also provides a non-transitory computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, it is configured to execute the model platforming processing method provided by each of the above. The method includes: obtaining node parameters of a model to be loaded, where the node parameters are used to characterize parameters of basic operation units of the model to be loaded; quantifying the node parameters to obtain quantified parameters; and generating a compilation file according to the quantified parameters in combination with a preset compilation template and loading the compilation file to a preset hardware platform to obtain a localized model, where the preset compilation template is constructed in advance based on a programming language determined for the preset hardware platform.

[0082] The device embodiments described above are merely illustrative. 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 distributed to multiple network units. Some or all of the modules can be selected according to actual needs to achieve the purpose of the solution of this embodiment. A person of ordinary skill in the art can understand and implement it without creative effort.

[0083] Through the description of the above embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus a necessary general hardware platform, and of course, it can also be implemented by hardware. Based on this understanding, the essence of the above technical solution, or the part that contributes to the prior art, can be embodied in the form of a software product. The computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disc, etc., and includes several instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods of each embodiment or some parts of the embodiments.

[0084] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and are not intended to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that they can still modify the technical solutions described in the foregoing embodiments, or perform equivalent replacements for some of the technical features; and these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A method for model platform processing, characterized in that, Including: Obtain the node parameters of the model to be loaded, where the node parameters are used to characterize the parameters of the basic operation units of the model to be loaded; Quantize the node parameters to obtain quantization parameters; According to the quantization parameters, combined with a preset compilation template, generate a compilation file and load it onto a preset hardware platform to obtain a localized model; wherein, the preset compilation template is constructed in advance based on the programming language of the preset hardware platform.

2. The model platform processing method according to claim 1, wherein The obtaining of the node parameters of the model to be loaded includes: Obtain the model to be loaded, where the model to be loaded is a model that has been previously converted based on a preset model format; According to the model to be loaded, search the model structure knowledge base to obtain the nodes of the model to be loaded; wherein, the model structure knowledge base is constructed in advance based on the model structure and the nodes corresponding to the model structure; Decompose the model to be loaded according to the nodes of the model to be loaded to obtain node parameters.

3. The model platform processing method according to claim 2, wherein The obtaining of the model to be loaded includes: Obtain a trained machine learning model instance from the machine learning library Sklearn; Based on a preset model format, perform model conversion on the machine learning instance to obtain the model to be loaded.

4. The method for model platform processing according to claim 1, characterized in that After obtaining the node parameters of the model to be loaded, it includes: Based on the number of nodes of the model to be loaded corresponding to the node parameters being greater than 1, determine whether there are nodes with the same structure in the nodes of the model to be loaded; Based on the nodes of the model to be loaded having the same structure, determine whether the nodes with the same structure are duplicate nodes. If they are duplicate nodes, retain the node parameters corresponding to any one of the duplicate nodes and share the retained node parameters to the node parameters corresponding to the other duplicate nodes; otherwise, merge the nodes and the corresponding node parameters of the nodes with the same structure.

5. The model platform processing method according to claim 1, wherein The node parameters include the input node parameters and output node parameters of the corresponding nodes. After obtaining the node parameters of the model to be loaded, it further includes: Based on the number of nodes of the model to be loaded corresponding to the node parameters being greater than 1, determine whether there is an output node parameter of a node that is an input node parameter of another node. If so, merge the corresponding nodes and the node parameters of the corresponding nodes; otherwise, do not merge.

6. The model platform processing method according to claim 1, wherein, After quantizing the node parameters, it further includes: Determine whether there are coefficient parameters in the node parameters; Based on there being coefficient parameters in the node parameters, determine the proportion of the coefficient parameters in the node parameters; Determine whether the proportion is lower than a preset proportion threshold. If the proportion is lower than the preset proportion threshold, delete the corresponding coefficient parameters; otherwise, retain the corresponding coefficient parameters.

7. The model platform processing method according to any one of claims 1-6, characterized in that Quantizing the node parameters to obtain quantization parameters includes: According to the nodes of the model to be loaded corresponding to the node parameters, search the quantization knowledge base to determine the quantization strategy of the corresponding nodes; wherein, the quantization knowledge base is constructed in advance based on each node of the model and the quantization strategies corresponding to each node, and the quantization strategy is configured in advance for the corresponding model nodes and includes at least one quantization method; According to the quantization strategy of the nodes, quantize the corresponding node parameters to obtain the corresponding quantization parameters.

8. A model platform processing device, characterized in that, Including: A parameter acquisition module acquires node parameters of a model to be loaded, where the node parameters are used to characterize parameters of basic operation units of the model to be loaded; A quantization module quantizes the node parameters to obtain quantized parameters; A model processing module generates a compilation file according to the quantized parameters in combination with a preset compilation template and loads the compilation file to a preset hardware platform to obtain a localized model; wherein the preset compilation template is constructed in advance based on a programming language of the preset hardware platform.

9. An electronic device, comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, characterized in that, When the processor executes the computer program, the steps of the model platformization processing method according to any one of claims 1 to 7 are implemented.

10. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, the steps of the model platformization processing method according to any one of claims 1 to 7 are implemented.