Data processing method and device

The method addresses the time-consuming normalization issue in neural network models by segmenting data, updating parameters in real-time, and utilizing parallel threads and cache optimization for efficient Softmax calculation, resulting in reduced processing time and enhanced performance.

WO2025251898A1PCT designated stage Publication Date: 2025-12-11SMARTER SILICON (SHANGHAI) TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
PCT/CN2025/095958
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Priority Date
2024-06-06
Filing Date
2025-05-20
Publication Date
2025-12-11

AI Technical Summary

Technical Problem

Normalization operations in neural network models based on attention mechanisms are time-consuming, necessitating a reduction in processing time to enhance performance.

Method used

A data processing method involving sequential reception of data segments, updating characteristic parameters based on each segment, and processing data using these parameters to obtain results, utilizing parallel threads and cache optimization for efficient Softmax calculation.

Benefits of technology

This approach significantly reduces processing time and enhances performance by enabling real-time parameter updates and cache optimization, thereby improving data processing efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN2025095958_11122025_PF_FP_ABST
    Figure CN2025095958_11122025_PF_FP_ABST
Patent Text Reader

Abstract

A data processing method for performing Softmax calculation includes: sequentially receiving a plurality of data segments of a first data set to be processed, the plurality of data segments being obtained by segmenting the first data set based on a data transmission order, each data segment including at least one piece of data to be processed; when receiving an ith data segment, updating a characteristic parameter of the first data set based on the ith data segment, i being a positive integer, and the characteristic parameter of the first data set being previously updated and obtained upon receiving an (i-1)th data segment; and after determining that the first data set has been received, processing each piece of data in the first data set using a target processing method based on the characteristic parameter of the first data set to obtain a processing result.
Need to check novelty before this filing date? Find Prior Art

Description

DATA PROCESSING METHOD AND DEVICECROSS-REFERENCE TO RELATED APPLICATION

[0001] This application claims priority to Chinese Patent Application No. 202410733640.7, filed on June 6, 2024, the entire content of which is incorporated herein by reference. FIELD OF TECHNOLOGY

[0002] The present disclosure relates to the field of data processing technology and, more specifically, to a data processing method and device.BACKGROUND

[0003] With the development of artificial intelligence technology, various neural network models based on attention mechanisms have been widely used in various fields.

[0004] Compared with other neural networks, the attention mechanism adds a complex normalization (Softmax) operation. However, normalization operations often take a long time. Therefore, there is a need to shorten the time consumption of normalization operations to improve the processing performance of neural network models based on attention mechanisms.SUMMARY

[0005] One aspect of this disclosure provides a data processing method for performing Softmax calculation. The data processing method includes sequentially receiving a plurality of data segments of a first data set to be processed, the plurality of data segments being obtained by segmenting the first data set based on a data transmission order, each data segment including at least one piece of data to be processed; when receiving an ith data segment, updating a characteristic parameter of the first data set based on the ith data segment, i being a positive integer, and the characteristic parameter of the first data set being previously updated and obtained upon receiving an (i-1) th data segment; and after determining that the first data set has been received, processing each piece of data in the first data set using a target processing method based on the characteristic parameter of the first data set to obtain a processing result.

[0006] Another aspect of this disclosure provides a data processing device. The data processing device includes at least one memory and at least one processor coupled to the at least one memory. The at least one processor is configured to sequentially receive a plurality of data segments of a first data set to be processed, the plurality of data segments being obtained by segmenting the first data set based on a data transmission order, each data segment including at least one piece of data to be processed. The at least one processor is further configured to, when receiving an ith data segment, update a characteristic parameter of the first data set based on the ith data segment, i being a positive integer, and the characteristic parameter of the first data set being previously updated and obtained upon receiving an (i-1) th data segment. The at least one processor is further configured to, after determining that the first data set has been received, process each piece of data in the first data set using a target processing method based on the characteristic parameter of the first data set to obtain a processing result.

[0007] Another aspect of this disclosure provides a non-transitory computer readable storage medium storing computer instructions, when executed by one or more processors, the computer instructions implement the data processing method in the present disclosure.BRIEF DESCRIPTION OF THE DRAWINGS

[0008] In order to provide a clearer illustration of various embodiments of the present disclosure or technical solutions in conventional technology, the drawings used in the description of the disclosed embodiments or the conventional technology are briefly described below. The following drawings are merely embodiments of the present disclosure. Other drawings may be obtained based on the disclosed drawings by those skilled in the art without creative efforts.

[0009] FIG. 1 is a flowchart of a data processing method according to some embodiments of the present disclosure.

[0010] FIG. 2 is a timing diagram of the data processing method according to some embodiments of the present disclosure.

[0011] FIG. 3 is a timing diagram of another data processing method according to some embodiments of the present disclosure.

[0012] FIG. 4 is a schematic structural diagram of a data processing device according to some embodiments of the present disclosure.

[0013] FIG. 5 is a schematic structural diagram of another data processing device according to some embodiments of the present disclosure.DETAILED DESCRIPTION

[0014] Technical solution according to various disclosed embodiments is described below with reference to the drawings. The described embodiments are merely some of embodiments of the present disclosure, but not all embodiments of the present disclosure. Other embodiments obtained based on the disclosed embodiments by those skilled in the art without creative efforts are within the scope of the present disclosure.

[0015] Embodiment of the present disclosure provide a data processing method for performing Softmax calculation.

[0016] The data processing method provided in the embodiments of the present disclosure can be applied to any data processing scenario of a neural network model based on the attention mechanism. For example, the data processing method can be applied to scenarios such as text generation, speech generation, and image generation of the artificial intelligence generated content (AIGC) model, as well as image classification scenarios of the vision transformer (ViT) model.

[0017] FIG. 1 is a flowchart of a data processing method according to some embodiments of the present disclosure. The method will be described in detail below.

[0018] 101, sequentially receiving a plurality of data segments of a first data set to be processed, the data segments being obtained by segmenting the first data set based on a data transmission order, each data segment including at least one piece of data to be processed.

[0019] In some embodiments, based on different scenarios, the first data set may have different sources.

[0020] For example, in a text generation scenario based on the AIGC model, the AIGC model may obtain the input text data and generate the output text data based on the input text data. In this application scenario, the first data set may be the text feature data extracted from input text data.

[0021] In the speech generation scenario based on the AIGC model, the AIGC model may obtain the input speech data and convert the input speech data into the output speech data that meets the requirements. For example, the input speech data generated by user A speaking can be converted into the output speech data that imitates the voice of user B. In this application scenario, the first data set may be the speech feature data extracted from the input speech data.

[0022] In the image classification scenario based on the ViT model, the ViT model may obtain the to-be-classified image data, process the image data, and output the classification result corresponding to the image data. In this application scenario, the first data set may be the image feature data extracted from the to-be-classified image data.

[0023] The various feature data in the above examples can be in the form of vectors or matrices, and each element in the vector or matrix can be used as one piece of to-be-processed data in the first data set.

[0024] In some embodiments, each data segment of the first data set may include one or more pieces of to-be-processed data.

[0025] In some embodiments, each data segment may include only one piece of to-be-processed data. For example, assume that the first data set includes 1000 pieces of to-be-processed data, the first data set can be divided into 1000 data segments, and each piece of the to-be-processed data can be a data segment.

[0026] In some embodiments, each data segment may also include a plurality of to-be-processed data, for example, m pieces of to-be-processed data. For example, assume that the first data set includes 10,000 pieces of to-be-processed data, and m is 20. Then the first data set can be divided into 500 data segments. The 1st to the 20th to-be-processed data can be the first data segment, the 21st to the 40th to-be-processed data can be the second data segment, etc.

[0027] In some embodiments, the amount of the to-be-processed data included in each data segment may be determined based on a performance indicator of the electronic device, and the electronic device may be an electronic device used to process the to-be-processed data. For example, the amount of to-be-processed data included in the data segment may be determined based on the frequency of the processor of the electronic device and the frequency of the cache of the electronic device. Generally, the higher the frequency of the processor, the faster the processor calculates data, and the higher the frequency of the cache, the faster the processor reads and writes data from the cache.

[0028] In the embodiments of the present disclosure, the less the to-be-processed data t each data segment includes, the greater the amount of calculation required by the processor when processing the data, and the more the to-be-processed data each data segment includes, the larger the amount of data that the processor needs to read and write from the cache when processing data. Therefore, for electronic devices with a higher processor frequency and a lower cache frequency, each data segment can be set to include fewer piece of the to-be-processed data. For example, each piece of data in the first data set can be regarded as a data segment, that is, a data segment only includes one piece of to-be-processed data. For electronic devices with lower processor frequency and higher cache frequency, each data segment can be set to include more pieces of the to-be-processed data. For example, every 20 or 40 consecutive to-be-processed data n the first data set can be taken as a data segment, that is, one data segment may include 20 or 40 pieces of to-be-processed data.

[0029] 102, when receiving the ith data segment, updating a characteristic parameter of the first data set based on the ith data segment, i being a positive integer, and the characteristic parameter of the first data set being previously updated and obtained in response to receiving an (i-1) th data segment.

[0030] In some embodiments, based on different calculation methods for the first data set, the characteristic parameter of the first data set to be updated in the process at 102 may also be different.

[0031] For example, when Softmax calculation needs to be performed on the first data set, the characteristic parameter of the first data set that need to be updated in the process at 102 may include a maximum value max of the first data set and the accumulated value row_sum of the power operation result of the first data set.

[0032] In combination with the above example, in the process at 102, the electronic device may calculate the received ith data segment based on the following formula to update the maximum value of the first data set and the accumulated value of the power operation result.

[0033] The maximum value of the first data set can be updated based on the following formula (1) :

[0034] maxi=MAX (maxi-1, Xi)       (1)

[0035] In formula (1) , maxi-1 represents the maximum value after the (i-1) th update and before the ith update, Xi represents the ith data segment, and maxi represents the maximum value of the first data set after the (i-1) th update, that is, after performing the process at 102. MAX (maxi-1, Xi) represents the maximum value among all the to-be-processed data included in maxi-1 and the ith data segment.

[0036] The value range of i can be greater than or equal to 1 and less than or equal to N, where N is the number of data segments included in the first data set. For example, if a first data set including 10,000 pieces of to-be-processed data is divided into data segments, each segment including 20 pieces of to-be-processed data, then the first data set can be divided into 500 data segments, and the corresponding N equals to 500. When i equals to 1, maxi-1 may be equal to a preset initial value, for example, 0.

[0037] In this embodiment, the (i-1) th update can be understood as an update process performed by the electronic device based on the (i-1) th data segment of the data set, and the ith update can be understood as an update process performed based on the ith data segment of the data set. For example, after the first data segment of the first data set is received, the characteristic parameter of the first data set can be updated based on the first data segment, and this process is equivalent to the first updating process.

[0038] Continue with the above example, after the maximum value of the first data set is updated based on the ith data segment, the accumulated value row_sum of the power operation result of the first data set can be updated based on the following formula (2) :

[0039]

[0040] In formula (2) , row_sumi-1 represents the accumulated value of the power operation result of the first data set before the ith update after the (i-1) th update, row_sumi represents the accumulated value of the power operation result of the first data set after the ith update, and exp () represents the result of the power operation with the natural constant e as the base and the data in the brackets as the exponent. For example, exp (2) represents the square of the natural constant e. m represents the number of unprocessed data included in each data segment, and xik represents the kth unprocessed data included in the ith data segment.

[0041] In some embodiments, when i equals to 1, row_sumi-1 may be equal to a preset initial value, for example, 0.

[0042] For example, assume that a data segment includes 10 pieces of to-be-processed data, after receiving the first data segment, the first updated row_sum1 obtained by updating row_sum0 based on to the first data segment can be expressed by the following formula (3) :

[0043]

[0044] After receiving the second data segment, the second updated row_sum2 obtained by updating row_sum1based on the second data segment can be expressed as follows:

[0045]

[0046] In some embodiments, when each data segment includes only one piece of to-be-processed data, the above formula (2) can be transformed into the following formula (5) :

[0047] row_sumi=row_sumi-1×exp (maxi-1-maxi) +exp (xi-maxi)  (5)

[0048] In the process at 102, the electronic device may synchronously update the characteristic parameter of the first data set while receiving the data segments.

[0049] For example, when each data segment includes one piece of to-be-processed data, before the electronic device receives a data segment and writes it into the cache, the updating process of the process at 102 can be completed based on the data segment. In this case, each time the processor of the electronic device receives a to-be-processed data, it first updates the maximum value based on the to-be-processed data, and then updates the accumulated value of the power operation result based on the to-be-processed data. After the two updates are completed, the to-be-processed data is written into the cache, and then the next to-be-processed data is received and the above process is repeated.

[0050] In the case where each data segment includes a plurality of pieces of to-be-processed data, taking the ith data segment as an example, the electronic device can update the maximum value of the first data set based on the ith data segment while receiving the ith data segment and writing it into the cache. After the ith data segment is received, during the reception of the (i+1) th data segment, the electronic device updates the accumulated value of the power operation result based on the ith updated maximum value and the ith data segment.

[0051] The method of updating the maximum value of the first data set based on the ith data segment while receiving the ith data segment and writing it into the cache may be as follows. The processor of the electronic device receives a plurality of pieces of to-be-processed data in the ith data segment in sequence. Each time a to-be-processed data is received, the to-be-processed data can be compared with the maximum value after the most recent update, the larger value can be determined as the maximum value after the next update, and then the to-be-processed data can be written into the cache. When the processor completes the above update operation on each piece of data to be processed in the ith data segment, the maximum value at this time is the maximum value after the ith update obtained based on the update of the ith data segment.

[0052] After obtaining the maximum value after the ith update, the accumulated value of the power operation result can be updated based on the maximum value after the ith update and the ith data segment. The update method may be as follows. Sequentially read each piece of data of the ith data segment from the cache. Each time a to-be-processed data is read, the difference between the to-be-processed data and the maximum value after the ith update can be calculated, and then the difference can be used as the exponent to perform a power operation with a natural constant as the base to obtain the power operation result corresponding to the to-be-processed data. The power operation result can be accumulated with the power operation result corresponding to the previous to-be-processed data in the ith data segment. After processing all the to-be-processed data in the ith data segment in this way, the accumulated value of the piecewise power operation results corresponding to the ith data segment can be obtained, that is, the accumulated term on the right side of the plus sign in the above formula (2) can be obtained. Subsequently, the processor can determine the accumulated value of the power operation result after the ith update based on the above formula (2) . The accumulated value of the power operation result after the ith update can be determined by using the accumulated value of the power operation result after the (i-1) th update, the maximum value after the (i-1) th update, the maximum value after the ith update, and the accumulated value of the segmented power operation result corresponding to the ith data segment.

[0053] In the process of receiving the ith data segment and writing it into the cache and updating the maximum value of the first data set based on the ith data segment, the processor of the electronic device can simultaneously update the accumulated value of the power operation result based on the maximum value after the (i-1) th update and the (i-1) th data segment based on the above update method to obtain the accumulated value of the power operation result after the (i-1) th update.

[0054] 103, after determining that the first data set has been received, processing each piece of data in the first data set based on the characteristic parameter of the first data set and a target processing method to obtain the processing result.

[0055] Each data segment in the first data set received in the process at 102 may be stored in a cache of the electronic device. After determining that the first data set has been received, the processor of the electronic device can read the first data set from the cache, process each of the to-be-processed data based on the characteristic parameters of the first data set, and obtain the corresponding processing result.

[0056] In some embodiments, the characteristic parameter of the first data set used in the process at 103 may be the characteristic parameter updated for the last time (i.e., updated for the Nth time) .

[0057] In some embodiments, depending on the calculation method of the first data set, the target processing method in the process at 103 may be different.

[0058] For example, when there is a need to perform Softmax calculation on the first data set, processing the to-be-processed data based on the target processing method in the process at 103 may include processing the data to be processed based on formula (6) .

[0059]

[0060] In formula (6) , maxN and row_sumN represent the maximum value and the accumulated value of the power operation result of the first data set after the last update, respectively. xi represents the ith to-be-processed data in the first data set, the value of i being 1 to M. M is the total number of to-be-processed data included in the first data set. For example, if the first data set contains 1000 pieces of to-be-processed data, then M is equal to 1000. Softmax (xi) represents the processing result corresponding to the ith to-be-processed data.

[0061] Consistent with the present disclosure, the to-be-processed data of the first data set can be received in segments, and the characteristic parameter of the first data set can be updated in real time after each segment is received. After the first data set is received, each piece of to-be-processed data in the first data set can be processed immediately based on the characteristic parameter of the first data set to obtain the corresponding processing results. In this way, there is no need to spend time to determine the characteristic parameter of the first data set after the first data set is received, thereby improving data processing performance and shortening the time.

[0062] In some embodiments, when the characteristic parameter of the first data set includes a plurality of characteristic parameters, for example, the characteristic parameter includes a first parameter and a second parameter, the electronic device may set a plurality of threads accordingly. Each thread may be used to update the corresponding characteristic parameters, and the synchronous update of the plurality of characteristic parameters can be achieved by synchronously running the plurality of threads.

[0063] Take the characteristic parameter including the first parameter and the second parameter as an example, a first thread and a second thread can be set for the electronic device. At this time, the process at 102 may include updating the first parameter and the second parameter using the first thread and the second thread respectively.

[0064] When the electronic device includes a first thread and a second thread, the electronic device may receive data segments of the first data set and update the first parameter and the second parameter of the first data set based on the timing diagram shown in FIG. 2.

[0065] In FIG. 2, the i data segments received are represented by data segment i. For example, data segment 1 represents the first data segment received after the start of data reception, and data segment 2 represents the second data segment received.

[0066] As shown in FIG. 2, after starting to receive data segments, the first thread first receives the first data segment of the first data set, and during the reception of the first data segment, the first parameter updated for the 0th time is updated in real time based on the first data segment, to obtain the first parameter updated for the 1st time. After the data segment 1 is received, during the time period of receiving the data segment 2, the first thread updates the first parameter updated for the 1st time in real time based on data segment 2 to obtain the first parameter updated for the 2nd time. During this time period, the second thread also starts to work, and updates the second parameter updated for the 0th time based on the data segment 1 and the first parameter updated for the 1st time, thereby obtaining the second parameter updated for the 1st time. In each time period thereafter, the first thread and the second thread both run in parallel, the first thread updates the first parameter based on the data segments received in the current time period, and the second thread updates the second parameter based on the previous data segments received in the previous time period.

[0067] For example, in the first period, the first parameter updated for the (i-1) th time (i.e., obtained from the (i-1) th update) is updated through the first thread based on each piece of data in the ith data segment to obtain the first parameter updated for the ith time. In the first period, the second parameter obtained by the (i-2) th update is also updated through the second thread based on the first parameter updated for the (i-1) th time and the to-be-processed data in the (i-1) th data segment to obtain the second parameter updated for the (i-1) th time. After entering the second period (i.e., during the second period) , the first parameter updated for the i-th time is updated based on each piece of data in the (i+1) th data segment through the first thread to obtain the first parameter updated for the (i+1) th time. In the second period, the second parameter obtained in the (i-1) th update is also updated through the second thread based on the first parameter updated for the ith time and the to-be-processed data in the ith data segment to obtain the second parameter updated for the ith time. This process continues until all data segments are received and the first parameter after the last update and the second parameter after the last update are obtained.

[0068] In the above process, the values of the first parameter updated for the 0th time and the second parameter updated for the 0th time may both be preset initial values, for example, both can be 0.

[0069] In view of the above example, when a normalization operation is performed on the first data set, the first parameter may be the maximum value of the first data set, and the second parameter may be the accumulated value of the power operation result of the first data set. When the process at 102 is performed, the first thread can receive the ith data segment in real time, and update the maximum value of the (i-1) th update in real time based on the received ith data segment to obtain the maximum value of the ith update. At the same time, the second thread also updates the accumulated value of the power operation result updated for the (i-2) th time based on the received (i-1) th data segment in the first period using the maximum value of the (i-1) th update obtained before the first period to obtain the accumulated value of the power operation result updated for the (i-1) th time.

[0070] After the first period ends and the second period begins, the first thread can receive the (i+1) th data segment in real time within the period, and update the maximum value of the ith update in real time based on the received (i+1) th data segment to obtain the maximum value of the (i+1) th update. At the same time, the second thread also updates the accumulated value of the power operation result updated for the (i-1) th time based on the received ith data segment in the second period using the ith updated maximum value obtained in the first period to obtain the accumulated value of the power operation result updated for the ith time.

[0071] Consistent with the present disclosure, by running the first thread and the second thread in parallel, the first parameter and the second parameter corresponding to the first data set can be synchronously updated during the time of receiving the data segments of the first data set in sequence, thereby further shortening the processing time of the first data set and improving the data processing performance.

[0072] In some embodiments, the electronic device may have a temporary storage unit for temporarily storing some data. After each time the characteristic parameter of the first data set is updated in the process at 102, the updated characteristic parameter may be temporarily stored in the temporary storage unit for use in the next update.

[0073] In some embodiments, the temporary storage unit may be arranged in a memory of the electronic device. For example, the temporary storage unit may be a Flop storage unit, and more specifically, the Flop storage unit may be implemented by a register.

[0074] In some embodiments, when the electronic device includes the first thread and the second thread, the first thread and the second thread may also be used to, in the first period, use the first thread to temporarily store the first parameter updated for the ith time, and use the second thread to temporarily store the second parameter updated for the (i-1) th time for use in the next update.

[0075] In view of the above example, when the first data set is normalized, after the first thread obtains the maximum value of the ith update in the first period, the maximum value of the ith update can be temporarily stored. After the second thread obtains the accumulated value of the power operation result updated for the (i-1) th time in the first period, the accumulated value of the power operation result updated for the (i-1) th time can be temporarily stored. After entering the second period, the first thread can obtain the maximum value of the ith update temporarily stored from the temporary storage unit to update it to the maximum value of the (i+1) th update. At the same time, the second thread can obtain the temporarily stored maximum value of the ith update and the accumulated value of the power operation result of the (i-1) th update to update and obtain the accumulated value of the power operation result of the ith update.

[0076] By setting a temporary storage unit, the processor of the electronic device can directly read and write the characteristic parameter before and after each update in the temporary storage unit, thereby reducing the number of times the processor accesses the cache of the electronic device, which further improves processing efficiency, and shortens data processing time.

[0077] In some embodiments, the electronic device may have a cache, and the cache area in the cache may be divided into a plurality of partitions, each partition being used to store a single data segment. The number of partitions may be at least greater than or equal to the number of data segments of the first data set. The cache can be part of the storage area allocated from the memory (DDR) or part of the storage area allocated from the processor's cache.

[0078] In some embodiments, the number of partitions may be equal to the number of data segments in the first data set plus 1. For example, if the first data set is divided into N data segments, then the cache area can be divided into N+1 partitions, and each partition can be used to store one data segment. In this case, the electronic device can store each received data segment in a preset cache area, and each data segment can be stored in a corresponding partition of the cache area.

[0079] In conjunction with the example of FIG. 2, when the electronic device has a first thread for updating the first parameter and a second thread for updating the second parameter, the first thread and the second thread may read and write the cache area as follows.

[0080] In the first period, the first thread receives data segment i, updates the first parameter updated for the (i-1) th time with data segment i, obtains the first parameter updated for the ith time, and writes data segment i to the corresponding partition in the cache area after the update is completed. At the same time, in the first period, the second thread reads data segment (i-1) from the partition storing data segment (i-1) in the cache area, updates the second parameter updated (i-2) th based on data segment (i-1) and the first parameter updated (i-1) th time, and obtains the second parameter updated (i-1) th. time. In the second, the first thread receives data segment (i+1) , updates the first parameter based on data segment (i+1) , obtains the first parameter updated for the (i+1) th time, and writes data segment (i+1) into the corresponding partition in the cache area after the update is completed. At the same time, in the second period, the second thread reads data segment i from the partition storing data segment i in the cache area, updates the second parameter updated (i-1) th time based on data segment i and the first parameter updated ith time, and obtains the second parameter updated ith time.

[0081] In some embodiments, when there are multiple to-be-processed data sets, for example, when the first data set and the second data set need to be processed in sequence, the first data set and the second data set may be read and written from the cache area by sequentially processing each data segment of the first data set based on the target processing method, obtaining the processing result corresponding to each data segment of the first data set, and making the partition corresponding to the data segment as idle; while processing the data segments of the first data set in sequence, sequentially receiving the data segments of the second to-be-processed data set, and storing the received data segments of the second data set in sequence in the partitions that are already in the idle state.

[0082] In some embodiments, the number of data segments of the second data set may be the same as the number of data segments of the first data set. For example, the first data set and the second data set both include N data segments. The number of partitions divided into the cache area may be 1 more than the number of data segments of the first data set, that is, the cache area may be divided into N+1 partitions.

[0083] Refer to FIG. 3. During the reception of the first data set, the electronic device can receive the data segments of the first data set in sequence based on the process at 101. Each time the ith data segment of the first data set is received, based on the process at 102, the characteristic parameter of the first data set can be updated using the ith data segment, and the ith data segment of the first data set can be stored into the corresponding partition in the cache area. This process can be repeated until the first data set is received.

[0084] When the first data set is received, the data storage in the cache area may be as shown in FIG. 3 (1) , where data segment 11 represents the first data segment of the first data set, and data segment 12 represents the second data segment of the first data set. The process continues, and data segment 1N represents the Nth data segment of the first data set, that is, the last data segment of the first data set.

[0085] After the first data set is received, the to-be-processed data in the first data set can be processed based on the characteristic parameter of the first data set to obtain a processing result. At this time, the data segments of the first data set can be processed in sequence, that is, data segment 11, data segment 12, data segment 13, ... until data segment 1N are processed in sequence.

[0086] As shown in FIG. 3 (2) , during the processing of data segment 11 to obtain the processing result, the first data segment of the second data set, i.e., data segment 21, can be synchronously received. The characteristic parameter of the second data set can be updated based on the data segment 21, and the data segment 21 can be stored in the only partition in the cache area that is in an idle state, that is, the partition N+1.

[0087] When the processing of data segment 11 is completed, the process of receiving data segment 21 and storing it in partition N+1 is also completed. The storage state of each partition in the data area is shown in FIG. 3 (3) , where the partition 1 that originally stores the data segment 11 may be marked as being in an idle state.

[0088] In some embodiments, when a partition is marked as idle, the data segments originally stored in the partition may be directly deleted, or the original data segments may be directly overwritten with the newly written data segments instead of being deleted.

[0089] After the processing of data segment 11 is completed, the processing of data segment 12 is entered. At this time, data segment 12 can be read from partition 2 and processed to obtain the processing results of each piece of data in data segment 12. While processing data segment 12, a second data segment of the second data set can be received, that is, data segment 22. The characteristic parameter of the second data set can be updated based on the data segment 22, and the data segment 22 can be stored in the only partition that is in an idle state at this time, that is, partition 1 that originally stored data segment 11.

[0090] The subsequent process is analogous to the above process. For any integer i greater than or equal to 1 and less than or equal to N, the processing process of the ith data segment of the first data set and the process of writing the ith data segment of the second data set into the partition can be performed synchronously. The ith data segment of the second data set can be stored in the partition that originally stored the (i-1) th data segment of the first data set. After the ith data segment of the first data set is processed, the partition where the data segment is located can be marked as idle such that the (i+1) th data segment of the second data set can be stored in the partition. In this way, the N+1 partitions of the cache area can be cyclically used to store the N data segments of the first data set and the N data segments of the second data set in sequence.

[0091] Consistent with the present disclosure, by cyclically using each partition in the cache area, multiple data sets can be processed continuously by occupying only a cache area slightly larger than the data volume of the first data set, thereby improving the utilization rate of the cache area and saving the storage space of the cache.

[0092] Embodiments of the present disclosure provide a data processing device. FIG. 4 is a schematic structural diagram of a data processing device according to some embodiments of the present disclosure. As shown in FIG. 4, the data processing device includes a first processing module 401 and a second processing module 402.

[0093] In some embodiments, the first processing module and the second processing module may be modules inside any processor in an electronic device that processes data using a neural network model.

[0094] For example, if the neural network model is deployed on a server device, the first processing module and the second processing module may be modules installed inside a processor of the server device; if the neural network model is deployed on a smartphone, the first processing module and the second processing module may be modules inside the processor of the smartphone; if the neural network model is deployed on a laptop, the first processing module and the second processing module may be modules inside the processor of the laptop.

[0095] The above processor can be any processor installed on the electronic device. For example, the processor may be a central processing unit (CPU) of an electronic device, a graphics processing unit (GPU) of an electronic device, or a neural-networks processor (NPU) of an electronic device.

[0096] In some embodiments, the first processing module may be configured to sequentially receive a plurality of data segments of a first data set to be processed, the data segments being obtained by segmenting the first data set based on a data transmission order, and each data segment including at least one piece of data to be processed. The first processing module may be further configured to, when receiving the ith data segment, update the characteristic parameter of the first data set obtained by receiving the (i-1) th data segment update based on the ith data segment, i being a positive integer.

[0097] In some embodiments, the second processing module may be configured to, after determining that the first data set has been received, process the to-be-processed data in the first data set based on the characteristic parameter of the first data set and a target processing method to obtain a processing result.

[0098] Embodiments of the present disclosure provides another data processing device. FIG. 5 is a schematic structural diagram of another data processing device according to some embodiments of the present disclosure. As shown in FIG. 5, the first processing module can include a temporary storage unit 501.

[0099] In some embodiments, the first processing module may include a temporary storage unit. The temporary storage unit may be used to store the characteristic parameter of the first data set after each update for use in the next update.

[0100] In some embodiments, as shown in FIG. 5, the first processing module can include a cache 502.

[0101] The cache area of the cache may be divided into a plurality of partitions, each partition may be used to store a single data segment, and the number of partitions may be at least greater than or equal to the number of data segments of the first data set.

[0102] In some embodiments, the second processing module may be further configured to process each data segment of the first data set in sequence based on the target processing method, obtain and output the processing result corresponding to each data segment of the first data set, and mark the partition corresponding to the data segment as in an idle state.

[0103] In some embodiments, the first processing module may be further configured to, while the second processing module sequentially processes each data segment of the first data set, sequentially receive the data segments of a second data set to be processed, and store the received data segments of the second data set in the partitions that are already in an idle state in sequence.

[0104] It should be noted that the various embodiments in the present specification are described in a progressive manner, and each embodiment focuses on differences from other embodiments, and the same similar parts between the various embodiments can be referred to each other.

[0105] For the working principle of the data processing device of this embodiment, reference can be made to the relevant steps of the data processing method of the above embodiment, which will not be described in detail here.

[0106] For the convenience of description, when describing the above system or device, the function is divided into various modules or units and described separately. Of course, when implementing the embodiments of the present disclosure, the function of each unit may be implemented in the same or multiple software and / or hardware.

[0107] A method according to the embodiments of the disclosure can be realized by means of software plus a hardware platform, or can be realized by a hardware platform. Embodiments of the present disclosure can be implemented in the form of a software product stored in a storage medium (such as ROM, RAM, magnetic disc, or optical disc) , which may include a number of instructions for enabling an electronic device, e.g., a mobile phone, a computer, a server, an air conditioner, or a network device, or the like, to perform a method consistent with the disclosure, such as one of the methods described above.

[0108] The terms “first, ” “second, ” “third, ” “fourth, ” or the like in the specification are merely used to distinguish an entity or an operation from another entity or operation, and are not intended to require or indicate that there is any such physical relationship or sequence between these entities or operations. In addition, the terms “including, ” “comprising, ” and variants thereof herein are open, non-limiting terminologies, which are meant to encompass a series of elements of processes, methods, items, or devices. Not only those elements, but also other elements that are not explicitly listed, or elements that are inherent to such processes, methods, items, or devices. In the absence of more restrictions, the elements defined by the statement “include a / an ... ” not preclude that other identical elements are included in the processes, methods, items, or devices that include the elements.

[0109] The embodiments disclosed herein are merely examples. Other applications, advantages, alternations, or modifications of, or equivalents to the disclosed embodiments are obvious to a person skilled in the art and are intended to be encompassed within the scope of the present disclosure.

Claims

1.A data processing method for performing Softmax calculation, comprising:sequentially receiving a plurality of data segments of a first data set to be processed, the plurality of data segments being obtained by segmenting the first data set based on a data transmission order, each data segment including at least one piece of data to be processed;when receiving an ith data segment, updating a characteristic parameter of the first data set based on the ith data segment, i being a positive integer, and the characteristic parameter of the first data set being previously updated and obtained upon receiving an (i-1) th data segment; andafter determining that the first data set has been received, processing each piece of data in the first data set using a target processing method based on the characteristic parameter of the first data set to obtain a processing result.2.The method of claim 1, wherein:the characteristic parameter includes a first parameter and a second parameter; andwhen receiving the ith data segment, updating the characteristic parameter of the first data set based on the ith data segment includes:updating the first parameter and the second parameter using a first thread and s second thread respectively;in a first period, updating the first parameter obtained from an (i-1) th time update based on each piece of data in the ith data segment through the first thread to obtain the first parameter updated for the ith time; andin the first period, updating the second parameter obtained from an (i-2) th update based on the first parameter updated for the (i-1) th time and the data in the (i-1) th data segment through the second thread to obtain the second parameter updated for the (i-1) th time.3.The method of claim 2, further comprising:during the first period, temporarily storing, by the first thread, the first parameter updated for the ith time, and temporarily storing, by the second thread, the second parameter updated for the (i-1) th time for use in a next update.4.The method of claim 1, further comprising:storing each received data segment in a preset cache area, wherein:the cache area is divided into a plurality of partitions, each partition is configured to store a single data segment, and a number of the partitions is at least greater than or equal to a number of data segments of the first data set.5.The method of claim 4, further comprising:sequentially processing each data segment of the first data set based on the target processing method, obtaining and outputting the processing result corresponding to each data segment of the first data set, and marking a partition corresponding to the data segment as in an idle state; andwhile sequentially processing the data segments of the first data set, sequentially receiving the data segments of a second data set to be processed, and sequentially storing the received data segments of the second data set in the partition in the idle state.6.The method of claim 2, further comprising:after the first thread updates the first parameter based on the ith data segment, storing, by the first thread, the ith data segment in the corresponding partition; andwhile the first thread stores the ith data segment in the corresponding partition, obtaining, by the second thread, the (i-1) th data segment from the corresponding partition to update the second parameter.7.A data processing device, comprising:at least one memory; andat least one processor coupled to the at least one memory and configured to:sequentially receive a plurality of data segments of a first data set to be processed, the plurality of data segments being obtained by segmenting the first data set based on a data transmission order, each data segment including at least one piece of data to be processed; when receiving an ith data segment, update a characteristic parameter of the first data set based on the ith data segment, i being a positive integer, and the characteristic parameter of the first data set being previously updated and obtained upon receiving an (i-1) th data segment; andafter determining that the first data set has been received, process each piece of data in the first data set using a target processing method based on the characteristic parameter of the first data set to obtain a processing result.8.The device of claim 7, wherein:the at least one memory includes a temporary storage, the temporary storage being configured to store the characteristic parameter of the first data set after each update for use in a next update.9.The device of claim 7 further comprising:a cache, wherein:a cache area of the cache is divided into a plurality of partitions, the plurality of partitions are configured to store a single data segment, and a number of partitions is at least greater than or equal to a number of data segments of the first data set.10.The device of claim 9, wherein the at least one processor is further configured to:sequentially process each data segment of the first data set based on the target processing method, obtain and output the processing result corresponding to each data segment of the first data set, and mark a partition corresponding to the data segment as in an idle state; andwhile the second processing module sequentially process each data segment of the first data set, sequentially receive the data segments of a second data set to be processed, and sequentially store the received data segments of the second data set in the partition in the idle state.11.A non-transitory computer readable storage medium storing one or more computer instructions, when executed by one or more processors, the computer instructions causing the one or more processors to implement:sequentially receiving a plurality of data segments of a first data set to be processed, the plurality of data segments being obtained by segmenting the first data set based on a data transmission order, each data segment including at least one piece of data to be processed;when receiving an ith data segment, updating a characteristic parameter of the first data set based on the ith data segment, i being a positive integer, and the characteristic parameter of the first data set being previously updated and obtained upon receiving an (i-1) th data segment; andafter determining that the first data set has been received, processing each piece of data in the first data set using a target processing method based on the characteristic parameter of the first data set to obtain a processing result.12.The computer readable storage medium of claim 11, wherein:the characteristic parameter includes a first parameter and a second parameter; andwhen receiving the ith data segment, updating the characteristic parameter of the first data set obtained by receiving the (i-1) th data segment update based on the ith data segment includes:updating the first parameter and the second parameter using a first thread and s second thread respectively;in a first period, updating the first parameter obtained from an (i-1) th time update based on each piece of data in the ith data segment through the first thread to obtain the first parameter updated for the ith time; andin the first period, updating the second parameter obtained from an (i-2) th update based on the first parameter updated for the (i-1) th time and the data in the (i-1) th data segment through the second thread to obtain the second parameter updated for the (i-1) th time.13.The computer readable storage medium of claim 12, wherein the computer instructions further cause the one or more processors to implement:during the first period, temporarily storing, by the first thread, the first parameter updated for the ith time, and temporarily storing, by the second thread, the second parameter updated for the (i-1) th time for use in a next update.14.The computer readable storage medium of claim 11, wherein the computer instructions further cause the one or more processors to implement:storing each received data segment in a preset cache area, wherein:the cache area is divided into a plurality of partitions, each partition is configured to store a single data segment, and a number of the partitions is at least greater than or equal to a number of data segments of the first data set.15.The computer readable storage medium of claim 14, wherein the computer instructions further cause the one or more processors to implement:sequentially processing each data segment of the first data set based on the target processing method, obtaining and outputting the processing result corresponding to each data segment of the first data set, and marking a partition corresponding to the data segment as in an idle state; andwhile sequentially processing the data segments of the first data set, sequentially receiving the data segments of a second data set to be processed, and sequentially storing the received data segments of the second data set in the partition in the idle state.16.The computer readable storage medium of claim 12, wherein the computer instructions further cause the one or more processors to implement:after the first thread updates the first parameter based on the ith data segment, storing, by the first thread, the ith data segment in the corresponding partition; andwhile the first thread stores the ith data segment in the corresponding partition, obtaining, by the second thread, the (i-1) th data segment from the corresponding partition to update the second parameter.