Data processing method and device, computer device, and storage medium
Patent Information
- Application Number
- CN202310457378.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-04-25
- Publication Date
- 2026-08-18
- Estimated Expiration
- 2043-04-25
AI Technical Summary
[0004]有鉴于此,本发明提供了一种数据处理方法、装置、计算机设备及存储介质,以解决现有技术中,利用深度神经网络模型进行数据处理时,对硬件平台的要求较高,且数据处理效率较低的问题
[0029]根据数据量大小与非结构化稀疏参数矩阵以及参数掩码矩阵之间的关系,确定目标数据处理模型处理待处理数据过程中的有效任务和无效任务,并确定各个有效任务对应的预期执行时间;
Smart Images

Figure CN116542313B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of data processing, and more specifically to data processing methods, apparatus, computer equipment, and storage media. Background Technology
[0002] With the development of artificial intelligence, deep neural network models have been widely used in various fields such as social security and public services, and various deep learning frameworks based on deep neural network models are constantly being proposed; however, as the number of layers in deep neural networks continues to increase, the number of parameters and the amount of computation in deep learning frameworks are also becoming larger and larger.
[0003] Therefore, using deep neural network models for data processing places high demands on the hardware platform and results in low data processing efficiency. Summary of the Invention
[0004] In view of this, the present invention provides a data processing method, apparatus, computer equipment, and storage medium to solve the problems of high hardware platform requirements and low data processing efficiency when using deep neural network models for data processing in the prior art.
[0005] In a first aspect, the present invention provides a data processing method, the method comprising:
[0006] Obtain the data to be processed and the corresponding original data processing model;
[0007] The original data processing model is compressed to generate the target data processing model;
[0008] Based on the data to be processed and the target data processing model, calculate the total workload of the target data processing model in processing the data to be processed.
[0009] The total workload is distributed across multiple hardware platforms to process the data to be processed.
[0010] The data processing method provided in this application obtains the data to be processed and the corresponding original data processing model. The original data processing model is compressed to generate a target data processing model. Redundant model connections are removed from the target data processing model, reducing the number of parameters and making the generated target data processing model more concise. Therefore, the efficiency of the target data processing model in processing the data to be processed is improved. Then, based on the data to be processed and the target data processing model, the total task load for processing the data to be processed by the target data processing model is calculated, ensuring the accuracy of the calculated total task load. The total task load is distributed to multiple hardware platforms to complete the processing of the data to be processed, realizing process-level computational task control. A computational task simplification mechanism based on sparse structure is designed, and existing computing platforms are used to achieve the connection between software compression and actual hardware acceleration, realizing hardware support for software-layer optimization results. The high compression ratio of the software layer is fully utilized, achieving efficient utilization of hardware resources and reducing the time and resource consumption during inference of the original data processing model. This improves the efficiency of data processing for the data to be processed.
[0011] In one optional implementation, the original data processing model is compressed to generate the target data processing model, including:
[0012] The original data processing model is pruned using an improved alternating direction multiplier pruning algorithm to generate the target data processing model.
[0013] The data processing method provided in this application prunes the original data processing model based on an improved alternating direction multiplier pruning algorithm to generate a target data processing model. This removes redundant model connections and reduces the number of parameters in the target data processing model, making it more concise. Therefore, it improves the efficiency of the target data processing model in processing the data to be processed. Furthermore, the method performs unstructured pruning on the original data processing model and then distributes the total workload across multiple hardware platforms, solving the problem that existing unstructured sparse original data processing models cannot be deployed on hardware.
[0014] In one optional implementation, the original data processing model is pruned based on an improved alternating direction multiplier pruning algorithm to generate a target data processing model, including:
[0015] A penalty factor is introduced into the original alternating direction multiplier pruning algorithm. The penalty factor is used to shorten the distance between the model parameters and the expected values corresponding to the model parameters in the original data processing model.
[0016] Initialize the expected values and penalty factors corresponding to the model parameters, and generate the initial expected values and initial penalty factors;
[0017] Based on the initial expected value and the initial penalty factor, the original data processing model is pruned and iteratively calculated to obtain the unstructured sparse parameter matrix corresponding to the target data processing model; the unstructured sparse parameter matrix is the parameter matrix obtained after pruning the model parameters;
[0018] Generate the target data processing model based on the unstructured sparse parameter matrix.
[0019] The data processing method provided in this application introduces a penalty factor into the original alternating direction multiplier pruning algorithm, initializes the expected values and penalty factors corresponding to the model parameters, and generates initial expected values and initial penalty factors. Based on the initial expected values and initial penalty factors, iterative calculations are performed on the original data processing model to obtain the unstructured sparse parameter matrix corresponding to the target data processing model. The target data processing model is generated based on the unstructured sparse parameter matrix, ensuring the accuracy of the obtained unstructured sparse parameter matrix, and thus ensuring the accuracy of the obtained target data processing model. This method compresses the original data processing model to obtain the target data processing model. Redundant model connections in the target data processing model are removed, reducing the number of parameters and making the generated target data processing model more concise. Therefore, the efficiency of the target data processing model in processing the data to be processed is improved.
[0020] In one optional implementation, based on the initial expected value and the initial penalty factor, the original data processing model is pruned iteratively to obtain the unstructured sparse parameter matrix corresponding to the target data processing model, including:
[0021] Based on the initial expected value and the initial penalty factor, the original data processing model is pruned and iteratively calculated to generate candidate data processing models;
[0022] Obtain the model accuracy and compression ratio corresponding to the candidate data processing model;
[0023] Based on the model accuracy and model compression ratio, the initial penalty factor is expanded according to a preset rule to generate candidate penalty factors;
[0024] Based on the initial expected value and candidate penalty factors, the candidate data processing model is pruned and iteratively calculated to obtain the unstructured sparse parameter matrix corresponding to the target data processing model.
[0025] The data processing method provided in this application performs iterative calculations on the original data processing model based on an initial expected value and an initial penalty factor, generating candidate data processing models. This ensures the accuracy of the generated candidate data processing models and achieves initial compression of the original data processing model. The method obtains the model accuracy and compression ratio corresponding to the candidate data processing models. Based on the model accuracy and compression ratio, the initial penalty factor is increased according to a preset rule to generate candidate penalty factors, ensuring the accuracy of the generated candidate penalty factors and achieving a gradual increase in the candidate penalty factors. Then, based on the initial expected value and candidate penalty factors, iterative calculations are performed on the candidate data processing models to obtain the unstructured sparse parameter matrix corresponding to the target data processing model. This results in a larger compression ratio for the generated unstructured sparse parameter matrix, thereby ensuring a larger compression ratio for the generated target data processing model. Therefore, it achieves the maximum compression ratio of the target data processing model while maintaining high model accuracy.
[0026] In one optional implementation, based on the data to be processed and the target data processing model, the total workload of the target data processing model in processing the data to be processed is calculated, including:
[0027] Get the size of the data to be processed;
[0028] Obtain the unstructured sparse parameter matrix and the parameter mask matrix corresponding to the target data processing model; the parameter mask matrix is used to characterize whether each element in the unstructured sparse parameter matrix has been pruned.
[0029] Based on the relationship between the data volume and the unstructured sparse parameter matrix and the parameter mask matrix, the effective and invalid tasks in the process of the target data processing model processing the data to be processed are determined, and the expected execution time corresponding to each effective task is determined.
[0030] The various valid tasks are merged to generate the total number of tasks.
[0031] The data processing method provided in this application embodiment obtains the size of the data to be processed, the unstructured sparse parameter matrix corresponding to the target data processing model, and the parameter mask matrix corresponding to the unstructured sparse parameter matrix. Then, based on the relationship between the data size and the unstructured sparse parameter matrix and the parameter mask matrix, it determines the effective and invalid tasks in the process of the target data processing model processing the data to be processed, and determines the expected execution time corresponding to each effective task, ensuring the accuracy of the determined effective and invalid tasks in the process of the target data processing model processing the data to be processed, and ensuring the accuracy of the determined expected execution time corresponding to each effective task. The effective tasks are merged to generate a total task quantity, ensuring the accuracy of the generated total task quantity.
[0032] In one alternative implementation, the total workload is distributed across multiple hardware platforms to process the data to be processed, including:
[0033] Obtain the computing power corresponding to each hardware platform;
[0034] Based on the computing power and the expected execution time of each effective task, the total task volume is divided into multiple sub-task volumes.
[0035] The workload of each subtask is allocated to the corresponding hardware platform.
[0036] Obtain the sub-computation results corresponding to each hardware platform;
[0037] The results of each sub-calculation are summarized to generate the result of processing the data to be processed.
[0038] The data processing method provided in this application obtains the computing power corresponding to each hardware platform; based on the computing power and the expected execution time of each effective task, the total task volume is divided into multiple sub-task volumes, ensuring the accuracy of the divided sub-task volumes. Each sub-task volume is allocated to its corresponding hardware platform; the sub-computation results corresponding to each hardware platform are obtained; and the sub-computation results are summarized to generate the result for processing the data to be processed, ensuring the accuracy of the generated result. This method simplifies and accelerates the computational task by mapping the software sparse algorithm to the hardware platform's computing process. It adapts the software model optimization results to hardware resources, thereby fully leveraging the advantages of flexible software configuration. It solves the problem that existing unstructured sparse target data processing models cannot be deployed on hardware.
[0039] In a second aspect, the present invention provides a data processing apparatus, the apparatus comprising:
[0040] The acquisition module is used to acquire the data to be processed and the original data processing model corresponding to the data to be processed.
[0041] The compression module is used to compress the original data processing model to generate the target data processing model;
[0042] The calculation module is used to calculate the total workload of the target data processing model in processing the data to be processed, based on the data to be processed and the target data processing model.
[0043] The completion module is used to distribute the total workload across multiple hardware platforms to process the data to be processed.
[0044] The data processing apparatus provided in this application acquires the data to be processed and the corresponding original data processing model. It then compresses the original data processing model to generate a target data processing model, removing redundant model connections and reducing the number of parameters, thus making the generated target data processing model more concise. This improves the efficiency of the target data processing model in processing the data to be processed. Next, based on the data to be processed and the target data processing model, the total workload of the target data processing model in processing the data to be processed is calculated, ensuring the accuracy of the calculated total workload. The total workload is distributed to multiple hardware platforms to complete the processing of the data to be processed. Process-level computational task control is implemented; a computational task simplification mechanism based on sparse structure is designed, and existing computing platforms are utilized to achieve connectivity between software compression and actual hardware acceleration, enabling hardware support for software-layer optimization results. This fully leverages the advantages of high compression ratio at the software layer, achieving efficient utilization of hardware resources and reducing the time and resource consumption during inference of the original data processing model. This, in turn, improves the efficiency of data processing for the data to be processed.
[0045] In one alternative implementation, a compression module is used to prune the original data processing model based on an improved alternating direction multiplier pruning algorithm to generate a target data processing model.
[0046] The data processing apparatus provided in this application prunes the original data processing model based on an improved alternating direction multiplier pruning algorithm to generate a target data processing model. This removes redundant model connections and reduces the number of parameters in the target data processing model, making it more concise. Therefore, it improves the efficiency of the target data processing model in processing the data to be processed. Furthermore, the above method performs unstructured pruning on the original data processing model and then distributes the total workload across multiple hardware platforms, solving the problem that existing unstructured sparse original data processing models cannot be deployed on hardware.
[0047] Thirdly, the present invention provides a computer device, comprising: a memory and a processor, the memory and the processor being communicatively connected to each other, the memory storing computer instructions, and the processor executing the computer instructions to perform the data processing method described in the first aspect or any corresponding embodiment thereof.
[0048] Fourthly, the present invention provides a computer-readable storage medium storing computer instructions for causing a computer to perform the data processing method described in the first aspect or any corresponding embodiment thereof. Attached Figure Description
[0049] To more clearly illustrate the specific embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the specific embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.
[0050] Figure 1 This is a schematic diagram of model pruning in the data processing method according to an embodiment of the present invention;
[0051] Figure 2 This is a schematic diagram of unstructured model pruning in the data processing method according to an embodiment of the present invention;
[0052] Figure 3 This is a schematic diagram of structured model pruning in the data processing method according to an embodiment of the present invention;
[0053] Figure 4 This is a flowchart illustrating a data processing method according to an embodiment of the present invention;
[0054] Figure 5 This is a flowchart illustrating a data processing method according to another embodiment of the present invention;
[0055] Figure 6 This is a flowchart illustrating a data processing method according to another embodiment of the present invention;
[0056] Figure 7 This is a schematic flowchart of a data processing method according to another embodiment of the present invention;
[0057] Figure 8 This is a structural block diagram of a data processing apparatus according to an embodiment of the present invention;
[0058] Figure 9 This is a schematic diagram of the hardware structure of a computer device according to an embodiment of the present invention. Detailed Implementation
[0059] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0060] With the development of artificial intelligence, deep neural network models have been widely used in various fields such as social security and public services, and various deep learning frameworks based on deep neural network models are constantly being proposed; however, as the number of layers in deep neural networks continues to increase, the number of parameters and the amount of computation in deep learning frameworks are also becoming larger and larger.
[0061] Therefore, before deploying deep neural network models on actual hardware platforms, sparsity compression is performed on the deep neural network models. Pruning, as a type of compression method, effectively reduces the number of model parameters by removing redundant model connections; in actual deployment, removing redundant connections results in a simplified model, thus accelerating deployment. For example, ... Figure 1 The diagram shown is a schematic of the model pruning process.
[0062] Pruning compression methods can be divided into two categories: unstructured pruning and structured pruning. Unstructured pruning refers to pruning parameters whose positions have no structure; that is, different pruning positions are unrelated and do not constitute a unified structure. For example, ... Figure 2 The diagram shows a schematic of pruning an unstructured model.
[0063] This pruning method can achieve a high compression ratio, but because the hardware design itself is geared towards structured computation, unstructured sparse models cannot effectively utilize the parallel capabilities of the hardware platform, resulting in very low actual speedup gains on hardware. Therefore, unstructured pruning is rarely used in practical data processing applications.
[0064] Structured pruning refers to pruning parameters where the positions of the pruned parameters have a structured nature (e.g., the pruned parameters present an entire row, column, or matrix structure). For example, ... Figure 3 The diagram shown illustrates the pruning process for a structured model.
[0065] This pruning method is very compatible with existing hardware and can be deployed on actual GPU platforms with simple model modifications. However, due to the limitation of the pruning location, the compression ratio is relatively low.
[0066] Therefore, using deep neural network models for data processing places high demands on the hardware platform and results in low data processing efficiency.
[0067] Based on this, this application provides a data processing method that accelerates the processing of data by compressing the original data processing model. Then, the total workload of processing the data is distributed across multiple hardware platforms to complete the processing, achieving hardware support for software-level optimization results. This solves the problem in the prior art where data processing using deep neural network models has high hardware platform requirements and low data processing efficiency.
[0068] According to an embodiment of the present invention, a data processing method embodiment is provided. It should be noted that the steps shown in the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions. Furthermore, although a logical order is shown in the flowchart, in some cases, the steps shown or described may be executed in a different order than that shown here.
[0069] It should be noted that the data processing method provided in this application embodiment can be executed by a data processing device. This device can be implemented as part or all of a computer device through software, hardware, or a combination of both. The computer device can be a server or a terminal. In this application embodiment, the server can be a single server or a server cluster composed of multiple servers. The terminal in this application embodiment can be a smartphone, personal computer, tablet computer, wearable device, or other intelligent hardware device such as an intelligent robot. The following method embodiments will use a computer device as the execution subject for illustration.
[0070] This embodiment provides a data processing method that can be used in the aforementioned computer devices, such as mobile phones and tablet computers. Figure 4 This is a flowchart of a data processing method according to an embodiment of the present invention, such as... Figure 4 As shown, the process includes the following steps:
[0071] Step S101: Obtain the data to be processed and the original data processing model corresponding to the data to be processed.
[0072] Specifically, the computer device can receive user-inputted data to be processed and the corresponding raw data processing model; the computer device can also receive data to be processed sent by other devices and the corresponding raw data processing model; the computer device can also receive data to be processed sent by users or other devices, and receive a training dataset, and use the training dataset to train the corresponding raw data processing model.
[0073] This application does not specifically limit the method by which computer devices acquire the data to be processed and the corresponding original data processing model.
[0074] The data to be processed can be image data, voice data, or text data. This application embodiment does not specifically limit the data to be processed.
[0075] The original data processing model can be one of the following network models: Deep Neural Network (DNN), Feedforward Neural Network and Perceptron (FF or FFNN), Radial Basis Function (RBF), Radial Basis Function (RBF), Convolutional Neural Network (CNN), Deep Convolutional Inverse Graphics Network (DCIGN), Generative Adversarial Network (GAN). This application does not specifically limit the original data processing model.
[0076] Step S102: Compress the original data processing model to generate the target data processing model.
[0077] Specifically, computer equipment can use a preset compression algorithm to compress the original data processing model and generate the target data processing model.
[0078] The preset compression algorithm can be a pruning compression algorithm, a distillation compression algorithm, or a quantization compression algorithm. The pruning compression algorithm can be an unstructured pruning algorithm or a structured pruning algorithm. This application does not specifically limit the preset compression algorithm.
[0079] This step will be explained in detail below.
[0080] Step S103: Calculate the total workload of the target data processing model in processing the data to be processed, based on the data to be processed and the target data processing model.
[0081] Specifically, after compressing the original data processing model to generate the target data processing model, the computer equipment can calculate the total workload of the target data processing model in processing the data to be processed based on the process of processing the data to be processed by the target data processing model.
[0082] This step will be explained in detail below.
[0083] Step S104: Distribute the total workload to multiple hardware platforms to complete the processing of the data to be processed.
[0084] Specifically, after calculating the total workload of the target data processing model in processing the data to be processed, the computer equipment can allocate the total workload to multiple hardware platforms according to the attribute information corresponding to each hardware platform, so as to complete the processing of the data to be processed.
[0085] Among them, computer equipment can distribute the total workload evenly across multiple hardware platforms, or it can distribute it unevenly across multiple hardware platforms.
[0086] The data processing method provided in this embodiment obtains the data to be processed and the corresponding original data processing model. The original data processing model is compressed to generate a target data processing model. Redundant model connections are removed from the target data processing model, reducing the number of parameters and making the generated target data processing model more concise. Therefore, the efficiency of the target data processing model in processing the data to be processed is improved. Then, based on the data to be processed and the target data processing model, the total task load for processing the data to be processed by the target data processing model is calculated, ensuring the accuracy of the calculated total task load. The total task load is distributed to multiple hardware platforms to complete the processing of the data to be processed, realizing process-level computational task control. A computational task simplification mechanism based on sparse structure is designed, and existing computing platforms are used to achieve the connection between software compression and actual hardware acceleration, realizing hardware support for software-layer optimization results. The high compression ratio of the software layer is fully utilized, achieving efficient utilization of hardware resources and reducing the time and resource consumption during inference of the original data processing model. This improves the efficiency of data processing for the data to be processed.
[0087] This embodiment provides a data processing method that can be used in the aforementioned computer devices, such as mobile phones and tablet computers. Figure 5 This is a flowchart of a data processing method according to an embodiment of the present invention, such as... Figure 5 As shown, the process includes the following steps:
[0088] Step S201: Obtain the data to be processed and the original data processing model corresponding to the data to be processed.
[0089] Please see details Figure 4 Step S101 of the illustrated embodiment will not be described again here.
[0090] Step S202: Compress the original data processing model to generate the target data processing model.
[0091] In some optional implementations, step S202 above includes:
[0092] Step S2021: Prune the original data processing model based on the improved alternating direction multiplier pruning algorithm to generate the target data processing model.
[0093] In some optional implementations, step S2021 above includes:
[0094] Step a1 introduces a penalty factor into the original alternating direction multiplier pruning algorithm.
[0095] The penalty factor is used to shorten the distance between the model parameters and the expected values corresponding to the model parameters in the original data processing model.
[0096] Specifically, computer devices can introduce a penalty factor into the original alternating direction multiplier pruning algorithm.
[0097] Step a2: Initialize the expected values and penalty factors corresponding to the model parameters, and generate the initial expected values and initial penalty factors.
[0098] The expected value of the model parameters represents the value that the model parameters should approximate after compression of the original data processing model. For example, assuming the expected value of the model parameters is 0, then the model parameters should approximate 0 after compression of the original data processing model.
[0099] Specifically, the computer equipment can initialize the expected values and penalty factors corresponding to the model parameters according to the compression requirements of the original data processing model, and generate the initial expected value and initial penalty factor.
[0100] It should be noted that the initial penalty factor can be a very small number.
[0101] Step a3: Based on the initial expected value and the initial penalty factor, perform pruning and iterative calculations on the original data processing model to obtain the unstructured sparse parameter matrix corresponding to the target data processing model.
[0102] The unstructured sparse parameter matrix is the parameter matrix obtained after pruning the model parameters.
[0103] Specifically, after the computer device initializes the expected values and penalty factors corresponding to the model parameters and generates the initial expected values and initial penalty factors, the computer device can use the improved alternating direction multiplier pruning algorithm to perform pruning processing and iterative calculation on the original data processing model to obtain the unstructured sparse parameter matrix corresponding to the target data processing model.
[0104] In some alternative implementations, step a3 above may include the following steps:
[0105] Step a31: Based on the initial expected value and the initial penalty factor, perform pruning and iterative calculations on the original data processing model to generate candidate data processing models.
[0106] Specifically, after the computer device initializes the expected values and penalty factors corresponding to the model parameters and generates the initial expected values and initial penalty factors, the improved alternating direction multiplier pruning algorithm can be used to perform pruning processing and iterative calculation on the original data processing model to generate candidate data processing models.
[0107] Step a32: Obtain the model accuracy and model compression ratio corresponding to the candidate data processing model.
[0108] Specifically, the computer equipment evaluates the model accuracy of the candidate data processing model using the validation dataset in the data to be processed, obtains the model accuracy corresponding to the candidate data processing model, and analyzes the unstructured sparse parameter matrix corresponding to the candidate data processing model to determine the model compression ratio corresponding to the candidate data processing model.
[0109] Step a33: Based on the model accuracy and model compression ratio, expand the initial penalty factor according to the preset rules to generate candidate penalty factors.
[0110] Specifically, when the model accuracy and model compression ratio corresponding to the candidate data processing model do not meet the preset requirements, the computer device can expand the initial penalty factor according to the preset rules to generate candidate penalty factors.
[0111] The preset rule can be to increase by 10 times each time, or by 5 times each time, or by other multiples each time, or by increasing by a geometric or arithmetic multiples. This application does not specifically limit the preset rule.
[0112] Step a34: Based on the initial expected value and candidate penalty factors, perform pruning and iterative calculations on the candidate data processing model to obtain the unstructured sparse parameter matrix corresponding to the target data processing model.
[0113] Specifically, after generating candidate penalty factors, the computer device can use an improved alternating direction multiplier pruning algorithm to perform pruning iterative calculations on the candidate data processing model based on the initial expected value and the candidate penalty factors, thereby generating a backup data processing model.
[0114] Then, the model accuracy and compression ratio of the backup data processing model are obtained. When the model accuracy and compression ratio of the backup data processing model do not meet the preset requirements, the computer device continues to expand the candidate initial penalty factors according to the preset rules. Then, the initial expected value and the expanded candidate penalty factors are used to perform pruning and iterative calculations on the backup data processing model until multiple iterations are completed. When the model accuracy and compression ratio of the target data processing model meet the preset requirements, the computer device obtains the unstructured sparse parameter matrix corresponding to the target data processing model.
[0115] To better illustrate the improved alternating direction multiplier pruning algorithm provided in the embodiments of this application, the embodiments of this application will exemplarily describe the alternating direction multiplier pruning algorithm.
[0116] (1) Problem 1: The problem that the original alternating direction multiplier pruning algorithm aims to solve is:
[0117]
[0118] subject to W i ∈S i , i = 1, ..., N, (1)
[0119] Among them, W i ,b i The parameters corresponding to the original data processing model; S i To satisfy the sparsity requirement W i That is, W i The corresponding expected value (for example: for a 5-layer original data processing model, there exist W1, W2, ..., W5; if we want the sparsity of layer W1 to be 20%, layer W2 to be 50%, ..., then S1 is W1 with only 20% non-zero elements, S2 is W2 with only 50% non-zero elements, ...).
[0120] (2) Problem 2: Since Problem 1 cannot be solved, Problem 1 is rewritten in the following form:
[0121]
[0122] where g i (·)is the indicator function of S i ,ie,
[0123]
[0124] Here, card(*) counts the number of non-zero elements in the matrix.
[0125] (3) Problem 3: Problem 2 cannot be solved using backpropagation to obtain W and b. Problem 2 can be rewritten in the following form:
[0126]
[0127] subject to W i =z i , i = 1, ..., N. (3)
[0128] Among them, Z i It is an auxiliary variable, the purpose of which is to facilitate solving formula (3) (because Z is introduced). i This simplifies the problem in the first row of formula (3) (originally W i W appears on both sides of the plus sign. i The change will affect the values on both sides of the plus sign. Now, Z... i With W i It is not a variable, so we need to solve for W. i When Z is considered to be i It's a fixed value.
[0129] (4) Problem 4: By enhancing the Lagrange method, a penalty factor is introduced into the original alternating direction multiplier pruning algorithm, transforming the constrained optimization problem of Problem 3 into the following unconstrained optimization problem (by finding the minimum value of Lp, the optimal Wi and bi are obtained):
[0130]
[0131] Among them, Λ i and W i The dimensions are the same, Λ i It corresponds to W i =Z i The constrained Lagrange multipliers (also known as dual variables), {ρ1, ..., ρN} are penalty factors, tr(*) denotes the rank of the matrix, ||*|| F 2 This represents the calculation of the L2 norm. Where, U... i , representing the scaled Λ i For L p The expression is minimized, and the result can be calculated using the backpropagation method.
[0132] (5) Question 5: Define variable U i =(1 / ρ i )Λi Then problem 4 is transformed into the following function.
[0133]
[0134] (6) For problem 5, the specific solution is as follows: Iterate through formulas (6)-(8) until formula (9) is satisfied.
[0135] The ADMM algorithm proceeds by repeating, for k=0, 1,..., the following
[0136] steps[2, 20]:
[0137]
[0138]
[0139]
[0140] until both of the following conditions are satisfies
[0141]
[0142] Step a4: Generate the target data processing model based on the unstructured sparse parameter matrix.
[0143] Specifically, after generating the unstructured sparse parameter matrix, the computer device can generate the target data processing model based on the unstructured sparse parameter matrix.
[0144] It should be noted that,
[0145] Step S203: Based on the data to be processed and the target data processing model, calculate the total workload of the target data processing model in processing the data to be processed.
[0146] Please see details Figure 4 Step S103 of the illustrated embodiment will not be described again here.
[0147] Step S204: Distribute the total workload to multiple hardware platforms to complete the processing of the data to be processed.
[0148] Please see details Figure 4 Step S104 of the illustrated embodiment will not be described again here.
[0149] The data processing method provided in this application introduces a penalty factor into the original alternating direction multiplier pruning algorithm, initializes the expected value and penalty factor corresponding to the model parameters, and generates initial expected value and initial penalty factor. Based on the initial expected value and initial penalty factor, iterative calculations of pruning are performed on the original data processing model to generate candidate data processing models, ensuring the accuracy of the generated candidate data processing models and achieving preliminary compression of the original data processing model. The model accuracy and model compression ratio corresponding to the candidate data processing models are obtained. Based on the model accuracy and model compression ratio, the initial penalty factor is increased according to a preset rule to generate candidate penalty factors, ensuring the accuracy of the generated candidate penalty factors and achieving a gradual increase in the candidate penalty factors. Then, based on the initial expected value and candidate penalty factors, iterative calculations of pruning are performed on the candidate data processing models to obtain the unstructured sparse parameter matrix corresponding to the target data processing model, making the compression ratio of the generated unstructured sparse parameter matrix larger, thereby ensuring a larger compression ratio corresponding to the generated target data processing model. Therefore, it achieves the maximum compression ratio of the target data processing model while ensuring high model accuracy. Redundant model connections in the target data processing model are removed, reducing the number of parameters and making the generated model more concise. This improves the efficiency of the target data processing model in processing the data to be processed. Furthermore, the method performs unstructured pruning on the original data processing model and then distributes the total workload across multiple hardware platforms, solving the problem of existing unstructured sparse original data processing models being unable to be deployed on hardware.
[0150] This embodiment provides a data processing method that can be used in the aforementioned computer devices, such as mobile phones and tablet computers. Figure 6 This is a flowchart of a data processing method according to an embodiment of the present invention, such as... Figure 3 As shown, the process includes the following steps:
[0151] Step S301: Obtain the data to be processed and the original data processing model corresponding to the data to be processed.
[0152] Please see details Figure 5 Step S201 of the illustrated embodiment will not be described again here.
[0153] Step S302: Compress the original data processing model to generate the target data processing model.
[0154] Please see details Figure 5 Step S202 of the illustrated embodiment will not be described again here.
[0155] Step S303: Based on the data to be processed and the target data processing model, calculate the total workload of the target data processing model in processing the data to be processed.
[0156] In some optional implementations, step S303 above includes:
[0157] S3031. Obtain the size of the data to be processed.
[0158] Specifically, computer equipment can identify the data to be processed and determine the size of the data.
[0159] S3032. Obtain the unstructured sparse parameter matrix and the parameter mask matrix corresponding to the target data processing model.
[0160] The parameter mask matrix is used to characterize whether each element in the unstructured sparse parameter matrix has been pruned.
[0161] Specifically, computer equipment can identify the target data processing model and determine the unstructured sparse parameter matrix corresponding to the target data processing model and the parameter mask matrix corresponding to the unstructured sparse parameter matrix.
[0162] S3033. Based on the relationship between the data size and the unstructured sparse parameter matrix and the parameter mask matrix, determine the effective and invalid tasks in the process of the target data processing model processing the data to be processed, and determine the expected execution time for each effective task.
[0163] Specifically, computer equipment can break down the data processing process into multiple computational tasks based on the relationship between the data size and the unstructured sparse parameter matrix. These computational tasks are then compared with the parameter mask matrix to determine the effective and ineffective tasks in the target data processing model's data processing process, and to determine the expected execution time for each effective task.
[0164] In this context, a valid task refers to a task in which the unstructured sparse parameter matrix contains non-zero elements when the data to be processed is used to perform calculations with the unstructured sparse parameter matrix, while an invalid task refers to a task in which the unstructured sparse parameter matrix does not contain non-zero elements when the data to be processed is used to perform calculations with the unstructured sparse parameter matrix.
[0165] For example, a computer device can call the pocl_spawn() function to determine the valid and invalid tasks in the process of the target data processing model processing the data to be processed, based on the relationship between the data size and the unstructured sparse parameter matrix and the parameter mask matrix.
[0166] S3034. Merge all valid tasks to generate the total number of tasks.
[0167] Specifically, after determining each valid task, the computer device can merge these valid tasks to generate a total task load.
[0168] Step S304: Distribute the total workload to multiple hardware platforms to complete the processing of the data to be processed.
[0169] In some optional implementations, step S304 above includes:
[0170] Step S3041: Obtain the computing power corresponding to each hardware platform.
[0171] Specifically, the computer device can receive the computing power corresponding to each hardware platform input by the user, and can also receive the computing power corresponding to each hardware platform sent by other devices. The computer device can also obtain the attribute information corresponding to each hardware platform, and then determine the computing power corresponding to each hardware platform based on the attribute information corresponding to each hardware platform.
[0172] This application does not specifically limit the method by which computer devices obtain the computing power corresponding to each hardware platform.
[0173] Step S3041: Divide the total task volume into multiple sub-task volumes based on the computing power and the expected execution time of each effective task.
[0174] Specifically, after acquiring the computing power of each hardware platform, the computer device can divide the total workload into multiple sub-tasks based on the computing power and the expected execution time of each effective task.
[0175] Step S3042: Allocate the workload of each subtask to the corresponding hardware platform.
[0176] Specifically, computer equipment can divide multiple subtasks and allocate the workload of each subtask to the corresponding hardware platform according to the computing power of the hardware platform.
[0177] For example, a computer device can call the clEnqueueNDRangeKernel() function to allocate the various subtasks to the corresponding hardware platforms.
[0178] Step S3043: Obtain the sub-computation results corresponding to each hardware platform.
[0179] Specifically, computer devices can obtain sub-computation results corresponding to each hardware platform based on the communication connection between the computer device and the hardware platform.
[0180] Step S3044: Summarize the results of each sub-calculation to generate the result of processing the data to be processed.
[0181] Specifically, computer equipment can aggregate the sub-computation results obtained from various hardware platforms to generate a result for processing the data to be processed.
[0182] The data processing method provided in this application embodiment obtains the size of the data to be processed, the unstructured sparse parameter matrix corresponding to the target data processing model, and the parameter mask matrix corresponding to the unstructured sparse parameter matrix. Then, based on the relationship between the data size and the unstructured sparse parameter matrix and the parameter mask matrix, it determines the effective and ineffective tasks in the process of the target data processing model processing the data to be processed, and determines the expected execution time corresponding to each effective task, ensuring the accuracy of the determined effective and ineffective tasks in the process of the target data processing model processing the data to be processed, and ensuring the accuracy of the determined expected execution time corresponding to each effective task. The effective tasks are merged to generate a total task quantity, ensuring the accuracy of the generated total task quantity. Then, it obtains the computing power corresponding to each hardware platform; based on the computing power and the expected execution time corresponding to each effective task, it divides the total task quantity into multiple sub-task quantities, ensuring the accuracy of the divided multiple sub-task quantities. The sub-task quantities are allocated to the corresponding hardware platforms; the sub-computation results corresponding to each hardware platform are obtained; the sub-computation results are summarized to generate the result of processing the data to be processed, ensuring the accuracy of the generated result of processing the data to be processed. The above method simplifies and accelerates computational tasks by mapping software sparse algorithms to hardware platform computing processes. It adapts software model optimization results to hardware resources, thus fully leveraging the advantages of flexible software configuration. It also addresses the problem that existing unstructured sparse target data processing models cannot be deployed on hardware.
[0183] To better illustrate the data processing method provided in the embodiments of this application, an exemplary embodiment of the data processing method is provided in this application.
[0184] For example, exemplarily, such as Figure 7 As shown, for a DNN model containing three fully connected layers, there are six optimizable parameter matrices: W1, b1, W2, b2, W3, b3. During pruning, some parameters in the parameter matrices are gradually compressed to near zero. After the progressive pruning algorithm is executed, by selecting a pruning threshold (e.g., threshold = 1e-5), the parameter values below the threshold in the six parameter matrices are set to zero, resulting in six unstructured sparse parameter matrices corresponding to the parameter matrices: Mask. w1Mask b1 Mask w2 Mask b2 Mask w3 Mask b3 (Each element of the unstructured sparse parameter matrix represents whether the model parameter at the corresponding position is set to zero).
[0185] After obtaining the unstructured sparse parameter matrix, the computer device uses the POCL tool to perform all computational tasks during the target data processing model's processing of the data. By comparing the computational tasks with the unstructured sparse parameter matrix, the number of valid and invalid tasks is determined. Meaningless invalid tasks (those whose computational results are always zero) are eliminated, leaving only the valid tasks. Taking a 4-core, 2-warp GPGPU hardware configuration as an example, assuming there are 64 valid tasks, the modified POCL tool will allocate 32 computational tasks to each core, distribute these 32 tasks across 2 warps, and then execute 16 loops within each warp to complete all computational tasks.
[0186] This embodiment also provides a data processing apparatus for implementing the above embodiments and preferred embodiments; details already described will not be repeated. As used below, the term "module" can refer to a combination of software and / or hardware that performs a predetermined function. Although the apparatus described in the following embodiments is preferably implemented in software, hardware implementation, or a combination of software and hardware, is also possible and contemplated.
[0187] This embodiment provides a data processing device, such as... Figure 8 As shown, it includes:
[0188] The acquisition module 401 is used to acquire the data to be processed and the original data processing model corresponding to the data to be processed.
[0189] Compression module 402 is used to compress the original data processing model to generate the target data processing model.
[0190] The calculation module 403 is used to calculate the total workload of the target data processing model in processing the data to be processed, based on the data to be processed and the target data processing model.
[0191] Module 404 is used to distribute the total workload across multiple hardware platforms to process the data to be processed.
[0192] In some optional implementations, the compression module 402 is specifically used to: prune the original data processing model based on the improved alternating direction multiplier pruning algorithm to generate the target data processing model.
[0193] In some optional implementations, the compression module 402 is specifically used to: introduce a penalty factor into the original alternating direction multiplier pruning algorithm, the penalty factor being used to shorten the distance between the model parameters and the expected values corresponding to the model parameters in the original data processing model; initialize the expected values and penalty factors corresponding to the model parameters, generating initial expected values and initial penalty factors; perform pruning iterative calculations on the original data processing model based on the initial expected values and initial penalty factors to obtain the unstructured sparse parameter matrix corresponding to the target data processing model; the unstructured sparse parameter matrix is the parameter matrix obtained after pruning the model parameters; and generate the target data processing model based on the unstructured sparse parameter matrix.
[0194] In some optional implementations, the compression module 402 is specifically used for: performing pruning and iterative calculations on the original data processing model based on the initial expected value and the initial penalty factor to generate a candidate data processing model; obtaining the model accuracy and model compression ratio corresponding to the candidate data processing model; expanding the initial penalty factor according to a preset rule based on the model accuracy and model compression ratio to generate a candidate penalty factor; and performing pruning and iterative calculations on the candidate data processing model based on the initial expected value and the candidate penalty factor to obtain the unstructured sparse parameter matrix corresponding to the target data processing model.
[0195] In some optional implementations, the above-mentioned calculation module 403 is specifically used for: obtaining the data volume of the data to be processed; obtaining the unstructured sparse parameter matrix and the parameter mask matrix corresponding to the target data processing model; the parameter mask matrix is used to characterize whether each element in the unstructured sparse parameter matrix has been pruned; based on the relationship between the data volume and the unstructured sparse parameter matrix and the parameter mask matrix, determining the effective and invalid tasks in the process of the target data processing model processing the data to be processed, and determining the expected execution time corresponding to each effective task; merging the effective tasks to generate the total task volume.
[0196] In some optional implementations, the above-mentioned completion module 404 is specifically used to: obtain the computing power corresponding to each hardware platform; divide the total task into multiple sub-tasks according to the computing power and the expected execution time corresponding to each effective task; allocate each sub-task to the corresponding hardware platform; obtain the sub-computation results corresponding to each hardware platform; and summarize the sub-computation results to generate the result of processing the data to be processed.
[0197] In this embodiment, the data processing device is presented in the form of a functional unit. Here, a unit refers to an ASIC circuit, a processor and memory that execute one or more software or fixed programs, and / or other devices that can provide the above-mentioned functions.
[0198] Further functional descriptions of the above modules and units are the same as those in the corresponding embodiments described above, and will not be repeated here.
[0199] This invention also provides a computer device having the above-described features. Figure 8 The data processing device shown.
[0200] Please see Figure 9 , Figure 9 This is a schematic diagram of the structure of a computer device provided in an optional embodiment of the present invention, such as... Figure 9 As shown, the computer device includes one or more processors 10, memory 20, and interfaces for connecting the components, including high-speed interfaces and low-speed interfaces. The components communicate with each other via different buses and can be mounted on a common motherboard or otherwise installed as needed. The processors can process instructions executed within the computer device, including instructions stored in or on memory to display graphical information of a GUI on external input / output devices (such as display devices coupled to the interfaces). In some alternative implementations, multiple processors and / or multiple buses can be used with multiple memories and multiple memory modules, if desired. Similarly, multiple computer devices can be connected, each providing some of the necessary operations (e.g., as a server array, a group of blade servers, or a multiprocessor system). Figure 9 Take a processor 10 as an example.
[0201] Processor 10 may be a central processing unit, a network processor, or a combination thereof. Processor 10 may further include a hardware chip. The hardware chip may be an application-specific integrated circuit (ASIC), a programmable logic device (PLD), or a combination thereof. The programmable logic device may be a complex programmable logic device (CAMP), a field-programmable gate array (FPGA), a general-purpose array logic (GPA), or any combination thereof.
[0202] The memory 20 stores instructions executable by at least one processor 10 to cause the at least one processor 10 to perform the method shown in the above embodiments.
[0203] The memory 20 may include a program storage area and a data storage area. The program storage area may store the operating system and applications required for at least one function; the data storage area may store data created based on the use of the computer device as shown by a landing page for an app. Furthermore, the memory 20 may include high-speed random access memory and may also include non-transitory memory, such as at least one disk storage device, flash memory device, or other non-transitory solid-state storage device. In some alternative embodiments, the memory 20 may optionally include memory remotely located relative to the processor 10, which can be connected to the computer device via a network. Examples of such networks include, but are not limited to, the Internet, intranets, local area networks, mobile communication networks, and combinations thereof.
[0204] The memory 20 may include volatile memory, such as random access memory; the memory may also include non-volatile memory, such as flash memory, hard disk or solid-state drive; the memory 20 may also include a combination of the above types of memory.
[0205] The computer device also includes an input device 30 and an output device 40. The processor 10, memory 20, input device 30, and output device 20 can be connected via a bus or other means. Figure 9 Taking the example of a connection between China and Israel via a bus.
[0206] Input device 30 can receive input numerical or character information, and generate key signal inputs related to user settings and function control of the computer device, such as a touchscreen, keypad, mouse, trackpad, touchpad, joystick, one or more mouse buttons, trackball, joystick, etc. Output device 40 may include display devices, auxiliary lighting devices (e.g., LEDs), and haptic feedback devices (e.g., vibration motors). The aforementioned display devices include, but are not limited to, liquid crystal displays, light-emitting diodes, displays, and plasma displays. In some alternative embodiments, the display device may be a touchscreen.
[0207] This invention also provides a computer-readable storage medium. The methods described above according to embodiments of the invention can be implemented in hardware or firmware, or implemented as computer code that can be recorded on a storage medium, or implemented as computer code downloaded via a network and originally stored on a remote storage medium or a non-transitory machine-readable storage medium and then stored on a local storage medium. Thus, the methods described herein can be processed by software stored on a storage medium using a general-purpose computer, a dedicated processor, or programmable or dedicated hardware. The storage medium can be a magnetic disk, optical disk, read-only memory, random access memory, flash memory, hard disk, or solid-state drive, etc.; further, the storage medium can also include combinations of the above types of memory. It is understood that computers, processors, microprocessor controllers, or programmable hardware include storage components capable of storing or receiving software or computer code, which, when accessed and executed by the computer, processor, or hardware, implements the methods shown in the above embodiments.
[0208] Although embodiments of the invention have been described in conjunction with the accompanying drawings, those skilled in the art can make various modifications and variations without departing from the spirit and scope of the invention, and such modifications and variations all fall within the scope defined by the appended claims.
Claims
1. A data processing method, characterized in that, The method includes: Obtain the data to be processed and the original data processing model corresponding to the data to be processed; The original data processing model is compressed to generate the target data processing model; Based on the data to be processed and the target data processing model, calculate the total workload of the target data processing model in processing the data to be processed; The total workload is distributed across multiple hardware platforms to complete the processing of the data to be processed; The step of compressing the original data processing model to generate the target data processing model includes: The original data processing model is pruned based on the improved alternating direction multiplier pruning algorithm to generate the target data processing model; The step of pruning the original data processing model using the improved alternating direction multiplier pruning algorithm to generate the target data processing model includes: A penalty factor is introduced into the original alternating direction multiplier pruning algorithm. The penalty factor is used to shorten the distance between the model parameters in the original data processing model and the expected values corresponding to the model parameters. Initialize the expected values corresponding to the model parameters and the penalty factor to generate initial expected values and initial penalty factors; Based on the initial expected value and the initial penalty factor, the original data processing model is pruned and iteratively calculated to obtain the unstructured sparse parameter matrix corresponding to the target data processing model; the unstructured sparse parameter matrix is the parameter matrix obtained after pruning the model parameters; The target data processing model is generated based on the unstructured sparse parameter matrix. The step of performing pruning and iterative calculations on the original data processing model based on the initial expected value and the initial penalty factor to obtain the unstructured sparse parameter matrix corresponding to the target data processing model includes: Based on the initial expected value and the initial penalty factor, the original data processing model is pruned iteratively calculated using an improved alternating direction multiplier pruning algorithm to generate a candidate data processing model. Obtain the model accuracy and model compression ratio corresponding to the candidate data processing model; When the model accuracy and model compression ratio corresponding to the candidate data processing model do not meet the preset requirements, the initial penalty factor is expanded according to the preset rule to generate a candidate penalty factor. Based on the initial expected value and the candidate penalty factor, the candidate data processing model is pruned and iteratively calculated to obtain the unstructured sparse parameter matrix corresponding to the target data processing model.
2. The method according to claim 1, characterized in that, The step of calculating the total workload of the target data processing model in processing the data to be processed based on the data to be processed and the target data processing model includes: Obtain the data volume of the data to be processed; Obtain the unstructured sparse parameter matrix corresponding to the target data processing model and the parameter mask matrix corresponding to the unstructured sparse parameter matrix; the parameter mask matrix is used to characterize whether each element in the unstructured sparse parameter matrix has been pruned. Based on the relationship between the data volume and the unstructured sparse parameter matrix and the parameter mask matrix, the effective and invalid tasks in the process of the target data processing model processing the data to be processed are determined, and the expected execution time corresponding to each effective task is determined. The various valid tasks are merged to generate the total number of tasks.
3. The method according to claim 1, characterized in that, The step of distributing the total workload across multiple hardware platforms to process the data to be processed includes: Obtain the computing power corresponding to each of the aforementioned hardware platforms; Based on the computing power and the expected execution time of each effective task, the total task volume is divided into multiple sub-task volumes. The subtasks are allocated to their respective hardware platforms. Obtain the sub-computation results corresponding to each of the aforementioned hardware platforms; The results of each sub-calculation are summarized to generate the result of processing the data to be processed.
4. A data processing apparatus, characterized in that, The device includes: The acquisition module is used to acquire the data to be processed and the original data processing model corresponding to the data to be processed; A compression module is used to compress the original data processing model to generate a target data processing model. The compression of the original data processing model to generate the target data processing model includes: pruning the original data processing model based on an improved alternating direction multiplier pruning algorithm to generate the target data processing model. The pruning of the original data processing model based on the improved alternating direction multiplier pruning algorithm to generate the target data processing model includes: introducing a penalty factor into the original alternating direction multiplier pruning algorithm, the penalty factor being used to shorten the distance between the model parameters in the original data processing model and the expected values corresponding to the model parameters; initializing the expected values corresponding to the model parameters and the penalty factor to generate initial expected values and initial penalty factors; iteratively calculating the pruning process on the original data processing model according to the initial expected values and the initial penalty factors to obtain the unstructured sparse parameter matrix corresponding to the target data processing model; the unstructured sparse parameter... The parameter matrix is the parameter matrix obtained after pruning the model parameters; the target data processing model is generated based on the unstructured sparse parameter matrix; wherein, the step of performing pruning processing iterative calculation on the original data processing model based on the initial expected value and the initial penalty factor to obtain the unstructured sparse parameter matrix corresponding to the target data processing model includes: performing pruning processing iterative calculation on the original data processing model using an improved alternating direction multiplier pruning algorithm based on the initial expected value and the initial penalty factor to generate candidate data processing models; obtaining the model accuracy and model compression ratio corresponding to the candidate data processing models; when the model accuracy and model compression ratio corresponding to the candidate data processing models do not meet the preset requirements, expanding the initial penalty factor according to a preset rule to generate candidate penalty factors; performing pruning processing iterative calculation on the candidate data processing models based on the initial expected value and the candidate penalty factor to obtain the unstructured sparse parameter matrix corresponding to the target data processing model; The calculation module is used to calculate the total workload of the target data processing model in processing the data to be processed, based on the data to be processed and the target data processing model. The completion module is used to distribute the total workload to multiple hardware platforms to complete the processing of the data to be processed.
5. The apparatus according to claim 4, characterized in that, The compression module is used to prune the original data processing model based on the improved alternating direction multiplier pruning algorithm to generate the target data processing model.
6. A computer device, characterized in that, include: A memory and a processor are communicatively connected, the memory stores computer instructions, and the processor executes the computer instructions to perform the data processing method of any one of claims 1 to 3.
7. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer instructions for causing the computer to perform the data processing method according to any one of claims 1 to 3.
Citation Information
Patent Citations
Heterogeneous computing scheduling method and device and computer readable storage medium
CN115983359A