Model deployment mode determination method and apparatus, electronic device, and storage medium

By transforming and dividing the algorithm model into computational subgraphs and rationally allocating memory space, the problem of unreasonable model deployment on self-developed AI chips was solved, improving deployment efficiency and the variety of models.

CN118709717BActive Publication Date: 2026-11-24GREE ELECTRIC APPLIANCE INC OF ZHUHAI +1
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202410830733.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-06-25
Publication Date
2026-11-24
Estimated Expiration
2044-06-25

AI Technical Summary

Technical Problem

Existing neural network model deployment tools cannot fully utilize the hardware performance of self-developed AI chips and suffer from waste due to unreasonable memory allocation.

Method used

The computation graph is obtained by transforming the algorithm model to be deployed, dividing it into multiple computation subgraphs, allocating memory space for each subgraph according to hardware performance, and determining whether the preset running conditions are met. If they are met, deployment is carried out.

Benefits of technology

It improves the deployment effect of algorithm models on self-developed AI chips, reduces the limitation on the number of model branches, increases the types of deployable algorithm models, and makes reasonable use of hardware acceleration features.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118709717B_ABST
    Figure CN118709717B_ABST
Patent Text Reader

Abstract

This invention provides a method, apparatus, electronic device, and computer-readable storage medium for determining a model deployment method, relating to the field of neural network technology. The method includes: transforming an algorithm model to be deployed, obtaining a corresponding computation graph, dividing the computation graph to obtain multiple computation subgraphs, determining the memory space to be allocated to each computation subgraph, obtaining multiple memory spaces corresponding to the multiple computation subgraphs, and determining whether the computation graph meets preset operating conditions based on the multiple memory spaces. If the computation graph meets the operating conditions, the algorithm model is deployed by deploying multiple computation subgraphs according to the multiple memory spaces. This invention increases the types of deployable algorithm models and improves the effectiveness of determining the algorithm model deployment method.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of neural network technology, and in particular to a method for determining a model deployment mode, a device for determining a model deployment mode, an electronic device, and a computer-readable storage medium. Background Technology

[0002] With the rapid development of deep learning, the application scenarios of neural networks are becoming increasingly widespread, and the demand for deploying neural networks at the edge is also growing. Unlike large neural network models deployed on PCs (personal computers) or in the cloud, which include both training and inference, edge deployments only perform the inference part of the model due to limitations in embedded hardware resources. For models trained on different frameworks, how to quickly and efficiently deploy and use them on embedded devices requires consideration of multiple factors. Different edge devices have different hardware characteristics, and there is no single deployment solution that can fully utilize all edge device features.

[0003] Currently, the front-end parsing tools of inference frameworks can uniformly convert algorithm models trained by mainstream frameworks. However, for self-developed AI (Artificial Intelligence) chips, the front-end parsing tools cannot make good use of the chip's hardware performance. At the same time, the memory allocation scheme of the inference framework has the problem of memory waste. Summary of the Invention

[0004] In view of the above problems, embodiments of the present invention are proposed to provide a method for determining a model deployment mode, an apparatus for determining a model deployment mode, an electronic device, and a computer-readable storage medium to overcome or at least partially solve the above problems.

[0005] This invention discloses a method for determining a model deployment mode, the method comprising:

[0006] The algorithm model to be deployed is transformed to obtain the corresponding computation graph;

[0007] The computation graph is divided to obtain multiple computation subgraphs;

[0008] Determine the memory space that needs to be allocated for each of the computation subgraphs, and obtain multiple memory spaces corresponding to multiple computation subgraphs;

[0009] Based on multiple memory spaces, determine whether the computation graph meets the preset operating conditions;

[0010] If the computation graph satisfies the operating conditions, the algorithm model is deployed by deploying multiple computation subgraphs based on multiple memory spaces.

[0011] In one or more embodiments, the transformation of the algorithm model to be deployed to obtain the corresponding computation graph includes:

[0012] The model format of the algorithm model to be deployed is converted to obtain the candidate algorithm model in the target model format;

[0013] The candidate algorithm model is analyzed to obtain a graph-format computation graph.

[0014] In one or more embodiments, the computation graph includes a plurality of nodes and a node list, the node list being used to record the number of each of the nodes;

[0015] The step of dividing the computation graph to obtain multiple computation subgraphs includes:

[0016] Based on the type of the nodes, the multiple nodes are divided into a first set of nodes and a second set of nodes;

[0017] The nodes with consecutive numbers in the first node set are divided into a computational subgraph to obtain at least one first candidate computational subgraph; and the nodes with consecutive numbers in the second node set are divided into a computational subgraph to obtain at least one second initial candidate computational subgraph.

[0018] Determine the complexity of each first candidate computational subgraph;

[0019] The first candidate computation subgraph with a complexity not exceeding the complexity threshold is changed into the second target candidate computation subgraph, and the first candidate computation subgraph with a complexity exceeding the complexity threshold is determined as the final first computation subgraph;

[0020] Based on the continuity of node numbers, each second initial candidate computational subgraph is integrated with each second target candidate computational subgraph to obtain the final second computational subgraph.

[0021] In one or more embodiments, each computational subgraph has a first identifier or a second identifier, wherein the first identifier is used to characterize that the output of the current computational subgraph is the input of another computational subgraph, and the second identifier is used to characterize that the output of the current computational subgraph is the input of multiple other computational subgraphs;

[0022] The step of determining the memory space to be allocated for each of the computation subgraphs and obtaining multiple memory spaces corresponding to multiple computation subgraphs includes:

[0023] For any target computation subgraph in each of the aforementioned computation subgraphs, obtain the identifier of the target computation subgraph;

[0024] If the identifier is the first identifier, then the memory space to be allocated for the target computation subgraph is a first memory of fixed capacity;

[0025] If the identifier is the second identifier, then the memory space to be allocated for the target computation subgraph is the newly allocated second memory; the capacity of the second memory is determined based on the requirements of the target computation subgraph.

[0026] In one or more embodiments, determining whether the computation graph meets preset operating conditions based on multiple memory spaces includes:

[0027] The sum of the multiple memory spaces is calculated to obtain the total memory space;

[0028] Determine the first memory space required for the algorithm model to run, and the second memory space required for the application corresponding to the algorithm model to run;

[0029] If neither the first memory space nor the second memory space exceeds the total memory space, then the computation graph satisfies the preset operating conditions.

[0030] In one or more embodiments, before determining the memory space to be allocated for each of the computation subgraphs and obtaining the multiple memory spaces corresponding to the multiple computation subgraphs, the method includes:

[0031] For any target computation subgraph in each of the aforementioned computation subgraphs, the computational data required for any target node in the target computation subgraph is stored in a specified memory space;

[0032] Determine whether the computational data required by the target node needs to be migrated;

[0033] If so, when it is determined that memory space needs to be allocated for the target computation subgraph, the computation data is migrated from the specified memory space to the allocated memory space.

[0034] In one or more embodiments, determining whether the computational data required for the target node needs to be migrated includes:

[0035] Determine whether the target node is an intermediate node of the target computation subgraph, and whether the output of the target node is the input of any other node in the computation graph;

[0036] If any target node in the target computation subgraph is not an intermediate node of the target computation subgraph, or if the output of the target node is not the input of any other node in the computation subgraph, then the computation data required by the target node does not need to be migrated.

[0037] If any target node in the target computation subgraph is an intermediate node of the target computation subgraph, and the output of the target node is the input of any other node in the computation subgraph, then the computation data required by the target node needs to be migrated.

[0038] Accordingly, embodiments of the present invention disclose a device for determining a model deployment method, the device comprising:

[0039] The conversion module is used to convert the algorithm model to be deployed and obtain the corresponding computation graph;

[0040] A partitioning module is used to partition the computation graph to obtain multiple computation subgraphs;

[0041] The first determining module is used to determine the memory space that needs to be allocated for each of the computation subgraphs and to obtain multiple memory spaces corresponding to multiple computation subgraphs;

[0042] The detection module is used to determine whether the computation graph meets preset operating conditions based on multiple memory spaces;

[0043] The second determining module is configured to, if the computation graph satisfies the operating conditions, deploy the algorithm model by deploying multiple computation subgraphs based on multiple memory spaces.

[0044] In one or more embodiments, the conversion module is specifically used for:

[0045] The model format of the algorithm model to be deployed is converted to obtain candidate algorithm models in the target model format;

[0046] The candidate algorithm model is analyzed to obtain a graph-format computation graph.

[0047] In one or more embodiments, the computation graph includes a plurality of nodes and a node list, the node list being used to record the number of each of the nodes;

[0048] The partitioning module is specifically used for:

[0049] Based on the type of the nodes, the multiple nodes are divided into a first set of nodes and a second set of nodes;

[0050] The nodes with consecutive numbers in the first node set are divided into a computational subgraph to obtain at least one first candidate computational subgraph; and the nodes with consecutive numbers in the second node set are divided into a computational subgraph to obtain at least one second initial candidate computational subgraph.

[0051] Determine the complexity of each first candidate computational subgraph;

[0052] The first candidate computation subgraph with a complexity not exceeding the complexity threshold is changed into the second target candidate computation subgraph, and the first candidate computation subgraph with a complexity exceeding the complexity threshold is determined as the final first computation subgraph;

[0053] Based on the continuity of node numbers, each second initial candidate computational subgraph is integrated with each second target candidate computational subgraph to obtain the final second computational subgraph.

[0054] In one or more embodiments, each computational subgraph has a first identifier or a second identifier, wherein the first identifier is used to characterize that the output of the current computational subgraph is the input of another computational subgraph, and the second identifier is used to characterize that the output of the current computational subgraph is the input of multiple other computational subgraphs;

[0055] The first determining module is specifically used for:

[0056] For any target computation subgraph in each of the aforementioned computation subgraphs, obtain the identifier of the target computation subgraph;

[0057] If the identifier is the first identifier, then the memory space to be allocated for the target computation subgraph is a first memory of fixed capacity;

[0058] If the identifier is the second identifier, then the memory space to be allocated for the target computation subgraph is the newly allocated second memory; the capacity of the second memory is determined based on the requirements of the target computation subgraph.

[0059] In one or more embodiments, the detection module is specifically used for:

[0060] The sum of the multiple memory spaces is calculated to obtain the total memory space;

[0061] Determine the first memory space required for the algorithm model to run, and the second memory space required for the application corresponding to the algorithm model to run;

[0062] If neither the first memory space nor the second memory space exceeds the total memory space, then the computation graph satisfies the preset operating conditions.

[0063] In one or more embodiments, it further includes:

[0064] The storage module is used to store the computational data required by any target node in any target computational subgraph into a specified memory space before determining the memory space to be allocated for each of the computational subgraphs and obtaining the multiple memory spaces corresponding to the multiple computational subgraphs.

[0065] The third determining module is used to determine whether the computational data required by the target node needs to be migrated.

[0066] The migration module is used to migrate the computation data from the specified memory space to the allocated memory space when it is determined that memory space needs to be allocated for the target computation subgraph.

[0067] In one or more embodiments, the third determining module is specifically used for:

[0068] Determine whether the target node is an intermediate node of the target computation subgraph, and whether the output of the target node is the input of any other node in the computation graph;

[0069] If any target node in the target computation subgraph is not an intermediate node of the target computation subgraph, or if the output of the target node is not the input of any other node in the computation subgraph, then the computation data required by the target node does not need to be migrated.

[0070] If any target node in the target computation subgraph is an intermediate node of the target computation subgraph, and the output of the target node is the input of any other node in the computation subgraph, then the computation data required by the target node needs to be migrated.

[0071] Accordingly, this invention discloses an electronic device, including: a processor, a memory, and a computer program stored in the memory and capable of running on the processor. When the computer program is executed by the processor, it implements the various steps of the above-described method embodiment for determining the model deployment mode.

[0072] Accordingly, embodiments of the present invention disclose a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the various steps of the above-described method embodiment for determining the model deployment mode.

[0073] The embodiments of the present invention have the following advantages:

[0074] The algorithm model to be deployed is transformed to obtain the corresponding computation graph. Then, the computation graph is divided into multiple computation subgraphs. The memory space required to allocate to each computation subgraph is determined, and multiple memory spaces corresponding to the multiple computation subgraphs are obtained. Based on the multiple memory spaces, it is determined whether the computation graph meets preset operating conditions. If the computation graph meets the operating conditions, the algorithm model is deployed by deploying multiple computation subgraphs according to the multiple memory spaces. In this way, a new memory allocation scheme is adopted for self-developed AI chips, thereby reducing the limitation on the number of model branches and increasing the types of deployable algorithm models. Moreover, dividing the computation graph into multiple computation subgraphs based on the hardware acceleration characteristics of the chip allows for more reasonable allocation of memory space to each computation subgraph, improving the deployment effect of the algorithm model. Attached Figure Description

[0075] Figure 1 This is a flowchart illustrating the steps of a method for determining a model deployment mode according to the present invention, in Embodiment 1.

[0076] Figure 2 This is a flowchart illustrating the steps of a second embodiment of the method for determining a model deployment mode according to the present invention;

[0077] Figure 3 This is a structural block diagram of an embodiment of a model deployment method determination device according to the present invention. Detailed Implementation

[0078] To make the above-mentioned objects, features and advantages of the present invention more apparent and understandable, the present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments.

[0079] One of the core concepts of this invention is the adoption of a new memory allocation scheme for self-developed AI chips, which reduces the limitation on the number of model branches and increases the variety of deployable algorithm models. Furthermore, by dividing the computation graph into multiple computation subgraphs based on the chip's hardware acceleration characteristics, memory space can be allocated more rationally to each computation subgraph, improving the deployment effect of the algorithm models.

[0080] Reference Figure 1 This document illustrates a flowchart of a method for determining a model deployment mode according to an embodiment of the present invention. This embodiment can be applied to determining the model deployment mode at the edge based on a self-developed AI chip. The edge model can be an algorithm model trained using different training models. Specifically, this embodiment may include the following steps:

[0081] Step 101: Transform the algorithm model to be deployed to obtain the corresponding computation graph.

[0082] In practical applications, different training models produce algorithm models with different formats, and the deployment methods for different formats of algorithm models are also different. Therefore, in order to facilitate unified deployment, the format of the algorithm model to be deployed can be converted to obtain the corresponding computation graph.

[0083] Early machine learning frameworks were primarily designed for fully connected and convolutional neural networks, which have simple topologies and whose layers are connected sequentially. Therefore, their topologies can be expressed using simple configuration files (e.g., Caffe's model definitions are based on the Protocol Buffer format).

[0084] The topologies of modern machine learning models are becoming increasingly complex, with notable examples including hybrid expert models, generative adversarial networks (GANs), and attention models. Complex model structures (such as loop structures with branches) require machine learning frameworks to perform fast and efficient analysis of the execution dependencies of model operators, gradient calculations, and training parameters. This facilitates model structure optimization, the development of scheduling strategies, and the automation of gradient calculations, thereby improving the efficiency of training complex models. Therefore, machine learning system designers need a general data structure to understand, represent, and execute machine learning models. To address this need, computation graph-based machine learning frameworks have emerged, continuing the design of separating front-end and back-end languages. At a high level, computation graphs implement the following key functions:

[0085] A unified representation of the computation process. When writing machine learning model programs, users often prefer to use high-level programming languages ​​(such as Python, Julia, and C++). However, hardware accelerators and other devices often only provide C and C++ programming interfaces, so machine learning system implementations typically need to be based on C and C++. Programs written in different high-level languages ​​therefore need to be expressed as a unified data structure so that they can be executed by the underlying shared C and C++ system modules. This data structure (i.e., the computation graph) can represent the user's input data, the computational logic in the model (often called operators), and the execution order between operators.

[0086] Automated gradient calculation. The user's model training program receives data samples from the training dataset, performs forward computation through a neural network, and finally calculates the loss value. Based on the loss value, the machine learning system calculates the gradient for each model parameter to update the model parameters. Considering that users can write arbitrary model topologies and loss calculation methods, the gradient calculation method must be general and capable of automatic execution. Computational graphs can help the machine learning system quickly analyze the gradient propagation relationships between parameters, achieving the goal of automated gradient calculation.

[0087] Analyze the lifecycle of model variables. During model training, the system generates temporary intermediate variables, such as activation values ​​in forward computation and gradients in backward computation. Forward computation intermediate variables may participate in the model's parameter updates along with the gradients. Through the computation graph, the system can accurately analyze the lifecycle of intermediate variables (when an intermediate variable is generated and destroyed), thereby helping the framework optimize memory management.

[0088] Optimize program execution. User-provided model programs have different network topologies. The machine learning framework uses computation graphs to analyze model structure and operator execution dependencies, and automatically finds strategies for parallel operator computation, thereby improving model execution efficiency.

[0089] In this embodiment of the invention, the step of transforming the algorithm model to be deployed to obtain the corresponding computation graph includes:

[0090] The model format of the algorithm model to be deployed is converted to obtain candidate algorithm models in the target model format;

[0091] The candidate algorithm model is analyzed to obtain a graph-format computation graph.

[0092] Specifically, algorithm models come in various formats, such as model.h5 and model.keras. For ease of description, we can uniformly refer to the algorithm model to be deployed as model.XX. For model.XX, it can be converted into a unified model format (denoted as the "target model format"), resulting in the converted algorithm model model.tmfile (denoted as the "candidate algorithm model"). This format conversion can be performed using the convert_tool in tengine-lite.

[0093] After converting the algorithm model format into a unified target model format, the converted algorithm model can be further parsed to obtain a graph-formatted computation graph.

[0094] Step 102: Divide the computation graph to obtain multiple computation subgraphs.

[0095] Since different chips have different hardware performance, in order to make full use of the hardware performance, the computation graph can be divided according to the hardware performance to obtain multiple computation subgraphs.

[0096] In this embodiment of the invention, the computation graph includes multiple nodes and a node linked list, wherein the node linked list is used to record the number of each node;

[0097] The step of dividing the computation graph to obtain multiple computation subgraphs includes:

[0098] Based on the type of the nodes, the multiple nodes are divided into a first set of nodes and a second set of nodes;

[0099] The nodes with consecutive numbers in the first node set are divided into a computational subgraph to obtain at least one first candidate computational subgraph; and the nodes with consecutive numbers in the second node set are divided into a computational subgraph to obtain at least one second initial candidate computational subgraph.

[0100] Determine the complexity of each first candidate computational subgraph;

[0101] The first candidate computation subgraph with a complexity not exceeding the complexity threshold is changed into the second target candidate computation subgraph, and the first candidate computation subgraph with a complexity exceeding the complexity threshold is determined as the final first computation subgraph;

[0102] Based on the continuity of node numbers, each second initial candidate computational subgraph is integrated with each second target candidate computational subgraph to obtain the final second computational subgraph.

[0103] Specifically, a computation graph consists of basic data structures (tensors) and basic operational units (operators). Operators are typically represented using nodes in a computation graph. That is, a computation graph includes multiple nodes, and correspondingly, to record each node, they can be numbered and recorded sequentially in a node linked list.

[0104] Nodes can be partitioned based on their type. Node types include those that support hardware acceleration and those that do not. In other words, nodes include first-level nodes (also called hardware operators) and second-level nodes (also called software operators). Therefore, partitioning nodes by type yields a first-level node set (the set of nodes supporting hardware acceleration, also called the hardware operator set) and a second-level node set (the set of nodes not supporting hardware acceleration, also called the software operator set).

[0105] After obtaining the first set of nodes, consecutively numbered nodes can be partitioned into computational subgraphs, thus obtaining at least one computational subgraph (denoted as the "first candidate computational subgraph"). For example, if the first set of nodes includes nodes 1, 3, 4, 5, and 9, then after partitioning, candidate computational subgraphs can be obtained. Figure 1 This includes node 1, a candidate computational sub-node. Figure 2 This includes nodes 3, 4, and 5, which are candidate computation sub-nodes. Figure 3 This includes node 9.

[0106] Similarly, after obtaining the second set of nodes, consecutively numbered nodes can be divided into computational subgraphs, thus obtaining at least one computational subgraph (denoted as the "second initial candidate computational subgraph"). For example, if the second set of nodes includes nodes 2, 6, 7, 8, and 10, then after partitioning, candidate computational subgraph 4, which includes node 2, candidate computational subgraph 5, which includes nodes 6, 7, and 8, and candidate computational subgraph 6, which includes node 10.

[0107] For any first candidate computational subgraph, its complexity (complicated) can be calculated. If the complexity of the computational subgraph does not exceed a complexity threshold, then the computational subgraph is changed to a second candidate computational subgraph (denoted as the "second target candidate computational subgraph"). In this way, after all first candidate computational subgraphs have been computed, all first candidate computational subgraphs with a complexity not exceeding the complexity threshold are changed to second target candidate computational subgraphs, and all first candidate computational subgraphs with a complexity exceeding the complexity threshold are determined as the final first computational subgraphs.

[0108] Then, following the sequential order of node numbers, all second target candidate computation subgraphs are integrated with all second initial candidate computation subgraphs to obtain at least one integrated second computation subgraph. For example, the second initial candidate computation subgraph... Figure 1 Including nodes 11 and 12, the second target candidate computation sub-module Figure 1 Including nodes 13 and 14, the second initial candidate computational sub-module Figure 2 Including nodes 17 and 18, the second initial candidate computational sub-component will be... Figure 1 Second target candidate computation sub-component Figure 1 Second initial candidate computation Figure 2 By integrating the results, the final second computational unit is obtained. Figure 1 This includes nodes 11, 12, 13, and 14, the second computational sub-module. Figure 2 This includes nodes 17 and 18.

[0109] It should be noted that the following formula can be used to calculate the complexity of the computational subgraph:

[0110] complicated = input_num / X

[0111] Here, `input_num` represents the input parameters of the hardware operators in the first candidate computation subgraph, and `X` is a preset threshold at which the time consumed by hardware and software operators to compute data is roughly equivalent. Since the time consumed by hardware operators to compute data includes data migration time, when `complicated` exceeds the complexity threshold, the first candidate computation subgraph can be confirmed as a hardware computation subgraph, i.e., the first computation subgraph. Otherwise, the first candidate computation subgraph is confirmed as the second target candidate computation subgraph, and its operators can be integrated with the operators in the second initial candidate computation subgraph.

[0112] Furthermore, when partitioning the first and second node sets, there is a special case where the node set cannot be partitioned. In this case, the entire first node set is a computational subgraph, and hardware acceleration can be used for the entire first node set. Similarly, the entire second node set is also a computational subgraph, and hardware acceleration is not used for the entire second node set.

[0113] Step 103: Determine the memory space to be allocated for each of the computational subgraphs, and obtain multiple memory spaces corresponding to multiple computational subgraphs.

[0114] Once the computational subgraphs are partitioned, the memory space required for each subgraph can be determined, thus obtaining multiple memory spaces corresponding to multiple computational subgraphs. When determining the memory space, it is not necessary to perform calculations on the data itself; the memory space required for each subgraph is calculated based on the order of the computational subgraphs.

[0115] In this embodiment of the invention, each computational subgraph has a first identifier or a second identifier. The first identifier is used to indicate that the output of the current computational subgraph is the input of another computational subgraph, and the second identifier is used to indicate that the output of the current computational subgraph is the input of multiple other computational subgraphs.

[0116] The step of determining the memory space to be allocated for each of the computation subgraphs and obtaining multiple memory spaces corresponding to multiple computation subgraphs includes:

[0117] For any target computation subgraph in each of the aforementioned computation subgraphs, obtain the identifier of the target computation subgraph;

[0118] If the identifier is the first identifier, then the memory space to be allocated for the target computation subgraph is a first memory of fixed capacity;

[0119] If the identifier is the second identifier, then the memory space to be allocated for the target computation subgraph is the newly allocated second memory; the capacity of the second memory is determined based on the requirements of the target computation subgraph.

[0120] Specifically, each computational subgraph has a unique identifier, which includes a first identifier and a second identifier. The first identifier is used to indicate that the output of the current computational subgraph is the input of another computational subgraph, where another computational subgraph is any computational subgraph other than the current computational subgraph in the computational graph. The second identifier is used to indicate that the output of the current computational subgraph is the input of multiple other computational subgraphs, where multiple other computational subgraphs are any multiple computational subgraphs other than the current computational subgraph in the computational graph.

[0121] Based on this, for any computation subgraph in each computation subgraph (denoted as "target computation subgraph"), when determining the memory space to be allocated, the identifier of the target computation subgraph can be obtained. If the identifier of the target computation subgraph is the first identifier, then it can be determined that a fixed-capacity memory space (denoted as "first memory") needs to be allocated to the target computation subgraph. If the identifier of the target computation subgraph is the second identifier, then it can be determined that a new memory space (denoted as "second memory") needs to be allocated for the target computation subgraph. The capacity of the newly allocated memory space can be determined based on the computation data requirements of the target computation subgraph.

[0122] Step 104: Determine whether the computation graph meets the preset operating conditions based on the multiple memory spaces.

[0123] Since the embodiments of the present invention are applied to the determination of the deployment method of the algorithm model, rather than the actual operation of the algorithm model, it is necessary to determine whether the computation graph after the transformation of the algorithm model meets the preset running conditions based on multiple memory spaces. If it does not meet the conditions, it means that the algorithm model may encounter abnormalities during actual operation and needs to be modified.

[0124] In this embodiment of the invention, determining whether the computation graph satisfies preset operating conditions based on multiple memory spaces includes:

[0125] The sum of the multiple memory spaces is calculated to obtain the total memory space;

[0126] Determine the first memory space required for the algorithm model to run, and the second memory space required for the application corresponding to the algorithm model to run;

[0127] If neither the first memory space nor the second memory space exceeds the total memory space, then the algorithm model satisfies the preset operating conditions.

[0128] Specifically, after determining the memory space to be allocated for each computational subgraph, the sum of multiple memory spaces can be calculated to obtain the total memory space to be allocated. Then, the memory space required by the algorithm model during runtime (denoted as "first memory space") and the memory space required by the application corresponding to the algorithm model during runtime (denoted as "second memory space") are determined. If the first memory space does not exceed the total memory space, and the second memory space does not exceed the total memory space, then the computational graph meets the preset operating conditions; if at least one of the first memory space and the second memory space exceeds the total memory space, then the computational graph does not meet the preset operating conditions.

[0129] Step 105: If the computation graph satisfies the running conditions, the algorithm model is deployed by deploying multiple computation subgraphs based on multiple memory spaces.

[0130] If the computation graph meets the preset operating conditions, then multiple computation subgraphs can be deployed according to the determined memory spaces. In other words, by deploying multiple computation subgraphs according to the determined memory spaces, the algorithm model can run normally during actual operation. If the computation graph does not meet the preset operating conditions, then alarm information can be generated, and developers can modify the algorithm model based on the alarm information.

[0131] In this embodiment of the invention, the algorithm model to be deployed is transformed to obtain a corresponding computation graph. Then, the computation graph is divided into multiple computation subgraphs. The memory space required to be allocated to each computation subgraph is determined, and multiple memory spaces corresponding to the multiple computation subgraphs are obtained. Based on the multiple memory spaces, it is determined whether the computation graph meets preset operating conditions. If the computation graph meets the operating conditions, the algorithm model is deployed by deploying multiple computation subgraphs according to the multiple memory spaces. In this way, a new memory allocation scheme is adopted for self-developed AI chips, thereby reducing the limitation on the number of model branches and increasing the types of deployable algorithm models. Moreover, dividing the computation graph into multiple computation subgraphs based on the hardware acceleration characteristics of the chip allows for more reasonable allocation of memory space to each computation subgraph, improving the deployment effect of the algorithm model.

[0132] Reference Figure 2 This document illustrates a flowchart of a second embodiment of the method for determining a model deployment mode according to the present invention. This embodiment can be applied to edge deployment of models based on self-developed AI chips. The edge model can be an algorithm model trained using different training models. Specifically, this embodiment may include the following steps:

[0133] Step 201: Transform the algorithm model to be deployed to obtain the corresponding computation graph.

[0134] In practical applications, different training models produce algorithm models with different formats, and the deployment methods for different formats of algorithm models are also different. Therefore, in order to facilitate unified deployment, the format of the algorithm model to be deployed can be converted to obtain the corresponding computation graph.

[0135] In this embodiment of the invention, the step of transforming the algorithm model to be deployed to obtain the corresponding computation graph includes:

[0136] The model format of the algorithm model to be deployed is converted to obtain candidate algorithm models in the target model format;

[0137] The candidate algorithm model is analyzed to obtain a graph-format computation graph.

[0138] Specifically, algorithm models come in various formats, such as model.h5 and model.keras. For ease of description, we can uniformly refer to the algorithm model to be deployed as model.XX. For model.XX, it can be converted into a unified target model format to obtain the converted algorithm model model.tmfile. This format conversion can be performed using the convert_tool in tengine-lite.

[0139] After converting the algorithm model format into a unified target model format, the converted algorithm model can be further parsed to obtain a graph-formatted computation graph.

[0140] Step 202: Divide the computation graph to obtain multiple computation subgraphs.

[0141] Since different chips have different hardware performance, in order to make full use of the hardware performance, the computation graph can be divided according to the hardware performance to obtain multiple computation subgraphs.

[0142] In this embodiment of the invention, the computation graph includes multiple nodes and a node linked list, wherein the node linked list is used to record the number of each node;

[0143] The step of dividing the computation graph to obtain multiple computation subgraphs includes:

[0144] Based on the type of the nodes, the multiple nodes are divided into a first set of nodes and a second set of nodes;

[0145] The nodes with consecutive numbers in the first node set are divided into a computational subgraph to obtain at least one first candidate computational subgraph; and the nodes with consecutive numbers in the second node set are divided into a computational subgraph to obtain at least one second initial candidate computational subgraph.

[0146] Determine the complexity of each first candidate computational subgraph;

[0147] The first candidate computation subgraph with a complexity not exceeding the complexity threshold is changed into the second target candidate computation subgraph, and the first candidate computation subgraph with a complexity exceeding the complexity threshold is determined as the final first computation subgraph;

[0148] Based on the continuity of node numbers, each second initial candidate computational subgraph is integrated with each second target candidate computational subgraph to obtain the final second computational subgraph.

[0149] Specifically, a computation graph consists of basic data structures (tensors) and basic operational units (operators). Operators are typically represented using nodes in a computation graph. That is, a computation graph includes multiple nodes, and correspondingly, to record each node, they can be numbered and recorded sequentially in a node linked list.

[0150] Nodes can be partitioned based on their type. Node types include those that support hardware acceleration and those that do not. In other words, nodes include first-level nodes (also called hardware operators) and second-level nodes (also called software operators). Therefore, partitioning nodes by type yields a first-level node set (the set of nodes supporting hardware acceleration, also called the hardware operator set) and a second-level node set (the set of nodes not supporting hardware acceleration, also called the software operator set).

[0151] After obtaining the first set of nodes, consecutively numbered nodes can be partitioned into a computational subgraph, thus obtaining at least one first candidate computational subgraph. Similarly, after obtaining the second set of nodes, consecutively numbered nodes can be partitioned into a computational subgraph, thus obtaining at least one second initial candidate computational subgraph. For any first candidate computational subgraph, its complexity (complicated) can be calculated. If the complexity of the computational subgraph does not exceed a complexity threshold, then the computational subgraph is changed to a second target candidate computational subgraph. In this way, after all first candidate computational subgraphs have been computed, all first candidate computational subgraphs with complexity not exceeding the complexity threshold are changed to second target candidate computational subgraphs, and all first candidate computational subgraphs with complexity exceeding the complexity threshold are determined as the final first computational subgraphs.

[0152] Then, following the sequential order of node numbers, all candidate computational subgraphs for the second objective are integrated with all candidate computational subgraphs for the second initial objective, resulting in at least one integrated second computational subgraph. It should be noted that the complexity of the computational subgraph can be calculated using the following formula:

[0153] complicated = input_num / X

[0154] Here, `input_num` represents the input parameters of the hardware operators in the first candidate computation subgraph, and `X` is a preset threshold at which the time consumed by hardware and software operators to compute data is roughly equivalent. Since the time consumed by hardware operators to compute data includes data migration time, when `complicated` exceeds the complexity threshold, the first candidate computation subgraph can be confirmed as a hardware computation subgraph, i.e., the first computation subgraph. Otherwise, the first candidate computation subgraph is confirmed as the second target candidate computation subgraph, and its operators can be integrated with the operators in the second initial candidate computation subgraph.

[0155] Furthermore, when partitioning the first and second node sets, there is a special case where the node set cannot be partitioned. In this case, the entire first node set is a computational subgraph, and hardware acceleration can be used for the entire first node set. Similarly, the entire second node set is also a computational subgraph, and hardware acceleration is not used for the entire second node set.

[0156] Step 203: For any target computation subgraph in each of the computation subgraphs, store the computational data required by any target node in the target computation subgraph into a specified memory space.

[0157] Step 204: Determine whether the computational data required by the target node needs to be migrated.

[0158] In practical applications, chips are configured with designated memory spaces, such as SRAM (Static Random-Access Memory). When any target node in the target computation subgraph is computing data, the data required for computation is stored in the designated memory space by default. However, due to the limitations of SRAM hardware performance, sometimes computing data based on SRAM takes longer than computing data based on the designated memory space. Therefore, it is necessary to determine whether the computation data required by any target node needs to be migrated from the designated memory space to the designated memory space.

[0159] In this embodiment of the invention, determining whether the computational data required for the target node needs to be migrated includes:

[0160] Determine whether the target node is an intermediate node of the target computation subgraph, and whether the output of the target node is the input of any other node in the computation graph;

[0161] If any target node in the target computation subgraph is not an intermediate node of the target computation subgraph, or if the output of the target node is not the input of any other node in the computation subgraph, then the computation data required by the target node does not need to be migrated.

[0162] If any target node in the target computation subgraph is an intermediate node of the target computation subgraph, and the output of the target node is the input of any other node in the computation subgraph, then the computation data required by the target node needs to be migrated.

[0163] Specifically, for any target node in the target computation subgraph, it is determined whether the target node is an intermediate node of the target computation subgraph, and whether the output of the target node is the input of any other node in the computation subgraph. An intermediate node can be any node in the target computation subgraph other than the first and last target nodes. For example, if the target computation subgraph includes node 1, node 2, node 3, and node 4, then node 2 and node 3 are intermediate nodes.

[0164] If the target node is not an intermediate node in the target computation subgraph, or if the output of the target node is not the input of any other node in the computation graph, then the computation data required by the target node does not need to be migrated.

[0165] If the target node is an intermediate node in the target computation subgraph, and the output of the target node is the input of any other node in the computation graph, then the computation data required by the target node needs to be migrated.

[0166] The same principle applies to other computational subgraphs, which allows us to determine whether the computational data required for each node in each computational subgraph needs to be migrated.

[0167] Step 205: If yes, then when the memory space to be allocated for the target computation subgraph is determined, the computation data is migrated from the specified memory space to the allocated memory space.

[0168] If it is determined that the computational data required by the target node needs to be migrated, then when the memory space to be allocated in the target computational subgraph is determined, the computational data can be migrated from the specified memory space to that memory space.

[0169] If it is determined that the computational data required by the target node does not need to be migrated, then the data can be computed directly based on the specified memory space.

[0170] Step 206: Determine the memory space to be allocated for each of the computational subgraphs, and obtain multiple memory spaces corresponding to the multiple computational subgraphs.

[0171] Once the computational subgraphs are partitioned, the memory space required for each subgraph can be determined, thus obtaining multiple memory spaces corresponding to multiple computational subgraphs. When determining the memory space, it is not necessary to perform calculations on the data itself; the memory space required for each subgraph is calculated based on the order of the computational subgraphs.

[0172] In this embodiment of the invention, each computational subgraph has a first identifier or a second identifier. The first identifier is used to indicate that the output of the current computational subgraph is the input of another computational subgraph, and the second identifier is used to indicate that the output of the current computational subgraph is the input of multiple other computational subgraphs.

[0173] The step of determining the memory space to be allocated for each of the computation subgraphs and obtaining multiple memory spaces corresponding to multiple computation subgraphs includes:

[0174] For any target computation subgraph in each of the aforementioned computation subgraphs, obtain the identifier of the target computation subgraph;

[0175] If the identifier is the first identifier, then the memory space to be allocated for the target computation subgraph is a first memory of fixed capacity;

[0176] If the identifier is the second identifier, then the memory space to be allocated for the target computation subgraph is the newly allocated second memory; the capacity of the second memory is determined based on the requirements of the target computation subgraph.

[0177] Specifically, each computational subgraph has a unique identifier, which includes a first identifier and a second identifier. The first identifier is used to indicate that the output of the current computational subgraph is the input of another computational subgraph, where another computational subgraph is any computational subgraph other than the current computational subgraph in the computational graph. The second identifier is used to indicate that the output of the current computational subgraph is the input of multiple other computational subgraphs, where multiple other computational subgraphs are any multiple computational subgraphs other than the current computational subgraph in the computational graph.

[0178] Based on this, for any target computation subgraph in each computation subgraph, when determining the memory space to be allocated, the identifier of the target computation subgraph can be obtained. If the identifier of the target computation subgraph is the first identifier, then it can be determined that a fixed-capacity memory space, the first memory, needs to be allocated for the target computation subgraph. If the identifier of the target computation subgraph is the second identifier, then it can be determined that a new second memory space needs to be allocated for the target computation subgraph. The capacity of the newly allocated memory space can be determined based on the computation data requirements of the target computation subgraph.

[0179] Step 207: Determine whether the computation graph meets the preset operating conditions based on the multiple memory spaces.

[0180] Since the embodiments of the present invention are applied to the determination of the deployment method of the algorithm model, rather than the actual operation of the algorithm model, it is necessary to determine whether the computation graph after the transformation of the algorithm model meets the preset running conditions based on multiple memory spaces. If it does not meet the conditions, it means that the algorithm model may encounter abnormalities during actual operation and needs to be modified.

[0181] In this embodiment of the invention, determining whether the computation graph satisfies preset operating conditions based on multiple memory spaces includes:

[0182] The sum of the multiple memory spaces is calculated to obtain the total memory space;

[0183] Determine the first memory space required for the algorithm model to run, and the second memory space required for the application corresponding to the algorithm model to run;

[0184] If neither the first memory space nor the second memory space exceeds the total memory space, then the algorithm model satisfies the preset operating conditions.

[0185] Specifically, after determining the memory space to be allocated for each computational subgraph, the sum of multiple memory spaces can be calculated to obtain the total memory space to be allocated. Then, the first memory space required by the algorithm model during runtime and the second memory space required by the application corresponding to the algorithm model during runtime are determined. If the first memory space does not exceed the total memory space, and the second memory space does not exceed the total memory space, then the computational graph meets the preset operating conditions; if at least one of the first and second memory spaces exceeds the total memory space, then the computational graph does not meet the preset operating conditions.

[0186] Step 208: If the computation graph satisfies the running conditions, the algorithm model is deployed by deploying multiple computation subgraphs based on multiple memory spaces.

[0187] If the computation graph meets the preset running conditions, then multiple computation subgraphs can be deployed according to the determined multiple memory spaces. In other words, by deploying multiple computation subgraphs according to the determined multiple memory spaces, the algorithm model can run normally during actual operation.

[0188] In this embodiment of the invention, the algorithm model to be deployed is transformed to obtain a corresponding computation graph. Then, the computation graph is divided into multiple computation subgraphs. The memory space required to be allocated to each computation subgraph is determined, and multiple memory spaces corresponding to the multiple computation subgraphs are obtained. Based on the multiple memory spaces, it is determined whether the computation graph meets preset operating conditions. If the computation graph meets the operating conditions, the algorithm model is deployed by deploying multiple computation subgraphs according to the multiple memory spaces. In this way, a new memory allocation scheme is adopted for self-developed AI chips, thereby reducing the limitation on the number of model branches and increasing the types of deployable algorithm models. Furthermore, by dividing the computation graph into multiple computation subgraphs according to the hardware acceleration characteristics of the chip, and by migrating the computational data required by the nodes from the specified memory space to the determined memory space, memory space can be allocated more rationally to each computation subgraph, improving the deployment effect of the algorithm model.

[0189] It should be noted that, for the sake of simplicity, the method embodiments are all described as a series of actions. However, those skilled in the art should understand that the embodiments of the present invention are not limited to the described order of actions, because according to the embodiments of the present invention, some steps can be performed in other orders or simultaneously. Furthermore, those skilled in the art should also understand that the embodiments described in the specification are preferred embodiments, and the actions involved are not necessarily essential to the embodiments of the present invention.

[0190] Reference Figure 3 The diagram illustrates a structural block diagram of an embodiment of a model deployment method determination device according to the present invention, which may specifically include the following modules:

[0191] The conversion module 301 is used to convert the algorithm model to be deployed and obtain the corresponding computation graph;

[0192] The partitioning module 302 is used to partition the computation graph to obtain multiple computation subgraphs;

[0193] The first determining module 303 is used to determine the memory space that needs to be allocated for each computational subgraph and to obtain multiple memory spaces corresponding to multiple computational subgraphs;

[0194] The detection module 304 is used to determine whether the computation graph meets the preset operating conditions based on multiple memory spaces;

[0195] The second determining module 305 is used to determine that if the computation graph satisfies the running conditions, the deployment mode of the algorithm model is to deploy multiple computation subgraphs according to multiple memory spaces.

[0196] In this embodiment of the invention, the conversion module 301 is specifically used for:

[0197] The model format of the algorithm model to be deployed is converted to obtain candidate algorithm models in the target model format;

[0198] The candidate algorithm model is analyzed to obtain a graph-format computation graph.

[0199] In this embodiment of the invention, the computation graph includes multiple nodes and a node linked list, wherein the node linked list is used to record the number of each node;

[0200] The partitioning module 302 is specifically used for:

[0201] Based on the type of the nodes, the multiple nodes are divided into a first set of nodes and a second set of nodes;

[0202] The nodes with consecutive numbers in the first node set are divided into a computational subgraph to obtain at least one first candidate computational subgraph; and the nodes with consecutive numbers in the second node set are divided into a computational subgraph to obtain at least one second initial candidate computational subgraph.

[0203] Determine the complexity of each first candidate computational subgraph;

[0204] The first candidate computation subgraph with a complexity not exceeding the complexity threshold is changed into the second target candidate computation subgraph, and the first candidate computation subgraph with a complexity exceeding the complexity threshold is determined as the final first computation subgraph;

[0205] Based on the continuity of node numbers, each second initial candidate computational subgraph is integrated with each second target candidate computational subgraph to obtain the final second computational subgraph.

[0206] In this embodiment of the invention, each computational subgraph has a first identifier or a second identifier. The first identifier is used to indicate that the output of the current computational subgraph is the input of another computational subgraph, and the second identifier is used to indicate that the output of the current computational subgraph is the input of multiple other computational subgraphs.

[0207] The first determining module 303 is specifically used for:

[0208] For any target computation subgraph in each of the aforementioned computation subgraphs, obtain the identifier of the target computation subgraph;

[0209] If the identifier is the first identifier, then the memory space to be allocated for the target computation subgraph is a first memory of fixed capacity;

[0210] If the identifier is the second identifier, then the memory space to be allocated for the target computation subgraph is the newly allocated second memory; the capacity of the second memory is determined based on the requirements of the target computation subgraph.

[0211] In this embodiment of the invention, the detection module 304 is specifically used for:

[0212] The sum of the multiple memory spaces is calculated to obtain the total memory space;

[0213] Determine the first memory space required for the algorithm model to run, and the second memory space required for the application corresponding to the algorithm model to run;

[0214] If neither the first memory space nor the second memory space exceeds the total memory space, then the computation graph satisfies the preset operating conditions.

[0215] In this embodiment of the invention, it further includes:

[0216] Storage module 306 is used to store the computational data required by any target node in any target computational subgraph into a specified memory space before determining the memory space to be allocated for each of the computational subgraphs and obtaining the multiple memory spaces corresponding to the multiple computational subgraphs.

[0217] The third determining module 307 is used to determine whether the computational data required by the target node needs to be migrated.

[0218] The migration module 308 is used to migrate the computation data from the specified memory space to the allocated memory space when it is determined that memory space needs to be allocated for the target computation subgraph.

[0219] In this embodiment of the invention, the third determining module 307 is specifically used for:

[0220] Determine whether the target node is an intermediate node of the target computation subgraph, and whether the output of the target node is the input of any other node in the computation graph;

[0221] If any target node in the target computation subgraph is not an intermediate node of the target computation subgraph, or if the output of the target node is not the input of any other node in the computation subgraph, then the computation data required by the target node does not need to be migrated.

[0222] If any target node in the target computation subgraph is an intermediate node of the target computation subgraph, and the output of the target node is the input of any other node in the computation subgraph, then the computation data required by the target node needs to be migrated.

[0223] As the device embodiment is basically similar to the method embodiment, the description is relatively simple, and relevant parts can be found in the description of the method embodiment.

[0224] This invention also provides an electronic device, comprising:

[0225] It includes a processor, a memory, and a computer program stored in the memory and capable of running on the processor. When the computer program is executed by the processor, it implements the various processes of the above-described method embodiment for determining the model deployment mode and achieves the same technical effect. To avoid repetition, it will not be described again here.

[0226] This invention also provides a computer-readable storage medium storing a computer program. When the computer program is executed by a processor, it implements the various processes of the above-described method embodiment for determining the model deployment mode and achieves the same technical effect. To avoid repetition, it will not be described again here.

[0227] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on the differences from other embodiments. The same or similar parts between the various embodiments can be referred to each other.

[0228] Those skilled in the art will understand that embodiments of the present invention can be provided as methods, apparatus, or computer program products. Therefore, embodiments of the present invention can take the form of entirely hardware embodiments, entirely software embodiments, or embodiments combining software and hardware aspects. Furthermore, embodiments of the present invention can take the form of computer program products implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0229] This invention is described with reference to flowchart illustrations and / or block diagrams of methods, terminal devices (systems), and computer program products according to embodiments of the invention. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing terminal device to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing terminal device, generate instructions for implementing the flowchart illustrations and / or block diagrams. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.

[0230] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing terminal device to operate in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1One or more processes and / or boxes Figure 1 The function specified in one or more boxes.

[0231] These computer program instructions can also be loaded onto a computer or other programmable data processing terminal equipment, causing a series of operational steps to be performed on the computer or other programmable terminal equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable terminal equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.

[0232] Although preferred embodiments of the present invention have been described, those skilled in the art, upon learning the basic inventive concept, can make other changes and modifications to these embodiments. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments as well as all changes and modifications falling within the scope of the embodiments of the present invention.

[0233] Finally, it should be noted that in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or terminal device that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or terminal device. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or terminal device that includes said element.

[0234] The above provides a detailed description of a method and apparatus for determining a model deployment mode provided by the present invention. Specific examples have been used to illustrate the principles and implementation methods of the present invention. The descriptions of the above embodiments are only for the purpose of helping to understand the method and core ideas of the present invention. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of the present invention. Therefore, the content of this specification should not be construed as a limitation of the present invention.

Claims

1. A method for determining a model deployment mode, characterized in that, The method includes: The algorithm model to be deployed is transformed to obtain the corresponding computation graph; the computation graph includes multiple nodes and a node linked list, and the node linked list is used to record the number of each node; Based on the type of the nodes, the multiple nodes are divided into a first set of nodes and a second set of nodes; The nodes with consecutive numbers in the first node set are divided into a computational subgraph to obtain at least one first candidate computational subgraph; and the nodes with consecutive numbers in the second node set are divided into a computational subgraph to obtain at least one second initial candidate computational subgraph. Determine the complexity of each first candidate computational subgraph; each computational subgraph has a first identifier or a second identifier, the first identifier being used to characterize that the output of the current computational subgraph is the input of another computational subgraph, and the second identifier being used to characterize that the output of the current computational subgraph is the input of multiple other computational subgraphs; The first candidate computation subgraph with a complexity not exceeding the complexity threshold is changed into the second target candidate computation subgraph, and the first candidate computation subgraph with a complexity exceeding the complexity threshold is determined as the final first computation subgraph; Based on the continuity of node numbers, each second initial candidate computation subgraph is integrated with each second target candidate computation subgraph to obtain the final second computation subgraph; For any target computation subgraph in each of the aforementioned computation subgraphs, obtain the identifier of the target computation subgraph; If the identifier is the first identifier, then the memory space to be allocated for the target computation subgraph is a first memory of fixed capacity; If the identifier is the second identifier, then the memory space to be allocated for the target computation subgraph is the newly allocated second memory; the capacity of the second memory is determined based on the requirements of the target computation subgraph. Based on multiple memory spaces, determine whether the computation graph meets the preset operating conditions; If the computation graph satisfies the operating conditions, the algorithm model is deployed by deploying multiple computation subgraphs based on multiple memory spaces.

2. The method for determining the model deployment mode according to claim 1, characterized in that, The process of transforming the algorithm model to be deployed to obtain the corresponding computation graph includes: The model format of the algorithm model to be deployed is converted to obtain the candidate algorithm model in the target model format; The candidate algorithm model is analyzed to obtain a graph-format computation graph.

3. The method for determining the model deployment mode according to claim 1, characterized in that, The step of determining whether the computation graph meets the preset operating conditions based on multiple memory spaces includes: The sum of the multiple memory spaces is calculated to obtain the total memory space; Determine the first memory space required for the algorithm model to run, and the second memory space required for the application corresponding to the algorithm model to run; If neither the first memory space nor the second memory space exceeds the total memory space, then the computation graph satisfies the preset operating conditions.

4. The method for determining the model deployment mode according to claim 1, characterized in that, Before determining the memory space to be allocated for each of the computation subgraphs and obtaining the multiple memory spaces corresponding to the multiple computation subgraphs, the process includes: For any target computation subgraph in each of the aforementioned computation subgraphs, the computational data required for any target node in the target computation subgraph is stored in a specified memory space; Determine whether the computational data required by the target node needs to be migrated; If so, when it is determined that memory space needs to be allocated for the target computation subgraph, the computation data is migrated from the specified memory space to the allocated memory space.

5. The method for determining the model deployment mode according to claim 4, characterized in that, Determining whether the computational data required for the target node needs to be migrated includes: Determine whether the target node is an intermediate node of the target computation subgraph, and whether the output of the target node is the input of any other node in the computation graph; If any target node in the target computation subgraph is not an intermediate node of the target computation subgraph, or if the output of the target node is not the input of any other node in the computation subgraph, then the computation data required by the target node does not need to be migrated. If any target node in the target computation subgraph is an intermediate node of the target computation subgraph, and the output of the target node is the input of any other node in the computation subgraph, then the computation data required by the target node needs to be migrated.

6. A device for determining a model deployment mode, characterized in that, The device includes: The transformation module is used to transform the algorithm model to be deployed and obtain the corresponding computation graph; the computation graph includes multiple nodes and a node linked list, and the node linked list is used to record the number of each node; A partitioning module is used to partition multiple nodes into a first node set and a second node set based on node type; partition consecutively numbered nodes in the first node set into a computational subgraph to obtain at least one first candidate computational subgraph; and partition consecutively numbered nodes in the second node set into a computational subgraph to obtain at least one second initial candidate computational subgraph; determine the complexity of each first candidate computational subgraph; each computational subgraph has a first identifier or a second identifier, the first identifier being used to characterize that the output of the current computational subgraph is the input of another computational subgraph, and the second identifier being used to characterize that the output of the current computational subgraph is the input of multiple other computational subgraphs; change first candidate computational subgraphs with a complexity not exceeding a complexity threshold to second target candidate computational subgraphs; and determine first candidate computational subgraphs with a complexity exceeding the complexity threshold as the final first computational subgraph; and integrate each second initial candidate computational subgraph with each second target candidate computational subgraph based on the continuity of node numbers to obtain the final second computational subgraph. The first determining module is used to obtain the identifier of any target computation subgraph in each of the computation subgraphs; if the identifier is the first identifier, then the memory space to be allocated to the target computation subgraph is a first memory of fixed capacity; if the identifier is the second identifier, then the memory space to be allocated to the target computation subgraph is a newly allocated second memory; the capacity of the second memory is determined based on the requirements of the target computation subgraph. The detection module is used to determine whether the computation graph meets preset operating conditions based on multiple memory spaces; The second determining module is configured to, if the computation graph satisfies the operating conditions, deploy the algorithm model by deploying multiple computation subgraphs based on multiple memory spaces.

7. An electronic device, characterized in that, include: A processor, a memory, and a computer program stored in the memory and capable of running on the processor, wherein the computer program, when executed by the processor, implements the steps of the method for determining the model deployment mode as described in any one of claims 1 to 5.

8. A computer-readable storage medium, characterized in that, A computer program is stored on the computer-readable storage medium, and when executed by a processor, the computer program implements the steps of the method for determining the model deployment mode as described in any one of claims 1 to 5.

Citation Information

Patent Citations

  • Memory management method and device in neural network forward calculation process

    CN108829610A

  • Method and apparatus for determining memory requirement in a network

    CN111052149A

  • Computation graph serialization method and device and storage medium

    CN117540808A