A data processing method, device and storage medium
By processing and quantifying the intermediate computing diagram of the neural network model, the second neural network model suitable for KPU is generated, and the problem that KPU cannot effectively support neural network model training can be solved, and the effect of improving data processing efficiency is achieved.
Patent Information
- Application Number
- CN202010236673.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-03-30
- Publication Date
- 2025-01-24
- Estimated Expiration
- 2040-03-30
AI Technical Summary
Due to hardware limitations in the prior art, KPUs cannot effectively support the training of neural network models, resulting in inefficient data processing.
By obtaining the first neural network model, determine the medium computing diagram, and process it and quantify it, generate a second neural network model, so that it can adapt to KPU's computing power.
When training with neural network models, give full play to the computing advantage of KPU, improve data processing efficiency, and solve the problem of low data processing efficiency caused by hardware limit.
Smart Images

Figure CN113469351B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of neural network technology, and in particular to a data processing method, device and storage medium. Background Art
[0002] With the development of machine learning technology, more and more types of neural network models have emerged. Different types of neural network models refer to neural network models with different frameworks and different model files generated after neural network model training.
[0003] Currently, most frameworks are designed and optimized for central processing unit (CPU) and graphics processing unit (GPU) computing, such as TensorFlow and other frameworks. Although CPUs and GPUs have the corresponding processing capabilities, in the process of training using neural network models, hardware devices with heterogeneous computing capabilities such as KPU have more targeted processing for convolution operations. This means that in the process of training using neural network models, the computing power of the artificial intelligence (AI) acceleration engine (KPU) of the Kendryte K210 chip is usually better than that of the CPU and GPU.
[0004] However, KPU does not have the ability to execute instructions like CPU and GPU. Therefore, there is an urgent need for a data processing method to optimize the neural network model so as to give full play to the advantages of KPU in the process of training the neural network model. Summary of the invention
[0005] The present application provides a data processing method, device and storage medium to solve the technical problem of affecting data processing efficiency due to hardware limitations.
[0006] To solve the above problems, the technical solutions provided by this application are as follows:
[0007] In a first aspect, an embodiment of the present application provides a data processing method. The method includes: obtaining a first neural network model; determining a first intermediate calculation graph according to the first neural network model; processing the first intermediate calculation graph to obtain a second intermediate calculation graph; quantizing the second intermediate calculation graph to obtain a second neural network model corresponding to the first neural network model.
[0008] In one possible implementation, the method is applied to a compiler, the second neural network model output by the compiler is input data of a target device, the first neural network model is a model type not supported by the target device, and the second neural network model is a model type supported by the target device.
[0009] In a possible implementation, the obtaining of the first neural network model may be implemented as follows: obtaining the first neural network model trained based on an initial model framework, wherein the initial model framework is a model framework obtained through a model design tool based on input data.
[0010] In one possible implementation, the processing of the first intermediate computation graph to obtain the second intermediate computation graph can be implemented as follows: converting the first operator in the first intermediate computation graph into a second operator, wherein the processing complexity of the data processing process corresponding to the first operator is greater than the processing complexity of the data processing process corresponding to the second operator.
[0011] In one possible implementation, the processing of the first intermediate computation graph to obtain the second intermediate computation graph can be implemented as follows: determining a target operator whose processing complexity is less than a threshold from multiple operators in the first intermediate computation graph, and processing the data processing process corresponding to the target operator.
[0012] In one possible implementation, the processing of the first intermediate computation graph to obtain the second intermediate computation graph can be implemented as follows: splitting the convolution operation in the first intermediate computation graph, wherein the dimension of the convolution operation before splitting is greater than the dimension of the convolution operation after splitting.
[0013] In a second aspect, an embodiment of the present application provides a data processing device. The device includes:
[0014] A communication unit is used to obtain a first neural network model.
[0015] A processing unit is used to determine a first intermediate calculation graph based on the first neural network model obtained by the communication unit.
[0016] The processing unit is further used to process the first intermediate calculation graph to obtain a second intermediate calculation graph.
[0017] The processing unit is also used to quantize the second intermediate calculation graph to obtain a second neural network model corresponding to the first neural network model.
[0018] In one possible implementation, the device is applied to a compiler, the second neural network model output by the compiler is input data of a target device, the first neural network model is a model type not supported by the target device, and the second neural network model is a model type supported by the target device.
[0019] In a possible implementation, the communication unit is also used to obtain the first neural network model trained based on an initial model framework, where the initial model framework is a model framework obtained through a model design tool based on input data.
[0020] In a possible implementation, the processing unit is further used to convert a first operator in the first intermediate calculation graph into a second operator, wherein the processing complexity of the data processing process corresponding to the first operator is greater than the processing complexity of the data processing process corresponding to the second operator.
[0021] In a possible implementation, the processing unit is further used to determine a target operator whose processing complexity is less than a threshold from multiple operators in the first intermediate calculation graph, and process the data processing process corresponding to the target operator.
[0022] In a possible implementation, the processing unit is further used to split the convolution operation in the first intermediate calculation graph, wherein the dimension of the convolution operation before the splitting is greater than the dimension of the convolution operation after the splitting.
[0023] In a third aspect, an embodiment of the present application provides a data processing device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the method described in the first aspect and any one of its various possible implementation methods is implemented.
[0024] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, wherein the storage medium stores a computer program, and when the computer program is executed by a processor, the method described in the first aspect and any one of its various possible implementation methods is implemented.
[0025] It can be seen from this that the data processing method provided in the embodiment of the present application can achieve model conversion with the help of devices such as compilers for models that KPU cannot support (i.e., the first neural network model). The specific conversion mechanism can be achieved by processing and quantizing the intermediate calculation graph of the first neural network model.
[0026] This means that by adopting the technical solution provided in the embodiment of the present application to optimize the neural network model, the advantages of KPU can be brought into play in the process of training the neural network model, thereby solving the technical problem in the prior art that data processing efficiency is affected by hardware limitations. BRIEF DESCRIPTION OF THE DRAWINGS
[0027] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0028] Figure 1 is a flow chart of a data processing method according to an embodiment of the present application;
[0029] Figure 2 is a flow chart of a data processing method according to another embodiment of the present application;
[0030] Figure 3 A schematic diagram of the structure of a target device provided according to an embodiment of the present application;
[0031] Figure 4 is a schematic interactive diagram of a model conversion method according to an embodiment of the present application;
[0032] Figure 5 is a flow chart of a data processing method according to another embodiment of the present application;
[0033] Figure 6 A schematic diagram of a data processing device is provided for an embodiment of the present application;
[0034] Figure 7 A schematic diagram of the structure of another data processing device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0035] In order to more clearly illustrate the overall concept of the present application, a detailed description is given below in an illustrative manner in conjunction with the accompanying drawings.
[0036] The embodiment of the present application provides a data processing method, which can be applied to devices such as compilers that can realize model conversion. Taking the compiler as an example, the purpose of the embodiment of the present application is to process the model through the compiler to realize model conversion, so that the model that is not suitable for the KPU can be converted into a model suitable for the KPU. In this way, the computing power of the KPU can be effectively utilized, so that the advantages of the KPU can be brought into play in the process of training using the neural network model. Of course, the advantages of the KPU can also be fully utilized in the subsequent use of the trained model for image recognition, text recognition and other data processing processes. Since the corresponding data processing process is moved to the KPU for implementation, it is possible to effectively save the resources of the CPU, GPU, etc. used for the above-mentioned data processing process, so that the CPU, GPU, etc. can have more sufficient resources to support the data processing functions that need to be implemented by terminals such as computers.
[0037] It should be noted that the model conversion mechanism provided by the implementation method of the embodiment of the present application can also be applied to other devices, that is, for models that cannot be supported on the target device, the technical solution provided by the embodiment of the present application can be used to implement model conversion, so that the final model can be run on the target device. Among them, the target device may include but is not limited to a device that carries a KPU.
[0038] The following further illustrates the technical solution provided in the embodiment of the present application by taking the target device as a device carrying the KPU as an example.
[0039] The present application embodiment provides a data processing method, such as Figure 1 As shown, the method includes S101 to S104.
[0040] S101. Obtain a first neural network model.
[0041] In the embodiment of the present application, taking the data processing method applied to a compiler as an example, the first neural network model refers to the content input into the compiler as input data. That is, the first neural network model is a model type that is not supported by the target device. In the case where the target device is a KPU, the first neural network may refer to a model for a CPU, GPU, etc., that is, a model that can be run on a device such as a computer that carries a CPU, GPU, etc.
[0042] In one implementation, the first neural network model may be a trained model, so that after the model conversion is implemented, the converted second neural network model can be directly run on the KPU.
[0043] S102. Determine a first intermediate computation graph (Immediate Computation Graph, ICG) according to the first neural network model.
[0044] The intermediate computation graph refers to the internal representation of the model in the compiler, which can be used to record various operators such as multiplication, addition, convolution, etc. In the embodiment of the present application, the first intermediate computation graph refers to the intermediate computation graph corresponding to the first neural network model, that is, it is used to record the operators involved in the first neural network.
[0045] S103: Process the first intermediate calculation graph to obtain a second intermediate calculation graph.
[0046] S104. quantize the second intermediate computation graph to obtain a second neural network model corresponding to the first neural network model.
[0047] In order to achieve model conversion, in an embodiment of the present application, the first intermediate calculation graph can be processed to obtain a second intermediate calculation graph corresponding to the converted model. In this way, the converted model, i.e., the second neural network model, can be obtained by quantizing the second intermediate calculation graph.
[0048] It can be seen from this that for the model that KPU cannot support (i.e., the first neural network model), model conversion can be achieved with the help of compilers and other devices. The specific conversion mechanism can be achieved by processing and quantizing the intermediate calculation graph of the first neural network model.
[0049] This means that by adopting the technical solution provided in the embodiment of the present application to optimize the neural network model, the advantages of KPU can be brought into play in the process of training the neural network model, thereby solving the technical problem in the prior art that data processing efficiency is affected by hardware limitations.
[0050] It should be noted that, when the technical solution provided in the embodiment of the present application is applied to a compiler, the second neural network model output by the compiler is the input data of the target device, and the second neural network model is a model type supported by the target device.
[0051] In one implementation of an embodiment of the present application, the first neural network model may refer to TensorFlow, TFLite, Caffe, PaddlePaddle model, etc., and the second neural network model may refer to a KPU model, that is, a model that can run on a KPU.
[0052] As the first neural network model before conversion, it can be a model trained according to user needs. Therefore, in one implementation of the embodiment of the present application, Figure 1 Based on the implementation shown in FIG. Figure 2 The implementation shown in FIG. 101 , in which S101 obtains a first neural network model, can be implemented as S1011 .
[0053] S1011. Obtain a first neural network model trained based on an initial model framework.
[0054] Among them, the initial model framework is a model framework obtained through a model design tool based on input data.
[0055] like Figure 3 The target device 20 includes a general component 21 for implementing model conversion, a model design tool 22 for implementing the first neural network model design, and a command line conversion tool 23. The general component 21, the model design tool 22, and the command line conversion tool 23 can exchange data with each other. The specific data transmission process may include but is not limited to Figure 3 Example data transfer paths.
[0056] The user can input the input data for generating the initial model framework into the model design tool 22 according to his / her needs. The model design tool can build the initial model framework through the ICG view model 221 and the model constraint check module 222. Among them, the ICG view model 221 can be used to stack operators; the model constraint check module 222 can be used to determine whether the operator or model framework can be supported by the current hardware.
[0057] After the initial model framework is built through the model design tool 22, the initial model framework can be used to implement parameter conversion through the command line conversion tool 23, and then the model framework is trained to obtain a trained first neural network model, and the first neural network model is obtained through the various functional modules in the general component 21 or by calling the various functions of the component 21 to obtain the second neural network model.
[0058] Among them, the general component 21 may include a model import module 211, an intermediate calculation graph 212 (which may include but is not limited to a first intermediate calculation graph, or a first intermediate calculation graph and a second intermediate calculation graph), a Transform model optimization module 213, a data set processing module 214, a model quantization module 215 and a model export module 216.
[0059] The following references Figure 4 The interactive diagram of the model conversion method shown in FIG. 1 is used to further illustrate the technical solution provided by the embodiment of the present application. The model and the conversion method may include S301 to S312.
[0060] S301: The data set processing module obtains a data set.
[0061] S302: The model import module obtains the trained first neural network model.
[0062] In an embodiment of the present application, a user can input a data set and a trained first neural network model into a compiler, so that the compiler implements model conversion based on the acquired data set and the trained first neural network model, thereby obtaining a second neural network model.
[0063] The data set may include parameters required for model quantization, and may also include samples for training the first neural network model and / or for training the second neural network model. It should be noted that in the embodiment of the present application, the storage form of the data set, the format of each data in the data set, the transmission method, etc. are not limited, and can be adjusted in combination with actual model conversion requirements or compiler specifications.
[0064] S303. The model importing module obtains a first intermediate calculation graph according to the first neural network model.
[0065] S304. The model import module sends the first intermediate calculation graph to the model export module.
[0066] S305. The model export module sends the first intermediate calculation graph to the Transform model optimization module.
[0067] In an embodiment of the present application, the model export module may forward the received first intermediate computation graph to the Transform model optimization module, so that the Transform model optimization module optimizes the first intermediate computation graph.
[0068] S306. The Transform model optimization module optimizes the first intermediate calculation graph to obtain a second intermediate calculation graph.
[0069] For the implementation process of optimizing the first intermediate computation graph to obtain the second intermediate computation graph, reference may be made to the description shown in any one of S1031 to S1033 below, which will not be described in detail here.
[0070] S307. The Transform model optimization module sends the second intermediate calculation graph to the model export module.
[0071] S308: The model export module sends a request for obtaining a data set to the data set processing module.
[0072] S309: The data set processing module sends the data set to the model export module.
[0073] In an embodiment of the present application, in S309, the data set processing module may send part or all of the data set to the model export module. Wherein, in the case where the data set only includes parameters required for model quantization, the data set processing module responds to the request for obtaining the data set sent by the model export module, and needs to send the parameters required for model quantization to the model export module; and in the case where the data set includes parameters required for model quantization and other data such as samples, the data set processing module responds to the request for obtaining the data set sent by the model export module, and needs to at least send the parameters required for model quantization to the model export module, and optionally send other part or all of the data included in the data set to the model export module.
[0074] S310, the model export module obtains an unquantized neural network model according to the data set and the second intermediate calculation graph.
[0075] It should be noted that, considering that the first neural network model is a trained model, the unquantized neural network model can be obtained only based on the second intermediate calculation graph. In addition, considering that the data set obtained by the model export module may only include the parameters required for model quantization, the unquantized neural network model can also be obtained only based on the second intermediate calculation graph. This means that S310 can also be implemented as a model export module to obtain an unquantized neural network model according to the second intermediate calculation graph. At this time, S310 can be executed before executing S309 in terms of timing, or executed at the same time as executing S309, and of course it can also be executed after executing S309.
[0076] It can be seen from this that Figure 4 The model conversion method shown is only an exemplary model conversion method and is not intended to be a limitation on the embodiments of the present application.
[0077] S311. The model export module calls the quantization function of the model quantization module to quantize the unquantized neural network model and obtain a second neural network model.
[0078] S312, the model export module outputs the second neural network model.
[0079] It should be noted that the above S301 and S302 can be implemented by the user to input data. For example, the user can use devices such as computers to input data sets, trained first neural network models and other contents into the compiler. Similarly, S312 can be implemented by the model export module of the compiler, with the help of components with output functions such as displays of devices such as computing devices, to output the second neural network model. Of course, the obtained second neural network model can also be stored in a computer, server or other device with storage resources or in the cloud, so that it can be called when the target device such as a KPU needs the second neural network model.
[0080] In order to enable devices such as KPU to support more operators, in one implementation of the embodiment of the present application, Figure 1 Or based on the implementation shown in 2, Figure 1 For example, it can also be implemented as Figure 5 The implementation shown in FIG. S103 processes the first intermediate calculation graph to obtain the second intermediate calculation graph, which can be implemented as one or a combination of multiple items in S1031 to S1033.
[0081] S1031. Convert the first operator in the first intermediate calculation graph into a second operator.
[0082] The processing complexity of the data processing process corresponding to the first operator is greater than the processing complexity of the data processing process corresponding to the second operator.
[0083] By converting the first operator into the second operator, the KPU can support more types of operators, that is, by converting the operator, the operator not supported by the KPU can be converted into the operator supported by the KPU, so that the KPU can carry more operations corresponding to the operators, that is, expand the operators supported by the KPU. It should be noted that, under normal circumstances, the complexity of the converted second operator is often less than the complexity of the first operator.
[0084] S1032. Determine a target operator whose processing complexity is less than a threshold from among multiple operators in the first intermediate computation graph, and process a data processing process corresponding to the target operator.
[0085] In order to save resources and time occupied by the neural network model in the process of processing data, in the process of generating the second intermediate calculation graph, that is, in the process of optimizing the first intermediate calculation graph, a simple operator, that is, the target operator, corresponding to the data processing process can be executed. In this way, in the calculation process of calling the optimized operator, the amount of calculation and the resources occupied by the calculation process can be reduced.
[0086] The threshold value can be preset, and can be determined based on one or more parameters such as resources and time occupied by the data processing process corresponding to the operator, or can be determined based on other factors that affect the data processing process. In the embodiment of the present application, the value, setting method, and expression form of the threshold value are not limited.
[0087] S1033. Split the convolution operation in the first intermediate calculation graph.
[0088] Among them, the dimension of the convolution operation before splitting is larger than the dimension of the convolution operation after splitting.
[0089] Considering that KPU and the like are often more suitable for implementing lower-dimensional convolution operations during convolution operations, in one implementation of the present application, the dimension of the convolution operation can be adjusted. That is, the convolution operation in the first intermediate calculation graph is split to obtain the convolution operation dimension processed by the English KPU. For example, a 5*5 matrix is cut to obtain a 3*3 or 4*4 matrix, thereby adjusting the dimension of the matrix involved in the convolution operation.
[0090] It can be seen from this that in the process of optimizing the first intermediate calculation graph, that is, in the process of obtaining the second intermediate calculation graph, the first intermediate calculation graph corresponding to the first neural network model can be processed by simplifying calculations, processing simple calculation processes in advance, and other implementation methods, so as to obtain the second intermediate calculation graph corresponding to the second neural network model supported by KPU.
[0091] It should be noted that the above S1031 to S1033 are only possible implementation methods of optimizing the first intermediate calculation graph exemplified in the embodiment of the present application, but in the process of actually generating the second intermediate calculation graph, other processing methods with the same effect or capable of achieving similar implementation results may also be used. In the embodiment of the present application, the specific implementation method of optimizing the first intermediate calculation graph is not limited.
[0092] In the embodiment of the present application, taking into account the particularity of the convolution operation, the processing result of the previous layer of convolution is usually used as the input of the next layer of convolution operation. However, in the actual operation process, the local cache (buffer) of the KPU can accommodate a limited matrix dimension. For a calculation graph with a higher dimension, the KPU needs to store the processing result of the previous layer of convolution to the DDR, and then obtain the processing result of the previous layer of convolution from the DDR, and then implement the convolution operation of the next layer. In this way, during each convolution operation, it is necessary to implement data interaction between the KPU and the DDR, so as to realize the reading and storage process of the convolution result. This undoubtedly increases the data transmission resources during the convolution operation and increases the total time occupied by the convolution operation.
[0093] In order to solve the above technical problems, in one implementation of the embodiment of the present application, the KPU can split the calculation graph during the execution of the convolution operation. That is, the calculation graph with a higher dimension is split into a calculation graph with a lower dimension, so that during the convolution operation, the processing results of each layer output are cached in the buffer, and then the convolution operation processing results of the previous layer are read from the buffer as the input of the next layer of convolution operation. This saves the frequent interaction between the KPU and the DDR, reduces the data transmission resources and time consumed in the convolution operation process, and effectively improves the throughput.
[0094] In summary, in one implementation of the embodiment of the present application, various types of models not supported by KPU can be compiled, so that these models not supported by KPU can be deployed on K210.
[0095] The present application embodiment provides a data processing device. Figure 6 As shown, the data processing device 40 may include:
[0096] The communication unit 41 is used to obtain a first neural network model.
[0097] The processing unit 42 is used to determine a first intermediate calculation graph according to the first neural network model obtained by the communication unit 41.
[0098] The processing unit 42 is further configured to process the first intermediate calculation graph to obtain a second intermediate calculation graph.
[0099] The processing unit 42 is also used to quantize the second intermediate calculation graph to obtain a second neural network model corresponding to the first neural network model.
[0100] In one implementation, the data processing device 40 is applied to a compiler, the second neural network model output by the compiler is the input data of the target device, the first neural network model is a model type not supported by the target device, and the second neural network model is a model type supported by the target device.
[0101] In one implementation, the communication unit 41 is also used to obtain a first neural network model trained based on an initial model framework, where the initial model framework is a model framework obtained through a model design tool based on input data.
[0102] In one implementation, the processing unit 42 is further used to convert the first operator in the first intermediate calculation graph into a second operator, wherein the processing complexity of the data processing process corresponding to the first operator is greater than the processing complexity of the data processing process corresponding to the second operator.
[0103] In one implementation, the processing unit 42 is further configured to determine a target operator whose processing complexity is less than a threshold from among multiple operators in the first intermediate computation graph, and process the data processing process corresponding to the target operator.
[0104] In one implementation, the processing unit 42 is further configured to split the convolution operation in the first intermediate computation graph, wherein the dimension of the convolution operation before the splitting is greater than the dimension of the convolution operation after the splitting.
[0105] In one implementation, the data processing device 40 may further include at least one of a storage unit 43 and a display unit 44. The storage unit 43 may be used to store the content required by the above-mentioned multiple units when implementing corresponding functions, and the display unit 44 may be used to display the progress of data processing, etc. In the embodiment of the present application, the content, format, etc. stored in the storage module are not limited.
[0106] It should be noted that the communication unit 41 can also be used to implement data interaction between the above-mentioned multiple units, and / or support data interaction between the data processing device and devices such as servers and other processing devices.
[0107] In the embodiment of the present application, the communication unit 41 can be implemented as a communication interface, the processing unit 42 can be implemented as a processor and / or a controller, the storage unit 43 can be implemented as a memory, and the display unit 44 can be implemented as a display.
[0108] like Figure 7 As shown, it is a schematic diagram of the structure of another data processing device provided in an embodiment of the present application. The data processing device 50 may include a communication interface 51 and a processor 52. In one implementation, the data processing device 50 may also include one or more of a memory 53 and a display 54. Among them, the communication interface 51, the processor 52, the memory 53 and the display 54 can communicate through a bus 55. Among them, the functions implemented by the above-mentioned components can refer to the description of the functions of each module in the previous text, and will not be repeated here.
[0109] It should be noted that the reference Figure 6 , Figure 7 The data processing device provided in the embodiment of the present application may include more or fewer modules and components than those shown in the figure, which is not limited here.
[0110] The present application provides a data processing device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, any one of the above-mentioned possible implementation methods is implemented.
[0111] The present application provides a computer-readable storage medium. The storage medium stores a computer program, and when the computer program is executed by a processor, the method of any one of the above-mentioned possible implementation modes is implemented.
[0112] Each embodiment in this specification is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the entity embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0113] The professionals should further realize that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented by electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in the above description according to the function. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.
[0114] The steps of the method or algorithm described in conjunction with the embodiments disclosed herein may be implemented using hardware, a software module executed by a processor, or a combination of the two. The software module may be placed in a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
[0115] The above are only embodiments of the present application and are not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included within the scope of the claims of the present application.
Claims
1. A data processing method, characterized in that: The method comprises: Obtain a first neural network model; the first neural network is applicable to a central processing unit and a graphics processing unit, but not to an artificial intelligence acceleration engine KPU; Determine a first intermediate computation graph according to the first neural network model; Converting the first operator in the first intermediate calculation graph into a second operator to obtain a second intermediate calculation graph, wherein the processing complexity of the data processing process corresponding to the first operator is greater than the processing complexity of the data processing process corresponding to the second operator; or, determining a target operator whose processing complexity is less than a threshold from multiple operators in the first intermediate calculation graph, and processing the data processing process corresponding to the target operator to obtain a second intermediate calculation graph; or, splitting the convolution operation in the first intermediate calculation graph to obtain a second intermediate calculation graph, wherein the dimension of the convolution operation before splitting is greater than the dimension of the convolution operation after splitting; The second intermediate computational graph is quantized to convert the first neural network model into a second neural network model suitable for the artificial intelligence acceleration engine KPU.
2. The method according to claim 1, characterized in that The method is applied to a compiler, the second neural network model output by the compiler is input data of a target device, the first neural network model is a model type not supported by the target device, and the second neural network model is a model type supported by the target device.
3. The method according to claim 1 or 2, characterized in that: The obtaining of the first neural network model comprises: The first neural network model trained based on an initial model framework is obtained, where the initial model framework is a model framework obtained through a model design tool based on input data.
4. A data processing device, characterized in that: The device comprises: A communication unit, used to obtain a first neural network model; the first neural network is applicable to a central processing unit and a graphics processing unit, but not to a target processor of an artificial intelligence acceleration engine KPU; A processing unit, configured to determine a first intermediate computation graph according to the first neural network model acquired by the communication unit; The processing unit is further used to convert the first operator in the first intermediate calculation graph into a second operator to obtain a second intermediate calculation graph, wherein the processing complexity of the data processing process corresponding to the first operator is greater than the processing complexity of the data processing process corresponding to the second operator; or, from multiple operators in the first intermediate calculation graph, determine a target operator whose processing complexity is less than a threshold, and process the data processing process corresponding to the target operator to obtain the second intermediate calculation graph; or, split the convolution operation in the first intermediate calculation graph to obtain the second intermediate calculation graph, wherein the dimension of the convolution operation before the splitting is greater than the dimension of the convolution operation after the splitting; The processing unit is also used to quantize the second intermediate computational graph to convert the first neural network model into a second neural network model suitable for the artificial intelligence acceleration engine KPU.
5. The device according to claim 4, characterized in that The device is applied to a compiler, the second neural network model output by the compiler is input data of a target device, the first neural network model is a model type not supported by the target device, and the second neural network model is a model type supported by the target device.
6. The device according to claim 4 or 5, characterized in that The communication unit is also used to obtain the first neural network model trained based on an initial model framework, where the initial model framework is a model framework obtained through a model design tool based on input data.
7. A data processing device, characterized in that: The method comprises a memory, a processor and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the method according to any one of claims 1 to 3 is implemented.
8. A computer-readable storage medium, characterized in that: The storage medium stores a computer program, and when the computer program is executed by a processor, the method according to any one of claims 1 to 3 is implemented.
Citation Information
Patent Citations
Neural network model processing method and device and electronic equipment
CN110378413A
Neural network processing method and device, computer device and storage medium
CN110674936A
Neural network model processing method and device, computer equipment and storage medium
CN110689115A