Data compiling processing method and device, storage medium, electronic equipment and chip
By slicing and reverse compiling, processing tensor data and generating unified instruction information, the problem of inconsistent tensor data compilation and output in the existing technology is solved, which improves compilation efficiency and reduces resource waste.
Patent Information
- Application Number
- CN202311414345.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-10-27
- Publication Date
- 2025-04-29
AI Technical Summary
The prior art cannot ensure that the output tensor of each tensor data is the same during the compilation process, resulting in a large number of different instruction information being generated, resulting in insufficient buffer memory, affecting execution efficiency and possibly leading to compilation failure.
By obtaining the tensor data and sampling type information in the target subgraph, the tensor data is divided into multiple paragraph data, and reversely compiled according to the sampling type information, and a unified instruction information is generated to ensure that the number of data rows of the intermediate paragraph data is the same.
Ensure the output consistency of tensor data compilation, reduce the diversity of instruction information, avoid the problem of insufficient buffer memory, improve the efficiency of instruction execution, and reduce resource waste.
Smart Images

Figure CN119902768A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of data processing technology, and in particular to a data compilation and processing method, device, storage medium, electronic device and chip. Background Art
[0002] Artificial Intelligence (AI) compilation is the process of using an AI compiler to compile a neural network model into the target instruction set of a target heterogeneous computing platform.
[0003] Currently, during the compilation process, due to the small memory capacity of the heterogeneous computing platform, the tensor compilation calculation needs to be randomly split into multiple tensors for separate compilation calculations, and then the compiled data is loaded into the heterogeneous platform separately, and the corresponding instruction calculation is executed according to the instruction information.
[0004] However, when using this random split calculation method, during the compilation process of each tensor data, it is impossible to ensure that the output tensor of each tensor data compilation is the same, resulting in the use of different instructions for compiling each tensor data, which in turn generates a large amount of different instruction information, causing insufficient buffer memory for storing instruction information, resulting in low efficiency in transmitting the execution instruction information, and even causing compilation failure. Summary of the invention
[0005] In view of this, the present application provides a data compilation and processing method, device, storage medium, electronic device and chip, the main purpose of which is to improve the technical problem that the current existing technology cannot ensure that the output tensor of each tensor data compilation is the same, which will generate a large amount of different instruction information, resulting in insufficient buffer memory for storing instruction information.
[0006] In a first aspect, the present application provides a data compilation processing method, comprising:
[0007] Obtaining first tensor data obtained by the target subgraph through the neural network model and sampling type information corresponding to the first tensor data;
[0008] The first tensor data is segmented according to the target number of paragraphs to obtain a plurality of segmented paragraph data, wherein, except for the first paragraph data and the last paragraph data, the numbers of tensor rows corresponding to the other intermediate paragraph data are the same;
[0009] According to the sampling type information, the plurality of paragraph data are respectively decompiled to obtain second tensor data corresponding to the plurality of paragraph data;
[0010] According to the second tensor data, instruction information corresponding to the second tensor data is generated, wherein unified instruction information is generated for second tensor data having the same number of tensor rows.
[0011] Optionally, the decompiling the plurality of paragraph data respectively according to the sampling type information to obtain second tensor data respectively corresponding to the plurality of paragraph data includes:
[0012] According to the sampling type information, the respective intermediate paragraph data are decompiled to obtain the second tensor data corresponding to the respective intermediate paragraph data;
[0013] Based on the second tensor data corresponding to each of the middle paragraph data, the second tensor data corresponding to the first paragraph data and the last paragraph data are obtained.
[0014] Optionally, the decompilation process is performed on each of the intermediate paragraph data according to the sampling type information to obtain the second tensor data corresponding to each of the intermediate paragraph data, including:
[0015] Determine, according to the sampling type information corresponding to each intermediate paragraph data in the sampling type information, a plurality of sampling types corresponding to each intermediate paragraph data and a sampling number of each intermediate paragraph data;
[0016] According to the target arrangement order of the multiple sampling types, starting from the first sampling type among the multiple sampling types, each intermediate paragraph data is reverse compiled for a target number of times to obtain the second tensor data corresponding to each intermediate paragraph data, wherein the target number of times is determined according to the sampling number.
[0017] Optionally, the decompilation process is performed on each intermediate segment data a target number of times starting from the first sampling type among the multiple sampling types according to the target arrangement order of the multiple sampling types to obtain the second tensor data corresponding to each intermediate segment data, including:
[0018] In each decompilation process, based on the second tensor data corresponding to the middle paragraph data of the last decompilation process and the sampling type corresponding to the current decompilation process, the decompilation process is performed to obtain the second tensor data corresponding to the middle paragraph data of the current decompilation process;
[0019] The next decompilation process is performed according to the second tensor data corresponding to the middle paragraph data of the current decompilation process, so as to obtain the second tensor data corresponding to the middle paragraph data of the next decompilation process.
[0020] Optionally, the decompilation process is performed based on the second tensor data corresponding to the intermediate paragraph data of the previous decompilation process and the sampling type corresponding to the current decompilation process to obtain the second tensor data corresponding to the intermediate paragraph data of the current decompilation process, including:
[0021] Analyze the second tensor data corresponding to each intermediate segment data of the last decompilation process to determine the completion data and stride data of the last decompilation process;
[0022] Based on the second tensor data corresponding to each intermediate paragraph data of the previous decompilation processing, the completion data and the stride data, decompilation processing is performed to obtain each intermediate paragraph data of the current decompilation processing.
[0023] Optionally, the reverse compilation process is performed based on the second tensor data corresponding to the intermediate paragraph data of the previous reverse processing and the sampling type corresponding to the current reverse compilation process to obtain the second tensor data corresponding to the intermediate paragraph data of the current reverse compilation process, including:
[0024] If the sampling type corresponding to the current decompilation process is upsampling, the second tensor data corresponding to the intermediate paragraph data of the previous decompilation process is decompiled according to the preset upsampling standard to obtain the second tensor data corresponding to the intermediate paragraph data of the current decompilation process.
[0025] Optionally, the performing of the reverse compilation process based on the second tensor data corresponding to the intermediate paragraph data of the last reverse processing and the sampling type corresponding to the current reverse compilation process to obtain the second tensor data corresponding to the intermediate paragraph data of the current reverse compilation process further includes:
[0026] If the sampling type corresponding to the current decompilation process is downsampling, the second tensor data corresponding to the intermediate paragraph data of the previous decompilation process is decompiled according to the preset downsampling standard to obtain the second tensor data corresponding to the intermediate paragraph data of the current decompilation process.
[0027] Optionally, before obtaining the second tensor data corresponding to the first paragraph data and the last paragraph data based on the second tensor data corresponding to each of the middle paragraph data, the method further includes:
[0028] Obtain first tensor row number data of the second tensor data corresponding to the plurality of paragraph data respectively;
[0029] The obtaining of the second tensor data corresponding to the first paragraph data and the last paragraph data respectively based on the second tensor data corresponding to each of the middle paragraph data respectively includes:
[0030] Determine the second tensor row number data of the second tensor data corresponding to each of the middle paragraph data;
[0031] Processing the first tensor row number data and the second tensor row number data to obtain a third tensor row number data corresponding to the first paragraph data and a fourth tensor row number data corresponding to the last paragraph data;
[0032] According to the third tensor row number data and the fourth tensor row number data, second tensor data corresponding to the first paragraph data and the last paragraph data are obtained respectively.
[0033] Optionally, the processing of the first tensor row number data and the second tensor row number data to obtain the third tensor row number data corresponding to the first paragraph data and the fourth tensor row number data corresponding to the last paragraph data includes:
[0034] In each decompilation process, the first tensor row number data and the tensor row number data of the second tensor data corresponding to the middle paragraph data of the previous decompilation process are processed to obtain the tensor row number data corresponding to the first paragraph data and the last paragraph data of the current decompilation process respectively;
[0035] The first paragraph data and the last paragraph data of the next decompilation process are obtained according to the tensor row number data corresponding to the first paragraph data and the last paragraph data of the current decompilation process.
[0036] Optionally, after obtaining the first paragraph data and the last paragraph data of the next decompilation process according to the tensor row number data corresponding to the first paragraph data and the last paragraph data of the current decompilation process, the method further includes:
[0037] In each reverse compilation process, based on the first paragraph data of the current reverse compilation process and the first paragraph data of the next reverse compilation process, determining the first paragraph sampling type corresponding to the current reverse compilation process;
[0038] Based on the last paragraph data of the current decompilation process and the last paragraph data of the next decompilation process, a last paragraph sampling type corresponding to the current decompilation process is determined.
[0039] Optionally, it further includes: generating sampling type information of the second tensor data corresponding to the first paragraph data based on the sampling type of the first paragraph of each decompilation process through the decompilation process of the target number of times;
[0040] Through the reverse compilation process of the target number of times, based on the sampling type of the last paragraph of each reverse compilation process, the sampling type information of the second tensor data corresponding to the last paragraph data is generated.
[0041] Optionally, generating instruction information corresponding to the second tensor data according to the second tensor data includes:
[0042] Generate unified first instruction information according to the sampling type information of the second tensor data corresponding to each intermediate segment data, wherein the first instruction information is used to instruct the second tensor data corresponding to each intermediate segment data to perform subsequent instruction calculation;
[0043] Generate second instruction information according to the first paragraph sampling type information of the second tensor data corresponding to the first paragraph data, wherein the second instruction information is used to instruct the second tensor data corresponding to the first paragraph data to perform subsequent instruction calculation;
[0044] According to the last segment sampling type information of the second tensor data corresponding to the last segment data, third instruction information is generated, and the third instruction information is used to instruct the second tensor data corresponding to the last segment data to perform subsequent instruction calculations.
[0045] In a second aspect, the present application provides a data compilation and processing device, comprising:
[0046] An acquisition module is configured to acquire first tensor data obtained by the target subgraph through the neural network model and sampling type information corresponding to the first tensor data;
[0047] a segmentation module configured to segment the first tensor data according to the target number of paragraphs to obtain a plurality of segmented paragraph data, wherein, except for the first paragraph data and the last paragraph data, the numbers of tensor rows corresponding to the other intermediate paragraph data are the same;
[0048] A compiling module is configured to perform reverse compilation processing on the plurality of paragraph data respectively according to the sampling type information to obtain second tensor data respectively corresponding to the plurality of paragraph data;
[0049] A generation module is configured to generate instruction information corresponding to the second tensor data based on the second tensor data, wherein unified instruction information is generated for second tensor data with the same number of tensor rows.
[0050] In a third aspect, the present application provides a computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the data compilation and processing method described in the first aspect is implemented.
[0051] In a fourth aspect, the present application provides an electronic device, comprising a storage medium, a processor, and a computer program stored on the storage medium and executable on the processor, wherein the processor implements the data compilation and processing method described in the first aspect when executing the computer program.
[0052] In a fifth aspect, the present application provides a chip comprising one or more interface circuits and one or more processors; the interface circuit is used to receive a signal from a memory of an electronic device and send the signal to the processor, wherein the signal comprises a computer instruction stored in the memory; when the processor executes the computer instruction, the electronic device executes the data compilation and processing method described in the first aspect.
[0053] By means of the above technical scheme, the present application provides a data compilation and processing method, device, storage medium, electronic device and chip, which specifically first obtains the first tensor data obtained by the target subgraph through the neural network model and the sampling type information corresponding to the first tensor data; divides the first tensor data according to the target number of paragraphs to obtain multiple paragraph data after division, wherein, except for the first paragraph data and the last paragraph data, the tensor rows corresponding to the other intermediate paragraph data are the same; then, according to the sampling type information, the multiple paragraph data are respectively reverse compiled to obtain the second tensor data corresponding to the multiple paragraph data; then, according to the second tensor data, the instruction information corresponding to the second tensor data is generated, wherein the second tensor data with the same number of tensor rows generates unified instruction information. Compared with the current existing technology, since the number of data rows may change during the reverse compilation process, the present application can ensure that the number of data rows of the second matrix data corresponding to the middle paragraph data is the same by not uniformly removing the second matrix data corresponding to the first paragraph data after segmentation and the second matrix data corresponding to the last paragraph data. When generating instructions, the second matrix data corresponding to the middle paragraph data can be processed in a loop using the same instruction, and no additional instructions are required to indicate the second matrix data corresponding to each middle paragraph data, thereby avoiding a large amount of instruction information causing program blocking, releasing the buffer memory used to store instruction information, ensuring the normal progress of data compilation, improving the efficiency of instruction execution of subsequent instruction calculations, and reducing resource waste.
[0054] The above description is only an overview of the technical solution of the present application. In order to more clearly understand the technical means of the present application, it can be implemented in accordance with the contents of the specification. In order to make the above and other purposes, features and advantages of the present application more obvious and easy to understand, the specific implementation methods of the present application are listed below. BRIEF DESCRIPTION OF THE DRAWINGS
[0055] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0056] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0057] Figure 1 A schematic diagram of a data compilation process method provided by an embodiment of the present application is shown;
[0058] Figure 2 A schematic diagram of a data compilation process method provided by an embodiment of the present application is shown;
[0059] Figure 3 A schematic diagram of an example process provided by an embodiment of the present application is shown;
[0060] Figure 3 A schematic diagram of an example process provided by an embodiment of the present application is shown;
[0061] Figure 4 A schematic diagram of an example process provided by an embodiment of the present application is shown;
[0062] Figure 5 A schematic diagram of an example process provided by an embodiment of the present application is shown;
[0063] Figure 6 A schematic diagram of an example process provided by an embodiment of the present application is shown;
[0064] Figure 7 A schematic diagram of an example process provided by an embodiment of the present application is shown;
[0065] Figure 8 A schematic diagram of the structure of a data compilation and processing device provided in an embodiment of the present application is shown. DETAILED DESCRIPTION
[0066] The embodiments of the present application will be described in more detail below with reference to the accompanying drawings. It should be noted that the embodiments and features in the embodiments of the present application can be combined with each other without conflict.
[0067] In order to improve the technical problem that the existing technology cannot ensure that the output tensor of each tensor data compilation is the same, and then a large amount of different instruction information will be generated, resulting in insufficient buffer memory for storing instruction information. This embodiment provides a data compilation processing method, such as Figure 1 As shown, the method includes:
[0068] Step 101: Obtain first tensor data obtained by a target subgraph through a neural network model and sampling type information corresponding to the first tensor data.
[0069] In the embodiments of the present application, the neural network model is an artificial neural network (ANNs), also referred to as a neural network (NNs), or a connection model, which is an algorithmic mathematical model that imitates the behavioral characteristics of animal neural networks and performs distributed parallel information processing. Neural networks process information by adjusting the interconnected relationships between a large number of internal nodes, depending on the complexity of the system.
[0070] It should be noted that the target subgraph may be a subgraph that needs to be input into the neural network model to obtain corresponding data.
[0071] Optionally, the tensor data may be in the form of multiple rows of data, and accordingly, the sampling type information corresponding to the first tensor data may be the number of sampling times required to obtain the first tensor data and the corresponding sampling type.
[0072] Step 102: segment the first tensor data according to the target number of paragraphs to obtain a plurality of segmented paragraph data.
[0073] Except for the first paragraph data and the last paragraph data, the numbers of tensor rows corresponding to the other middle paragraph data are the same.
[0074] In some examples, the target number of paragraphs is a preset number of paragraphs based on the first tensor data.
[0075] Exemplarily, the first tensor data contains 10 lines. If the target number of paragraphs is 4, the first tensor data can be divided into 3 lines for the first paragraph, 3 lines for the second paragraph, 3 lines for the third paragraph, and 1 line for the fourth paragraph. The corresponding middle paragraph data are the second paragraph and the third paragraph, and the number of lines of the second paragraph and the third paragraph must remain the same.
[0076] Step 103: Decompile the plurality of paragraph data respectively according to the sampling type information to obtain second tensor data respectively corresponding to the plurality of paragraph data.
[0077] In an embodiment of the present application, the second tensor data is data obtained by performing multiple reverse compilation processes on multiple paragraph data.
[0078] The reverse compilation process in this embodiment is a reverse process of the compilation process. Accordingly, the second tensor data is data obtained by performing multiple compilations and reverse processes on multiple paragraph data.
[0079] Step 104: Generate instruction information corresponding to the second tensor data according to the second tensor data.
[0080] Among them, the second tensor data with the same number of tensor rows generates unified instruction information.
[0081] For this embodiment, the instruction information can be used to instruct the second tensor data to perform subsequent instruction calculations.
[0082] Exemplarily, if in the second tensor data, the number of rows of the second tensor data corresponding to the first paragraph data is 3 rows, the number of rows of the second tensor data corresponding to the middle paragraph data is 7 rows, and the number of rows of the second tensor data corresponding to the last paragraph data is 1 row, then the second tensor data corresponding to the middle paragraph data generates unified instruction information, and the second tensor data corresponding to the first paragraph data and the second tensor data corresponding to the last paragraph data respectively generate corresponding instruction information.
[0083] Compared with the current prior art, since the number of data rows may change during the reverse compilation process, this embodiment can ensure that the number of data rows of the second matrix data corresponding to the middle paragraph data is the same by not uniformly removing the second matrix data corresponding to the first paragraph data and the second matrix data corresponding to the last paragraph data after segmentation. When generating instructions, the second matrix data corresponding to the middle paragraph data can be processed in a loop using the same instruction, and no additional instructions are required to indicate the second matrix data corresponding to each middle paragraph data, thereby avoiding a large amount of instruction information causing program blocking, releasing the buffer memory used to store instruction information, ensuring the normal progress of data compilation, improving the efficiency of instruction execution of subsequent instruction calculations, and reducing resource waste.
[0084] As a refinement and extension of the above embodiment, in order to fully illustrate the specific implementation process of the method of this embodiment, this embodiment provides the following Figure 2 The specific method shown includes:
[0085] Step 201: Obtain first tensor data obtained by a target subgraph through a neural network model and sampling type information corresponding to the first tensor data.
[0086] As an optional embodiment, if the first tensor data obtained by the target subgraph A through the neural network model contains n rows, they are 0 rows, 1 row, 2 rows to n-1 rows respectively.
[0087] Step 202: segment the first tensor data according to the target number of paragraphs to obtain a plurality of segmented paragraph data.
[0088] Except for the first paragraph data and the last paragraph data, the numbers of tensor rows corresponding to the other middle paragraph data are the same.
[0089] Exemplarily, based on step 201, n rows of the first tensor data are divided into hsecs segments by row, and the middle segment data can be determined by formula 1. Specifically, formula 1 is as follows:
[0090] Slice i =ceil(n / hsecs) 0<i<hsecs-1 (Formula 1)
[0091] In Formula 1, slice indicates that the paragraph data is from the 0th paragraph to the hsecs-1th paragraph, slice indicates the size of the segmentation, that is, the paragraph data after segmentation, i indicates the number of paragraph data, ceil indicates the upward rounding function, and hsecs indicates the total number of segments segmented, that is, the target number of paragraphs.
[0092] Correspondingly, the last paragraph data can be determined by formula 2. Specifically, formula 2 is as follows:
[0093] Slice i =n%hsecs i=hsecs-1 (Formula 2)
[0094] In Formula 2, % means remainder.
[0095] For example, if the first tensor data obtained by the neural network model for sub-graph B is 91 rows of data and needs to be divided into 10 segments, then Formula 1 and Formula 2 can be used to obtain the starting number of rows of each paragraph data corresponding to sub-graph B as indx = [0, 10, 20, 30, 40, 50, 60, 70, 80, 90]; accordingly, the number of rows corresponding to each paragraph data can be determined as slice = [10, 10, 10, 10, 10, 10, 10, 1].
[0096] The multiple paragraph data obtained after segmenting the first tensor data of sub-graph B satisfy the requirement that the number of tensor rows of the middle paragraph data is the same, and accordingly, the number of starting rows of each paragraph data increases arithmetically.
[0097] Step 203: Decompile each intermediate segment data according to the sampling type information to obtain the second tensor data corresponding to each intermediate segment data.
[0098] Optionally, step 203 may specifically include: determining multiple sampling types corresponding to each intermediate paragraph data and the sampling times of each intermediate paragraph data based on the sampling type information corresponding to each intermediate paragraph data in the sampling type information; performing reverse compilation processing on each intermediate paragraph data for a target number of times starting from the first sampling type in the multiple sampling types according to the target arrangement order of the multiple sampling types to obtain the second tensor data corresponding to each intermediate paragraph data.
[0099] The target number is determined according to the sampling number.
[0100] In an embodiment of the present application, step 203 may specifically include: in each reverse compilation process, reverse compilation process is performed based on the second tensor data corresponding to the intermediate paragraph data of the previous reverse compilation process and the sampling type corresponding to the current reverse compilation process to obtain the second tensor data corresponding to the intermediate paragraph data of the current reverse compilation process; and the next reverse compilation process is performed based on the second tensor data corresponding to the intermediate paragraph data of the current reverse compilation process to obtain the second tensor data corresponding to the intermediate paragraph data of the next reverse compilation process.
[0101] For example, Figure 3 As shown, it is reflected that the embodiment of the present application splits the first matrix data into multiple paragraphs of data and processes them separately; accordingly, the first matrix data corresponds to Figure 3 Output data in Figure 3 In the example, the first matrix data is 32 rows. For example, the middle paragraph data corresponding to the first matrix data is 8 paragraph data of 4 rows, which are respectively decompiled.
[0102] Further exemplary, Figure 3 In the example, relu and Conv represent the sampling types corresponding to each decompilation. Specifically, Figure 3 From output to input, the 8 4-line paragraph data are respectively subjected to a relu type decompilation process, and the second tensor data corresponding to the current middle paragraph data is 4 lines.
[0103] Correspondingly, according to the 8 4-row second tensor data corresponding to the middle paragraph data of the current decompilation processing and Figure 3 The Conv sampling type corresponding to the next decompilation process is decompiled again to obtain the second tensor data of 8 6 rows corresponding to the middle paragraph data of the next decompilation process, and so on, and finally obtain Figure 3 The input data having the same number of rows as the output data is the second tensor data corresponding to each intermediate paragraph data in the embodiment of the present application.
[0104] In some examples, step 203 may specifically include: analyzing the second tensor data corresponding to each intermediate paragraph data of the last reverse compilation process, and determining the completion data and stride data of the last reverse compilation process; performing reverse compilation processing based on the second tensor data, completion data and stride data corresponding to each intermediate paragraph data of the last reverse compilation process, and obtaining each intermediate paragraph data of the current reverse compilation process.
[0105] It should be noted that step 203 may specifically include: if the sampling type corresponding to the current decompilation process is upsampling, then according to the preset upsampling standard, the second tensor data corresponding to the intermediate paragraph data of the previous decompilation process is decompiled and processed to obtain the second tensor data corresponding to the intermediate paragraph data of the current decompilation process.
[0106] In an embodiment of the present application, step 203 may specifically include: if the sampling type corresponding to the current reverse compilation process is downsampling, then according to a preset downsampling standard, the second tensor data corresponding to the intermediate paragraph data of the previous reverse compilation process is reverse compiled and processed, to obtain the second tensor data corresponding to the intermediate paragraph data of the current reverse compilation process.
[0107] Optionally, the sampling type may include upsampling, downsampling and normal sampling. Downsampling may include Conv, maxpool, averagepool and other types. Upsampling may include transpose_conv and other sampling types. Normal sampling may include Add, sin, exp and other sampling types.
[0108] Further optionally, taking the third time of reverse compilation processing as an example, if the corresponding sampling type is downsampling, it is necessary to obtain the second tensor data corresponding to the middle paragraph data of the second reverse compilation processing and the second tensor data corresponding to the middle paragraph data of the second reverse compilation processing in the row direction. The top complement data, the bottom complement data, the step data, and the expanded step data of the second tensor data corresponding to the middle paragraph data of the second reverse compilation processing need to be obtained. According to Formula 3 and Formula 4, the second tensor data corresponding to the middle paragraph data of the fourth reverse compilation processing can be determined. Specifically, Formula 3 and Formula 4 are as follows:
[0109] ix=ox×s-pt (Formula 3)
[0110] is=(os-1)×s+k (Formula 4)
[0111] In Formula 3 and Formula 4, ix represents the starting row number of the second tensor data corresponding to the intermediate paragraph data of the fourth decompilation processing, ox represents the starting row number of the second tensor data corresponding to the intermediate paragraph data of the third decompilation processing, s represents the step data in the row direction, pt represents the top completion data of the second tensor data corresponding to the intermediate paragraph data of the second decompilation processing in the row direction, is represents the segmentation size of the second tensor data corresponding to the intermediate paragraph data of the second decompilation processing, os represents the segmentation size of the second tensor data corresponding to the intermediate paragraph data of the second decompilation processing, and k represents the expanded step data of the second tensor data corresponding to the intermediate paragraph data of the second decompilation processing in the row direction.
[0112] Accordingly, the preset downsampling standard that needs to be met can be shown in the following formulas 5 and 6:
[0113] When pt>0: ox≥s / pt (Formula 5)
[0114] ox+os≤(ih+pt+s-k) / s (Formula 6)
[0115] In Formula 5 and Formula 6, ih represents the row number of the second tensor data corresponding to the middle paragraph data of the second decompilation process.
[0116] It should be noted that the preset downsampling condition is used to ensure that the sizes of the second matrix data corresponding to the middle section data are equal, and the starting number of rows of the second matrix data corresponding to the middle section data increases arithmetically.
[0117] In some examples, taking the third time of the current decompilation process as an example, if the corresponding sampling type is upsampling, such as Figure 4 The figure shows the mapping relationship between the input and output of a transpose_conv operator, where z[0]…z[4] represents a total of 5 rows of input data, and x[0]…x
[14] represents a total of 15 rows of output data. In addition to z[0]…z[4], the input data also includes completion and stride data, which are all 0. The arrows in the figure indicate which rows of input data need to correspond to the output of a row of input. For example, to calculate the output of the row of data x[5], the four rows of data {z[1], 0, 0, z[2]} need to be input.
[0118] Exemplarily, it is necessary to obtain the second tensor data corresponding to the middle paragraph data of the second reverse compilation process and the top complement data, bottom complement data, step data, and expanded step data of the second tensor data corresponding to the middle paragraph data of the second reverse compilation process in the row direction. According to Formula 7 and Formula 8, the second tensor data corresponding to the middle paragraph data of the fourth reverse compilation process can be determined. Specifically, Formula 7 and Formula 8 are as follows:
[0119] ix=ceil[(ox+pt-k+1) / s](Public Notice 7)
[0120] is=floor[(ox+os+pt) / s]-ceil[(ox+pt-k+1) / s]+1(Formula 8)
[0121] In Formula 7 and Formula 8, the ceil function represents rounding up, and the floor function represents rounding down.
[0122] Accordingly, the preset upsampling standard that needs to be met can be shown as in the following formula 9, formula 10 and formula 11:
[0123] ox>k-s-pt+1 (Formula 9)
[0124] os%s=0 (Formula 10)
[0125] floor[(ox+os+pt-k+1) / s]+1<ih (Formula 11)
[0126] It should be noted that the preset upsampling condition is used to ensure that the sizes of the second matrix data corresponding to the middle section data are equal, and the starting number of rows of the second matrix data corresponding to the middle section data increases arithmetically.
[0127] In the embodiment of the present application, for the second matrix data corresponding to the middle paragraph data corresponding to the common sampling type, the number of rows and the size of the data before and after the reverse compilation process are the same.
[0128] Step 204 : Based on the second tensor data corresponding to each of the middle paragraph data, obtain the second tensor data corresponding to the first paragraph data and the last paragraph data.
[0129] In the embodiment of the present application, before step 204, the method of this embodiment may include: obtaining first tensor row number data of the second tensor data corresponding to the plurality of paragraph data respectively.
[0130] For this embodiment, the first tensor row number data is the total number of rows corresponding to the second tensor data obtained after reverse compilation of multiple paragraph data is completed.
[0131] It should be noted that the number of data rows in the first matrix data is the same as the number of data rows in the first tensor data, that is, the total number of data rows does not change before and after the decompilation process.
[0132] Optionally, step 204 may specifically include: determining the second tensor row number data of the second tensor data corresponding to each intermediate paragraph data; processing the first tensor row number data and the second tensor row number data to obtain the third tensor row number data corresponding to the first paragraph data and the fourth tensor row number data corresponding to the last paragraph data; and obtaining the second tensor data corresponding to the first paragraph data and the last paragraph data respectively based on the third tensor row number data and the fourth tensor row number data.
[0133] In some examples, the second tensor row number data is the total number of rows corresponding to the second tensor data obtained after the middle paragraph data is decompiled, the third tensor row number data is the number of rows corresponding to the second tensor data obtained after the first paragraph data is decompiled, and the fourth tensor data is the number of rows corresponding to the second tensor data obtained after the last paragraph data is decompiled.
[0134] Correspondingly, the difference between the first tensor row number data and the second tensor row number data can obtain the third tensor row number data corresponding to the first paragraph data and the fourth tensor row number data corresponding to the last paragraph data.
[0135] In some examples, step 204 may further specifically include: in each reverse compilation process, processing the first tensor row number data and the tensor row number data of the second tensor data corresponding to the middle paragraph data of the previous reverse compilation process, to obtain the tensor row number data corresponding to the first paragraph data and the last paragraph data of the current reverse compilation process; according to the tensor row number data corresponding to the first paragraph data and the last paragraph data of the current reverse compilation process, to obtain the first paragraph data and the last paragraph data of the next reverse compilation process;
[0136] Exemplarily, in each compilation process, since the number of rows of the second tensor data corresponding to the intermediate paragraph data is the same, the number of rows of the second tensor data corresponding to the intermediate paragraph data obtained in the current compilation process can be used to obtain the tensor row number data corresponding to the first paragraph data and the last paragraph data of the current compilation process, thereby obtaining the first paragraph data and the last paragraph data for the next reverse compilation process.
[0137] It should be noted that step 204 may specifically include: in each reverse compilation process, based on the first paragraph data of the current reverse compilation process and the first paragraph data of the next reverse compilation process, determining the first paragraph sampling type corresponding to the current reverse compilation; based on the last paragraph data of the current reverse compilation process and the last paragraph data of the next reverse compilation process, determining the last paragraph sampling type corresponding to the current reverse compilation.
[0138] Optionally, step 204 may further specifically include: generating sampling type information of the second tensor data corresponding to the first paragraph data based on the sampling type of the first paragraph of each reverse compilation process through reverse compilation processing for a target number of times; generating sampling type information of the second tensor data corresponding to the last paragraph data based on the sampling type of the last paragraph of each reverse compilation process through reverse compilation processing for a target number of times.
[0139] Step 205: Generate instruction information corresponding to the second tensor data according to the second tensor data.
[0140] Among them, the second tensor data with the same number of tensor rows generates unified instruction information.
[0141] In an embodiment of the present application, step 205 may specifically include: generating unified first instruction information based on the sampling type information of the second tensor data corresponding to each intermediate paragraph data; generating second instruction information based on the first paragraph sampling type information of the second tensor data corresponding to the first paragraph data; generating third instruction information based on the last paragraph sampling type information of the second tensor data corresponding to the last paragraph data.
[0142] Among them, the first instruction information is used to instruct the second tensor data corresponding to each intermediate paragraph data to perform subsequent instruction calculations, the second instruction information is used to instruct the second tensor data corresponding to the first paragraph data to perform subsequent instruction calculations, and the third instruction information is used to instruct the second tensor data corresponding to the last paragraph data to perform subsequent instruction calculations.
[0143] In an embodiment of the present application, after completing the segmentation of the above method, the sizes of the second tensor data corresponding to each intermediate paragraph data are equal, and the starting rows of the second tensor data corresponding to the intermediate paragraph data increase in arithmetic progression. Since the instruction information of the second tensor data corresponding to the first paragraph data is different from the instruction information of the second tensor data corresponding to the intermediate paragraph data, three sets of special instructions will be generated. First, the corresponding instructions are generated for the second tensor data corresponding to the first paragraph data, then the corresponding instructions are generated for the second tensor data corresponding to the intermediate paragraph data, and finally the corresponding instructions are generated for the second tensor data corresponding to the last paragraph data, and these instructions will finally be cached in the memory.
[0144] In the subsequent execution of instruction calculations, such as Figure 5 As shown, the instructions of the second tensor data corresponding to the first paragraph data are first placed in the instruction emission queue and executed in sequence, and then the instructions of the second tensor data corresponding to the middle paragraph data are placed in the instruction emission queue. Since the instructions of the second tensor data corresponding to the middle paragraph data need to be executed multiple times in a loop, and the size and number of rows of the second tensor data corresponding to each middle paragraph data are the same, the corresponding instructions can be emitted in a loop when executing the instructions of the second tensor data corresponding to the middle paragraph data, thereby improving the efficiency of instruction execution and reducing resource waste. Finally, the instructions of the second tensor data corresponding to the last paragraph data are executed to complete the instruction calculation of the entire data.
[0145] The embodiments of the present application are mainly used to compile a neural network model into a target instruction set of a specified heterogeneous computing platform. This process is called AI compilation, and the program transposition used to compile the neural network model is called an AI compiler.
[0146] Correspondingly, heterogeneous computing was born in the mid-1980s, mainly referring to the computing method of using computing units with different types of instruction sets and architectures to form a system. Common computing unit categories include central processing unit (CPU), graphics processing unit (GPU), digital signal processor (DSP), application specific integrated circuit (ASIC), field programmable gate array (FPGA), etc. A heterogeneous computing platform often contains processors using different instruction set architectures (ISA), which work together to complete computing tasks.
[0147] With the advancement of technology, the demand for high-performance parallel computing in the consumer electronics market is exploding, especially in machine vision, artificial intelligence, cloud computing, augmented reality (AR) / virtual reality (VR), software-defined radio and other emerging fields, which have a great demand for heterogeneous computing systems. Heterogeneous computing enables computing units on the same system-on-chip to complete their respective computing tasks through programming, thereby achieving more efficient and lower power consumption results than a single computing unit.
[0148] In order for neural network models to be able to calculate efficiently on heterogeneous platforms, in addition to a high-performance hardware computing platform, efficient compilation by the AI compiler is also required. The AI compiler must not only take on the changes in the neural network model algorithm and meet the research demands of algorithm developers for continuous exploration, but also meet the demands of diverse hardware in the final binary output and meet the resource requirements of different deployment environments. It must meet the universality of the framework, the flexibility requirements of ease of use, and the continuous optimization of performance. The AI compiler ensures the convenient expression and efficient execution of machine learning algorithms, and is becoming an important part of the design of machine learning frameworks.
[0149] In order to solve the problem of small memory capacity on the device side, such as Figure 6As shown in the figure, a calculation needs to be split into multiple calculations. Each calculation after splitting is called a tiling. The corresponding data needs to be loaded into the device memory in multiple times. For example, the 10 lines of input data are split into 4 parts, and two lines of data are output each time. After four calculations, all 8 lines of data are output. The number of lines in each split is called the slice size.
[0150] exist Figure 6 The size of the slice of each tiling may be different, so when generating instructions, the technical solution needs to generate corresponding instructions for each tiling, and cannot use a loop to loop to represent the instructions of each tiling.
[0151] like Figure 7 As shown, the hardware resources of the heterogeneous platform can perform matrix operation instructions and vector operation instructions (called special instructions) for specific computing tasks, as well as scalar instructions for processing ordinary tasks. Some information required by special instructions, such as the memory address of the operation, the size and shape of the data operated, etc., needs to be calculated by ordinary instructions and saved to the corresponding registers. In actual scenarios, the scalar instruction processing capability of the device side is relatively weak. The embodiment of the present application aims to reduce the generation of scalar instructions in the instruction generation of neural network model compilation.
[0152] Generating corresponding calculation instructions for each compilation process will lead to insufficient instruction cache memory. If the calculation instructions for each compilation process are simply represented by a loop, since the data size of each compilation process may be different, a large number of scalar calculation instructions will be introduced to calculate the compilation data, which may reduce the instruction issuance speed and cause the calculation of the entire hardware to be blocked in the operation process of scalar instructions. Even if the data size of each output compilation process is guaranteed to be consistent during the compilation calculation, the existence of downsampling operators such as the conv operator and upsampling operators such as the transpose_conv operator will also cause the data size of the input compilation process of each compilation process to be different in the end.
[0153] Compared with the current prior art, since there are upsampling types and downsampling types in the process of reverse compilation, the size and number of rows of data will change in the process of reverse compilation. This embodiment can ensure that the data size and number of rows of the second matrix data corresponding to the middle paragraph data are the same by not uniformly removing the second matrix data corresponding to the first paragraph data after segmentation and the second matrix data corresponding to the last paragraph data. When generating instructions, the second matrix data corresponding to the middle paragraph data can be looped with the same instruction. Since the size and number of rows of the second matrix data corresponding to the middle paragraph data are the same, no additional scalar instructions are required to calculate the second matrix data corresponding to each middle paragraph data, avoiding program blocking during the execution of scalar instructions, releasing the buffer memory used to store instruction information, ensuring the normal progress of data compilation, and cyclically issuing the same instructions, which can improve the efficiency of instruction execution of subsequent instruction calculations and reduce resource waste.
[0154] Further, as Figure 1 and Figure 2 The specific implementation of the method shown in this embodiment provides a data compilation processing device, such as Figure 8 As shown, the device includes: an acquisition module 31, a segmentation module 32, a compilation module 33, and a generation module 34.
[0155] An acquisition module 31 is configured to acquire first tensor data obtained by a target subgraph through a neural network model and sampling type information corresponding to the first tensor data;
[0156] The segmentation module 32 is configured to segment the first tensor data according to the target number of paragraphs to obtain a plurality of segmented paragraph data, wherein, except for the first paragraph data and the last paragraph data, the numbers of tensor rows corresponding to the other intermediate paragraph data are the same;
[0157] A compiling module 33 is configured to perform reverse compilation processing on the plurality of paragraph data respectively according to the sampling type information to obtain second tensor data respectively corresponding to the plurality of paragraph data;
[0158] The generating module 34 is configured to generate instruction information corresponding to the second tensor data according to the second tensor data, wherein unified instruction information is generated for the second tensor data with the same number of tensor rows.
[0159] In some examples of this embodiment, the compilation module 33 is specifically configured to perform reverse compilation processing on each of the intermediate paragraph data according to the sampling type information to obtain the second tensor data corresponding to each of the intermediate paragraph data; based on the second tensor data corresponding to each of the intermediate paragraph data, obtain the second tensor data corresponding to the first paragraph data and the last paragraph data.
[0160] In some examples of the present embodiment, the compilation module 33 is further specifically configured to determine multiple sampling types corresponding to each intermediate paragraph data and the sampling times of each intermediate paragraph data based on the sampling type information corresponding to each intermediate paragraph data in the sampling type information; according to the target arrangement order of the multiple sampling types, starting from the first sampling type in the multiple sampling types, each intermediate paragraph data is reverse compiled for a target number of times to obtain the second tensor data corresponding to each intermediate paragraph data, wherein the target number of times is determined based on the sampling number.
[0161] In some examples of the present embodiment, the compilation module 33 is further specifically configured to perform a reverse compilation process in each reverse compilation process based on the second tensor data corresponding to the intermediate paragraph data of the previous reverse compilation process and the sampling type corresponding to the current reverse compilation process, to obtain the second tensor data corresponding to the intermediate paragraph data of the current reverse compilation process; and perform the next reverse compilation process based on the second tensor data corresponding to the intermediate paragraph data of the current reverse compilation process, to obtain the second tensor data corresponding to the intermediate paragraph data of the next reverse compilation process.
[0162] In some examples of the present embodiment, the compilation module 33 is further configured to analyze the second tensor data corresponding to each intermediate paragraph data of the last reverse compilation process, and determine the completion data and stride data of the last reverse compilation process; based on the second tensor data corresponding to each intermediate paragraph data of the last reverse compilation process, the completion data and the stride data, reverse compilation processing is performed to obtain each intermediate paragraph data of the current reverse compilation process.
[0163] In some examples of the present embodiment, the compilation module 33 is further configured to perform a reverse compilation process on the second tensor data corresponding to the intermediate paragraph data of the previous reverse compilation process according to a preset upsampling standard if the sampling type corresponding to the current reverse compilation process is upsampling, so as to obtain the second tensor data corresponding to the intermediate paragraph data of the current reverse compilation process.
[0164] In some examples of the present embodiment, the compilation module 33 is further configured to perform a reverse compilation process on the second tensor data corresponding to the intermediate paragraph data of the previous reverse compilation process according to a preset downsampling standard if the sampling type corresponding to the current reverse compilation process is downsampling, so as to obtain the second tensor data corresponding to the intermediate paragraph data of the current reverse compilation process.
[0165] In some examples of the present embodiment, the compilation module 33 is also configured to obtain first tensor row number data of the second tensor data corresponding to the multiple paragraph data respectively; accordingly, the compilation module 33 is also specifically configured to determine second tensor row number data of the second tensor data corresponding to each of the intermediate paragraph data respectively; process the first tensor row number data and the second tensor row number data to obtain third tensor row number data corresponding to the first paragraph data and fourth tensor row number data corresponding to the last paragraph data; and obtain the second tensor data corresponding to the first paragraph data and the last paragraph data respectively based on the third tensor row number data and the fourth tensor row number data.
[0166] In some examples of this embodiment, the compiling module 33 is further configured to process the first tensor row number data and the tensor row number data of the second tensor data corresponding to the middle paragraph data of the previous decompilation process in each decompilation process, and obtain the tensor row number data corresponding to the first paragraph data and the last paragraph data of the current decompilation process. According to the tensor row number data corresponding to the first paragraph data and the last paragraph data of the current decompilation process, the first paragraph data and the last paragraph data of the next decompilation process are obtained;
[0167] In some examples of this embodiment, the compilation module 33 is further configured to determine, in each reverse compilation process, the first paragraph sampling type corresponding to the current reverse compilation based on the first paragraph data of the current reverse compilation process and the first paragraph data of the next reverse compilation process; and determine the last paragraph sampling type corresponding to the current reverse compilation based on the last paragraph data of the current reverse compilation process and the last paragraph data of the next reverse compilation process.
[0168] In some examples of this embodiment, the compilation module 33 is further configured to generate sampling type information of the second tensor data corresponding to the first paragraph data based on the sampling type of the first paragraph of each reverse compilation process through the target number of reverse compilation processes; and to generate sampling type information of the second tensor data corresponding to the last paragraph data based on the sampling type of the last paragraph of each reverse compilation process through the target number of reverse compilation processes.
[0169] In some examples of the present embodiment, the generation module 34 is specifically configured to generate unified first instruction information according to the sampling type information of the second tensor data corresponding to each intermediate paragraph data, and the first instruction information is used to instruct the second tensor data corresponding to each intermediate paragraph data to perform subsequent instruction calculations; generate second instruction information according to the first paragraph sampling type information of the second tensor data corresponding to the first paragraph data, and the second instruction information is used to instruct the second tensor data corresponding to the first paragraph data to perform subsequent instruction calculations; generate third instruction information according to the last paragraph sampling type information of the second tensor data corresponding to the last paragraph data, and the third instruction information is used to instruct the second tensor data corresponding to the last paragraph data to perform subsequent instruction calculations.
[0170] It should be noted that for other corresponding descriptions of the functional units involved in the data compilation processing method provided in this embodiment, reference can be made to Figure 1 and Figure 2 The corresponding description in will not be repeated here.
[0171] Based on the above Figure 1 and Figure 2 The method shown in the embodiment also provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the above-mentioned Figure 1 and Figure 2 The method shown.
[0172] Based on this understanding, the technical solution of the present application can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, USB flash drive, mobile hard disk, etc.), including a number of instructions for enabling a computer device (which can be a personal computer, server, or network device, etc.) to execute the methods of various implementation scenarios of the present application.
[0173] Based on the above Figure 1 and Figure 2 The method shown, and Figure 8 In order to achieve the above-mentioned purpose, the embodiment of the present application also provides an electronic device, such as a smart phone, a tablet computer, a drone, an intelligent robot or other intelligent terminal, which includes a storage medium and a processor; the storage medium is used to store a computer program; the processor is used to execute the computer program to achieve the above-mentioned Figure 1 and Figure 2 The method shown.
[0174] Optionally, the above-mentioned physical device may also include a user interface, a network interface, a camera, a radio frequency (RF) circuit, a sensor, an audio circuit, a WI-FI module, etc. The user interface may include a display, an input unit such as a keyboard, etc., and the optional user interface may also include a USB interface, a card reader interface, etc. The network interface may optionally include a standard wired interface, a wireless interface (such as a WI-FI interface), etc.
[0175] Those skilled in the art will appreciate that the above-mentioned physical device structure provided in this embodiment does not constitute a limitation on the physical device, and may include more or fewer components, or a combination of certain components, or different arrangements of components.
[0176] The storage medium may also include an operating system and a network communication module. The operating system is a program that manages the hardware and software resources of the above-mentioned physical device, and supports the operation of the information processing program and other software and / or programs. The network communication module is used to realize the communication between the components inside the storage medium, and the communication with other hardware and software in the information processing physical device.
[0177] Based on the above Figure 1 and Figure 2 The method shown, and Figure 8 The virtual device embodiment shown in the embodiment further provides a chip, including one or more interface circuits and one or more processors; the interface circuit is used to receive a signal from a memory of an electronic device and send the signal to the processor, the signal including a computer instruction stored in the memory; when the processor executes the computer instruction, the electronic device executes the above-mentioned Figure 1 and Figure 2 The method shown.
[0178] Through the description of the above implementation mode, the technicians in this field can clearly understand that the present application can be implemented by means of software plus the necessary general hardware platform, or by hardware. By applying the scheme of this embodiment, compared with the current prior art, due to the presence of upsampling type and downsampling type in the process of reverse compilation processing, the size and number of rows of the data will change during the reverse compilation processing. This embodiment can ensure that the data size and number of rows of the second matrix data corresponding to the middle paragraph data are the same by not uniformly removing the second matrix data corresponding to the first paragraph data after segmentation and the second matrix data corresponding to the last paragraph data. When generating instructions, the second matrix data corresponding to the middle paragraph data can be processed in a loop with the same instruction. Since the size and number of rows of the second matrix data corresponding to the middle paragraph data are the same, no additional scalar instructions are required to calculate the second matrix data corresponding to each middle paragraph data, avoiding program blocking during the execution of scalar instructions, releasing the buffer memory used to store instruction information, ensuring the normal progress of data compilation, and cyclically transmitting the same instructions, which can improve the efficiency of instruction execution of subsequent instruction calculations and reduce resource waste.
[0179] It should be noted that, in this article, relational terms such as "first" and "second" are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.
[0180] The above is only a specific implementation of the present application, so that those skilled in the art can understand or implement the present application. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein can be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to the embodiments described herein, but will conform to the widest scope consistent with the principles and novel features applied for herein.
Claims
1. A data compilation processing method, characterized in that: include: Obtaining first tensor data obtained by the target subgraph through the neural network model and sampling type information corresponding to the first tensor data; The first tensor data is segmented according to the target number of paragraphs to obtain a plurality of segmented paragraph data, wherein, except for the first paragraph data and the last paragraph data, the numbers of tensor rows corresponding to the other intermediate paragraph data are the same; According to the sampling type information, the plurality of paragraph data are respectively decompiled to obtain second tensor data corresponding to the plurality of paragraph data; According to the second tensor data, instruction information corresponding to the second tensor data is generated, wherein unified instruction information is generated for second tensor data having the same number of tensor rows.
2. The method according to claim 1, characterized in that The decompiling process is performed on the plurality of paragraph data respectively according to the sampling type information to obtain second tensor data respectively corresponding to the plurality of paragraph data, including: According to the sampling type information, the respective intermediate paragraph data are decompiled to obtain the second tensor data corresponding to the respective intermediate paragraph data; Based on the second tensor data corresponding to each of the middle paragraph data, the second tensor data corresponding to the first paragraph data and the last paragraph data are obtained.
3. The method according to claim 2, characterized in that The decompilation process is performed on each of the intermediate paragraph data according to the sampling type information to obtain the second tensor data corresponding to each of the intermediate paragraph data, including: Determine, according to the sampling type information corresponding to each intermediate paragraph data in the sampling type information, a plurality of sampling types corresponding to each intermediate paragraph data and a sampling number of each intermediate paragraph data; According to the target arrangement order of the multiple sampling types, starting from the first sampling type among the multiple sampling types, each intermediate paragraph data is reverse compiled for a target number of times to obtain the second tensor data corresponding to each intermediate paragraph data, wherein the target number of times is determined according to the sampling number.
4. The method according to claim 3, characterized in that According to the target arrangement order of the multiple sampling types, starting from the first sampling type among the multiple sampling types, the target number of times of reverse compilation processing are performed on each of the intermediate paragraph data to obtain the second tensor data corresponding to each of the intermediate paragraph data, including: In each decompilation process, based on the second tensor data corresponding to the middle paragraph data of the last decompilation process and the sampling type corresponding to the current decompilation process, the decompilation process is performed to obtain the second tensor data corresponding to the middle paragraph data of the current decompilation process; The next decompilation process is performed according to the second tensor data corresponding to the middle paragraph data of the current decompilation process, so as to obtain the second tensor data corresponding to the middle paragraph data of the next decompilation process.
5. The method according to claim 3, characterized in that: The method of performing a decompilation process based on the second tensor data corresponding to the middle paragraph data of the last decompilation process and the sampling type corresponding to the current decompilation process to obtain the second tensor data corresponding to the middle paragraph data of the current decompilation process includes: Analyze the second tensor data corresponding to each intermediate segment data of the last decompilation process to determine the completion data and stride data of the last decompilation process; Based on the second tensor data corresponding to each intermediate paragraph data of the previous decompilation processing, the completion data and the stride data, decompilation processing is performed to obtain each intermediate paragraph data of the current decompilation processing.
6. The method according to claim 3, characterized in that The method of performing reverse compilation based on the second tensor data corresponding to the middle paragraph data of the last reverse processing and the sampling type corresponding to the current reverse compilation processing to obtain the second tensor data corresponding to the middle paragraph data of the current reverse compilation processing includes: If the sampling type corresponding to the current decompilation process is upsampling, the second tensor data corresponding to the intermediate paragraph data of the previous decompilation process is decompiled according to the preset upsampling standard to obtain the second tensor data corresponding to the intermediate paragraph data of the current decompilation process.
7. The method according to claim 6, characterized in that The method further comprises: performing a reverse compilation process based on the second tensor data corresponding to the middle paragraph data of the last reverse processing and the sampling type corresponding to the current reverse compilation process to obtain the second tensor data corresponding to the middle paragraph data of the current reverse compilation process, and further comprising: If the sampling type corresponding to the current decompilation process is downsampling, the second tensor data corresponding to the intermediate paragraph data of the previous decompilation process is decompiled according to the preset downsampling standard to obtain the second tensor data corresponding to the intermediate paragraph data of the current decompilation process.
8. The method according to claim 4, characterized in that Before obtaining the second tensor data corresponding to the first paragraph data and the last paragraph data based on the second tensor data corresponding to each of the middle paragraph data, the method further includes: Obtain first tensor row number data of the second tensor data corresponding to the plurality of paragraph data respectively; The obtaining of the second tensor data corresponding to the first paragraph data and the last paragraph data respectively based on the second tensor data corresponding to each of the middle paragraph data respectively includes: Determine the second tensor row number data of the second tensor data corresponding to each of the middle paragraph data; Processing the first tensor row number data and the second tensor row number data to obtain a third tensor row number data corresponding to the first paragraph data and a fourth tensor row number data corresponding to the last paragraph data; According to the third tensor row number data and the fourth tensor row number data, second tensor data corresponding to the first paragraph data and the last paragraph data are obtained respectively.
9. The method according to claim 8, characterized in that The processing of the first tensor row number data and the second tensor row number data to obtain the third tensor row number data corresponding to the first paragraph data and the fourth tensor row number data corresponding to the last paragraph data includes: In each decompilation process, the first tensor row number data and the tensor row number data of the second tensor data corresponding to the middle paragraph data of the previous decompilation process are processed to obtain the tensor row number data corresponding to the first paragraph data and the last paragraph data of the current decompilation process respectively; The first paragraph data and the last paragraph data of the next decompilation process are obtained according to the tensor row number data corresponding to the first paragraph data and the last paragraph data of the current decompilation process.
10. The method according to claim 9, characterized in that After obtaining the first paragraph data and the last paragraph data of the next decompilation process according to the tensor row number data corresponding to the first paragraph data and the last paragraph data of the current decompilation process, the method further includes: In each reverse compilation process, based on the first paragraph data of the current reverse compilation process and the first paragraph data of the next reverse compilation process, determining the first paragraph sampling type corresponding to the current reverse compilation process; Based on the last paragraph data of the current decompilation process and the last paragraph data of the next decompilation process, a last paragraph sampling type corresponding to the current decompilation process is determined.
11. The method according to claim 10, characterized in that The method further comprises: Generate sampling type information of the second tensor data corresponding to the first paragraph data based on the sampling type of the first paragraph of each decompilation process through the target number of decompilation processes; Through the reverse compilation process of the target number of times, based on the sampling type of the last paragraph of each reverse compilation process, the sampling type information of the second tensor data corresponding to the last paragraph data is generated.
12. The method according to any one of claims 1 to 11, characterized in that The step of generating instruction information corresponding to the second tensor data according to the second tensor data includes: Generate unified first instruction information according to the sampling type information of the second tensor data corresponding to each intermediate segment data, wherein the first instruction information is used to instruct the second tensor data corresponding to each intermediate segment data to perform subsequent instruction calculation; Generate second instruction information according to the first paragraph sampling type information of the second tensor data corresponding to the first paragraph data, wherein the second instruction information is used to instruct the second tensor data corresponding to the first paragraph data to perform subsequent instruction calculation; According to the last segment sampling type information of the second tensor data corresponding to the last segment data, third instruction information is generated, and the third instruction information is used to instruct the second tensor data corresponding to the last segment data to perform subsequent instruction calculations.
13. A data compilation and processing device, characterized in that: include: An acquisition module is configured to acquire first tensor data obtained by the target subgraph through the neural network model and sampling type information corresponding to the first tensor data; a segmentation module configured to segment the first tensor data according to the target number of paragraphs to obtain a plurality of segmented paragraph data, wherein, except for the first paragraph data and the last paragraph data, the numbers of tensor rows corresponding to the other intermediate paragraph data are the same; A compiling module is configured to perform reverse compilation processing on the plurality of paragraph data respectively according to the sampling type information to obtain second tensor data respectively corresponding to the plurality of paragraph data; A generation module is configured to generate instruction information corresponding to the second tensor data based on the second tensor data, wherein unified instruction information is generated for second tensor data with the same number of tensor rows.
14. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 12 is implemented.
15. An electronic device comprising a storage medium, a processor, and a computer program stored in the storage medium and executable on the processor, characterized in that: When the processor executes the computer program, the method according to any one of claims 1 to 12 is implemented.
16. A chip, characterized in that: It comprises one or more interface circuits and one or more processors; the interface circuit is used to receive a signal from a memory of an electronic device and send the signal to the processor, the signal comprising a computer instruction stored in the memory; when the processor executes the computer instruction, the electronic device executes the method described in any one of claims 1 to 12.