Method, device and related product for processing data

By distributing high-precision data to intervals and mapping to low-precision formats, the problem of increased computational complexity in neural networks is solved, efficient data processing and computing resource utilization are achieved, and the processing efficiency of machine learning models is significantly improved.

CN112434781BActive Publication Date: 2024-09-10SHANGHAI CAMBRICON INFORMATION TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN201910792847.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2019-08-26
Publication Date
2024-09-10
Estimated Expiration
2039-08-26

AI Technical Summary

Technical Problem

As the number of neural network layers increases and the computational complexity increases, it is difficult for existing technologies to effectively utilize limited computing resources for efficient data processing, especially when processing large-scale floating-point data, resulting in insufficient computing power of computing devices and affecting machine learning. model efficiency.

Method used

By distributing data in a high-precision format into a predetermined number of intervals, determining the average value of the data, and mapping it to a low-precision format, and using a truncation threshold to quantify the data, the high-precision data is converted into a low-precision format, reducing data processing. volume and transmission volume, and improve the computing resource utilization of computing devices.

Benefits of technology

It achieves high-precision data processing accuracy while reducing the amount of data processing, significantly accelerates data exchange, and improves the processing efficiency and resource utilization of computing equipment.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112434781B
    Figure CN112434781B
Patent Text Reader

Abstract

The present disclosure relates to a method, device and related products for processing data. In an embodiment of the present disclosure, when processing data related to a neural network, an optimal truncation threshold of multiple data is determined. The data is truncated using the truncation data threshold, and the multiple data are quantized from a high-precision format to a low-precision format. The method in the present disclosure reduces the amount of data processing while ensuring the accuracy of data processing as high as possible. In addition, the method also helps to significantly reduce the amount of data transmission, thereby greatly accelerating the data exchange between multiple computing devices.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of computer technology, and in particular to a method and device for processing data and related products. Background Art

[0002] With the development of computer technology, deep learning algorithms are increasingly being used to handle various complex tasks. Using deep learning algorithms to process data has achieved good results in search technology, data mining, machine learning, machine translation, natural language processing, multimedia learning, speech, recommendation and personalization technology, and other related fields.

[0003] As the number of network layers increases, the computational complexity increases, and improving the computing power of devices is very important for the development of deep learning. Therefore, people use various methods to improve the computing power of devices. However, there are still many problems to be solved in improving computing power in the process of machine learning. Summary of the invention

[0004] In view of this, the present disclosure provides a method, an apparatus, and related products that can be used to process data.

[0005] According to a first aspect of the present disclosure, a method for processing data is provided. The method includes obtaining a plurality of data for a machine learning model, the data being represented in a first data format. The method also includes distributing the plurality of data in a first group of intervals based on the values ​​of the plurality of data, the number of the first group of intervals being predetermined. The method also includes determining a first average value of the plurality of data. The method also includes mapping the data distributed in the first group of intervals to a second group of intervals according to a plurality of different mapping units, so as to determine a second average value of the mapped data according to the corresponding mapping units, wherein the mapping unit includes a predetermined number of continuous intervals starting from a first interval of the first group of intervals, wherein the end interval of the mapping unit is distributed with data greater than or located in the end interval among the plurality of data, the number of intervals in the second group of intervals being related to a second data format, and the precision of the second data format being lower than that of the first data format. The method also includes performing processing on the plurality of data based on the first average value and a plurality of second average values, so that the processed plurality of data are represented in a second data format.

[0006] According to a second aspect of the present disclosure, a device for processing data is provided. The device includes an acquisition module configured to obtain multiple data for a machine learning model, the data being represented in a first data format; a distribution module configured to distribute the multiple data in a first group of intervals based on the values ​​of the multiple data, the number of the first group of intervals being predetermined; a first average value determination module configured to determine a first average value of the multiple data; a first mapping module configured to map the data distributed in the first group of intervals to a second group of intervals according to a plurality of different mapping units, so as to determine a second average value of the mapped data according to the corresponding mapping unit, wherein the mapping unit includes a predetermined number of continuous intervals starting from a first interval of the first group of intervals, wherein an end interval of the mapping unit is distributed with data of the multiple data that is greater than or located in the end interval, the number of intervals in the second group of intervals is related to a second data format, and the precision of the second data format is lower than that of the first data format; and an execution module configured to perform processing on the multiple data based on the first average value and the plurality of second average values, so that the processed multiple data are represented in the second data format.

[0007] According to a third aspect of the present disclosure, an artificial intelligence chip is provided. The artificial intelligence chip includes a processor; and a memory storing computer program instructions, wherein the processor runs the computer program instructions in the memory to control the artificial intelligence chip to execute the method according to the first aspect.

[0008] According to a fourth aspect of the present disclosure, an electronic device is provided. The electronic device is based on the artificial intelligence chip described in the third aspect of the present disclosure.

[0009] According to the fifth aspect of the present disclosure, a board is provided. The board includes: a storage device, an interface device, a control device, and the artificial intelligence chip according to the third aspect of the present disclosure; wherein the artificial intelligence chip is connected to the storage device, the control device, and the interface device respectively; the storage device is used to store data; the interface device is used to realize data transmission between the artificial intelligence chip and an external device; the control device is used to monitor the status of the artificial intelligence chip.

[0010] By deducing the technical features in the claims, the beneficial effects of the technical problems in the corresponding background technologies can be achieved. Other features and aspects of the present disclosure will become clear from the following detailed description of exemplary embodiments with reference to the accompanying drawings. BRIEF DESCRIPTION OF THE DRAWINGS

[0011] The accompanying drawings, which are included in and constitute a part of the specification, illustrate exemplary embodiments, features and aspects of the present disclosure together with the specification, and are used to explain the principles of the present disclosure. In the exemplary embodiments of the present disclosure, the same reference numerals generally represent the same components.

[0012] Figure 1 A schematic diagram illustrating an example environment 100 in which devices and / or methods according to embodiments of the present disclosure may be implemented;

[0013] Figure 2 illustrates a flow chart of a process 200 for processing data according to an embodiment of the present disclosure;

[0014] Figure 3 illustrates a flow chart of a process 300 for processing data according to an embodiment of the present disclosure;

[0015] Figure 4 The figure shows a structural block diagram of a device 400 for processing data according to an embodiment of the present disclosure.

[0016] Figure 5 FIG. 5 is a block diagram of a board 500 according to an embodiment of the present disclosure.

[0017] In the various drawings, the same or corresponding reference numerals represent the same or corresponding parts. DETAILED DESCRIPTION

[0018] The following will be combined with the drawings in the embodiments of the present disclosure to clearly and completely describe the technical solutions in the embodiments of the present disclosure. Obviously, the described embodiments are part of the embodiments of the present disclosure, not all of the embodiments. Based on the embodiments in the present disclosure, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present disclosure.

[0019] It should be understood that the terms "first", "second", "third", and "fourth" in the claims, specifications, and drawings of the present disclosure are used to distinguish different objects rather than to describe a specific order. The terms "include" and "comprise" used in the specifications and claims of the present disclosure indicate the presence of the described features, wholes, steps, operations, elements, and / or components, but do not exclude the presence or addition of one or more other features, wholes, steps, operations, elements, components, and / or their collections.

[0020] It should also be understood that the terms used in this disclosure are only for the purpose of describing specific embodiments and are not intended to limit the disclosure. As used in this disclosure and claims, the singular forms of "a", "an", and "the" are intended to include the plural forms unless the context clearly indicates otherwise. It should also be further understood that the term "and / or" used in this disclosure and claims refers to any combination of one or more of the associated listed items and all possible combinations, including these combinations.

[0021] As used in this specification and claims, the term "if" may be interpreted as "when" or "upon" or "in response to determining" or "in response to detecting," depending on the context. Similarly, the phrase "if it is determined" or "if [described condition or event] is detected" may be interpreted as meaning "upon determination" or "in response to determining" or "upon detection of [described condition or event]" or "in response to detecting [described condition or event]," depending on the context.

[0022] With the development of neural network algorithms, the number of layers in the neural network is increasing. This development trend makes the computational complexity higher and higher. In addition, this development trend of neural networks requires a significant development in the computing power of computing devices. In some cases, due to the limitation of computing resources, it is not possible to make good use of limited computing resources to process neural network algorithms.

[0023] The data processed in computing devices is generally 32-bit floating point data. When the amount of such floating point data to be processed is very large, the computing device needs to provide strong computing power and a large storage space to store this data. In addition, if the amount of data transmitted during the transmission process is too large, it will also affect the efficiency of machine learning model processing.

[0024] In order to solve at least one existing problem, the present disclosure proposes a method for processing data. By distributing the processed data related to the neural network into a predetermined number of intervals, and then selecting the optimal truncation threshold based on the average value of the data. The data is truncated using the truncation data threshold, and the data is quantized from a high-precision format to a low-precision format. For example, 32-bit floating-point data is converted to 8-bit integer data. The method in the present disclosure reduces the amount of data processing while ensuring the accuracy of data processing as high as possible. In addition, the method also helps to significantly reduce the amount of data transmission, thereby greatly accelerating the data exchange between multiple computing devices.

[0025] Figure 1 A schematic diagram of an example environment 100 is illustrated in which devices and / or methods according to embodiments of the present disclosure may be implemented.

[0026] In the example environment 100, a plurality of data 102 related to a machine learning model is included. Each of the plurality of data 102 has the same high precision format. The precision format of the data 102 is only relative to the precision of the plurality of data 104 after conversion. Figure 1 1 and 2. It is shown that the plurality of data 102 are, for example, 32-bit floating point data. Figure 1 The number of bits of the data 102 being 32 bits is only for example and not for limitation of the disclosure. The data 102 may be any suitable relatively high precision format data, such as 64-bit double precision data or any suitable precision data set as required.

[0027] In some embodiments, the machine learning model is a neural network model, which includes, but is not limited to, a convolutional neural network model, a recursive neural network model, and the like.

[0028] In some embodiments, in some embodiments, the multiple data 102 related to the machine learning model can be weight values, input neuron data, output neuron data, and / or bias values ​​of the machine learning model. The above examples are only used to describe the present disclosure, but not to specifically limit the present disclosure. The multiple data 102 related to the machine learning model can be any relevant data used or to be processed in the machine learning model.

[0029] The plurality of data 102 related to the machine learning model is converted into a plurality of data 104 in a low-precision format through processing by a computing device. Figure 1 As shown, multiple data 102 are converted from floating point data in a 32-bit high-precision format to multiple 8-bit integer data 104 in a low-precision format. Each data in the multiple data 104 is represented by 8 bits. Therefore, the multiple data 104 can represent a range between -128 and 127. It should be understood that the low-precision format of the multiple data 104 is only relative to the precision format of the data 102 before conversion. Figure 1 The fact that each of the plurality of data 104 is represented by 8 data bits is merely an example and is not a specific limitation of the present disclosure. Therefore, the precision format of the plurality of data 104 can be any suitable data type with a lower precision format than the plurality of data 102.

[0030] Computing devices used to convert data in a high-precision format to a low-precision format include, but are not limited to, personal computers, server computers, handheld or laptop devices, mobile devices (such as mobile phones, personal digital assistants (PDAs), media players, etc.), multiprocessor systems, consumer electronics, minicomputers, mainframe computers, distributed computing environments including any of the above systems or devices, etc.

[0031] In the process of converting the plurality of data 102 into the plurality of data 104 by the computing device, the maximum value of the absolute value of the data in the plurality of data 102 is first determined. Then the entire range from 0 to the maximum value is divided into a set of intervals of a predetermined number N. The plurality of data 102 is distributed into the set of intervals according to the size of their absolute values. The predetermined number N can be any suitable value. Preferably, the predetermined number N is greater than the maximum value of the data in the low-precision format. For example, when an integer is represented by 8 bits, the maximum value represented by 8 bits is 127. Therefore, the predetermined number N can be a value greater than 127, such as 256, 528, 1024, 2048.

[0032] The computing device determines a first average value of the plurality of data before performing the interval conversion. The computing device also forms a mapping unit with the first j intervals in a group of intervals, where j is a positive integer greater than 0, and j changes from a value M less than N to N, so that N-M+1 mapping units can be formed. Preferably, M=the maximum value represented by the data in the low-precision format+1. In the example of the aforementioned data 102, for example, M=127+1=128.

[0033] The computing device may map N-M+1 mapping units to a second group of intervals of a second number divided based on the number of bits of the data in the low-precision format, respectively, for determining a second average value of the mapped data according to the corresponding mapping unit. For each mapping unit, the computing device may obtain a second average value of the data after being mapped to the second interval. For each mapping unit, the computing device may determine the difference between the first average value and the second average value. In one example, the mapping unit with the smallest difference is determined, that is, the size of j is determined. A truncation threshold may be determined based on the size of j. Then, the data is truncation processed, that is, the data greater than the truncation threshold in the multiple data is modified to the truncation threshold. Then, a scaling value is determined using the truncation value. The multiple data that have been truncation processed are scaled using the scaling value to convert the data into multiple data 104 having a second data format.

[0034] After converting the plurality of data 102 into the plurality of data 104 , the plurality of data 104 may be provided to a machine learning model for processing 106 by the machine learning model.

[0035] above Figure 1 A schematic diagram of an example environment 100 in which devices and / or methods according to embodiments of the present disclosure may be implemented is shown below. Figure 2 A process 200 for processing data according to an embodiment of the present disclosure is described, wherein Figure 2 A flow chart of a process 200 for processing data according to an embodiment of the present disclosure is illustrated.

[0036] like Figure 2As shown, at box 202, the computing device obtains a plurality of data for a machine learning model, and the plurality of data is represented in a first data format. Figure 1 As shown, the computing device obtains a plurality of data 102 , and each data in the plurality of data 102 is in a 32-bit floating point format. Figure 1 The fact that each of the plurality of data 102 is in a 32-bit floating point format is merely an example and is not a specific limitation to the present disclosure.

[0037] In some embodiments, the multiple data used for the machine learning model are weight values, input neuron data, output neuron data, and / or bias values ​​in the machine learning model. The above examples are only used to describe the present disclosure, but are not specifically limited to the present disclosure. The multiple data used for the machine learning model can be any relevant data used in the machine learning model.

[0038] At box 204, the computing device distributes the multiple data in a first group of intervals based on the values ​​of the multiple data, and the number of the first group of intervals is predetermined. In order to quantize the data, the data is generally distributed into a predetermined number of intervals. In some embodiments, the number N of data intervals can be set to any suitable number. For example, 256, 1024 or 2048. Alternatively or additionally, the number N of data intervals can be selected to be greater than the maximum integer represented by the converted data type. For example, when the data to be converted is an 8-bit integer, the maximum integer represented by the 8-bit integer is 127, therefore, a number greater than 127 can be selected as the number of intervals. For example, the number N of data intervals can be 256, 512, 1024 or 2048.

[0039] After determining the number N of intervals to be divided, the data with the largest absolute value among the multiple data is determined, and then the entire data interval between 0 and the maximum absolute value is divided into a first group of intervals including N intervals.

[0040] At block 206, the computing device determines a first average of the plurality of data. In order to measure the accuracy of the conversion, the present disclosure measures the accuracy of the conversion by the difference between the average of the data before the conversion and the average of the data after the conversion. Therefore, it is necessary to calculate the average of the plurality of data before the conversion.

[0041] In some embodiments, when calculating the average value of the received multiple data, the computing device first determines the absolute value of the multiple data and the number of the multiple data. Then, the computing device determines the average value based on the absolute value and the number of data in the multiple data. For example, the absolute values ​​of all data are summed and then divided by the number of absolute values ​​to determine the first average value of the data to be processed.

[0042] In some embodiments, when calculating the first average value of the received multiple data, the computing device determines the median value of each interval in the first group of intervals and the number of data in each interval. For ease of calculation, the median value of each interval is used as the average value of the data in the interval. Then, the computing device determines the average value based on the median value of each interval and the number of data in the interval. More specifically, the computing device multiplies the median value of each interval by the number of data in each interval, adds the sum, and then divides it by the total number of data to determine the first average value of the data.

[0043] In some embodiments, when determining the first average value of multiple data, the first average value is associated with the corresponding mapping unit. The computing device first determines the number of data in each interval of the mapping unit and the median value of each interval, where one mapping unit corresponds to the first j intervals starting from the first interval in the first group of intervals, and the last interval of the j intervals is used as the end interval. Then, the data in the interval after the end interval in the first group of intervals are placed in the end interval. That is, the number of data in the end interval of the mapping unit is now the sum of the number of data in the interval corresponding to the end interval in the first group of intervals and all intervals after the interval. Then, the computing device determines the first average value based on the number of data in each interval and the median value of each interval.

[0044] At box 208, the computing device maps the data distributed in the first group of intervals to the second group of intervals according to multiple different mapping units for determining a second average value of the mapped data according to the corresponding mapping units, wherein the mapping unit includes a predetermined number of continuous intervals starting from the first interval of the first group of intervals, wherein the end interval of the mapping unit is distributed with data of the multiple data that is greater than or located at the end interval, and the number of intervals in the second group of intervals is related to a second data format, and the precision of the second data format is lower than that of the first data format.

[0045] After dividing the plurality of data into the first group of intervals, the first j intervals are selected from the first group of intervals as mapping units, and the value of j ranges from a value M less than N to the total number of intervals N in the first group of intervals. Therefore, there are N-M+1 mapping units. Preferably, the value of M is greater than the maximum value represented by the data in the low-precision format. In an example, when the data in the low-precision format is 8 bits, the maximum value represented is 127, and M is 128.

[0046] The computing device then maps the N-M+1 mapping units to a second set of intervals of a second number that can be represented by data in the low-precision format. Figure 1If the format of the plurality of data 104 in the mapping unit is an 8-bit integer, the interval in each mapping unit can be mapped to the 128 intervals of the second group of intervals. Therefore, j / 128 intervals in the mapping unit are mapped to one interval in the second group of intervals.

[0047] Then, for each mapping unit, the computing device can obtain a second average value of the data after being mapped to the second interval. After being mapped to the second interval, for each mapping unit, the average value after mapping is determined by the median value of the intervals in the second group of intervals and the number of intervals located therein. For example, the second average value is obtained by multiplying the median value of each interval in the second interval by the number of data in each interval, and then dividing by the total number of data.

[0048] At block 210, the computing device performs processing on the plurality of data based on the first average value and the plurality of second average values, so that the processed plurality of data is represented in a second data format. The process of processing the plurality of data will be described below in conjunction with Figure 3 Describe in detail.

[0049] By using the above method, data in a high-precision format can be converted into data in a low-precision format for processing. Since the number of bits used to represent the data is reduced, the computing resources used to process the data can be reduced. At the same time, since the mapping unit with the smallest difference from the average value of the data before the conversion is selected from multiple mapping units, the accuracy of the processing result can be retained as much as possible.

[0050] above Figure 2 A flowchart of a process 200 for processing data according to an embodiment of the present disclosure is described. Figure 3 describe Figure 2 The process for processing data at block 210, wherein Figure 3 A flow chart of a process 300 for processing data according to an embodiment of the present disclosure is illustrated.

[0051] At block 302, the computing device determines a plurality of difference values ​​related to a plurality of mapping units based on the first average value and a plurality of second average values. After obtaining the first average value of the received plurality of data and the second average value corresponding to each mapping unit, the computing device determines the difference value between the first average value and each second average value. Therefore, the computing device can obtain a plurality of difference values ​​corresponding to a plurality of mappings.

[0052] In one example, the entire interval from 0 to the maximum absolute value of multiple data is divided into 2048 intervals. When multiple data are changed from the first precision format to an 8-bit integer, j changes from 128 to 2047 to select the first j+1 intervals from the 2048 intervals as mapping units. As described above, the first average value mean1 of multiple data can be obtained. For each j value, which corresponds to a mapping unit, the data in the interval after the mapping unit is placed in the last interval of the j+1 intervals of the mapping unit. Then the j+1 interval is mapped to 128 second intervals, and then the middle value of each interval in the 128 second intervals and the number of data in each interval in the second interval are determined. Then the product of the middle value of each interval in the j+1 intervals and the number of data in the interval is added, and then divided by the total number of data to determine the second average value mean2. For each mapping unit, the difference in the average value after the interval truncation process is mean1-mean2.

[0053] At block 304, a truncation threshold for the plurality of data is determined based on the plurality of difference values. The computing device determines a mapping unit corresponding to the smallest difference value among the plurality of difference values ​​based on the plurality of difference values. In one example, after obtaining the plurality of difference values, the computing device divides each difference value among the plurality of difference values ​​by the first average value corresponding thereto to obtain a plurality of difference rates. The mapping unit with the smallest difference rate is selected as the mapping unit. In one example, after obtaining the plurality of difference values, the computing device selects the mapping unit corresponding to the smallest difference value among the plurality of difference values ​​as the selected mapping unit.

[0054] After determining the mapping unit based on multiple difference values, the size of j is determined. Then the truncation threshold can be determined by the size of j. In one example, the truncation threshold can be determined by the following formula (1):

[0055]

[0056] Wherein best_j is the interval number of the mapping unit corresponding to the determined minimum difference or difference rate, N represents the number of intervals in the first group of divided intervals, and absmax represents the maximum absolute value among multiple data.

[0057] At block 306, the computing device truncates the obtained multiple data based on the truncation threshold. After obtaining the truncation threshold, the computing device adjusts the values ​​of the multiple data that are greater than the truncation threshold to the truncation threshold.

[0058] At block 308, the computing device determines a scaling value related to the mapping unit based on the truncation threshold. In one example, after selecting the mapping unit corresponding to the threshold difference, the computing device determines the truncation threshold for the received multiple data based on the number of intervals corresponding to the mapping unit. Then, the scaling value scale is determined using the truncation threshold threshold by the following formula (2).

[0059] scale = threshold / (2 n-1 -1) (2),

[0060] Here, n represents the number of bits of data in the second data format.

[0061] In one example, when the converted data is an 8-bit integer, scale=threshold / 127. The above examples are only used to illustrate the present disclosure, but are not specifically limited to the present disclosure.

[0062] Optionally, at block 310, the computing device performs scaling processing on the truncated multiple data based on the scaling value, and then obtains multiple data in the second data format. In some embodiments, the scaling processing of the multiple data can also be performed on other computing devices.

[0063] By using the above method, when converting data from a first data format to a second data format, an optimal truncation threshold can be found to minimize the error between the data before and after the data format conversion.

[0064] In one embodiment, a plurality of data represented in a first data format for a machine learning model is obtained, for example, a 32-bit floating point format. In order to reduce the amount of data, the plurality of data is converted into a second data format, for example, 8-bit integer data. The maximum absolute value absmax is found from the plurality of data. Then, the interval from 0 to the maximum absolute value is divided into 2048 intervals. Before the conversion, the plurality of data is first distributed into 2048 data intervals according to the size of the absolute value.

[0065] Then count the number of data distributed in each of the 2048 intervals. For example, bin[i] represents the number of data whose absolute values ​​fall between i / 2048absmax and (i+1) / 2048absmax, that is, the number of data falling in the i+1th interval, and bin[0] represents the number of data whose absolute values ​​fall between the first interval 0 and 1 / 2048absmax.

[0066] At this time, a first average value of the plurality of data may be determined. In one example, the first average value mean1 of the plurality of data is determined by adding the absolute values ​​of the plurality of data and dividing by the number of the plurality of data. In one example, the first average value mean1 of the plurality of data may be determined by multiplying the median value of each interval by the number of data in each interval, then adding the products for all intervals, and then dividing by the number of data. In some examples, the first average value mean1 may be determined later when each mapping unit is determined.

[0067] Let j be the number of intervals corresponding to the mapping unit. When the second data format is an 8-bit integer, j varies from 128 to 2047, and each value of j from 128 to 2047 corresponds to a mapping unit.

[0068] For each value of j, bin_before[0] = bin[0], bin_before[1] = bin[1], ..., bin_before[j-2] = bin[j-2], that is, the number of data in the first j-1 interval remains unchanged. That is, the number of data distributed in the jth interval is the sum of the number of data originally distributed in interval j and after interval j.

[0069] At this time, after the data interval is truncated, the average value of the data after the interval is truncated can also be used as the first average value. After the interval is truncated, the intermediate value is multiplied by the number of data in the interval for each interval, and then the product of each interval is added and divided by the total number of data to determine the first average value mean1 for each mapping unit.

[0070] For each j value, that is, corresponding to each mapping unit, bin_before[0], bin_before[1], ..., bin_before[j-1] are compressed to bin_next[0], bin_next[1], ..., bin_next

[127] . That is, the j / 128th bin_before corresponds to a bin_next. Then calculate the average value of the adjusted multiple intervals, that is, multiply the middle value of each interval by the number of data in each interval, divide the sum of the products of all intervals by the total number of data, and obtain the average value mean2 of the second group of intervals corresponding to the mapping unit. Then the difference mean1-mean2 between the first average value and the second average value can be determined.

[0071] The difference ratio between the first mean value mean1 and the second mean value mean2 is calculated by the following formula (3):

[0072] diff_mean = abs(mean1–mean2) / mean1 (3),

[0073] Where abs(mean1-mean2) represents the absolute value of (mean1-mean2).

[0074] Let j change from 128 to 2047, and for each j value there is a corresponding diff_mean, and select the j value corresponding to the smallest diff_mean from all j values. After determining the j value, the truncation threshold can be determined by the above formula (1). Then, the multiple data are truncate. After the truncation process is completed, the quantization of the multiple data is completed by the above formula (2).

[0075] It should be noted that, for the aforementioned method embodiments, for the sake of simplicity, they are all described as a series of action combinations, but those skilled in the art should be aware that the present disclosure is not limited by the order of the actions described, because according to the present disclosure, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all optional embodiments, and the actions and modules involved are not necessarily required by the present disclosure.

[0076] It should be further noted that, although the various steps in the flowchart are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence in the order indicated by the arrows. Unless there is a clear description in this article, the execution of these steps is not strictly limited in order, and these steps can be executed in other orders. Moreover, at least a portion of the steps in the flowchart may include multiple sub-steps or multiple stages, and these sub-steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these sub-steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a portion of the sub-steps or stages of other steps.

[0077] Figure 4A device 400 for processing data is shown, including an acquisition module 402, configured to obtain multiple data for a machine learning model, the data being represented in a first data format; a distribution module 404, configured to distribute the multiple data in a first group of intervals based on the values ​​of the multiple data, the number of the first group of intervals being predetermined; a first average value determination module 406, configured to determine a first average value of the multiple data; a first mapping module 408, configured to map the data distributed in the first group of intervals to a second group of intervals according to a plurality of different mapping units, so as to determine a second average value of the mapped data according to the corresponding mapping units, wherein the mapping unit includes a predetermined number of continuous intervals starting from a first interval of the first group of intervals, wherein an end interval of the mapping unit is distributed with data of the multiple data that is greater than or located at the end interval, the number of intervals in the second group of intervals is related to a second data format, and the precision of the second data format is lower than that of the first data format; and an execution module 410, configured to perform processing on the multiple data based on the first average value and the plurality of second average values, so that the processed multiple data are represented in the second data format.

[0078] In some embodiments, the first mapping module 408 includes: a redistribution module configured to redistribute the data of the multiple data that is larger than the end interval of the mapping unit to the end interval of the mapping unit; and a second mapping module configured to map the multiple mapping units to a second group of intervals respectively for determining a second average value of the mapped data according to the corresponding mapping units.

[0079] In some embodiments, the execution module 410 includes: a difference determination module, configured to determine multiple difference values ​​related to multiple mapping units based on the first average value and multiple second average values; a truncation threshold determination module, configured to determine a truncation threshold for the multiple data based on the multiple difference values; a truncation module, configured to truncate the obtained multiple data based on the truncation threshold; and a scaling value determination module, configured to determine a scaling value related to the mapping unit based on the truncation threshold.

[0080] In some embodiments, the execution module 410 further includes: a scaling module configured to scale the truncated plurality of data based on the scaling value.

[0081] In some embodiments, the apparatus further includes: an interval determination module configured to determine a first group of intervals related to the plurality of data based on an absolute maximum value of the data.

[0082] In some embodiments, the first average value determination module 406 includes: an absolute value and number determination module, configured to determine the absolute value of the data in the multiple data and the number of the multiple data; and a second average value determination module, configured to determine the average value based on the absolute value of the data in the multiple data and the number.

[0083] In some embodiments, the first average value determination module 406 includes: a first intermediate value and number determination module, configured to determine the intermediate value of each interval in the first group of intervals and the number of data each interval has; and a third average value determination module, configured to determine the average value based on the intermediate value and the number.

[0084] In some embodiments, the first average value determination module 406 includes: a second intermediate value and number determination module, configured to determine the number of data located in each interval of the mapping unit and the intermediate value of each interval; and a fourth average value determination module, configured to determine the first average value based on the number and the intermediate value.

[0085] In some embodiments, the number of intervals in the second set of intervals is determined based on the number of bits associated with the second data format.

[0086] It should be understood that the above-mentioned device embodiments are only illustrative, and the device of the present disclosure can also be implemented in other ways. For example, the division of units / modules described in the above-mentioned embodiments is only a logical function division, and there may be other division methods in actual implementation. For example, multiple units, modules or components can be combined, or can be integrated into another system, or some features can be ignored or not executed.

[0087] In addition, unless otherwise specified, each functional unit / module in each embodiment of the present disclosure may be integrated into one unit / module, or each unit / module may exist physically separately, or two or more units / modules may be integrated together. The above-mentioned integrated unit / module may be implemented in the form of hardware or in the form of a software program module.

[0088] If the integrated unit / module is implemented in the form of hardware, the hardware may be a digital circuit, an analog circuit, etc. The physical implementation of the hardware structure includes but is not limited to transistors, memristors, etc. Unless otherwise specified, the artificial intelligence processor may be any appropriate hardware processor, such as a CPU, a GPU, an FPGA, a DSP, an ASIC, etc. Unless otherwise specified, the storage unit may be any appropriate magnetic storage medium or magneto-optical storage medium, such as a resistive random access memory RRAM (Resistive Random Access Memory), a dynamic random access memory DRAM (Dynamic Random Access Memory), a static random access memory SRAM (Static Random-Access Memory), an enhanced dynamic random access memory EDRAM (Enhanced Dynamic Random Access Memory), a high-bandwidth memory HBM (High-Bandwidth Memory), a hybrid memory cube HMC (Hybrid Memory Cube), etc.

[0089] If the integrated unit / module is implemented in the form of a software program module and sold or used as an independent product, it can be stored in a computer-readable memory. Based on this understanding, the technical solution of the present disclosure is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a memory, including a number of instructions to enable a computer device (which can be a personal computer, a server or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present disclosure. The aforementioned memory includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, disk or optical disk and other media that can store program codes.

[0090] In a possible implementation, an artificial intelligence chip is also disclosed, which includes the above-mentioned data processing device.

[0091] In a possible implementation, a board is also disclosed, which includes a storage device, an interface device, a control device and the above-mentioned artificial intelligence chip; wherein the artificial intelligence chip is connected to the storage device, the control device and the interface device respectively; the storage device is used to store data; the interface device is used to realize data transmission between the artificial intelligence chip and an external device; the control device is used to monitor the status of the artificial intelligence chip.

[0092] Figure 5 A structural block diagram of a board 500 according to an embodiment of the present disclosure is shown. Figure 5 In addition to the chips 506-1-506-N (where N is a positive integer and may be collectively referred to as chip 506 for ease of description), the board may also include other supporting components, including but not limited to: a storage device 502, an interface device 507 and a control device 504;

[0093] The storage device 502 is connected to the artificial intelligence chip via a bus 505 for storing data. The storage device may include multiple groups of storage units 503-1, ..., 503-N, where N is a positive integer, which may be collectively referred to as storage units 503 for ease of description. Each group of storage units 503 is connected to the artificial intelligence chip 506 via a bus 505. It can be understood that each group of storage units 503 may be DDR SDRAM (English: Double Data Rate SDRAM, double rate synchronous dynamic random access memory).

[0094] DDR can double the speed of SDRAM without increasing the clock frequency. DDR allows data to be read out on the rising and falling edges of the clock pulse. The speed of DDR is twice that of standard SDRAM. In one embodiment, the storage device may include 4 groups of storage units. Each group of storage units may include multiple DDR4 particles (chips). In one embodiment, the artificial intelligence chip may include 4 72-bit DDR4 controllers, 64 bits of the above 72-bit DDR4 controllers are used to transmit data, and 8 bits are used for ECC verification. It can be understood that when DDR4-3200 particles are used in each group of storage units, the theoretical bandwidth of data transmission can reach 25600MB / s.

[0095] In one embodiment, each group of the storage units includes a plurality of double rate synchronous dynamic random access memories arranged in parallel. DDR can transmit data twice in one clock cycle. A controller for controlling DDR is arranged in the chip to control the data transmission and data storage of each of the storage units.

[0096] The interface device 507 is electrically connected to the artificial intelligence chip 506. The interface device 507 is used to realize data transmission between the artificial intelligence chip and the external device 501 (such as a server or a computer). For example, in one embodiment, the interface device 507 can be a standard PCIE interface. For example, the data to be processed is transmitted to the chip by the server through the standard PCIE interface to realize data transfer. Preferably, when the PCIE 3.0X 16 interface is used for transmission, the theoretical bandwidth can reach 16000MB / s. In another embodiment, the interface device 507 can also be other interfaces. The present disclosure does not limit the specific forms of expression of the above-mentioned other interfaces. The interface unit can realize the switching function. In addition, the calculation results of the artificial intelligence chip 506 are still transmitted back to the external device 501 (such as a server) by the interface device 507.

[0097] The control device 504 is electrically connected to the artificial intelligence chip 506. The control device 504 is used to monitor the state of the artificial intelligence chip 506. Specifically, the artificial intelligence chip 506 and the control device 504 can be electrically connected through an SPI interface. The control device may include a single-chip microcomputer (Micro Controller Unit, MCU). For example, the artificial intelligence chip 506 may include multiple processing chips, multiple processing cores or multiple processing circuits, which can drive multiple loads. Therefore, the artificial intelligence chip 506 can be in different working states such as multi-load and light load. The control device can realize the regulation of the working state of multiple processing chips, multiple processing and / or multiple processing circuits in the artificial intelligence chip.

[0098] In a possible implementation, an electronic device is disclosed, which includes the above-mentioned artificial intelligence chip. The electronic device includes a data processing device, a robot, a computer, a printer, a scanner, a tablet computer, a smart terminal, a mobile phone, a driving recorder, a navigator, a sensor, a camera, a server, a cloud server, a camera, a video camera, a projector, a watch, a headset, a mobile storage, a wearable device, a vehicle, a household appliance, and / or a medical device.

[0099] The transportation means include airplanes, ships and / or vehicles; the household appliances include televisions, air conditioners, microwave ovens, refrigerators, rice cookers, humidifiers, washing machines, electric lights, gas stoves, and range hoods; the medical equipment includes magnetic resonance imaging, ultrasound machines and / or electrocardiographs.

[0100] In the above embodiments, the description of each embodiment has its own emphasis. For the part not described in detail in a certain embodiment, please refer to the relevant description of other embodiments. The technical features of the above embodiments can be combined arbitrarily. In order to make the description concise, all possible combinations of the technical features in the above embodiments are not described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0101] The foregoing content can be better understood in accordance with the following terms:

[0102] Item A1, a method for processing data, comprising: obtaining multiple data for a machine learning model, the data being represented in a first data format; distributing the multiple data in a first group of intervals based on the values ​​of the multiple data, the number of the first group of intervals being predetermined; determining a first average value of the multiple data; mapping the data distributed in the first group of intervals to a second group of intervals according to multiple different mapping units, so as to determine a second average value of the mapped data according to the corresponding mapping units, wherein the mapping unit includes a predetermined number of continuous intervals starting from a first interval of the first group of intervals, wherein an end interval of the mapping unit is distributed with data of the multiple data that is greater than or located at the end interval, the number of intervals in the second group of intervals is related to a second data format, and the accuracy of the second data format is lower than that of the first data format; and performing processing on the multiple data based on the first average value and the multiple second average values, so that the processed multiple data are represented in the second data format.

[0103] Item A2, a method according to Item A1, wherein mapping the data distributed in the first group of intervals to the second group of intervals according to multiple different mapping units includes: redistributing the data in the multiple data that is larger than the end interval of the mapping unit to the end interval of the mapping unit; and mapping the multiple mapping units to the second group of intervals respectively for determining a second average value of the mapped data according to the corresponding mapping units.

[0104] Item A3, according to the method described in Item A1, wherein performing processing on the multiple data includes: determining multiple difference values ​​related to multiple mapping units based on the first average value and multiple second average values; determining a truncation threshold for the multiple data based on the multiple difference values; truncating the obtained multiple data based on the truncation threshold; and determining a scaling value related to the mapping unit based on the truncation threshold.

[0105] Clause A4, a method according to clause A1, wherein performing processing on the plurality of data further comprises: scaling the truncated plurality of data based on the scaling value.

[0106] Item A5, according to the method described in Item A1, also includes: determining a first group of intervals related to the multiple data based on the absolute maximum value of the data.

[0107] Item A6, according to the method described in Item A1, wherein determining the first average value of the multiple data includes: determining the absolute value of the data in the multiple data and the number of the multiple data; and determining the average value based on the absolute value of the data in the multiple data and the number.

[0108] Item A7, according to the method described in Item A1, wherein determining the first average value of the multiple data includes: determining the middle value of each interval in the first group of intervals and the number of data each interval has; and determining the average value based on the middle value and the number.

[0109] Item A8, according to the method described in Item A1, wherein determining a first average value of the multiple data includes: determining the number of data located in each interval of the mapping unit and the median value of each interval; and determining the first average value based on the number and the median value.

[0110] Clause A9, a method according to clause A1, wherein the number of intervals in the second set of intervals is determined based on a number of bits associated with the second data format.

[0111] Item A10, a device for processing data, comprising: an acquisition module, configured to obtain multiple data for a machine learning model, the data being represented in a first data format; a distribution module, configured to distribute the multiple data in a first group of intervals based on the values ​​of the multiple data, the number of the first group of intervals being predetermined; a first average value determination module, configured to determine a first average value of the multiple data; a first mapping module, configured to map the data distributed in the first group of intervals to a second group of intervals according to a plurality of different mapping units, so as to determine a second average value of the mapped data according to the corresponding mapping units, wherein the mapping unit comprises a predetermined number of continuous intervals starting from a first interval of the first group of intervals, wherein an end interval of the mapping unit is distributed with data of the multiple data that is greater than or located at the end interval, the number of intervals in the second group of intervals is related to a second data format, and the precision of the second data format is lower than that of the first data format; and an execution module, configured to perform processing on the multiple data based on the first average value and the plurality of second average values, so that the processed multiple data are represented in the second data format.

[0112] Item A11, an apparatus according to Item A10, wherein the first mapping module includes: a redistribution module configured to redistribute the data among the multiple data that is larger than the end interval of the mapping unit to the end interval of the mapping unit; and a second mapping module configured to map the multiple mapping units to a second group of intervals respectively for determining a second average value of the mapped data according to the corresponding mapping units.

[0113] Item A12, an apparatus according to Item A10, wherein the execution module includes: a difference determination module, configured to determine a plurality of difference values ​​related to a plurality of the mapping units based on the first average value and a plurality of the second average values; a truncation threshold determination module, configured to determine a truncation threshold for the plurality of data based on the plurality of difference values; a truncation module, configured to truncate the plurality of data obtained based on the truncation threshold; and a scaling value determination module, configured to determine a scaling value related to the mapping unit based on the truncation threshold.

[0114] Clause A13, an apparatus according to clause A12, wherein the execution module further comprises: a scaling module configured to scale the truncated plurality of data based on the scaling value.

[0115] Item A14, according to the apparatus described in Item A10, further includes: an interval determination module configured to determine a first group of intervals related to the multiple data based on the absolute maximum value of the data.

[0116] Item A15, an apparatus according to Item A10, wherein the first average value determination module includes: an absolute value and number determination module, configured to determine the absolute value of data in the multiple data and the number of the multiple data; and a second average value determination module, configured to determine the average value based on the absolute value of data in the multiple data and the number.

[0117] Item A16, an apparatus according to Item A10, wherein the first average value determination module includes: a first intermediate value and number determination module, configured to determine the intermediate value of each interval in the first group of intervals and the number of data each interval has; and a third average value determination module, configured to determine the average value based on the intermediate value and the number.

[0118] Item A17, an apparatus according to Item A10, wherein the first average value determination device includes: a second intermediate value and number determination module, configured to determine the number of data located in each interval of the mapping unit and the intermediate value of each interval; and a fourth average value determination module, configured to determine the first average value based on the number and the intermediate value.

[0119] Item A18, an apparatus as described in item A10, wherein the number of intervals in the second set of intervals is determined based on a number of bits associated with the second data format.

[0120] Item A19, an artificial intelligence chip, comprising a processor; and a memory storing computer program instructions, wherein the processor runs the computer program instructions in the memory to control the artificial intelligence chip to execute a method according to any one of items A1-A9.

[0121] Item A20, an electronic device, characterized in that the electronic device includes an artificial intelligence chip as described in Item A19.

[0122] Item A21, a board card, characterized in that the board card includes: a storage device, an interface device and a control device and an artificial intelligence chip as described in Item A19; wherein the artificial intelligence chip is connected to the storage device, the control device and the interface device respectively; the storage device is used to store data; the interface device is used to realize data transmission between the artificial intelligence chip and external equipment; the control device is used to monitor the status of the artificial intelligence chip.

[0123] Item A22, according to the board described in Item A21, it is characterized in that the storage device includes: multiple groups of storage units, each group of the storage units is connected to the artificial intelligence chip through a bus, and the storage units are: DDR SDRAM; the chip includes: a DDR controller for controlling the data storage and data storage of each of the storage units; the interface device is: a standard PCIE interface.

[0124] The embodiments of the present disclosure are described in detail above. Specific examples are used herein to illustrate the principles and implementation methods of the present disclosure. The description of the above embodiments is only used to help understand the method and its core idea of ​​the present disclosure. At the same time, changes or deformations made by those skilled in the art based on the ideas of the present disclosure, the specific implementation methods and the scope of application of the present disclosure, all belong to the scope of protection of the present disclosure. In summary, the content of this specification should not be understood as a limitation on the present disclosure.

Claims

1. A method for processing data, comprising: Obtaining a plurality of data for a machine learning model, wherein the data is represented in a first data format; Distributing the plurality of data into a first set of intervals based on values ​​of the plurality of data, the number of the first set of intervals being predetermined; determining a first average of the plurality of data; Mapping the data distributed in the first group of intervals to a second group of intervals according to a plurality of different mapping units, so as to determine a second average value of the mapped data according to the corresponding mapping units, wherein the mapping unit includes a predetermined number of continuous intervals starting from a first interval of the first group of intervals, wherein an end interval of the mapping unit is distributed with data of the plurality of data that is greater than or located at the end interval, and the number of intervals in the second group of intervals is related to a second data format, and the second data format has a lower precision than the first data format; as well as Based on the first average value and the plurality of second average values, performing processing on the plurality of data so that the processed plurality of data is represented in the second data format; The processing of the plurality of data includes: determining a plurality of difference values ​​related to a plurality of the mapping units based on the first average value and a plurality of the second average values; determining a cutoff threshold for the plurality of data based on the plurality of difference values; Truncating the obtained plurality of data based on the truncation threshold; and Based on the truncation threshold, a scaling value associated with the mapping unit is determined for processing the truncated plurality of data.

2. The method according to claim 1, wherein mapping the data distributed in the first group of intervals to the second group of intervals according to a plurality of different mapping units comprises: Redistributing data of the plurality of data that is larger than the end interval of the mapping unit to the end interval of the mapping unit; as well as The plurality of mapping units are respectively mapped to a second set of intervals for determining a second average value of the mapped data according to the corresponding mapping units.

3. The method according to claim 1, wherein performing processing on the plurality of data further comprises: The truncated plurality of data are scaled based on the scaling value.

4. The method according to claim 1, further comprising: A first group of intervals related to the plurality of data is determined based on the absolute maximum values ​​of the data.

5. The method according to claim 1, wherein determining a first average value of the plurality of data comprises: determining an absolute value of data in the plurality of data and the number of the plurality of data; as well as The average value is determined based on the absolute value of the data and the number of the plurality of data.

6. A device for processing data, comprising: An acquisition module, configured to obtain a plurality of data for a machine learning model, wherein the data is represented in a first data format; a distribution module configured to distribute the plurality of data into a first group of intervals based on values ​​of the plurality of data, wherein the number of the first group of intervals is predetermined; A first average value determination module, configured to determine a first average value of the plurality of data; a first mapping module configured to map the data distributed in the first group of intervals to a second group of intervals according to a plurality of different mapping units, so as to determine a second average value of the mapped data according to the corresponding mapping units, wherein the mapping unit comprises a predetermined number of continuous intervals starting from a first interval of the first group of intervals, wherein an end interval of the mapping unit is distributed with data of the plurality of data that is greater than or located at the end interval, and the number of intervals in the second group of intervals is related to a second data format, and the second data format has a lower precision than the first data format; as well as an execution module configured to execute processing on the plurality of data based on the first average value and the plurality of second average values, so that the processed plurality of data are represented in the second data format; The execution module includes: a difference determination module, configured to determine a plurality of difference values ​​related to a plurality of the mapping units based on the first average value and a plurality of the second average values; a truncation threshold determination module, configured to determine a truncation threshold for the plurality of data based on the plurality of difference values; a truncation module, configured to truncate the obtained plurality of data based on the truncation threshold; and a scaling value determination module, configured to determine a scaling value related to the mapping unit based on the truncation threshold for processing the truncated plurality of data.

7. An artificial intelligence chip, comprising: processor; as well as A memory storing computer program instructions, wherein the processor runs the computer program instructions in the memory to control the artificial intelligence chip to execute the method according to any one of claims 1 to 5.

8. An electronic device, characterized in that: The electronic device comprises the artificial intelligence chip as claimed in claim 7.

9. A board, characterized in that: The board includes: a storage device, an interface device and a control device and the artificial intelligence chip as claimed in claim 7; Wherein, the artificial intelligence chip is connected to the storage device, the control device and the interface device respectively; The storage device is used to store data; The interface device is used to realize data transmission between the artificial intelligence chip and external equipment; The control device is used to monitor the status of the artificial intelligence chip.