Data processing method and device, electronic equipment and storage medium
By detecting and utilizing multiple single-head processing arrays to process sub-data vectors in the integrated storage and computing chip, the problem of low data processing efficiency in the integrated storage and computing chip is solved and a more efficient data processing process is achieved.
Patent Information
- Application Number
- CN202410101343.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-01-24
- Publication Date
- 2024-10-22
AI Technical Summary
In the storage and computing integrated chip, the data processing efficiency is low because it needs to wait for all vector caches to be completed before processing, resulting in too long preparation time.
By detecting the number of vectors of the current sub-data, if it is not less than the preset minimum number, use multiple single-head processing arrays to process it, and cache the next batch of vectors when K vectors are cached, until all sub-data processing is completed , using the attention layer for feature processing and caching to reduce waiting time.
It improves the processing efficiency of the data to be processed by the storage and computing integrated chip, saves cache time, and avoids the process of waiting for all vector caches to be completed.
Smart Images

Figure CN118820171A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of storage-computing integration technology, and in particular to a data processing method, device, electronic device and storage medium. Background Art
[0002] As a new computing architecture, the core of integrated storage and computing is to fully integrate storage and computing, and combine advanced packaging, new storage devices and other technologies in the post-Moore era to achieve an order of magnitude improvement in computing energy efficiency. In-memory computing refers to integrated storage and computing in a narrow sense. During the chip design process, there is no distinction between storage units and computing units, and the integration of storage and computing is truly realized. In related technologies, in the process of processing data through integrated storage and computing chips, all vector representations of the data need to be cached before the data can be processed, which requires a lot of preparation time, resulting in low data processing efficiency. Summary of the invention
[0003] A data processing method, device, electronic device and storage medium provided in the embodiments of the present application can improve the data processing efficiency of a storage and computing integrated chip.
[0004] The technical solution of this application is implemented as follows:
[0005] The present application provides a data processing method, including:
[0006] Determine, based on the vector information of the current sub-data currently cached, a result of detecting the number of vectors of the current sub-data; wherein the current sub-data belongs to a plurality of sub-data included in the data to be processed;
[0007] When the quantity detection result indicates that the number of vectors of the current sub-data is not less than a preset minimum number, the vectors of the current sub-data are processed using multiple single-head processing arrays, and the next batch of vectors are cached for the multiple sub-data until the processing of the multiple sub-data is completed to obtain the processing results of the data to be processed; wherein, an attention layer in the preset processing model is deployed on each of the single-head processing arrays.
[0008] In the above solution, the step of determining the result of the vector quantity detection for the current sub-data based on the vector information of the current sub-data currently cached includes:
[0009] Acquire the vector information of the current sub-data;
[0010] The number of vectors represented by the vector information is compared with the preset minimum number to determine the number detection result.
[0011] In the above solution, after determining the result of the number detection of the vectors for the current sub-data based on the vector information of the current sub-data currently cached, the method further includes:
[0012] When the quantity detection result indicates that the number of vectors of the current sub-data is less than the preset minimum number, the vector corresponding to the next sub-data is obtained from the multiple sub-data for caching, until the number of vectors is cached to K, the vectors of the K sub-data are processed using the multiple single-head processing arrays, and the next batch of vectors are cached until the processing of the multiple sub-data is completed to obtain the processing results of the data to be processed; wherein K is an integer greater than 0.
[0013] In the above scheme, the vector of the current sub-data is processed by using multiple single-head processing arrays, and the next batch of vectors are cached for the multiple sub-data until the processing of the multiple sub-data is completed to obtain the processing result of the data to be processed, including:
[0014] Processing the first input feature determined based on the vector of the current sub-data through each of the single-head processing arrays to obtain at least one first intermediate feature of the current sub-data corresponding to each of the single-head processing arrays, and caching a first predetermined feature of at least one of the first intermediate features; the at least one first intermediate feature includes at least one of the following: a first intermediate query feature, a first intermediate keyword feature, and a first intermediate value feature;
[0015] Determine a first intermediate result corresponding to the current sub-data based on at least one of the first intermediate features and a first feature of the cache, wherein the first feature represents a predetermined feature of a previous batch of vectors cached before the current moment;
[0016] Sequentially cache vectors corresponding to K of the M sub-data, process the vectors corresponding to the K sub-data through each of the single-head processing arrays to obtain at least one second intermediate feature of each of the single-head processing arrays corresponding to the K sub-data, and cache a second predetermined feature of at least one of the second intermediate features; wherein the plurality of sub-data include: M sub-data, where M is an integer greater than 1;
[0017] Based on at least one of the second intermediate features and the cached second features, second intermediate results corresponding to the K sub-data are determined until the M sub-data are processed and N intermediate results are obtained; wherein the second feature includes: the first feature and the first predetermined feature; N is an integer greater than 0;
[0018] A processing result of the data to be processed is obtained based on the N intermediate results.
[0019] In the above scheme, before processing the first input feature determined based on the vector of the current sub-data through each of the single-head processing arrays to obtain at least one first intermediate feature of the current sub-data corresponding to each of the single-head processing arrays, and caching a first predetermined feature of at least one of the first intermediate features, the method further includes:
[0020] The first input feature is determined based on the sum of the vector of the current sub-data and a position encoding vector; wherein the position encoding vector is determined based on the position of the current sub-data in the plurality of sub-data.
[0021] In the above scheme, the first input feature determined based on the vector of the current sub-data is processed by each of the single-head processing arrays to obtain at least one first intermediate feature of the current sub-data corresponding to each of the single-head processing arrays, and a first predetermined feature of at least one of the first intermediate features is cached, including:
[0022] By each of the single-head processing arrays, the first input feature is multiplied by a query weight matrix to obtain the first intermediate query feature, the first input feature is multiplied by a keyword weight matrix to obtain the first intermediate keyword feature, and the first input feature is multiplied by an intermediate value weight matrix to obtain the first intermediate value feature;
[0023] The first intermediate key feature and the first intermediate value feature corresponding to each of the single-head processing arrays are cached.
[0024] In the above scheme, the first feature includes: a cache keyword feature and a cache intermediate value feature;
[0025] The determining, based on at least one of the first intermediate features and the first feature of the cache, a first intermediate result corresponding to the current sub-data includes:
[0026] Processing at least one of the first intermediate features based on an attention mechanism to determine an attention feature corresponding to each of the single-head processing arrays;
[0027] Concatenate the attention feature with the corresponding cache keyword feature and the cache intermediate value feature to obtain a concatenated matrix;
[0028] The first intermediate result is determined based on each of the concatenated matrices.
[0029] In the above scheme, after the first input feature determined based on the vector of the current sub-data is processed by each of the single-head processing arrays to obtain at least one first intermediate feature of the current sub-data corresponding to each of the single-head processing arrays, and a first predetermined feature of at least one of the first intermediate features is cached, the method further includes:
[0030] Delete the cached vector of the current subdata.
[0031] The present application also provides a data processing device, including:
[0032] A determination unit, configured to determine a result of a vector quantity detection for the current sub-data based on vector information of the current sub-data currently cached; wherein the current sub-data belongs to a plurality of sub-data included in the data to be processed;
[0033] A cache processing unit is used to process the vectors of the current sub-data using multiple single-head processing arrays when the number detection result indicates that the number of vectors of the current sub-data is not less than a preset minimum number, and cache the next batch of vectors for the multiple sub-data until the processing of the multiple sub-data is completed to obtain the processing results of the data to be processed; wherein an attention layer in the preset processing model is deployed on each of the single-head processing arrays.
[0034] An embodiment of the present application further provides an electronic device, including a memory and a processor, wherein the memory stores a computer program that can be run on the processor, and the processor implements the steps in the above method when executing the computer program.
[0035] An embodiment of the present application further provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the steps in the above method are implemented.
[0036] In an embodiment of the present application, based on the vector information of the current sub-data currently cached, the number detection result of the vector of the current sub-data is determined; wherein the current sub-data belongs to multiple sub-data included in the data to be processed; when the number detection result indicates that the number of vectors of the current sub-data is not less than the preset minimum number, multiple single-head processing arrays are used to process the vector of the current sub-data, and the next batch of vectors are cached for multiple sub-data until the processing of multiple sub-data is completed to obtain the processing result of the data to be processed; wherein an attention layer in the preset processing model is deployed on each single-head processing array. In this way, when the storage-computing integrated chip processes data, only the number of cached vectors is not less than the preset minimum number, and the cached current sub-data can be processed without waiting for the vectors of multiple sub-data to be cached, which saves cache time and improves the processing efficiency of the storage-computing integrated chip for the data to be processed. BRIEF DESCRIPTION OF THE DRAWINGS
[0037] Figure 1 An optional effect schematic diagram of the related technology provided by the embodiment of the present application;
[0038] Figure 2 An optional effect schematic diagram of the related technology provided by the embodiment of the present application;
[0039] Figure 3 An optional effect schematic diagram of the related technology provided by the embodiment of the present application;
[0040] Figure 4 An optional flowchart of a data processing method provided in an embodiment of the present application;
[0041] Figure 5 An optional effect diagram of the data processing method provided in the embodiment of the present application;
[0042] Figure 6 An optional flowchart of a data processing method provided in an embodiment of the present application;
[0043] Figure 7 An optional flowchart of a data processing method provided in an embodiment of the present application;
[0044] Figure 8 An optional flowchart of a data processing method provided in an embodiment of the present application;
[0045] Fig. 9 An optional flowchart of a data processing method provided in an embodiment of the present application;
[0046] Fig.10 An optional effect diagram of the data processing method provided in the embodiment of the present application;
[0047] Fig.11 An optional effect diagram of the data processing method provided in the embodiment of the present application;
[0048] Fig.12 An optional flowchart of a data processing method provided in an embodiment of the present application;
[0049] Fig.13 A schematic diagram of the structure of a data processing device provided in an embodiment of the present application;
[0050] Fig.14 A hardware entity schematic diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0051] In order to make the purpose, technical solutions and advantages of the present application clearer, the technical solutions of the present application are further elaborated in detail below in conjunction with the drawings and embodiments. The described embodiments should not be regarded as limiting the present application. All other embodiments obtained by ordinary technicians in the field without making creative work are within the scope of protection of the present application.
[0052] In the following description, reference is made to “some embodiments”, which describe a subset of all possible embodiments, but it will be understood that “some embodiments” may be the same subset or different subsets of all possible embodiments and may be combined with each other without conflict.
[0053] If similar descriptions of "first / second" appear in the application documents, the following instructions are added. In the following description, the terms "first\second\third" involved are merely used to distinguish similar objects and do not represent a specific ordering of the objects. It can be understood that "first\second\third" can be interchanged in a specific order or sequence where permitted, so that the embodiments of the present application described herein can be implemented in an order other than that illustrated or described herein.
[0054] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which this application belongs. The terms used herein are only for the purpose of describing the embodiments of this application and are not intended to limit this application.
[0055] Combination Figure 1 In-memory computing is a research hotspot for new computing paradigms. Its essence is to use the physical properties of different storage media to redesign the storage circuit so that it has both computing and storage capabilities. Multiple storage and computing arrays are deployed in the integrated storage and computing chip to directly eliminate the boundaries between "storage" and "computing", so that computing energy efficiency can be improved by orders of magnitude. The most typical scenario for in-memory computing is to provide operator acceleration for vector-matrix multiplication for artificial intelligence (AI) algorithms. A lot of research has been carried out in the field of neural networks, such as convolutional neural networks (CNN) and recurrent neural networks (RNN). Combined with Figure 2, analog in-memory computing is mainly based on the laws of physics (Ohm's law and Kirchhoff's law), and multiplication and addition operations are implemented on the memory array. Take the resistive random access memory (RRAM), also known as memristor, as an example. Memristor circuits can be made into array structures, similar to the shape of a matrix. Using its matrix computing capabilities, it can be widely used in AI reasoning scenarios. In the AI reasoning process, the inference result can be obtained by completing the multiplication and addition operations by inputting the vector and the parameter matrix of the model. Since the entire operation process no longer needs to repeatedly read a large number of model parameters from the memory, the bottleneck of the von Neumann architecture is bypassed, and the energy efficiency ratio is significantly improved. In addition to memristors, other storage media can also meet the same parallel computing requirements through different physical mechanisms.
[0056] For example, the inference result can be calculated by combining formula (1)
[0057]
[0058] Among them, V1, V2 and V3 are input vectors, G 11 is the parameter of the first row and first column in the parameter matrix, G 1j v j is the product of the jth input vector and the parameter in the first row and jth column, ΣG 1j v j G 2j v j G 3j v j It is the product of the input vector and the parameter matrix, which is the inference result.
[0059] In related technologies, the sub-attention layer of the Transformer model is usually deployed on a storage and computing integrated chip. Figure 3, the Transformer model includes multiple self-attention layers, and the parameter matrices of multiple self-attention layers can be deployed on a storage-computing integrated chip to realize in-memory computing. Among them, the self-attention layer is actually the attention operation layer, and because its query vector q, keyword vector k and value vector v come from the same input, it is called the self-attention layer. The processing flow of the Transformer model may include: first encode the word, add it to the position encoding vector, and get the word vector representation of the word. Multiple word vectors together get the self-attention layer input X. Its shape is (b, N, 512); then define three learnable matrices to be implemented through nn.Li near, and its shape is (512, M), generally M is equal to the previous dimension 512, so that the dimension after calculation remains unchanged; multiply X and the matrix to get the QKV output, the shape is (b, N, M); then perform dot multiplication of Q and K to calculate the vector similarity; use softmax to convert it to probability distribution; and perform weighted summation of the probability distribution and V. Among them, the output of the Transformer model is still a vector, which needs to be connected to a softmax layer for classification training. Suppose our model learns 10,000 different English words from the training set (the "output vocabulary" of our model). Therefore, the output after softmax is a vector of 10,000 cells, where each cell corresponds to the score of a certain word. This is actually a normal multi-classification problem, but with a larger dimension.
[0060] This application embodiment provides a data processing method, see Figure 4 , is an optional flow chart of the data processing method provided in the embodiment of the present application, which will be combined with Figure 4 The steps shown are explained.
[0061] S101 . Determine a result of detecting the number of vectors of current sub-data based on vector information of current sub-data currently cached.
[0062] In an embodiment of the present application, the storage and computing integrated chip of the data processing device includes a cache part and multiple single-head processing arrays, wherein each of the single-head processing arrays deploys an attention layer in a preset processing model (Transformer model). The data processing device can encode the current sub-data into a vector and cache it, and obtain the vector information of the current sub-data currently cached. The number of vectors in the cache part is determined based on the vector information, and the number of vectors is compared with the preset minimum number to determine the number detection result.
[0063] The preset minimum number may be 1, and in other embodiments, the preset minimum number may also be other values.
[0064] The quantity detection result is used to characterize whether the number of vectors of the current sub-data is less than the preset minimum number. The current sub-data belongs to multiple sub-data included in the data to be processed. Each sub-data can be text data, or other data that can be processed by the Transformer model.
[0065] S102. When the quantity detection result indicates that the number of vectors of the current sub-data is not less than a preset minimum number, the vectors of the current sub-data are processed using multiple single-head processing arrays, and the next batch of vectors are cached for the multiple sub-data until the processing of the multiple sub-data is completed to obtain the processing results of the data to be processed.
[0066] In an embodiment of the present application, when the quantity detection result indicates that the number of vectors of the current sub-data is not less than a preset minimum number, the data processing device uses multiple single-head processing arrays to process the cached vectors of the current sub-data and output the corresponding first intermediate result, and caches the next vector for the multiple sub-data. When the number of the next batch of cached vectors is not less than the preset minimum number, the next batch of vectors is processed using multiple single-head processing arrays and the second intermediate result is output, until the processing of the multiple sub-data is completed, and multiple intermediate results are obtained, and the multiple intermediate results are combined to determine the processing result for the data to be processed.
[0067] Exemplarily, the embodiment of the present application provides a Transformer cache pre-fetch mechanism using a storage-computing integrated chip, which is used to perform Transformer operations on an input word sequence. The data to be processed can be encoded as a vector; the medium of the storage-computing integrated chip is not limited, and can be a storage-computing integrated medium such as a memristor or NandFlash. Figure 5 , the integrated storage and computing chip includes: an on-chip memory for caching the vector of the current sub-data; and multiple single-head processing arrays, each of which has a built-in parameter matrix of the Transforme model for multiplication and addition operations. The data processing device can determine whether the on-chip memory contains at least one vector based on the vector information and the number of heads of the multi-head attention mechanism in the Transformer. If so, at least one input word vector representation is obtained based on the currently cached vector. The above-mentioned input word vector representation is input into the multiple single-head processing arrays in the integrated storage and computing chip to obtain the multiplication and addition operation results (intermediate results) of the word vector representation and the parameter matrix at the output end.
[0068] Exemplarily, the processing of input vectors by multiple single-head processing arrays is similar to a grouping operation. The input vectors are input into each single-head processing array respectively to obtain the matrix output of each single-head processing array. Finally, the multiple matrix outputs are concat to obtain the processing result of the data to be processed.
[0069] In some other embodiments, after the vector of the current sub-data is processed by multiple single-head processing arrays, the cached vector of the current sub-data may be deleted. Figure 5 , that is, deleting the vector of the current sub-data cached in the on-chip memory.
[0070] In an embodiment of the present application, based on the vector information of the current sub-data currently cached, the number detection result of the vector of the current sub-data is determined; wherein the current sub-data belongs to multiple sub-data included in the data to be processed; when the number detection result indicates that the number of vectors of the current sub-data is not less than the preset minimum number, multiple single-head processing arrays are used to process the vector of the current sub-data, and the next batch of vectors are cached for multiple sub-data until the processing of multiple sub-data is completed to obtain the processing result of the data to be processed; wherein an attention layer in the preset processing model is deployed on each single-head processing array. In this way, when the storage-computing integrated chip processes data, only the number of cached vectors is not less than the preset minimum number, and the cached current sub-data can be processed without waiting for the vectors of multiple sub-data to be cached, which saves cache time and improves the processing efficiency of the storage-computing integrated chip for the data to be processed.
[0071] See also Figure 6 , is an optional flow chart of a data processing method provided in an embodiment of the present application, Figure 4 S101 shown in the figure can be implemented through S1011 to S1012, which will be described in combination with the steps.
[0072] S1011. Obtain the vector information of the current sub-data.
[0073] In the embodiment of the present application, the data processing device encodes the current sub-data to obtain a corresponding vector matrix, caches the vector matrix, and obtains information of the cached vector matrix.
[0074] In the embodiment of the present application, the data processing device may encode the current sub-data by a given encoding method (for example, in natural language processing, each word in the input word may be converted into a word sequence vector by the Emmedding layer provided by the torch.nn package) to obtain the encoding information matrix of the current sub-data, that is, the word vector matrix X n*d , n is the number of words in the current sub-data, d is the dimension of the vector, and the number of vectors in the current sub-data is the number of words n.
[0075] S1012: Compare the number of vectors represented by the vector information with the preset minimum number to determine the number detection result.
[0076] In the embodiment of the present application, the data processing device compares the number of vectors represented by the information of the acquired vector matrix with a preset minimum number to determine a quantity detection result.
[0077] In an embodiment of the present application, the number of vectors represented by the acquired vector information is compared with the preset minimum number to determine the number detection result. When the number of vectors represented by the number detection result is not less than the preset minimum number, the processing process of the current sub-data can be started without waiting for all vectors of the data to be processed to be cached, thereby saving time and improving the processing efficiency of the data to be processed.
[0078] See also Figure 7 , is an optional flow chart of a data processing method provided in an embodiment of the present application, Figure 4 The steps S101 to S102 shown in the figure can be implemented through S201, which will be described in combination with the steps.
[0079] S201. When the quantity detection result indicates that the number of vectors of the current sub-data is less than the preset minimum number, the vector corresponding to the next sub-data is obtained from the multiple sub-data for caching, until K vectors are cached, the vectors of K sub-data are processed using multiple single-head processing arrays, and the next batch of vectors are cached until the processing of multiple sub-data is completed to obtain the processing results of the data to be processed.
[0080] In an embodiment of the present application, when the number of vectors of the current sub-data cached by the quantity detection result is less than the preset minimum number, the data processing device obtains the vector of the next data from multiple sub-data for caching, until K vectors are cached, an intermediate result is determined based on the parameter matrix in the multiple single-head processing arrays and the cached K vectors, and then the next batch of vectors (K vectors) are cached, until multiple sub-data are processed and multiple intermediate results are obtained, and the multiple intermediate results are combined to obtain the processing result of the data to be processed. Wherein, K is an integer greater than 0, and K is equal to the preset minimum number.
[0081] In an embodiment of the present application, when the number detection result indicates that the number of vectors of the current sub-data cached is less than a preset minimum number, the control logic needs to control the reading circuit to read the word vector representation of the input word from the external storage device and cache it to the on-chip memory on the storage and computing integrated chip; it is not necessary to read the word vector representations of all input words into the on-chip memory before performing calculations, and calculations can be performed while inputting. When the word vector representation data in the on-chip memory already contains at least one word vector representation processed by the multi-head attention mechanism, the calculation can be started; thereafter, the word sequence representation of the next word is read sequentially from the external memory and stored in the on-chip memory for subsequent calculations.
[0082] In an embodiment of the present application, when the number of cached vectors does not reach a preset minimum number, vectors of sub-data continue to be cached from the data to be processed until K vectors are cached and the K vectors are processed. In this way, the data processing process can be executed with the minimum number of vectors. Compared with a solution that requires caching all vectors of the data to be processed before executing data processing, caching time is saved and the processing efficiency of the data to be processed is improved.
[0083] See also Figure 8 , is an optional flow chart of a data processing method provided in an embodiment of the present application, Figure 4 S102 shown in the figure can also be implemented through S1021 to S1025, which will be explained in combination with the steps.
[0084] S1021. Process a first input feature determined based on the vector of the current sub-data through each of the single-head processing arrays to obtain at least one first intermediate feature of the current sub-data corresponding to each of the single-head processing arrays, and cache a first predetermined feature of at least one of the first intermediate features.
[0085] In an embodiment of the present application, multiple sub-data in the data to be processed are arranged in a certain order, and the data processing device determines the first input feature based on the vector of the current sub-data and the position of the current sub-data in the multiple sub-data. The first input feature is multiplied by the parameter matrix in each single-head processing array to determine at least one corresponding first intermediate feature. Among them, the at least one first intermediate feature includes at least one of the following: a first intermediate query feature, a first intermediate keyword feature, and a first intermediate value feature. The data processing device can cache the first intermediate keyword feature and the first intermediate value feature.
[0086] In an embodiment of the present application, the storage-computing integrated chip also includes: a plurality of single-head processing arrays, the number of which is determined by the number of heads of the multi-head attention layer in the Transformer model, and each single-head processing array contains a parameter matrix of the corresponding attention layer and a programming circuit for controlling the multiplication and addition operation of the parameter matrix. The data processing device obtains the weight series in advance according to the three different weight matrices of the Transformer, and controls the programming circuit to write the weight series into the single-head processing array of the storage-computing integrated chip; each single-head processing array obtains the corresponding Q, K, and V matrices according to the first input feature of the input and the three weight matrices (W1, W2, W3), that is: word vector representation *W1=Q (first intermediate query feature); word vector representation *W2=K (first intermediate keyword feature); word vector representation *W3=V (first intermediate value feature). The data processing device caches the K and V matrices.
[0087] In some other embodiments, the data processing device can also cache the vector-matrix multiplication and addition operation results in the attention mechanism processing module as input data for the next vector-matrix multiplication operation to the on-chip memory. That is, the obtained Q, K, and V matrices can be cached to the on-chip memory for re-input or programming to the vector-matrix multiplication unit for calculation to obtain the Self-Attention output of the Transformer.
[0088] S1022: Determine a first intermediate result corresponding to the current sub-data based on at least one of the first intermediate features and a cached first feature.
[0089] In an embodiment of the present application, the data processing device performs attention processing on at least one first intermediate feature based on the single-head processing array, and determines the first intermediate result corresponding to the current sub-data in combination with the first feature corresponding to the single-head processing array. The first feature represents a predetermined feature for the previous batch of vectors cached before the current moment.
[0090] The previous batch of vectors may be vectors of sub-data cached before the current sub-data. In the embodiment of the present application, the first feature may include K and V matrices corresponding to the previous batch of vectors.
[0091] S1023, sequentially cache vectors corresponding to K of the sub-data among the M sub-data, process the vectors corresponding to the K sub-data through each of the single-head processing arrays to obtain at least one second intermediate feature of each of the single-head processing arrays corresponding to the K sub-data, and cache a second predetermined feature of at least one of the second intermediate features.
[0092] In an embodiment of the present application, the data processing device can also cache vectors corresponding to K sub-data after the current sub-data, determine the second input features corresponding to the K sub-data based on the vectors corresponding to the K sub-data and the positions of the K sub-data in multiple sub-data, input the second input features into each of the single-head processing arrays, multiply the second input features with the query weight matrix through each of the single-head processing arrays to obtain a second intermediate query feature, multiply the second input features with the keyword weight matrix to obtain a second intermediate keyword feature, and multiply the second input features with the intermediate value weight matrix to obtain a second intermediate value feature; cache the second intermediate keyword feature and the second intermediate value feature.
[0093] S1024. Determine second intermediate results corresponding to the K sub-data based on at least one of the second intermediate features and the cached second feature, until all the M sub-data are processed to obtain N intermediate results.
[0094] In the embodiment of the present application, the data processing device performs attention processing on at least one second intermediate feature based on the single-head processing array, and determines the second intermediate result corresponding to the current sub-data in combination with the second feature corresponding to the single-head processing array, until the M sub-data are processed and N intermediate results are obtained. The second feature includes: the first feature and the first predetermined feature.
[0095] In the embodiment of the present application, the second feature may include the K and V matrices corresponding to the current sub-data, and the K and V matrices of the previous batch of sub-data before the current sub-data.
[0096] S1025. Obtain a processing result of the data to be processed based on the N intermediate results.
[0097] In the embodiment of the present application, the data processing device can combine the N intermediate results to obtain the processing result of the data to be processed.
[0098] In the embodiment of the present application, vectors corresponding to K sub-data among the M sub-data are cached in sequence, and the vectors corresponding to the K sub-data are processed through each single-head processing array to obtain at least one second intermediate feature of the K sub-data corresponding to each single-head processing array, and the second predetermined feature in at least one second intermediate feature is cached, and the second intermediate result corresponding to the K sub-data is determined based on at least one second intermediate feature and the cached second feature, until the M sub-data are processed and N intermediate results are obtained. In this way, the method of determining the corresponding second intermediate result using the cached second feature and at least one second intermediate feature reduces the process of repeated feature calculation, saves computing resources, and thus improves the processing efficiency of the data to be processed.
[0099] See also Fig. 9 , is an optional flow chart of a data processing method provided in an embodiment of the present application, Figure 8 S1021 to S1022 shown in the figure can also be implemented by S301 to S306, which will be described in combination with the steps.
[0100] S301. Determine the first input feature based on the sum of the vector of the current sub-data and the position encoding vector; wherein the position encoding vector is determined based on the position of the current sub-data among the multiple sub-data.
[0101] In an embodiment of the present application, a data processing device determines a position of current sub-data among multiple sub-data, forms a position encoding vector based on the position, and adds the vector of the current sub-data and the position encoding vector to determine a first input feature.
[0102] S302. Through each of the single-head processing arrays, the first input feature is multiplied by a query weight matrix to obtain the first intermediate query feature, the first input feature is multiplied by a keyword weight matrix to obtain the first intermediate keyword feature, and the first input feature is multiplied by an intermediate value weight matrix to obtain the first intermediate value feature.
[0103] In an embodiment of the present application, the data processing device multiplies the first input feature with the query weight matrix through each single-head processing array to obtain a first intermediate query feature, multiplies the first input feature with the keyword weight matrix to obtain a first intermediate keyword feature, and multiplies the first input feature with the intermediate value weight matrix to obtain a first intermediate value feature.
[0104] Exemplary, combined Fig.10 The data processing device can determine the first input feature (X) based on the sum of the vector of the current sub-data and the position encoding vector, and compare X with the keyword weight matrix Multiply to determine the K1 matrix (first intermediate keyword feature), and multiply X with the query weight matrix Multiply to determine the Q1 matrix (the first intermediate query feature), and multiply X with the intermediate value weight matrix The multiplication determines the V1 matrix (the first intermediate value feature).
[0105] The embodiment of the present application also proposes a Tranformer model adaptation acceleration method based on cache optimization: when the Transformer performs reasoning tasks, it can combine the model processing tasks and processes with the storage and computing integrated chip structure to realize the accelerated processing of the model for tasks. Transformer reasoning needs to be completed word by word. Taking NLP as an example, if the reasoning task is: Patent work is very important in the research institute. The process is:
[0106] The input for the first reasoning is: special, and the output is: patent; the input for the second reasoning is: patent, and the output is: patent worker; and so on, until completion.
[0107] Therefore, the results of each processing can be saved for use in the next reasoning, avoiding repeated operations on previous data in the next reasoning.
[0108] The reasoning involves the operations of K, Q, and V matrices as follows:
[0109] Design K module and V module, which are initially empty;
[0110] First, get the first word vector representation, denoted as X, to find the first token;
[0111] X needs to be multiplied with three linear matrices to calculate the K, Q, and V matrices;
[0112] S303: Cache the first intermediate keyword feature and the first intermediate value feature corresponding to each of the single-head processing arrays.
[0113] In the embodiment of the present application, after determining the first intermediate query feature, the first intermediate keyword feature, and the first intermediate value feature corresponding to each single-head processing array, the data processing device may cache the first intermediate keyword feature and the first intermediate value feature corresponding to each single-head processing array. The cached first intermediate keyword feature and the first intermediate value feature are used to provide data support when calculating the intermediate results of the next batch of vectors.
[0114] In an embodiment of the present application, when multiple single-head processing arrays process the first input feature, calculations need to be performed for each transformer layer, and a K module and a V module are designed in the storage and computing integrated chip, and the K matrix and the V matrix are saved therein. When outputting a token (the first intermediate result), the filling of K and V is completed in the storage and computing integrated chip.
[0115] S304: Process at least one of the first intermediate features based on the attention mechanism to determine the attention feature corresponding to each of the single-head processing arrays.
[0116] In an embodiment of the present application, the data processing device determines the attention feature corresponding to each single-head processing array based on multiplying the transposed matrix of the first intermediate query feature and the first intermediate keyword feature, taking the square root of the vector dimension of the first intermediate query feature and the first intermediate keyword feature, and then multiplying it with the first intermediate value feature.
[0117] Exemplarily, the data processing device may determine the attention feature based on formula (2).
[0118]
[0119] Among them, Attention(Q,K,V) represents the attention feature, K T is the transposed matrix of the K matrix, Q is the first intermediate query feature, V is the first intermediate value feature, d k It is the number of columns of the Q and K matrices, that is, the vector dimension.
[0120] S305 , concatenating the attention feature with the corresponding cache keyword feature and the cache intermediate value feature to obtain a concatenated matrix.
[0121] In the embodiment of the present application, the data processing device splices the attention feature with the cache keyword feature and the cache intermediate value feature corresponding to the single-head processing array to determine the splicing matrix corresponding to each single-head processing array.
[0122] S306: Determine the first intermediate result based on each of the splicing matrices.
[0123] In the embodiment of the present application, the data processing device may further perform a linear transformation on each splicing matrix, and determine the first intermediate result based on the splicing matrix after the linear transformation.
[0124] In some other embodiments, after calculating the first intermediate result, the KV Cache stage is used: it occurs in the process of calculating the second output token (prediction value) to the last token. At this time, the K module and V module of the storage and computing integrated chip have values. Each round of reasoning only needs to read these two parts of the value, and at the same time, the new K and V calculated in the current round are appended to the K and V modules in the storage and computing chip, so that the attention calculation of QKV can be quickly completed by the storage and computing chip calculation module.
[0125] Exemplary, combined Fig.11 , the data processing device can determine the corresponding Q matrix, K matrix and V matrix based on the vector corresponding to the current sub-data, determine the first intermediate result based on the Q matrix, K matrix and V matrix corresponding to the current sub-data, and the K matrix cached in the storage-computing integrated K module and the V matrix cached in the storage-computing integrated V module, and cache the K matrix corresponding to the current sub-data in the storage-computing integrated K module, and store the V matrix corresponding to the current sub-data in the storage-computing integrated V module. The data processing device can determine the corresponding Q matrix, K matrix and V matrix based on the vector corresponding to the next batch of sub-data, and determine the second intermediate result based on the Q matrix, K matrix and V matrix corresponding to the next batch of sub-data, and the K matrix cached in the storage-computing integrated K module and the V matrix cached in the storage-computing integrated V module. Until multiple intermediate results are obtained after the processing of multiple sub-data is completed, the multiple intermediate results are combined to determine the processing result of the data to be processed.
[0126] In an embodiment of the present application, the first intermediate keyword feature and the first intermediate value feature corresponding to each single-head processing array are cached. At least one first intermediate feature is processed based on the attention mechanism to determine the attention feature corresponding to each single-head processing array. At least one first intermediate feature is processed based on the attention mechanism to determine the attention feature corresponding to each single-head processing array. The attention feature is spliced with the corresponding cache keyword feature and the cache intermediate value feature to obtain a splicing matrix. The first intermediate result is determined based on each splicing matrix. In this way, when processing the vectors of each batch of sub-data, there is no need to recalculate the first intermediate keyword feature and the first intermediate value feature corresponding to the repeated sub-data. The cached cache keyword feature and the cache intermediate value feature can be spliced with the attention feature corresponding to each batch of sub-data to determine the corresponding first intermediate result, saving the processing time of each batch of sub-data, thereby improving the processing efficiency of the data to be processed.
[0127] See also Fig.12, which is an optional flow chart of the data processing method provided in an embodiment of the present application, will be explained in conjunction with the steps.
[0128] S401, control the reading circuit to read the word vector representation corresponding to the input data from the external device and cache it into the cache on the storage and computing chip.
[0129] In an embodiment of the present application, the data processing device controls the reading circuit to read the word vector of the input word from the external storage device and cache it to the on-chip memory on the storage and computing integrated chip.
[0130] S402. According to the word vector dimension and the number of heads of the multi-head attention mechanism in the model, determine whether the cache contains at least one word vector representation processed by the multi-head attention mechanism.
[0131] In an embodiment of the present application, the data processing device determines whether the cache contains at least one word vector processed by the multi-head attention mechanism based on the word vector dimension and the number of heads of the multi-head attention mechanism in the Transformer model.
[0132] S403: Obtain a first input feature according to a set of word vector representations to be calculated in a cache.
[0133] In an embodiment of the present application, if the cache contains at least one word vector processed by a multi-head attention mechanism, the first input feature is determined based on the position information of the input word among multiple words and the cached word vector.
[0134] S404: Input the first input feature into multiple processing arrays in the CIM and perform a self-attention operation.
[0135] In the embodiment of the present application, the data processing device inputs the first input feature into multiple processing arrays in the computing in memory (CIM) technology to perform a self-attention operation until the processing results of the multiple words are determined after the multiple words are processed.
[0136] The present application proposes a cache pre-fetching method for implementing Transformer parallel computing based on a storage-computing integrated chip, ensuring that at least one word vector representation can be cached, which can be provided to CIM to implement Transformer and reduce on-chip memory capacity. The present application also designs a storage-computing chip structure, which includes multiple h-head self-attention mechanism modules to ensure that the multi-head self-attention mechanism can be directly executed in parallel from a physical structure, thereby improving the efficiency of Transformer parallel computing. Moreover, due to the computing characteristics of the storage-computing chip itself that performs calculations in situ according to physical laws, the weight data can be directly programmed into the weight matrix, and the calculation can be performed in situ, which can effectively reduce data movement, increase computing speed and reduce energy consumption. The present application also proposes a model processing method based on multi-tasking and cache acceleration, which fully utilizes the Transformer model reasoning characteristics and the characteristics of the storage-computing integrated chip, so that the processing process can be accelerated when performing reasoning processing on the storage-computing integrated chip, reducing repeated calculation processes and cache overhead, improving model processing efficiency, and reducing power consumption.
[0137] See also Fig.13 , which is a structural diagram of a data processing device provided in an embodiment of the present application.
[0138] The embodiment of the present application further provides a data processing device 800 , including: a determination unit 801 and a cache processing unit 802 .
[0139] A determining unit 801 is used to determine a vector quantity detection result for the current sub-data based on vector information of the current sub-data currently cached, wherein the current sub-data belongs to a plurality of sub-data included in the data to be processed;
[0140] The cache processing unit 802 is used to process the vectors of the current sub-data using multiple single-head processing arrays when the number detection result indicates that the number of vectors of the current sub-data is not less than a preset minimum number, and cache the next batch of vectors for the multiple sub-data until the processing of the multiple sub-data is completed to obtain the processing results of the data to be processed; wherein, an attention layer in the preset processing model is deployed on each of the single-head processing arrays.
[0141] In the embodiment of the present application, the determining unit 801 in the data processing device 800 is used to obtain the vector information of the current sub-data;
[0142] The number of vectors represented by the vector information is compared with the preset minimum number to determine the number detection result.
[0143] In an embodiment of the present application, the cache processing unit 802 in the data processing device 800 is used to obtain the vector corresponding to the next sub-data from multiple sub-data for caching when the number detection result indicates that the number of vectors of the current sub-data is less than the preset minimum number, until the number of vectors is cached to K, and then use multiple single-head processing arrays to process the vectors of K sub-data, and cache the next batch of vectors until the processing of multiple sub-data is completed to obtain the processing results of the data to be processed; wherein K is an integer greater than 0.
[0144] In the embodiment of the present application, the cache processing unit 802 in the data processing device 800 is used to process the first input feature determined based on the vector of the current sub-data through the multiple single-head processing arrays to obtain at least one first intermediate feature corresponding to the current sub-data, and cache the first predetermined feature of the at least one first intermediate feature; the at least one first intermediate feature includes at least one of the following: a first intermediate query feature, a first intermediate keyword feature, and a first intermediate value feature;
[0145] Determine a first intermediate result corresponding to the current sub-data based on at least one of the first intermediate features and a first feature of the cache, wherein the first feature represents a predetermined feature cached before the current moment;
[0146] Sequentially cache vectors corresponding to K of the sub-data among the M sub-data, process the vectors corresponding to the K sub-data through a plurality of the single-head processing arrays to obtain at least one second intermediate feature corresponding to the K sub-data, and cache a second predetermined feature among at least one of the second intermediate features; wherein the plurality of sub-data include: M sub-data, where M is an integer greater than 1;
[0147] Based on at least one of the second intermediate features and the cached second features, second intermediate results corresponding to the K sub-data are determined until the M sub-data are processed and N intermediate results are obtained; wherein the second feature includes: the first feature and the first predetermined feature; N is an integer greater than 0;
[0148] A processing result of the data to be processed is obtained based on the N intermediate results.
[0149] In an embodiment of the present application, the cache processing unit 802 in the data processing device 800 is used to determine the first input feature based on the sum of the vector of the current sub-data and the position encoding vector; wherein the position encoding vector is determined based on the position of the current sub-data among the multiple sub-data.
[0150] In the above scheme, the first input feature determined based on the vector of the current sub-data is processed by the plurality of single-head processing arrays to obtain at least one first intermediate feature corresponding to the current sub-data, and a first predetermined feature in at least one of the first intermediate features is cached, including:
[0151] Multiplying the first input feature by a query weight matrix to obtain the first intermediate query feature, multiplying the first input feature by a keyword weight matrix to obtain the first intermediate keyword feature, and multiplying the first input feature by an intermediate value weight matrix to obtain the first intermediate value feature through the plurality of single-head processing arrays;
[0152] The first intermediate key feature and the first intermediate value feature are cached.
[0153] In the embodiment of the present application, the first feature includes: a cache keyword feature and a cache intermediate value feature; the cache processing unit 802 in the data processing device 800 is used to determine the similarity between the first intermediate query feature and the combined keyword feature, and determine the first intermediate result based on the product of the similarity and the combined intermediate value feature; wherein the combined keyword feature is determined based on the combination of the first intermediate keyword feature and the cache keyword feature, and the combined intermediate value feature is determined based on the first intermediate value feature and the cache intermediate value feature.
[0154] In the embodiment of the present application, the cache processing unit 802 in the data processing device 800 is used to delete the cached vector of the current sub-data.
[0155] It should be noted that in the embodiment of the present application, if the above-mentioned data processing method is implemented in the form of a software function module and sold or used as an independent product, it can also be stored in a computer-readable storage medium. Based on such an understanding, the technical solution of the embodiment of the present application can be essentially or partly embodied in the form of a software product that contributes to the relevant technology. The computer software product is stored in a storage medium, including a number of instructions to enable a data processing device (which can be a personal computer, etc.) to execute all or part of the methods described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a U disk, a mobile hard disk, a read-only memory (ROM), a magnetic disk or an optical disk. In this way, the embodiment of the present application is not limited to any specific combination of hardware and software.
[0156] Correspondingly, an embodiment of the present application provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the steps in the method on the data processing device side are implemented.
[0157] Correspondingly, an embodiment of the present application provides an electronic device 900, including a memory 902 and a processor 901, wherein the memory 902 stores a computer program that can be executed on the processor 901, and the processor 901 implements the steps in the above method when executing the program.
[0158] It should be noted here that the description of the above storage medium and device embodiments is similar to the description of the above method embodiments, and has similar beneficial effects as the method embodiments. For technical details not disclosed in the storage medium and device embodiments of this application, please refer to the description of the method embodiments of this application for understanding.
[0159] It should be noted that Fig.14 A hardware entity diagram of an electronic device provided in an embodiment of the present application, such as Fig.14 As shown, the hardware entity of the electronic device 900 includes: a processor 901 and a memory 902, wherein;
[0160] The processor 901 generally controls the overall operation of the electronic device 900 .
[0161] The memory 902 is configured to store instructions and applications executable by the processor 901, and can also cache data to be processed or processed by the processor 901 and various modules in the electronic device 900 (for example, image data, audio data, voice communication data, and video communication data), which can be implemented through flash memory (FLASH) or random access memory (Random Access Memory, RAM).
[0162] It should be understood that "one embodiment" or "an embodiment" mentioned throughout the specification means that specific features, structures or characteristics related to the embodiment are included in at least one embodiment of the present application. Therefore, "in one embodiment" or "in an embodiment" appearing throughout the specification does not necessarily refer to the same embodiment. In addition, these specific features, structures or characteristics can be combined in one or more embodiments in any suitable manner. It should be understood that in various embodiments of the present application, the size of the sequence number of the above-mentioned processes does not mean the order of execution, and the execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application. The above-mentioned sequence numbers of the embodiments of the present application are only for description and do not represent the advantages and disadvantages of the embodiments.
[0163] It should be noted that, in this article, the terms "include", "comprises" or any other variations 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, an element defined by the sentence "comprises a ..." does not exclude the existence of other identical elements in the process, method, article or device including the element.
[0164] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. The device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as: multiple units or components can be combined, or can be integrated into another system, or some features can be ignored, or not executed. In addition, the coupling, direct coupling, or communication connection between the components shown or discussed can be through some interfaces, and the indirect coupling or communication connection of the device or unit can be electrical, mechanical or other forms.
[0165] The units described above as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units; they may be located in one place or distributed on multiple network units; some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.
[0166] In addition, all functional units in the embodiments of the present application may be integrated into one processing unit, or each unit may be a separate unit, or two or more units may be integrated into one unit; the above-mentioned integrated units may be implemented in the form of hardware or in the form of hardware plus software functional units.
[0167] A person skilled in the art can understand that all or part of the steps of implementing the above method embodiment can be completed by hardware related to program instructions, and the aforementioned program can be stored in a computer-readable storage medium. When the program is executed, it executes the steps of the above method embodiment; and the aforementioned storage medium includes: a mobile storage device, a read-only memory (ROM), a magnetic disk or an optical disk, and other media that can store program codes.
[0168] Alternatively, if the above-mentioned integrated unit of the present application is implemented in the form of a software function module and sold or used as an independent product, it can also be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the embodiment of the present application can be essentially or partly embodied in the form of a software product that contributes to the relevant technology. The computer software product is stored in a storage medium, including several instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the methods described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a mobile storage device, a ROM, a magnetic disk, or an optical disk.
[0169] The above is only an implementation method of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
Claims
1. A data processing method, characterized in that: include: Determine, based on the vector information of the current sub-data currently cached, a result of detecting the number of vectors of the current sub-data; wherein the current sub-data belongs to a plurality of sub-data included in the data to be processed; When the quantity detection result indicates that the number of vectors of the current sub-data is not less than a preset minimum number, the vectors of the current sub-data are processed using multiple single-head processing arrays, and the next batch of vectors are cached for the multiple sub-data until the processing of the multiple sub-data is completed to obtain the processing results of the data to be processed; wherein, an attention layer in the preset processing model is deployed on each of the single-head processing arrays.
2. The data processing method according to claim 1, characterized in that: The determining, based on the vector information of the current sub-data currently cached, a result of detecting the number of vectors of the current sub-data includes: Acquire the vector information of the current sub-data; The number of vectors represented by the vector information is compared with the preset minimum number to determine the number detection result.
3. The data processing method according to claim 1, characterized in that: After determining the result of the detection of the number of vectors for the current sub-data based on the vector information of the current sub-data currently cached, the method further includes: When the quantity detection result indicates that the number of vectors of the current sub-data is less than the preset minimum number, the vector corresponding to the next sub-data is obtained from the multiple sub-data for caching, until the number of vectors is cached to K, the vectors of the K sub-data are processed using the multiple single-head processing arrays, and the next batch of vectors are cached until the processing of the multiple sub-data is completed to obtain the processing results of the data to be processed; wherein K is an integer greater than 0.
4. The data processing method according to any one of claims 1 to 3, characterized in that: The processing of the vector of the current sub-data by using multiple single-head processing arrays and caching the vectors of the next batch for the multiple sub-data until the processing of the multiple sub-data is completed to obtain the processing result of the data to be processed includes: Processing the first input feature determined based on the vector of the current sub-data through each of the single-head processing arrays to obtain at least one first intermediate feature of the current sub-data corresponding to each of the single-head processing arrays, and caching a first predetermined feature of at least one of the first intermediate features; the at least one first intermediate feature includes at least one of the following: a first intermediate query feature, a first intermediate keyword feature, and a first intermediate value feature; Determine a first intermediate result corresponding to the current sub-data based on at least one of the first intermediate features and a first feature of the cache, wherein the first feature represents a predetermined feature of a previous batch of vectors cached before the current moment; Sequentially cache vectors corresponding to K of the M sub-data, process the vectors corresponding to the K sub-data through each of the single-head processing arrays to obtain at least one second intermediate feature of each of the single-head processing arrays corresponding to the K sub-data, and cache a second predetermined feature of at least one of the second intermediate features; wherein the plurality of sub-data include: M sub-data, where M is an integer greater than 1; Based on at least one of the second intermediate features and the cached second features, second intermediate results corresponding to the K sub-data are determined until the M sub-data are processed and N intermediate results are obtained; wherein the second feature includes: the first feature and the first predetermined feature; N is an integer greater than 0; A processing result of the data to be processed is obtained based on the N intermediate results.
5. The data processing method according to claim 4, characterized in that: Before processing the first input feature determined based on the vector of the current sub-data through each of the single-head processing arrays to obtain at least one first intermediate feature of the current sub-data corresponding to each of the single-head processing arrays, and caching a first predetermined feature of at least one of the first intermediate features, the method further includes: The first input feature is determined based on the sum of the vector of the current sub-data and a position encoding vector; wherein the position encoding vector is determined based on the position of the current sub-data in the plurality of sub-data.
6. The data processing method according to claim 4, characterized in that: The step of processing the first input feature determined based on the vector of the current sub-data through each of the single-head processing arrays to obtain at least one first intermediate feature of the current sub-data corresponding to each of the single-head processing arrays, and caching a first predetermined feature of at least one of the first intermediate features, comprises: By each of the single-head processing arrays, the first input feature is multiplied by a query weight matrix to obtain the first intermediate query feature, the first input feature is multiplied by a keyword weight matrix to obtain the first intermediate keyword feature, and the first input feature is multiplied by an intermediate value weight matrix to obtain the first intermediate value feature; The first intermediate key feature and the first intermediate value feature corresponding to each of the single-head processing arrays are cached.
7. The data processing method according to claim 6, characterized in that: The first features include: cache keyword features and cache intermediate value features; The determining, based on at least one of the first intermediate features and the first feature of the cache, a first intermediate result corresponding to the current sub-data includes: Processing at least one of the first intermediate features based on an attention mechanism to determine an attention feature corresponding to each of the single-head processing arrays; Concatenate the attention feature with the corresponding cache keyword feature and the cache intermediate value feature to obtain a concatenated matrix; The first intermediate result is determined based on each of the concatenated matrices.
8. The data processing method according to claim 4, characterized in that: After processing the first input feature determined based on the vector of the current sub-data through each of the single-head processing arrays to obtain at least one first intermediate feature of the current sub-data corresponding to each of the single-head processing arrays, and caching a first predetermined feature of at least one of the first intermediate features, the method further includes: Delete the cached vector of the current subdata.
9. A data processing device, characterized in that: include: A determination unit, configured to determine a result of a vector quantity detection for the current sub-data based on vector information of the current sub-data currently cached; wherein the current sub-data belongs to a plurality of sub-data included in the data to be processed; A cache processing unit is used to process the vectors of the current sub-data using multiple single-head processing arrays when the number detection result indicates that the number of vectors of the current sub-data is not less than a preset minimum number, and cache the next batch of vectors for the multiple sub-data until the processing of the multiple sub-data is completed to obtain the processing results of the data to be processed; wherein an attention layer in the preset processing model is deployed on each of the single-head processing arrays.
10. An electronic device, characterized in that: The method comprises a memory and a processor, wherein the memory stores a computer program executable on the processor, and the processor implements the steps in the method according to any one of claims 1 to 8 when executing the computer program.
11. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps in the method according to any one of claims 1 to 8 are implemented.
