Data processing method, electronic equipment and readable medium

By blocking and feature conversion processing of the input data and weight data of the MHA network, the problem of excessive memory usage in high-dimensional data processing of neural network models is solved, and the processing efficiency and memory utilization of electronic devices are improved.

CN120409568APending Publication Date: 2025-08-01ARM TECH CHINA CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510503522.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-04-21
Publication Date
2025-08-01

AI Technical Summary

Technical Problem

With the widespread application of neural network models, electronic devices occupy too much memory space when processing high-dimensional data, resulting in a decrease in available memory space and affecting device performance.

Method used

By chunking the input data and weight data of the MHA network and performing feature conversion processing, the amount of data processed in a single time is reduced and the memory usage is reduced.

Benefits of technology

It effectively reduces the memory space usage and improves the processing efficiency and performance of electronic devices, especially in a multi-core processor environment, improving the efficiency of data processing and memory utilization.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120409568A_ABST
    Figure CN120409568A_ABST
Patent Text Reader

Abstract

The invention relates to the field of computers, and particularly provides a data processing method, electronic equipment and a readable medium. The method is applied to the electronic equipment and comprises the following steps: acquiring to-be-processed first data; the first data is input into a first model to obtain a first processing result, the first model comprises a multi-head attention MHA network, the MHA network processes the first data, the first data is quantized and deformed to obtain first intermediate data, the first intermediate data is divided into P input sub-data, and P is an integer larger than 1; based on Q pieces of weight sub-data, first feature conversion processing is conducted on the P pieces of input sub-data, first conversion data of the first intermediate data is obtained, the Q pieces of weight sub-data are obtained by dividing the first weight data, and Q is an integer larger than 1; and obtaining first result data based on the first conversion data. Through the method provided by the embodiment of the invention, the memory occupation of the electronic equipment can be reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computers, and in particular, to a data processing method, an electronic device, and a readable medium. Background Art

[0002] With the rapid development of artificial intelligence, neural network models are increasingly widely used. For example, neural network models using deep neural networks (such as deep neural networks based on multi-head attention (MHA)) have been widely applied to data processing in various fields, and significant results have been achieved in many key artificial intelligence fields such as image recognition, object detection, reinforcement learning, and semantic analysis.

[0003] As the dimension of the data to be processed increases, when an electronic device (such as a computer) runs a neural network model, it will occupy a large amount of the memory space of the electronic device. Summary of the Invention

[0004] This application provides a data processing method, an electronic device, and a readable medium to reduce the occupation of memory space.

[0005] In a first aspect, this application provides a data processing method applied to an electronic device. The method includes: obtaining first data to be processed; inputting the first data into a first model to obtain a first processing result, where: the first model includes a multi-head attention MHA network, and the processing of the first data by the MHA network includes: performing quantization transformation processing on the first data to obtain first intermediate data, dividing the first intermediate data into P input sub-data, where P is an integer greater than 1; performing first feature transformation processing on the P input sub-data based on Q weight sub-data to obtain first transformed data of the first intermediate data, where the Q weight sub-data are obtained by dividing first weight data, and Q is an integer greater than 1; obtaining first result data based on the first transformed data.

[0006] That is, in the embodiments of this application, by partitioning the input data (i.e., the first intermediate data) and the weight data of the MHA network, and then performing feature transformation processing (or called operation reorganization processing) based on the partitioned data, the amount of data processed at one time can be reduced, thereby reducing the occupation of memory space.

[0007] In a possible implementation of the above first aspect, the first intermediate data and the first weight data are matrices, and the number of columns of the first intermediate data is the same as the number of rows of the first weight data; dividing the first intermediate data into P input sub-data includes: dividing the first intermediate data into P input sub-data along the row direction of the first intermediate data; and the Q weight sub-data are obtained based on dividing the first weight data along the column direction of the first weight data.

[0008] In a possible implementation of the first aspect described above, based on Q weight sub-data, perform a first feature transformation process on P input sub-data to obtain first transformation data of first intermediate data, including: performing a dot product operation on each of the P input sub-data and the Q weight sub-data respectively to obtain Q result sub-data corresponding to each input sub-data; performing a deformation process on the result sub-data corresponding to each input sub-data to obtain Q first output sub-data corresponding to each input sub-data, where the number of dimensions of the first output sub-data is the same as the number of dimensions of the first transformation data; and performing a splicing process on the first output sub-data corresponding to each input sub-data to obtain the first transformation data.

[0009] In a possible implementation of the first aspect described above, the first transformation data includes four dimensions, and the four dimensions include a first dimension and a second dimension; and the first intermediate data is divided into P input sub-data along the row direction of the first intermediate data, including: based on the batch size of the first dimension, dividing the first intermediate data into P input sub-data along the row direction of the first intermediate data, and the batch size of the first dimension is P; and the Q weight sub-data are obtained by dividing the first weight data along the column direction of the first weight data based on the batch size of the second dimension, and the batch size of the second dimension is Q.

[0010] In a possible implementation of the first aspect described above, the first transformation data includes at least four dimensions; and the first transformation data includes a first dimension group and a second dimension group, the first dimension group includes k dimensions, and the second dimension group includes j dimensions; and the first intermediate data is divided into P input sub-data along the row direction of the first intermediate data, including: based on the batch size of (k - 1) dimensions in the first dimension group, dividing the first intermediate data into P input sub-data along the row direction of the first intermediate data, and the product of the batch sizes of the (k - 1) dimensions is P; and the Q weight sub-data are obtained by dividing the first weight data along the column direction of the first weight data based on the batch size of (j - 1) dimensions in the second dimension group, and the product of the batch sizes of the (j - 1) dimensions is Q.

[0011] In a possible implementation of the first aspect described above, performing a deformation process on the result sub-data corresponding to each input sub-data to obtain Q first output sub-data corresponding to each input sub-data, including: adding a first dimension and a second dimension to the result sub-data corresponding to each input sub-data to obtain Q first output sub-data corresponding to each input sub-data, where the batch sizes of the first dimension and the second dimension in the Q first output sub-data are 1.

[0012] In a possible implementation of the first aspect above, the P first output sub - data corresponding to each input sub - data are concatenated to obtain the first conversion data, including: concatenating the Q first output sub - data corresponding to each input sub - data along the second dimension to obtain P second output sub - data corresponding one - to - one to the P input sub - data, and the batch size of each second output sub - data in the second dimension is Q; concatenating the P second output sub - data along the second dimension to obtain the first conversion data, and the batch size of the first conversion data in the first dimension is P.

[0013] In a possible implementation of the first aspect above, the number of dimensions of the first conversion data is 4, and the number of dimensions of the first intermediate data is 2.

[0014] In a possible implementation of the first aspect above, the MHA network includes a quantization transformation module, an operation reorganization module, and a weighted operation module. The quantization transformation module is used to perform quantization transformation processing on the first data to obtain the first intermediate data, and divide the first intermediate data into P input sub - data, where P is an integer greater than 1; the operation reorganization module is used to perform a first feature transformation process on the P input sub - data based on Q weight sub - data to obtain the first conversion data of the first intermediate data, where the Q weight sub - data are obtained by dividing the first weight data, and Q is an integer greater than 1; the weighted operation module is used to obtain the first result data based on the first conversion data.

[0015] In a second aspect, the present application provides an electronic device, including: a memory for storing instructions executed by one or more processors of the electronic device; and a processor, which is one of the processors of the electronic device, for running the instructions to enable the electronic device to implement the data processing method of the first aspect above.

[0016] In a third aspect, the present application provides a readable medium, which contains instructions that cause the electronic device to implement the data processing method of the first aspect above when executed by the processor of the electronic device. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] Figure 1 According to an embodiment of the present application, a schematic diagram of an application scenario is shown;

[0018] Figure 2A According to an embodiment of the present application, a first structural diagram of an MHA network is shown;

[0019] Figure 2B According to an embodiment of the present application, a second structural diagram of an MHA network is shown;

[0020] Figure 3 According to an embodiment of the present application, a first structural diagram of an operation reorganization module is shown;

[0021] Figure 4A An FC operation process schematic diagram is shown according to an embodiment of the present application;

[0022] Figure 4B A deformation processing process schematic diagram is shown according to an embodiment of the present application;

[0023] Figure 4C A transpose processing process schematic diagram is shown according to an embodiment of the present application;

[0024] Figure 5A A schematic diagram of a feature conversion and dimension transformation process based on block data is shown according to an embodiment of the present application;

[0025] Figure 5B A schematic diagram of a process for partitioning input data is shown according to an embodiment of the present application;

[0026] Figure 5C A schematic diagram of a process for partitioning weight data is shown according to an embodiment of the present application;

[0027] Figure 5D A schematic diagram of a feature conversion process based on block data is shown according to an embodiment of the present application;

[0028] Figure 5E A schematic diagram of a deformation processing process based on block data is shown according to an embodiment of the present application;

[0029] Figure 5F A schematic diagram of a splicing processing process based on block data is shown according to an embodiment of the present application;

[0030] Figure 6 A first flow schematic diagram of a data processing method is shown according to an embodiment of the present application;

[0031] Figure 7 A second structural schematic diagram of an operation recombination module is shown according to an embodiment of the present application;

[0032] Figure 8 A second flow schematic diagram of a data processing method is shown according to an embodiment of the present application;

[0033] Figure 9 A structural schematic diagram of an electronic device 100 is shown according to an embodiment of the present application. Detailed implementation manners

[0034] The illustrative embodiments of the present application include but are not limited to data processing methods, readable electronic devices, and readable media.

[0035] For ease of understanding, the terms related to the embodiments of the present application are introduced below.

[0036] (1) Fully-connected operator: The fully-connected operator is used to perform one-dimensional or multi-dimensional linear transformations on the input information, generating an adapted intermediate representation for subsequent operations. In the MHA network, the fully-connected operator can split the original input into multi-channel information (such as query (Q), key (K), value (V)) according to preset rules. For example, by performing dot product operations on the input information and the weight information corresponding to each multi-channel respectively, information corresponding to each multi-channel is obtained, and finally the information of each channel is integrated into a unified output form, providing basic support for the attention mechanism.

[0037] (2) Reshaping operator: The reshaping operator is used to reorganize the data structure while keeping the total amount of data unchanged, that is, to adjust the number of dimensions and the batch size of the dimensions of the data structure to meet the processing requirements of a specific data structure.

[0038] (3) Transpose operator: The transpose operator is used to exchange the order between data dimensions to meet the processing requirements of a specific data structure.

[0039] (4) Concatenation operator: The concatenation operator is used to combine multiple independent data into a unified representation. For example, data with the same size (the same batch size for each dimension) can be concatenated in any dimension.

[0040] (5) Sizes of data: Describe the batch sizes of each dimension in the data structure. For example, the size of a two-dimensional matrix is "number of rows × number of columns", and the size of a three-dimensional tensor is "height × width × depth". The size of each dimension represents the expansion of the data in a certain direction, where the specific values of the number of rows, number of columns, height, width, and depth can represent the batch sizes of the corresponding dimensions.

[0041] The technical solution of the present application will be introduced below with reference to the accompanying drawings.

[0042] The electronic device can run a neural network model (i.e., the first model), such as a model including the MHA network, to perform inference tasks.

[0043] For example, in natural language processing tasks (such as sentence analysis, semantic understanding, etc.), the NLP model can include the MHA network. The data types input to the MHA network can include text sequences, word embeddings, position encodings, etc. The output data of the MHA network can include a context-aware feature sequence for capturing global semantic feature information, and can be associated with downstream modules to generate classification labels, sequence annotations, or translated text.

[0044] For example, in computer vision tasks (such as image classification, object detection, etc.), the data types input to the MHA network can include image data, video data, etc. The output data of the MHA network can include enhanced feature maps, flattened sequences, etc., and can be associated with downstream modules to generate classification results or object detection results.

[0045] For example, in an audio processing task, the data type input to the MHA network may include audio data, and the output data of the MHA network may include temporal acoustic features, which can then be further decoded into speech text or classification labels.

[0046] For example, for a time series prediction task, the data type input to the MHA network may include time series data, and the output data of the MHA network may be temporal coding features to support regression and classification predictions of future values or events by downstream modules.

[0047] For example, for a user behavior modeling task, when predicting a user's interests or preferences, the data type input to the MHA network may include user behavior data, and the output data of the MHA network may include user representation vectors, so that the recommendation probability of push content can be further generated based on the user representation vectors, and then the target push content can be determined.

[0048] Reference Figure 1 , which shows an application scenario provided by an embodiment of the present invention. Among them, it includes a user U, a user terminal 101, and a server 102. Among them, the user terminal 101 can communicate with the server 102 based on the operations of the user U, such as sending a data processing request to the server 101; the server 101 can process the data carried in the data processing request through a neural network model and return the processing result of the data to the user terminal 101. Optionally, the user terminal 101 can also respond to data processing requests of other devices (such as the server 102 or other client terminals), perform data processing, and return the data processing result.

[0049] In the embodiments of the present application, the user terminal 101 includes, but is not limited to, physical devices such as smart phones, desktop computers, tablet computers, laptop computers, digital assistants, and smart wearable devices, and may also include software running on the physical devices, such as application programs, etc. The user terminal 101 includes a UI (User Interface) layer, and the user terminal 102 can obtain the data input by the user and the operations of the user through the UI layer.

[0050] In the embodiments of the present application, the server 102 may include an independent physical server, or may be a server cluster or distributed system composed of multiple physical servers, or may also be a cloud server providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN (Content Delivery Network), and big data and artificial intelligence platforms.

[0051] For example, in a natural language processing scenario, the client 101 sends a data processing request to the server 102 in response to detecting a user operation, such as a user inputting a Chinese sentence and clicking the translation button. The data processing request may include data to be processed (i.e., the first data to be processed, such as a Chinese sentence). The server 102 can preprocess the text into input data to obtain the text features corresponding to the data to be processed (such as the text features corresponding to the Chinese sentence). Then, the server 102 analyzes and infers the text features based on the model, outputs the corresponding data processing result (such as the translation result corresponding to the Chinese sentence), and returns the data processing result to the client 101, enabling the client 101 to display the data processing result (i.e., the first processing result) to the user U.

[0052] Taking the natural language processing scenario as an example below, in combination with Figure 2A 、 Figure 2B introduce the process of the MHA network processing data.

[0053] Refer to Figure 2A , the MHA network may include a quantization transformation module 1, an operation recombination module with three branches (the operation recombination module 2a corresponding to the query (Q), the operation recombination module 2b corresponding to the key (K), and the operation recombination module 2c corresponding to the value (V)), and an operation weighting module 3.

[0054] Among them, the operation recombination module (such as the operation recombination module 2a, the operation recombination module 2b, and the operation recombination module 2c) is used to perform feature transformation on the input quantization data based on different weight data. For example, in a natural language processing scenario, the features obtained by feature transformation may include Q output data, K output data, and V output data, where the Q output data represents the content to be concerned about (such as the context relationship), the K output data represents the features of the content to be concerned about (such as the specific context relationship of the text), and the V output data represents the information content (such as the specific semantics of the text).

[0055] In a natural language processing scenario, the quantization transformation module 1 can be used to receive the input text (i.e., the input data), quantize the input text into quantization data, and deform the obtained quantization data. For example, the input text may be a Chinese sentence to be translated. According to some embodiments, the number of dimensions of the quantization data is relatively low. And the quantization data is high-dimensional data, that is, the batch size of the feature dimension (i.e., the last dimension) of the quantization data is relatively large or the number of features is relatively large. For example, in a 2D tensor with a size of [8192, 320], the number of dimensions is 2, and the batch size of the feature dimension (i.e., the second dimension) is 320, reaching hundreds, so this two-dimensional tensor is a high-dimensional representation of the feature.

[0056] In some alternative embodiments, the quantized data may have three dimensions. One of the dimensions may represent the batch size, such as the number of text sequences. The second dimension may represent the sequence length, such as the number of words in a text sequence. Specifically, when the number of words in a text sequence is less than the number of words represented by the second dimension, the text sequence may be padded to that number of words, and when the number of words in a text sequence is more than the sequence length represented by the second dimension, the text sequence may be truncated to that number of words. The third dimension may represent the embedding dimension, such as the dimensionality of the vector to which each word is mapped.

[0057] As an example, the input text may include two text sequences. During the quantization process, the quantization transformation module 1 may perform word segmentation on the two text sequences to obtain each word (which may include words, symbols, etc.), then convert the words into high-dimensional tensors, and pad the number of words in the text sequences to obtain quantized data. For example, each word of the two text sequences may be converted into a 320-dimensional tensor, and the number of words in the two text sequences may be padded to 4096 to obtain quantized data with a size of [2, 4096, 320]. After obtaining the quantized data with a size of [2, 4096, 320], the quantized data may be transformed to obtain the transformed quantized data. Among them, the transformed quantized data is the input data of the operation reorganization module, and its size is [8192, 320].

[0058] The operation reorganization modules 2a, 2b, and 2c may be used to perform feature transformation on the data obtained by the quantization transformation module 1. For example, perform feature transformation on the data with a size of [8192, 320] to obtain output data with a size of [2, 8, 4096, 40]. It can be understood that the number of dimensions of the output data is higher than that of the input data. For example, the operation reorganization module 2a may be used to perform a dot product operation on the input data and the Q weight data, and reorganize the operation result to obtain the Q output data; the operation reorganization module 2b may be used to perform a dot product operation on the input data and the K weight data, and reorganize the operation result to obtain the K output data; the operation reorganization module 2c may be used to perform a dot product operation on the input data and the V weight data, and reorganize the operation result to obtain the V output data.

[0059] For example, in a natural language processing scenario, corresponding to the input data of the model being a text sequence, the Q output data determined by the operation reorganization module 2a may be used to represent the semantic features to be queried, the K output data determined by the operation reorganization module 2b may be used to represent the context relationship of the words in the input text, and the V output data determined by the operation reorganization module 2c may be used to represent the specific semantic information of the words in the input text.

[0060] The operation weighting module 3 can be used to fuse the Q output data, K output data, and V output data to obtain the processed result data of the input data using the MHA network. It can be understood that the number of dimensions of the input data and output data of the operation weighting module 3 is the same. For example, the operation weighting module 3 can be used to fuse the Q output data, K output data, and V output data obtained by the operation reorganization module 2a, operation reorganization module 2b, and operation reorganization module 2c through operations such as multiplication, normalization, and weighting.

[0061] In some embodiments, the above-mentioned processed result data obtained by the operation weighting module 3 can be used as the input of other networks. For example, according to some embodiments, after obtaining the processed result data, the processed result data can be deformed. For example, the processed result data can include the result data of multiple attention heads. Therefore, the result data of multiple attention heads in the processed result data can be merged to obtain the deformed processed result data. Then, the deformed processed result data is mapped to the vocabulary to obtain the output text. For example, the vocabulary can be an English vocabulary, and the output text can be an English sentence obtained by translating the input Chinese sentence.

[0062] It can be seen that in the above embodiments, since the weighting operation module downstream of the operation reorganization module does not change the number of dimensions of the data, the output data of the operation reorganization module needs to be consistent with the number of dimensions of the output data of the MHA network (for example, 4 dimensions). However, the dimension of the input data input to the operation reorganization module is usually lower (for example, 2 dimensions), and this dimension number is less than the dimension of the input data required by the weighting operation module. Therefore, after the operation reorganization module performs feature transformation on the input data based on the weight data, it usually needs to adjust the dimension (the number of dimensions and the batch size of each dimension) of the obtained features so that the dimension of the output data of the reorganization operation module meets the requirements of the weighting operation module for the dimension of the input data.

[0063] In some embodiments, the operation reorganization module can be used to convert low-dimensional features into high-dimensional features through a deformation operator, and then adjust the order of each dimension in the high-dimensional features through a transpose operator so that the dimension of the adjusted high-dimensional features and the batch size of each dimension meet the requirements of the weighting operation module for the dimension of the input data.

[0064] Next, taking the operation reorganization module including a sequentially executed full connect (FC) operator, reshape (RESHAPE) operator, and transpose (TRANSFORMER) operator as an example, the process of the MHA network processing the input data is introduced.

[0065] For example, Figure 2B shows a schematic diagram of an MHA network including a reorganization operation module.

[0066] Reference Figure 2B , in some embodiments, the quantization transformation module 1 may include a quantization operator and a transformation operator. The operation reorganization modules 2a, 2b, and 2c may each include an FC operator, a transformation operator, and a transpose operator. The operation weighting module 3 may include operators such as a multiplication operator, a normalization operator, a transformation operator, and a weighting operator.

[0067] In one example, the input data size of the quantization transformation module 1 is [N out , W out , C out ; the output data of the quantization transformation module 1, and the input data sizes of the operation reorganization modules 2a, 2b, and 2c are [N out W out , H out , C out ; the output data of the operation reorganization modules 2a, 2b, and 2c, and the input data size of the operation weighting module 3 are [N out , H out , W out , C out ; the output data size of the operation weighting module 3 is [1, N out H out , W out , C out .

[0068] It can be understood that in this embodiment, C out represents the feature representation in the neural network output data. For example, if the neural network output data requires a feature representation with 40 feature quantities, then C out is 40.

[0069] It can be understood that this application does not limit the values of N out , H out , W out , C out . According to some embodiments, N out and H out are respectively less than W out . For example, N out can be 2, H out can be 8, and W out can be 4096.

[0070] The quantization transformation module 1 can be used to first quantize the input data through the quantization operator to obtain a size of [N out , W out , H out C outThe quantized data, and then the deformable operator is used to deform the quantized data of size [N, W, HC] to obtain data of size [N out H out ,H out C out . This data can be used as the input data for the operation reorganization module 2a, the operation reorganization module 2b, and the operation reorganization module 2c.

[0071] Then, the operation reorganization module 2a can be used to perform feature transformation processing on the input data, where the number of dimensions of the output data is reduced compared to the input data. Specifically, the FC operator uses the weight data to perform feature transformation on the input data of size [N out H out ,H out C out to obtain result data of size [N out H out ,H out C out ; then, the deformable operator is used to deform the result data of [N out H out ,H out C out to obtain deformed data of size [N out ,W out ,H out ,C out ; then, the transpose operator is used to transpose the deformed data of size [N out ,W out ,H out ,C out to obtain Q output data of size [N out ,H out ,W out ,C out that meets the input data requirements of the operation weighting module 3.

[0072] The operation reorganization module 2b can be used to perform feature transformation processing on the input data, where the number of dimensions of the output data is reduced compared to the input data. Specifically, the FC operator uses the weight data to perform feature transformation on the input data of size [N out H out ,H out C out to obtain result data of size [N out H out ,H out C out ; then, the deformable operator is used to deform the [N out H out ,H out C outThe result data is deformed to obtain deformed data with dimensions [N out , W out , H out , C out ; then, the deformed data with dimensions [N out , W out , H out , C out is transposed to obtain K output data with dimensions [N out , H out , W out , C out , which is the input data conforming to operation weighting module 3.

[0073] Operation recombination module 2c can be used to perform feature transformation processing on the input data, where the number of dimensions of the output data is reduced compared to the input data. Specifically, the FC operator uses weight data to perform feature transformation on the input data with dimensions [N out H out , H out , C out to obtain result data with dimensions [N out , H out , H out , C out ; then, the result data of [N out , H out , H out , C out is deformed to obtain deformed data with dimensions [N out , W out , H out , C out ; then, the deformed data with dimensions [N out , W out , H out , C out is transposed to obtain V output data with dimensions [N out , H out , W out , C out , which is the input data conforming to operation weighting module 3.

[0074] Operation weighting module 3 can be used to perform operation weighting processing on the Q output data, K output data, and V output data with dimensions [N out , H out , W out , C out output by operation recombination module 2a, operation recombination module 2b, and operation recombination module 2c to obtain the processed result data corresponding to the input data of quantization deformation module 1, and its dimensions are [1, Nout H out , W out , C out . Among them, the number of dimensions of the output data remains the same as that of the input data. Exemplarily, N out H out can represent the number of attention heads for dividing the hidden layer dimension (i.e., the dimension with size HC) during the weighted operation. The number of attention heads refers to the number of blocks for the data block processing by the operation weighting module 3, indicating that the operation weighting module 3 uses N out H out independent data blocks to analyze the data.

[0075] It can be understood that Figure 2A - Figure 2B the MHA network shown is only an example. In other embodiments, the data processing method provided in this application embodiment can be applied to other models including the above operation recombination module. It can be understood that the structure of the operation weighting module 3 in the MHA network is not limited to Figure 2B the structure shown. In other embodiments, compared with the embodiment of Figure NB, the operation weighting module 3 may further include more or fewer operators.

[0076] Next, taking N out as 2, H out as 8, W out as 4096, and C out as 40 as an example, in combination with Figure 3 , Figure 4A - 4C , the process of feature transformation of the input data by the operation recombination module (such as the operation recombination module 2a, operation recombination module 2b, operation recombination module 2c) is introduced.

[0077] It can be understood that Figure 3 the structure of the operation recombination module shown and Figure 2B the structures of the operation recombination module 2a, operation recombination module 2b, and operation recombination module 2c shown are the same, and the data processing processes are the same.

[0078] Figure 3 shows an exemplary process of data processing through the Figure 2B operation recombination module shown.

[0079] Referring to Figure 3 , through the FC operator, the input data can be subjected to FC operation, and the dot product operation is performed on the input data and the weight data to obtain the result data, where the sizes of the input data and the result data are [8192, 320].

[0080] Through the deformation operator, the result data obtained by the FC operation can be deformed, and the size of the deformed result data is [2, 4096, 8, 40].

[0081] The transposed result data obtained by the deformation process can be transposed by a transpose operator. For example, the second dimension and the third dimension of the result data are exchanged to obtain output data, and the size of the output data is [2, 8, 4096, 40].

[0082] Reference Figure 4A , the FC operation performed by the FC operator can be a dot product operation on the input feature data with a size of [8192, 320] and the weight data with a size of [320, 320] to obtain result data with a size of [8192, 320].

[0083] Reference Figure 4B , the deformation process performed by the deformation operator can be to split the first dimension in the result data with a size of [8192, 320] into two dimensions with a size of [2, 4096], and split the second dimension into two dimensions with a size of [8, 40], to obtain deformed data with a size of [2, 4096, 8, 40].

[0084] Reference Figure 4C , the transpose process performed by the transpose operator can be to exchange the second dimension and the third dimension in the deformed data with a size of [2, 4096, 8, 40] to obtain output data with a size of [2, 8, 4096, 40].

[0085] However, in the process of the operation recombination module determining Q data, K data, and V data based on the above FC operator through feature transformation (such as FC operation), it is necessary to load the high-dimensional input data with a size of [8192, 320] and the high-dimensional weight data with a size of [320, 320] into the memory of the electronic device at one time, which occupies a large amount of the memory space of the electronic device; in the process of the above transpose process, it is necessary to load the high-dimensional data with a size of [2, 4096, 8, 40] into the memory at one time, which will also cause a large amount of occupation of the memory space of the electronic device. Thus, in the process of performing the above operation recombination process, the peak value of memory occupation will be too high, reducing the available memory space of the electronic device. In addition, if the available space of the memory of the electronic device is less than the memory space required for the aforementioned feature transformation and transpose process, the electronic device will not be able to execute the above process.

[0086] To solve the problem of excessive memory space occupation in the process of feature transformation and dimension transformation of data, the present application provides a data processing method. In this method, the input data can be split into multiple input sub-data, and the weight data can be split into multiple weight sub-data, and each weight sub-data is respectively used to perform feature transformation (such as FC operation) on each input sub-data to obtain multiple result sub-data.

[0087] In this way, during the process of performing feature transformation on the input data, the electronic device only needs to load one or more input sub-data and the corresponding weight sub-data of the one or more input sub-data into the memory at the same time period, rather than loading all the input data and all the weight data into the memory simultaneously, which can avoid the problem of excessive peak memory occupancy.

[0088] In some embodiments, after obtaining the result sub-data through feature transformation, dimensional transformation can be performed on the result sub-data. Among them, each result sub-data is deformed separately so that the number of dimensions of the deformed output sub-data is a preset number of dimensions (for example, the preset number of dimensions meets the input data size requirements of the subsequent operation weighting module), and then the deformed output sub-data are spliced to obtain the output data.

[0089] In this way, through the deformation and splicing processes, it can be ensured that complete output data (with the same size as the output data size of the operation recombination module shown in Figure 3 and Figure 4A - Figure 4C ) is obtained. Moreover, it is possible to avoid performing an overall transpose operation on all the result data, so there is no need to load all the result data into the memory simultaneously, thereby further reducing the memory occupancy during the data processing process.

[0090] Taking the input data with a size of [8192, 320] in the foregoing embodiment as an example, it is divided into 2 input sub-data, and the size of each input sub-data is [4096, 320]; the weight data with a size of [320, 40] is divided into 8 weight sub-data, and the size of each weight sub-data is [320, 40]. An exemplary process of processing the input data with a size of [8192, 320] to obtain output data with a size of [2, 8, 4096, 40] is introduced below.

[0091] It can be understood that since the number of input sub-data is 2, the feature transformation and dimensional transformation shown in Figure 5A can be performed on each of the 2 input sub-data.

[0092] Below, in combination with Figure 5A , an exemplary process of performing feature transformation and dimensional change on each of the 2 input sub-data is introduced.

[0093] Referring to Figure 5A , the electronic device can perform feature transformation (such as dot product) on the input sub-data with a size of [4096, 320] and the weight sub-data with a size of [320, 40] to obtain result sub-data with a size of [4096, 40]. It can be understood that since the number of weight sub-data is 8, for any one input sub-data, the number of result sub-data with a size of [4096, 40] is also 8.

[0094] Then, the electronic device can deform the resulting sub-data with a size of [4096, 40] to obtain first output sub-data with a size of [1, 1, 4096, 40]. It can be understood that for any one input sub-data, the number of first output sub-data with a size of [1, 1, 4096, 40] is 8. In this way, the dimension of the first output sub-data is the same as the dimension of the output data, so that the output data can be obtained by subsequently splicing the first output sub-data. After obtaining 8 first output sub-data corresponding to 1 input sub-data, the electronic device can splice the 8 first output sub-data with a size of [1, 1, 4096, 40] corresponding to this input sub-data in the second dimension to obtain second output sub-data with a size of [1, 8, 4096, 40] corresponding to this input sub-data.

[0095] It can be understood that after performing Figure 5A the data processing shown respectively on 2 input sub-data, 1 second output sub-data corresponding to each of the 2 input sub-data can be obtained, that is, a total of 2 second output sub-data with a size of [1, 8, 4096, 40] are obtained.

[0096] Finally, the electronic device splices the 2 second output sub-data with a size of [1, 8, 4096, 40] corresponding to the 2 input sub-data along the first dimension, and finally obtains output data with a size of [2, 8, 4096, 40].

[0097] It can be understood that based on the above method, Figure 5A the feature transformation process shown, compared with Figure 4A the feature transformation process shown, performs data processing based on the divided data, thereby reducing the memory occupancy.

[0098] In some scenarios, the electronic device can serially execute the above feature transformation process. Among them, the input data to be processed when calculating each resulting sub-data is divided into 2 parts, and the weight data is divided into 8 parts. Therefore, the data processing amount is reduced by 16 times, and thus the memory amount occupied by this part of the data is also reduced by 16 times.

[0099] In other scenarios, the electronic device can parallelly execute the above feature transformation process. For example, in a multi-core processor scenario, different cores can be used to parallelly process different divided data blocks, thereby improving the data processing efficiency and at the same time reducing the total memory occupied by the data processing.

[0100] For example, if data processing is performed on two output sub-data through two cores in parallel, the data processing efficiency is increased to twice; for each of the two output sub-data, based on the weight sub-data divided into 8 blocks for feature transformation, the memory amount occupied by the data processed by each core is reduced by 16 times, and the total memory amount occupied by the data processed by the two cores is reduced by 8 times.

[0101] In addition, Figure 5A the dimension transformation process shown compared with the dimension transformation process shown, eliminates the transpose step through the deformation and splicing steps, so that it is not necessary to load the complete data into the memory for transposition at the same time, and the problem of excessive memory peak caused by transposition can be further avoided.

[0102] In some embodiments, the splicing process can be completed during the process of writing to the disk, thus not occupying memory space. For example, for the 8 first output sub-data corresponding to the first input sub-data, first store the first first output sub-data, and then append and store the second second output sub-data to the storage space of the first first output sub-data, and so on, until the 8th first output sub-data is completely stored. At this time, the first second output sub-data (spliced from the 8 first output sub-data corresponding to the first input sub-data) has been stored in the disk. Then store the 8 first output sub-data corresponding to the second input sub-data in the same way. At this time, the second second output sub-data (spliced from the 8 first output sub-data corresponding to the second input sub-data) is appended and stored in the disk. In this way, the process of splicing 8 first output sub-data based on the second dimension twice, and the process of splicing 2 second output sub-data based on the first dimension are completed.

[0103] In some embodiments, a data processing method can be applied to a first model (such as an MHA network), where the first model includes an operation reorganization module (such as the operation reorganization module 2a, operation reorganization module 2b, operation reorganization module 2c in the MHA network shown Figure 4B - Figure 4C ), which includes an FC operator, a deformation operator, and a splicing operator that are executed in sequence. Among them, the FC operator is used to perform FC operations on the input sub-data obtained by dividing the input data into blocks and the weight sub-data obtained by dividing the weight data into blocks to obtain result sub-data; the deformation operator is used to deform the result sub-data obtained by the FC operation to obtain output sub-data; the splicing operator is used to splice the output sub-data obtained by the deformation to obtain output data.

[0104] According to some embodiments, dividing the input data and the weight data into blocks includes: based on (K - 2) dimensions among K dimensions, splitting the input data into P input sub-data along the row direction, and splitting the weight data corresponding to the input data into Q weight sub-data along the column direction.

[0105] For example, referring to Figure 2A and Figure 5B , the size of the input data is [8192, 320], the size of the output data is [2, 8, 4096, 40], and K is 4. Before the FC operation, the input data can be split into 2 input sub-data along the row direction based on the first dimension (batch size of 2) in the output data, where the size of the input sub-data is [4096, 320]; and the weight data can be split into 8 weight sub-data along the column direction respectively, where the size of each weight sub-data is [320, 40].

[0106] According to some embodiments, based on the input sub-data obtained by partitioning the input data and the weight sub-data obtained by partitioning the weight data, an FC operation is performed to obtain result sub-data, including: performing a dot product operation on P input sub-data and Q weight sub-data respectively to obtain PQ result sub-data.

[0107] For example, referring to Figure 5C , during the process of performing the FC operation through the FC operator, each input sub-data in the 2 input sub-data and each weight sub-data in the 8 weight sub-data are respectively subjected to a dot product operation, and 8 result sub-data corresponding to each input sub-data. Among them, by performing 2 sets of dot product operations on the 2 input sub-data and the 8 weight sub-data respectively, 16 result sub-data can be obtained. Since the size of the first dimension of the input sub-data is 4096 and the size of the second dimension of the weight sub-data is 40, the size of the result sub-data obtained by the dot product of the input sub-data and the weight sub-data is [4096, 40].

[0108] It can be understood that compared with the Figure 5D shown FC operation process, the amount of data to be processed in the FC operation process of this embodiment is greatly reduced, thereby reducing the memory occupancy of data processing.

[0109] According to some embodiments, the result sub-data obtained by the FC operation is deformed to obtain output sub-data, including: adjusting the dimension of the PQ result sub-data from 2 dimensions to K dimensions to obtain PQ output sub-data.

[0110] For example, referring to Figure 4A , after the FC operation is completed, the deformation operator can be used to perform deformation processing on 2 sets of result sub-data (8 result sub-data in each set) respectively to increase 2 dimension numbers, where the batch size of each newly added dimension is 1, to obtain 16 first output sub-data, and the size of the first output sub-data is [1, 1, 4096, 40]. It can be understood that the dimension number of the first output sub-data is the same as the dimension number of the operation result of the recombination operation.

[0111] According to some embodiments, the deformed output sub-data is spliced to obtain output data, including: splicing Q second intermediate data along the above K-2 dimensions to obtain the processing result of the first processing on the input data.

[0112] For example, referring to Figure 5E , finally, 16 deformed output sub-data can be spliced by a splicing operator based on 2 newly added dimensions during the deformation process. For example, in the first step, 8 output sub-data corresponding to each input sub-data are spliced in the second dimension, and the size of the obtained second output sub-data is [1, 8, 4096, 40]; the above first step operation can be performed 2 times for 2 input sub-data respectively, and a total of 2 second output sub-data can be obtained. Finally, the 2 second output sub-data are spliced in the first dimension by a splicing operator, and the obtained final output data has a size of [2, 8, 4096, 40]. It can be understood that the size of this output data is the same as the size of the output data in the foregoing embodiments based on Figure 5F , Figure 3 .

[0113] In the above Figure 4A - Figure 4C illustrated embodiment of the data processing method, compared with the above Figure 5B - Figure 5F illustrated embodiment of the data processing method, during the FC operation, the memory space occupied by the FC operation of a single input sub-data and sub-weights is reduced to 1 / 16, thereby reducing the memory peak of the FC operation and deformation processing. In addition, the above processing process realizes the function of the transpose operator through deformation processing and data splicing, so that it is possible to avoid using a transpose operator with a high memory occupancy for transpose processing, and the storage space occupied by transpose processing of high-dimensional data can be further reduced.

[0114] Next, a data processing method provided by an embodiment of the present application will be introduced in combination with Figure 4A - Figure 4C . The method can be executed by a processor of an electronic device using a first model, and includes the following steps.

[0115] S101: Receive a data processing request, and determine the input data to be processed according to the data processing request.

[0116] It can be understood that the processor can receive the data processing request and determine the input data to be processed according to the data processing request. Among them, the dimension of the input data is 2.

[0117] In some embodiments, referring to Figure 6 , the processor can be the processor in the client 101 or the server 102. For example, when the client 101 detects a user operation, it can receive the data processing request corresponding to the user operation; for another example, the client 101 can forward the data processing request to the server 102.

[0118] According to some embodiments, the input data to be processed may be Figure 1 or Figure 2A the output data (i.e., the first intermediate data) of the quantization deformation module 1 shown in the figure.

[0119] According to some embodiments, the data processing request may include input data, and the dimension of the input data is 2.

[0120] According to other embodiments, the data processing request may include raw data, and the processor may preprocess the raw data to obtain input data, where the dimension of the input data is 2.

[0121] According to some embodiments, the data processing request may be a request corresponding to a natural language processing task, the data to be processed may be the text to be processed, and the input data may be the text features corresponding to the text to be processed. Correspondingly, the data processing result obtained in S109 may be the processing result corresponding to the result to be processed, for example, it may be a processing result in text form, such as a translated text in text form, a semantic analysis result, etc.

[0122] According to some embodiments, after receiving the data processing request, the processor may store the input data in the memory.

[0123] S102: Split the input data into P input sub-data along the row direction, and split the weight data into Q weight sub-data along the column direction.

[0124] It can be understood that the input data and the weight data are used for FC operation.

[0125] According to some embodiments, the dimension number of the weight data is 2, and the batch size of each dimension of the weight data is the same as the batch size of the second dimension of the input data. After determining the input data to be processed, the processor may split the input data along the row direction to obtain P input sub-data; split the weight data along the column direction to obtain Q weight sub-data.

[0126] According to some embodiments, the processor may read the input data and the weight data from the memory and perform splitting, and then store the P input sub-data and the Q weight sub-data obtained by splitting in the memory.

[0127] S103: Determine the first input sub-data among the P input sub-data as the i-th input sub-data currently being processed.

[0128] According to some embodiments, after the splitting is completed, the processor may traverse the P input sub-data to perform dot product operations on each input sub-data and the Q weight sub-data. First, it may traverse to the first input sub-data, that is, determine the first input sub-data as the i-th input sub-data currently being processed.

[0129] S104: Determine whether i is equal to P; if not, go to S105; if so, go to S108.

[0130] It can be understood that the processor can determine whether the traversal is completed. If i is equal to P, it means that the traversal of P input sub - data is completed, and then go to S108 for the splicing process of the output sub - data corresponding to the P input sub - data.

[0131] If i is not equal to P, it means that the traversal of P input sub - data is not completed, then go to S105 to continue execution.

[0132] S105: Perform a dot - product operation on the i - th input sub - data and Q weight sub - data to obtain Q result sub - data.

[0133] It can be understood that S105 can be executed by the processor through the FC operator in the first model.

[0134] For the i - th input sub - data, the processor can perform a dot - product operation on the i - th input sub - data and each of the Q weight sub - data through the FC operator to obtain Q result sub - data corresponding to the i - th input sub - data.

[0135] It can be understood that the batch size of the last dimension of the result sub - data is the same as the batch size of the last dimension of the output data in S108.

[0136] According to some embodiments, the batch size of the second - last dimension of the result sub - data is the same as the batch size of the second - last dimension of the output data in S108.

[0137] According to some embodiments, each core in the multi - core processor can read the i - th input sub - data and Q weight sub - data from the memory, and perform a dot - product operation on each weight sub - data in the i - th input sub - data and Q weight sub - data respectively to obtain Q result sub - data corresponding to the i - th input sub - data, and store them in the memory.

[0138] S106: Add (K - 2) dimensions to the Q result sub - data to obtain Q first output sub - data with dimension K.

[0139] It can be understood that S106 can be executed by the processor through the deformation operator in the first model.

[0140] For the i - th input sub - data, the processor can add (K - 2) dimensions to the Q result sub - data corresponding to the i - th input sub - data through the deformation operator, where the batch size of each dimension is 1, to obtain Q first output sub - data with dimension K.

[0141] According to some embodiments, the added (K - 2) dimensions are not the last dimension in the first output sub - data. That is to say, the (K - 2) dimensions can be added at any position before the last dimension of the first output sub - data. For example, the added (K - 2) dimensions can be the 1st to the (K - 2)nd dimensions in the first output sub - data.

[0142] According to some embodiments, the processor can read Q result sub - data for performing the dimension - increasing deformation operation, add (K - 2) dimensions thereto, and then store the Q first output sub - data obtained by the deformation into the memory.

[0143] S107: Concatenate the Q first output sub - data to obtain the second output sub - data corresponding to the i - th input sub - data.

[0144] It can be understood that S107 can be executed by the processor through the concatenation operator in the first model.

[0145] It can be understood that after obtaining the Q first output sub - data, the processor can concatenate the Q first output sub - data through the concatenation operator to obtain the second output sub - data corresponding to the i - th input sub - data.

[0146] According to some embodiments, if the batch size of the n - th dimension of the output data in S108 is Q, then the Q first output sub - data can be concatenated in the n - th dimension so that the batch size of the n - th dimension of the obtained second output sub - data is Q, thus being consistent with the output data of S108.

[0147] According to some embodiments, the processor can read the Q first output sub - data from the memory for concatenation, and then store the concatenated second output sub - data into the memory.

[0148] S108: Concatenate the P second output sub - data corresponding to the P input sub - data to obtain the output data; increment i by 1, and go to S104.

[0149] It can be understood that S108 can be executed by the processor through the concatenation operator in the first model.

[0150] It can be understood that after traversing the P first input sub - data, S107 has been executed P times. The processor can concatenate the P second output sub - data corresponding to the P first input sub - data to obtain the output data (i.e., the output data of the operation recombination module, i.e., the first conversion data).

[0151] According to some embodiments, if the batch size of the m - th dimension of the output data in S108 is P, then the P second output sub - data can be concatenated in the m - th dimension so that the batch size of the n - th dimension of the obtained output data is P.

[0152] According to some embodiments, the processor may read P second output sub - data from the memory for stitching, and then store the stitched output data into the memory.

[0153] S + 109: Determine the data processing result corresponding to the data processing request based on the output data.

[0154] It can be understood that after obtaining the output data, subsequent operations may be performed based on the output data to obtain the data processing result (i.e., the first processing result) corresponding to the data processing request.

[0155] According to some embodiments, the first model may further include other operators, and the data processing result may be the processing result of the data by other operators.

[0156] For example, the processing process of S + 102 - S + 108 may replace the operation recombination module in the MHA network, so that when running the first model, 3 output data can be obtained respectively for Q, K, and V; on this basis, the first model may further include Figure 2B other deformation operators, weighting operators, etc. as shown, and the 3 output data may be processed by other operators to obtain the first result data; then the first result data may be further processed by the downstream module of the MHA network to obtain the first processing result. For example, after the MHA network finishes running, the first result data may also be processed by other functional modules, such as visual processing, statistical processing, or classification processing, etc., to obtain the first processing result.

[0157] It can be understood that the embodiments of the present application do not limit the traversal order of the input sub - data and the weight sub - data. In other embodiments, during the execution of S + 103 - S + 107, traversing the input sub - data may be replaced by traversing the weight sub - data, where in S + 105, the product of each weight sub - data and all input sub - data is calculated, and during the execution of S + 107, based on the dimension with batch size P in the output data, P first output sub - data corresponding to each weight sub - data are stitched to obtain the second output sub - data corresponding to each weight sub - data. Since Q output sub - data are traversed, S + 103 - S + 107 can be executed Q times, thereby obtaining Q second output sub - data. Then S + 108 is executed to stitch the Q second output sub - data with the dimension with batch size Q in the output data to obtain the output data.

[0158] In the above - mentioned embodiments, since the data is block - operated during the FC operation, the input and output data of a single operation become fewer, thereby reducing the memory occupancy; by eliminating the transpose operator, one - time reading and writing of high - dimensional data can be avoided, thereby reducing the memory occupancy.

[0159] Note: There seems to be an error in the original text where "S109" is written as "S + 109" and "S102 - S108" are written as "S + 102 - S + 108" in some places. The translation is done based on the original text as provided.According to some embodiments, since the FC operation is split into multiple sub - operation steps, in the case of being used in a multi - core processor, the operation tasks can be assigned to different cores for processing, thereby improving the processing efficiency.

[0160] In some embodiments, in the scenario of a multi - core processor, the memory may include a main memory and a shared memory. Since the amount of input and output data of the FC operation is reduced, and thus the amount of input and output data for deformation and splicing is reduced, the processor can cache the input and output data of the FC operator and the deformation operator, and the first output sub - data obtained by splicing in the shared memory, while storing other data (such as the received data to be processed, the input data before chunking, the second output sub - data obtained by splicing, and the output data) in the main memory. Since the shared memory has a higher bandwidth compared to the main memory, it can improve the bandwidth to further improve the processing performance of the multi - core processor.

[0161] It can be understood that caching data to the shared memory means that when the processor obtains the data, it stores the data in the shared memory, and when the processor needs to use the data in subsequent processing, it reads the data from the shared memory.

[0162] According to some embodiments, the same multi - core processor can be used to process the same task (using the same input data) with the model before and after optimization, and compare the running parameters of Core0 (the first core) of the multi - core processor to determine the optimization effect of the model. Among them, when Core0 uses Figure 2B the model shown to process the task, the running time of the FC operator - deformation operator - transpose operator is 5.62 ms, accounting for 1.71%; while when Core0 applies the data processing method provided by the embodiments of the present application, the running time of the FC operator - deformation operator - splicing operator is reduced to 2.00 ms, and the proportion is reduced to 0.61%. Therefore, the data processing method provided by the embodiments of the present application can improve the processing performance of the multi - core processor.

[0163] The following combines Figure 2B and Figure 6 , taking K as 4 as an example to introduce an exemplary process for the first processing of input data. It can be understood that among them, the size of the input data is [N out W out , H out C out , the size of the weight data is [H out C out , H out C out , and the size of the output data is [N out , H out , W out , C out, that is, the output data includes 4 dimensions, and the batch sizes of these 4 dimensions are N out , H out , W out , C out .

[0164] Reference Figure 7 , during the execution of S102, the input data can be split into N out input sub - data along the column direction, where the size of the input sub - data is [W out , H out C out ; and the weight data can be split into H out weight sub - data along the row direction, where the size of the weight sub - data is [H out C out , C out .

[0165] During the execution of S105, each of the N out input sub - data and each of the H out weight sub - data are respectively subjected to dot - product operations, and each input sub - data corresponds to H out result sub - data. Among them, by performing S105 on the N out input sub - data N out times, N out H out result sub - data can be obtained, where the size of the result sub - data is [W out , C out .

[0166] After the FC operation is completed, during the execution of S106, the H out result sub - data can be respectively subjected to deformation processing to increase 2 dimensions, where the batch size of each newly added dimension is 1, obtaining H out first output sub - data, whose size is [1, 1, W out , C out . Among them, by performing S106 on the N out input sub - data N out times, N out H out first output sub - data can be obtained. It can be understood that the number of dimensions of the first output sub - data is the same as that of the operation result of the recombination operation.

[0167] Finally, during the execution of S107 and S108, the N out H outThe deformed output sub-data is concatenated based on the 2 newly added dimensions during the deformation process. For example, first execute S107, and concatenate the H corresponding to each input sub-data in the 2nd dimension out output sub-data, and the size of the obtained second output sub-data is [1, H out , W out , C out ; Executing S107 N out times can obtain N out second output sub-data. Then execute S108, and concatenate N out second output sub-data in the 1st dimension to obtain the final output data, whose size is [N out , H out , W out , C out .

[0168] In the above embodiment, the input data is partitioned based on the batch size N in the 1st dimension of the output data, and the weight data is partitioned based on the batch size in the 2nd dimension of the output data. out

[0169] In some other embodiments, it can also be that the input data is partitioned based on the batch size N in the 1st dimension of the output data, and the weight data is partitioned based on the batch size H in the 2nd dimension of the output data. For example, during the execution of S102, the input data can also be split into H out input sub-data along the column direction, and the weight data is split into N out weight sub-data along the row direction respectively. Then, during the execution of S105, each input sub-data in the H out input sub-data and each weight sub-data in the N out weight sub-data are respectively subjected to dot product operations to obtain N<![CDATA[ out ]]result sub-data corresponding to each input sub-data in the H<![CDATA[ out ]]input sub-data. After the FC operation is completed, during the execution of S106, N<![CDATA[ out ]]H<![CDATA[ out ]]result sub-data can be respectively subjected to deformation processing to increase 2 dimension numbers, where the batch size of each newly added dimension is 1. Then, execute S107 to concatenate the N<![CDATA[ out ]]H<![CDATA[ out ]]result sub-data corresponding to each input sub-data in the 1st dimension to obtain the intermediate data with a size of [N<![CDATA[ out ]], 1, W<![CDATA[ out ]], C<![CDATA[ out ]], C<![CDATA[ out ]]; Finally, execute S108 to concatenate H<![CDATA[ out ]]The final output data obtained from the deformed data has a size of [N out , H out , W out , C out .

[0170] It should be noted that the above number of K is only for illustration, and this application does not limit the number of K.

[0171] In the above embodiment where K is 4, the number of partitions P of the input data can be the batch size N of the first dimension of the output data (with a size of [N out , H out , W out , C out ), and the number of partitions Q of the weight data can be the batch size H of the second dimension of the output data out ; or, the number of partitions P of the input data can be the batch size H of the second dimension of the output data out ; and the number of partitions Q of the weight data can be the batch size N of the first dimension of the output data out . out

[0172] In some embodiments, K can be any integer greater than or equal to 2, and the number of partitions P of the input data and the number of partitions Q of the weight data can be determined based on the sizes of the output data and the input data. As mentioned above, the number of dimensions of the output data is K, and the number of dimensions of the input data is 2.

[0173] The following introduces a method for determining P and Q. Two specific embodiments are introduced in detail. In the first embodiment, K is 4, the size of the input data is [8192, 320], the size of the output data is [2, 8, 4096, 40], and the size of the weight data is [320, 320]; in the second embodiment, K is 5, the size of the input data is [8192, 320], the size of the output data is [2, 2, 8, 2048, 40], and the size of the weight data is [320, 320].[[]]

[0174] For ease of description, hereinafter, the batch size of the first dimension of the input data is simply referred to as p, and the batch size of the second dimension of the input data is simply referred to as q.

[0175] According to some embodiments, each dimension of the output data can include a first dimension group and a second dimension group. Among them, the number of dimensions of the first dimension group is h, and the number of dimensions of the second dimension group is (k - h). The product of the batch sizes of the h dimensions of the first dimension group can be equal to p, the second dimension group includes the last 1 dimension of the output data, and the product of the batch sizes of the (k - h) dimensions can be equal to q.

[0176] ​It can be understood that the size of the first dimension group is used to determine P, and the size of the second dimension group is used to determine Q.

[0177] According to some embodiments, P can be the product of the batch sizes of (h - 1) dimensions in the first dimension group. According to some embodiments, Q can be the product of the batch sizes of (k - h - 1) dimensions in the second dimension group except for the last 1 dimension of the output data.

[0178] That is to say, the above-mentioned (h - 1) dimensions and (k - h - 1) dimensions do not include the last 1 dimension. It can be understood that in the embodiment where k is 4 and h is 2, the (h - 1) dimensions can be the first dimension, the (k - h - 1) dimensions can be the second dimension, and neither the first dimension nor the second dimension is the last 1 dimension.

[0179] In the first embodiment above, the first dimension group is [2, 4096], and P can be the batch size 2 of the first dimension of the output data (i.e., the aforementioned m-th dimension); the second dimension group is [8, 40], and Q can be the batch size 8 of the second dimension of the output data (i.e., the aforementioned n-th dimension).

[0180] In the second embodiment above, the first dimension group is [2, 2, 2048], and P can be the product of the batch sizes 2 and 2 of the first and second dimensions of the output data (i.e., the aforementioned m-th dimension), which is 4; the second dimension group is [8, 40], and Q can be the batch size 8 of the third dimension of the output data (i.e., the aforementioned n-th dimension).

[0181] It can be understood that after determining P and Q, subsequent processes such as chunking and splicing can be performed based on the determined P and Q. The following combines Figure 7 to introduce an exemplary process of chunking, FC operation, transformation, and splicing based on input data and weight data.

[0182] By executing S102, after dividing the input data into P parts based on the first dimension (i.e., based on the row direction) and dividing the weight data into Q parts based on the second dimension (i.e., based on the column direction), the batch size of the first dimension of the obtained input sub-data can be the batch size of 1 dimension in the first dimension group except for the above-mentioned (h - 1) dimensions, and the batch size of the second dimension of the obtained weight sub-data can be the batch size of the last 1 dimension in the second dimension group.

[0183] In the first embodiment above, P is 2, Q is 8, the size of the input sub-data obtained by dividing based on P is [4096, 320], and the size of the weight sub-data obtained by dividing based on Q is [320, 40].

[0184] In the second embodiment described above, P is 4, Q is 8, the size of the input sub-data divided based on P is [2048, 320], and the size of the weight sub-data divided based on Q is [320, 40].

[0185] By executing S105, the input sub-data and the weight sub-data can be subjected to a dot product operation to obtain result sub-data. Since the batch size of the first dimension of the input data is the batch size of 1 dimension except the above (h - 1) dimensions in the first dimension group, and the batch size of the second dimension of the weight sub-data can be the batch size of the last 1 dimension in the second dimension group, therefore, the batch size of the first dimension of the result sub-data is the batch size of 1 dimension except the above (h - 1) dimensions in the first dimension group, and the batch size of the second dimension of the result sub-data can be the batch size of the last 1 dimension in the second dimension group.

[0186] In the first embodiment described above, the size of the result sub-data obtained by the dot product operation is [4096, 40].

[0187] In the second embodiment described above, the size of the result sub-data obtained by the dot product operation is [2048, 40].

[0188] During the execution of S106, (K - 2) dimensions can be added before the last 1 dimension of the result sub-data to obtain the first output sub-data. Among them, the newly added dimensions in the first output sub-data include the above (h - 1) dimensions and the above (K - h - 1) dimensions.

[0189] In the first embodiment described above, the size of the result sub-data obtained by the dot product operation is [4096, 40]. By adding 2 dimensions (the first and second dimensions of the output data), the first output sub-data is obtained, and the size of the first output sub-data is [1, 1, 4096, 40].

[0190] In the second embodiment described above, the size of the result sub-data obtained by the dot product operation is [2048, 40]. By adding 3 dimensions (the first, second, and third dimensions of the output data), the first output sub-data is obtained, and the size of the first output sub-data is [1, 1, 1, 2048, 40].

[0191] By executing S107, the first output sub-data can be concatenated based on the above (K - h - 1) dimensions to obtain the second output sub-data.

[0192] In the first embodiment described above, the first output sub-data can be concatenated based on the second dimension with a batch size of 8 in the output data to obtain the second output sub-data, and its size is [1, 8, 4096, 40].

[0193] In the second embodiment described above, the first output sub-data may be concatenated based on the third dimension with a batch size of 8 in the output data to obtain second output sub-data with a size of [1, 1, 8, 2048, 40].

[0194] By executing S108, the final output data may be obtained by concatenating the above-mentioned (h - 1) second output sub-data.

[0195] In the first embodiment described above, the first output sub-data may be concatenated based on the first dimension with a batch size of 2 in the output data to obtain second output sub-data with a size of [2, 8, 4096, 40].

[0196] In the second embodiment described above, the first output sub-data may be concatenated based on the first and second dimensions with a size of [2, 2] in the output data to obtain second output sub-data with a size of [2, 2, 8, 2048, 40].

[0197] Next, Figure 6 a data processing method provided by an embodiment of the present application will be introduced. Referring to Figure 8 , this method may be executed by an electronic device and includes the following steps.

[0198] S201: Obtain first data to be processed.

[0199] It can be understood that the present application does not limit the data type of the first data (i.e., the data to be processed in the above text). For example, the first data may be text data.

[0200] S202: Input the first data into a first model to obtain a first processing result.

[0201] According to some embodiments, the input data of the first model is the first data, and the output data is the first processing result (i.e., the data processing result in the above text). It can be understood that the present application does not limit the data type of the first processing result. For example, the first processing result may be text data.

[0202] According to some embodiments, the first model includes an MHA network. In the first model, the MHA network may further include other upstream modules and downstream modules, and the embodiments of the present application do not limit this. It can be understood that in the case where the MHA network includes an upstream module, the first data may be processed by the upstream module, and then the data obtained after being processed by the upstream module is input into the MHA network to obtain the first result data output by the MHA network. It can be understood that in the case where the MHA network does not have a downstream module, the first result data may be the same as the first processing result; or, in the case where the MHA network has a downstream module, the first result data may be processed by the downstream module to obtain the first processing result.

[0203] According to some embodiments, the processing of the first data by the MHA network includes: performing quantization transformation processing on the first data to obtain first intermediate data (i.e., the input data in S101 and S102 above); dividing the first intermediate data into P input sub-data, where P is an integer greater than 1; based on Q weight sub-data, performing first feature transformation processing on the P input sub-data to obtain first transformed data of the first intermediate data, where the Q weight sub-data are obtained by dividing the first weight data, and Q is an integer greater than 1; obtaining first result data based on the first transformed data (i.e., the output data in S108 and S109 above). Exemplarily, the above quantization transformation processing can refer to the description of the processing flow of the quantization transformation module 1 above, and the above first feature transformation processing can refer to the description for Figure 8 , Figure 2A the description of the processing flow of the quantization transformation module 1 above, and the above first feature transformation processing can refer to the description for Figure 2B , Figure 5A - Figure 5F in S102 - S108 and Figure 6 the description of, and the process of obtaining the first result data based on the first transformed data above can refer to the description of the processing flow of the weighted operation module 3 in combination with Figure 7 , Figure 2A above, which will not be elaborated here.

[0204] According to some embodiments, the first intermediate data and the first weight data are matrices. For example, the number of columns of the first intermediate data is the same as the number of rows of the first weight data. For example, referring to Figure 2B , the size of the input data is [N out W out , H out C out , the size of the weight data is [H out C out , H out C out , and the number of columns of the input data is the same as the number of rows of the first weight data.

[0205] According to some embodiments, dividing the first intermediate data into P input sub-data includes: dividing the first intermediate data into P input sub-data along the row direction of the first intermediate data; and the Q weight sub-data are obtained by dividing the first weight data along the column direction of the first weight data. For example, referring to Figure 7 , Figure 5B and Figure 5C , the division of the input data is based on the row direction, and the division of the weight data is based on the column direction.

[0206] In a possible implementation of the first aspect above, based on Q weighted sub-data, a first feature conversion process is performed on P input sub-data to obtain first conversion data of the first intermediate data, including: performing a dot product operation on each P input sub-data and the Q weighted sub-data respectively to obtain Q result sub-data corresponding to each input sub-data; performing deformation processing on the result sub-data corresponding to each input sub-data to obtain Q first output sub-data corresponding to each input sub-data, wherein the number of dimensions of the first output sub-data is the same as the number of dimensions of the first conversion data; performing splicing processing on the first output sub-data corresponding to each input sub-data to obtain the first conversion data. The description of the above dot product operation can refer to the above description of Figure 7 、 Figure 5D S105, Figure 6 The description of the FC operation in the above deformation process can refer to the above description of the FC operation in the above description of the deformation process. Figure 7 、 Figure 5E S106, Figure 6 The description of the deformation processing in the above splicing process can refer to the above Figure 7 、 Figure 5F S107 and S108, Figure 6 The description of the splicing process will not be repeated here.

[0207] In a possible implementation of the first aspect above, the first conversion data includes four dimensions, the four dimensions include a first dimension and a second dimension; and the first intermediate data is divided into P input sub-data along the row direction of the first intermediate data, including: based on the batch size of the first dimension, the first intermediate data is divided into P input sub-data along the row direction of the first intermediate data, and the batch size of the first dimension is P; and the Q weight sub-data are obtained by dividing the first weight data along the column direction of the first weight data based on the batch size of the second dimension, and the batch size of the second dimension is Q. For example, referring to Figure 7 , the batch size of the first dimension is N out , the batch size of the second dimension is H out , then P is N out , Q is H out .

[0208] In a possible implementation of the above first aspect, the first conversion data includes at least four dimensions; and the first conversion data includes a first dimension group and a second dimension group, the first dimension group includes k dimensions, and the second dimension group includes j dimensions; and the first intermediate data is divided into P input sub-data along the row direction of the first intermediate data, including: based on the batch size of (k - 1) dimensions in the first dimension group, the first intermediate data is divided into P input sub-data along the row direction of the first intermediate data, and the product of the batch sizes of (k - 1) dimensions is P; and Q weight sub-data are obtained by dividing the first weight data along the column direction of the first weight data based on the batch size of (j - 1) dimensions in the second dimension group, and the product of the batch sizes of (j - 1) dimensions is Q. For example, in the above embodiment where K is 5, the input data size is [8192, 320], the output data size is [2, 2, 8, 2048, 40], and the weight data size is [320, 320], the first dimension group is [2, 2, 2048], P can be the product of the batch sizes 2 and 2 of the first and second dimensions of the output data, that is, 4; the second dimension group is [8, 40], and Q can be the batch size 8 of the third dimension of the output data.

[0209] In a possible implementation of the above first aspect, the result sub-data corresponding to each input sub-data is deformed to obtain Q first output sub-data corresponding to each input sub-data, including: adding a first dimension and a second dimension to the result sub-data corresponding to each input sub-data to obtain Q first output sub-data corresponding to each input sub-data, where the batch sizes of the first dimension and the second dimension in the Q first output sub-data are 1. For example, referring to Figure 7 , during the deformation process, 2 dimensions are added to the result sub-data, that is, the first dimension and the second dimension are added.

[0210] In a possible implementation of the above first aspect, the P first output sub-data corresponding to each input sub-data are concatenated to obtain the first conversion data, including: concatenating the Q first output sub-data corresponding to each input sub-data along the second dimension to obtain P second output sub-data corresponding one-to-one to the P input sub-data, and the batch size of each second output sub-data in the second dimension is Q; concatenating the P second output sub-data along the second dimension to obtain the first conversion data, and the batch size of the first conversion data in the first dimension is P. It can be understood that the above concatenation process can refer to the descriptions of S107 and S108 in the above text for Figure 7 and Figure 5F and will not be elaborated here.

[0211] In a possible implementation of the above first aspect, the number of dimensions of the first conversion data is 4, and the number of dimensions of the first intermediate data is 2. For example, referring to the above text for Figure 6For the description, the dimension number of the output data (i.e., the first transformed data) is 4, and the dimension number of the input data (i.e., the first intermediate data) is 2.

[0212] According to some embodiments, S801 - S802 can be executed by a processor of an electronic device, and the process data processed (such as input sub - data, weight sub - data, the first transformed data, etc.) can be cached in a memory.

[0213] According to some embodiments, the processor is a multi - core processor, and during the process of the MHA network in S802 processing the first data, at least part of the data can be cached in the shared memory, and another part of the data can be stored in the main memory.

[0214] For example, during the process that the processor performs a first feature transformation process on P input sub - data based on Q weight sub - data to obtain the first transformed data of the first intermediate data, all the process data before obtaining the first transformed data can be cached in the shared memory.

[0215] For another example, the processor performs a dot - product operation on each of the P input sub - data and the Q weight sub - data respectively to obtain Q result sub - data corresponding to each input sub - data and caches them in the shared memory; reads the Q result sub - data corresponding to each input sub - data from the shared memory, performs a deformation process on the result sub - data corresponding to each input sub - data to obtain Q first output sub - data corresponding to each input sub - data and caches them in the shared memory, where the dimension number of the first output sub - data is the same as the dimension number of the first transformed data; reads the Q first output sub - data corresponding to each input sub - data from the shared memory, and performs a splicing process on the first output sub - data corresponding to each input sub - data to obtain the first transformed data and stores it in the main memory.

[0216] Furthermore, Figure 5A - Figure 5F According to some embodiments of the present application, a schematic structural diagram of an electronic device 100 is shown. As Figure 9 shown, the electronic device 100 includes one or more processors 101, a system memory 102, a non - volatile memory (NVM) 103, a communication interface 104, an input / output (I / O) device 105, and a system control logic 106 for coupling the processor 101, the system memory 102, the non - volatile memory 103, the communication interface 104, and the input / output (I / O) device 105.

[0217] Among them: The processor 101 may include one or more processing units. For example, it may include a central processing unit (CPU), a graphics processing unit (GPU), a digital signal processor (DSP), a micro-programmed control unit (MCU), an artificial intelligence (AI) processor, or a field-programmable gate array (FPGA), a neural-network processing unit (NPU), etc. The processing module or processing circuit may include one or more single-core or multi-core processors. According to some embodiments, the processor is a superscalar processor.

[0218] The system memory 102 is a volatile memory, such as a random-access memory (RAM), a double data rate synchronous dynamic random access memory (DDR SDRAM), etc. The system memory is used to temporarily store data and / or instructions.

[0219] The non-volatile memory 103 may include one or more tangible, non-transitory computer-readable media for storing data and / or instructions. In some embodiments, the non-volatile memory 103 may include any suitable non-volatile memory such as flash memory and / or any suitable non-volatile storage device, such as a hard disk drive (HDD), a compact disc (CD), a digital versatile disc (DVD), a solid-state drive (SSD), etc. In some embodiments, the non-volatile memory 103 may also be a removable storage medium, such as a secure digital (SD) memory card, etc. For example, in some embodiments, the system memory 102 may be used to store an incremental BTB as Figure 9 shown.

[0220] In particular, the system memory 102 and the non-volatile memory 103 may respectively include: a temporary copy and a permanent copy of the instruction 107. The instruction 107 may include: when executed by at least one of the processors 101, enabling the electronic device 100 to implement the data processing methods provided by the embodiments of the present application.

[0221] The communication interface 104 may include a transceiver for providing a wired or wireless communication interface for the electronic device 100, and thus communicating with any other suitable device via one or more networks. In some embodiments, the communication interface 104 may be integrated with other components of the electronic device 100. For example, the communication interface 104 may be integrated in the processor 101. In some embodiments, the electronic device 100 may communicate with other devices via the communication interface 104.

[0222] The input / output (I / O) device 105 may include input devices such as a keyboard, a mouse, etc., and output devices such as a display, etc. A user may interact with the electronic device 100 via the input / output (I / O) device 105, such as inputting a neural network model to be run, etc.

[0223] The system control logic 106 may include any suitable interface controller to provide any suitable interface for other modules of the electronic device 100. For example, in some embodiments, the system control logic 106 may include one or more memory controllers to provide an interface connected to the system memory 102 and the non-volatile memory 103.

[0224] In some embodiments, at least one of the processors 101 may be logically packaged with one or more controllers for the system control logic 106 to form a System in Package (SiP). In some other embodiments, at least one of the processors 101 may also be integrated with the logic of one or more controllers for the system control logic 106 on the same chip to form a System-on-Chip (SoC).

[0225] It can be understood that Figure 3 - Figure 7 Figure 9 The structure of the illustrated electronic device 100 is only an example. In some other embodiments, the electronic device 100 may include more or fewer components than those shown in the figure, or combine certain components, or split certain components, or have different component arrangements. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.

[0226] It can be understood that the electronic device 100 can be any electronic device, including but not limited to mobile phones, wearable devices (such as smart watches, etc.), tablet computers, desktop computers, laptop computers, handheld computers, notebook computers, ultra-mobile personal computers (UMPCs), netbooks, as well as cellular phones, personal digital assistants (PDAs), augmented reality (AR) / virtual reality (VR) devices, etc. The embodiments of the present application are not limited thereto.

[0227] Embodiments of the mechanisms disclosed in this application can be implemented in hardware, software, firmware, or a combination of these implementation methods. Embodiments of the present application can be implemented as a computer program or program code executed on a programmable system, which includes at least one processor, a storage system (including volatile and non-volatile memories and / or storage elements), at least one input device, and at least one output device.

[0228] The program code can be applied to the input instructions to perform the various functions described in this application and generate output information. The output information can be applied to one or more output devices in a known manner. For the purposes of this application, the processing system includes any system having a processor such as, for example, a Digital Signal Processor (DSP), a microcontroller, an Application Specific Integrated Circuit (ASIC), or a microprocessor.

[0229] The program code can be implemented in a high-level procedural language or an object-oriented programming language to communicate with the processing system. When needed, the program code can also be implemented in assembly language or machine language. In fact, the mechanisms described in this application are not limited to the scope of any specific programming language. In any case, the language can be a compiled language or an interpreted language.

[0230] In some cases, the disclosed embodiments may be implemented in hardware, firmware, software, or any combination thereof. The disclosed embodiments may also be implemented as instructions carried or stored on one or more transient or non-transitory machine-readable (e.g., computer-readable) storage media, which may be read and executed by one or more processors. For example, the instructions may be distributed via a network or via other computer-readable media. Thus, machine-readable media can include any mechanism for storing or transmitting information in a form readable by a machine (e.g., a computer), including but not limited to, floppy disks, optical disks, optical discs, CD-ROMs, magneto-optical discs, ROMs, RAMs, EPROMs, EEPROMs, magnetic or optical cards, flash memory, or tangible machine-readable memories for transmitting information (e.g., carrier waves, infrared signals, digital signals, etc.) in electrical, optical, acoustic, or other forms of propagated signals using the Internet. Thus, machine-readable media includes any type of machine-readable media suitable for storing or transmitting electronic instructions or information in a form readable by a machine (e.g., a computer).

[0231] In the drawings, some structural or method features may be shown in a particular arrangement and / or order. However, it should be understood that such a particular arrangement and / or ordering may not be required. Rather, in some embodiments, these features may be arranged in a manner and / or order different from that shown in the illustrative drawings. Additionally, the inclusion of a structural or method feature in a particular figure does not imply that such a feature is required in all embodiments, and in some embodiments, these features may not be included or may be combined with other features.

[0232] It should be noted that the various units / modules mentioned in the device embodiments of the present application are all logical units / modules. Physically, a logical unit / module may be a physical unit / module, a part of a physical unit / module, or may be implemented as a combination of multiple physical units / modules. The physical implementation manner of these logical units / modules themselves is not the most important. The combination of the functions implemented by these logical units / modules is the key to solving the technical problems proposed in the present application. In addition, in order to highlight the innovative part of the present application, the above-mentioned device embodiments of the present application do not introduce units / modules that are not closely related to solving the technical problems proposed in the present application. This does not mean that there are no other units / modules in the above-mentioned device embodiments.

[0233] It should be noted that in the examples and description of this patent, the terms "comprising", "including" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device comprising a series of elements not only includes those elements, but also includes other elements not expressly listed, or also includes elements inherent to such process, method, article or device. Without further limitation, an element defined by the statement "comprising one" does not exclude the presence of additional identical elements in the process, method, article or device comprising the said element.

[0234] Although this application has been illustrated and described by reference to certain preferred embodiments thereof, those of ordinary skill in the art should understand that various changes may be made thereto in form and detail without departing from the spirit and scope of this application.

Claims

1. A data processing method, characterized in that, Applied to an electronic device, the method includes: Obtain first data to be processed; Input the first data into a first model to obtain a first processing result, where: The first model includes a multi-head attention (MHA) network, and the processing of the first data by the MHA network includes: Perform quantization transformation processing on the first data to obtain first intermediate data, Divide the first intermediate data into P input sub-data, where P is an integer greater than 1; Based on Q weight sub-data, perform first feature transformation processing on the P input sub-data to obtain first transformed data of the first intermediate data, where the Q weight sub-data are obtained by dividing first weight data, and Q is an integer greater than 1; Obtain first result data based on the first transformed data.

2. The method according to claim 1, wherein The first intermediate data and the first weight data are matrices, and the number of columns of the first intermediate data is the same as the number of rows of the first weight data; The dividing the first intermediate data into P input sub-data includes: Divide the first intermediate data into the P input sub-data along the row direction of the first intermediate data; And The Q weight sub-data are obtained by dividing the first weight data along the column direction of the first weight data.

3. The method according to claim 2, wherein The performing first feature transformation processing on the P input sub-data based on Q weight sub-data to obtain first transformed data of the first intermediate data includes: Perform dot product operations on each of the P input sub-data and the Q weight sub-data respectively to obtain Q result sub-data corresponding to each input sub-data; Perform transformation processing on the result sub-data corresponding to each input sub-data to obtain Q first output sub-data corresponding to each input sub-data, where the number of dimensions of the first output sub-data is the same as the number of dimensions of the first transformed data; Perform splicing processing on the first output sub-data corresponding to each input sub-data to obtain the first transformed data.

4. The method according to claim 3, wherein The first transformed data includes four dimensions, and the four dimensions include a first dimension and a second dimension; and The dividing the first intermediate data into the P input sub-data along the row direction of the first intermediate data includes: Based on the batch size of the first dimension, divide the first intermediate data into the P input sub-data along the row direction of the first intermediate data, and the batch size of the first dimension is P; and The Q weight sub-data are obtained by dividing the first weight data along the column direction of the first weight data based on the batch size of the second dimension, and the batch size of the second dimension is Q.

5. The method according to claim 3, wherein The first transformed data includes at least four dimensions; and, the first transformed data includes a first dimension group and a second dimension group, the first dimension group includes k dimensions, and the second dimension group includes j dimensions; and The dividing the first intermediate data into the P input sub-data along the row direction of the first intermediate data includes: Based on the batch size of (k - 1) dimensions in the first dimension group, the first intermediate data is divided into the P input sub - data along the row direction of the first intermediate data, and the product of the batch sizes of the (k - 1) dimensions is P; and the Q weight sub - data are obtained by dividing the first weight data along the column direction of the first weight data based on the batch size of (j - 1) dimensions in the second dimension group, and the product of the batch sizes of the (j - 1) dimensions is Q.

6. The method according to claim 4, characterized in that, The performing deformation processing on the result sub - data corresponding to each input sub - data to obtain Q first output sub - data corresponding to each input sub - data includes:[[]] Adding the first dimension and the second dimension to the result sub - data corresponding to each input sub - data to obtain Q first output sub - data corresponding to each input sub - data, where the batch sizes of the first dimension and the second dimension in the Q first output sub - data are 1.

7. The method according to claim 6, wherein The performing splicing processing on the P first output sub - data corresponding to each input sub - data to obtain the first conversion data includes:[[]] Splicing the Q first output sub - data corresponding to each input sub - data along the second dimension to obtain P second output sub - data corresponding one - to - one to the P input sub - data, and the batch size of each second output sub - data in the second dimension is Q; Splicing the P second output sub - data along the second dimension to obtain the first conversion data, and the batch size of the first conversion data in the first dimension is P.

8. The method according to any one of claims 1-7, characterized in that, The number of dimensions of the first conversion data is 4, and the number of dimensions of the first intermediate data is 2.

9. An electronic device, characterized in that, Including:[[]] A memory for storing instructions executed by one or more processors of the electronic device; And a processor, which is one of the processors of the electronic device, for running the instructions to enable the electronic device to implement the data processing method according to any one of claims 1 to 8.

10. A readable medium, characterized in that, The readable medium contains instructions that, when executed by a processor of an electronic device, cause the electronic device to implement the data processing method according to any one of claims 1 to 8.