Data type selection method, apparatus, and readable storage medium
Patent Information
- Application Number
- CN202211032359.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-08-26
- Publication Date
- 2026-09-18
- Estimated Expiration
- 2042-08-26
AI Technical Summary
由于神经网络中不同的网络位置、不同的算子、以及在训练过程中不同的阶段,其数据的分布情况都是不一样的,若固定使用单一低位宽的浮点数来进行运算,在很多场景下会牺牲精度与性能
[0010] In a fifth aspect, this disclosure provides a data type selection device, comprising: a statistics module, a setting module, and a decision module. The statistics module is used to statistically analyze the exponential distribution information of target data in a target network layer, the exponential distribution information including the exponential distribution range and the exponential value distribution magnitude; the setting module is used to: set the exponential bit width of the target data according to the exponential distribution range, and set the mantissa bit width of the target data according to the exponential value distribution magnitude; the decision module is used to determine the data type corresponding to the target data according to the exponential bit width and the mantissa bit width.
Smart Images

Figure CN117688993B_ABST
Abstract
Description
Technical Field
[0001] This disclosure generally relates to the field of neural networks. More specifically, this disclosure relates to methods, apparatus, and readable storage media for selecting data types. Background Technology
[0002] Training neural networks requires a large amount of data processing, and this massive amount of data processing places higher demands on processing speed. Since using low-bit-width floating-point operations can accelerate training and reduce memory usage, quantization is performed first when training a neural network. This involves converting high-bit-width (high-precision) floating-point numbers into low-bit-width (low-precision) floating-point numbers before performing calculations.
[0003] Existing techniques often use a fixed data type for a class of operators when performing quantization, but this is not optimal because the distribution of input data is not always the same. For example, the data distribution differs at different locations in the network, different categories of operators have different data distributions, and the data distribution changes between the early and later stages of training. Since the data distribution varies at different network locations, with different operators, and at different stages of training, using a single low-bit-width floating-point number for calculations will sacrifice accuracy and performance in many scenarios.
[0004] Therefore, a data type selection scheme that can balance computational efficiency and computational accuracy is urgently needed. Summary of the Invention
[0005] In order to at least address one or more of the technical problems mentioned above, this disclosure provides methods, apparatus and readable storage media for selecting data types in several aspects.
[0006] In a first aspect, this disclosure provides a data type selection method, comprising: statistically analyzing the exponential distribution information of target data in a target network layer, the exponential distribution information including the exponential distribution range and the exponential value distribution magnitude; setting the exponential bit width of the target data according to the exponential distribution range; setting the mantissa bit width of the target data according to the exponential value distribution magnitude; and determining the data type of the target data according to the exponential bit width and the mantissa bit width.
[0007] In a second aspect, this disclosure provides a computer-readable storage medium having stored thereon computer program code for a data type selection method, which, when executed by a processing device, performs the aforementioned data type selection method of the first aspect.
[0008] In a third aspect, this disclosure provides a computer program product including a computer program for a data type selection method, which, when executed by a processor, implements the steps of the data type selection method described in the first aspect.
[0009] In a fourth aspect, this disclosure provides a computing device including a memory, a processor, and a computer program stored in the memory, the processor executing the computer program to implement the steps of the data type selection method of the first aspect.
[0010] In a fifth aspect, this disclosure provides a data type selection device, comprising: a statistics module, a setting module, and a decision module. The statistics module is used to statistically analyze the exponential distribution information of target data in a target network layer, the exponential distribution information including the exponential distribution range and the exponential value distribution magnitude; the setting module is used to: set the exponential bit width of the target data according to the exponential distribution range, and set the mantissa bit width of the target data according to the exponential value distribution magnitude; the decision module is used to determine the data type corresponding to the target data according to the exponential bit width and the mantissa bit width.
[0011] This disclosure provides a data type selection scheme. By statistically analyzing the exponential distribution range and exponential value distribution of target data in the target network layer, the exponential bit width and mantissa bit width of the target data are dynamically set, thereby determining the data type of the target data. In other words, if different target data have different exponential distribution ranges and / or exponential value distributions, even within the same network layer, the data type of the target data may differ. Because this disclosure considers the data distribution of the target data during the processing of external data in the neural network model, the total bit width of the data can effectively represent the target data, balancing computational efficiency and accuracy. Attached Figure Description
[0012] The above and other objects, features, and advantages of exemplary embodiments of this disclosure will become readily apparent upon reading the following detailed description with reference to the accompanying drawings. In the drawings, several embodiments of this disclosure are illustrated by way of example and not limitation, and like or corresponding reference numerals denote like or corresponding parts, wherein:
[0013] Figure 1 It is a schematic format for indicating data types;
[0014] Figure 2 This is a flowchart illustrating a data type selection method according to an embodiment of this disclosure;
[0015] Figure 3 This is an exemplary data distribution diagram illustrating a target data of an embodiment of this disclosure;
[0016] Figure 4 This is a flowchart illustrating a data type selection method according to another embodiment of this disclosure;
[0017] Figure 5 This is a schematic diagram illustrating a data type selection device according to another embodiment of this disclosure. Detailed Implementation
[0018] The technical solutions in the embodiments of this disclosure will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of this disclosure, not all of them. Based on the embodiments in this disclosure, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this disclosure.
[0019] It should be understood that the terms “comprising” and “including” used in this disclosure and claims indicate the presence of the described features, integrals, steps, operations, elements and / or components, but do not exclude the presence or addition of one or more other features, integrals, steps, operations, elements, components and / or collections thereof.
[0020] It should also be understood that the terminology used herein is for the purpose of describing particular embodiments only and is not intended to limit the scope of this disclosure. As used in this disclosure and claims, the singular forms “a,” “an,” and “the” are intended to include the plural forms unless the context clearly indicates otherwise. It should also be understood that the term “and / or” as used in this disclosure and claims refers to any combination and all possible combinations of one or more of the associated listed items, and includes such combinations.
[0021] As used in this specification and claims, the term "if" may be interpreted, depending on the context, as "when," "once," "in response to determination," or "in response to detection."
[0022] The specific embodiments disclosed herein will now be described in detail with reference to the accompanying drawings.
[0023] In neural networks, using low-bit-width floating-point arithmetic can accelerate training and reduce memory usage. Floating-point numbers are numerical representations of numbers belonging to a specific subset of rational numbers. In computers, they are used to approximate a real number, and the decimal point can "float." The IEEE floating-point standard uses V = (-1)... S *M*2 E A floating-point number is represented in the form of . Here, S is the sign bit; when S is 0, the floating-point number is positive, and when S is 1, the floating-point number is negative. In general, the sign bit occupies one bit width by default. M is the mantissa; the value range of M indicates the size of the mantissa bit width. E is the exponent; the floating-point number is weighted, with the weight being 2 raised to the power of E. The value of the exponent bit indicates the size of the exponent bit width.
[0024] Figure 1 The following shows an example of a floating-point number data type, such as... Figure 1As shown, floating-point numbers are represented in a computer using three fields: the S field, the E field, and the M field, corresponding to the sign bit width, exponent bit width, and mantissa bit width, respectively. The total bit width of a floating-point number is the sum of the sign bit width, exponent bit width, and mantissa bit width. The FP32 data type has 32 bits (bits 0 to 31 in the diagram), where the S field occupies 1 bit (bit 31 in the diagram, indicating a bit width of 1), the E field occupies 8 bits (bits 30 to 23 in the diagram, indicating a bit width of 8), and the M field occupies 23 bits (bits 22 to 0 in the diagram, indicating a bit width of 23). Data type FP16 has 16 bits (bits 0 to 15 in the diagram), where the S field occupies 1 bit (bit 15 in the diagram, indicating a bit width of 1), the E field occupies 8 bits (bits 14 to 7 in the diagram, indicating a bit width of 8), and the M field occupies 7 bits (bits 6 to 0 in the diagram, indicating a bit width of 7). Data type FP8 has 8 bits (bits 0 to 7 in the diagram), where the S field occupies 1 bit (bit 7 in the diagram, indicating a bit width of 1), the E field occupies 6 bits (bits 6 to 1 in the diagram, indicating a bit width of 6), and the M field occupies 1 bit (bit 0 in the diagram, indicating a bit width of 1).
[0025] In existing solutions, data in the same layer is often quantized using a single low-bit-width floating-point number. While this can improve the efficiency of floating-point operations, it cannot dynamically adjust the data type based on changes in data distribution. In many application scenarios, this fails to meet the precision requirements of network training data.
[0026] In view of this, this disclosure focuses on the statistical analysis of the data distribution of the target data for the target network layer. Based on the statistical analysis, the distribution information of the target data is determined, and the data type of the target data is determined based on this information. The target network layer refers to any layer in the neural network model, more specifically, the network layer that receives the data whose distribution is to be analyzed and performs calculations; the target data refers to the training data of the target network layer, which is generally neuron data (such as image data, speech data) or weights.
[0027] Figure 2 A flowchart illustrating a data type selection method according to an embodiment of this disclosure is shown.
[0028] In step 201, the exponential distribution information of the target data in the target network layer is statistically analyzed, wherein the exponential distribution information includes the exponential distribution range and the exponential value distribution.
[0029] In this embodiment, the exponential distribution information refers to the result of statistical analysis of the exponential values corresponding to a set of target data and the number of times the exponential values appear in the set of target data. Figure 3 An exemplary exponential distribution plot is shown. Specifically, Figure 3 This shows the exponential distribution of all topdiff data (target data) in a fully connected layer (target network layer) of a transformer neural network model. The horizontal axis represents the range of exponential values of this set of topdiff data, from -10 to -70, and the vertical axis represents the number of occurrences of each exponential value in this set of topdiff data.
[0030] The Transformer neural network model, published by Google in 2017, is a model that utilizes an attention mechanism to improve training speed. It includes multiple encoder modules for encoding text and multiple decoder modules for decoding the encoded files. Topdiff, on the other hand, is an operator that outputs gradients in reverse in a convolutional neural network. Both the Transformer neural network model and the Topdiff operator are well-known to those skilled in the art and will not be elaborated upon further.
[0031] In this embodiment, the exponential distribution range refers to the distribution range of the exponent bits corresponding to all data in this set of target data. Figure 3 For example, its exponential distribution ranges from -10 to -70. The exponential value distribution refers to the distribution of each exponential value within the exponential distribution range, that is, the number of occurrences of each exponential value. It should be noted that the number of exponential values between -70 and -56 and between -13 and -10 is not zero, but compared to other exponential values, their number is so small that it cannot be accurately displayed in the graph.
[0032] Understandable, Figure 3 For ease of intuitive understanding, a visually represented data distribution chart may not actually exist in actual computer processing. The specific exponential distribution range and value distribution are presented through character codes derived from the statistical results. In summary, this step involves forming a similar... Figure 3 Statistical tables or computer-readable statistical character codes.
[0033] In step 202, the exponent width of the target data is set according to the exponent distribution range. In this embodiment, there are several ways to set the exponent width.
[0034] One method is the exponential distribution range method, which subtracts the minimum exponential value (minE) from the maximum exponential value (maxE) in the target data as the benchmark for calculating the exponential bit width. Figure 3 For example, if the maximum value of the exponent is -10 and the minimum value of the exponent is -70, then... Figure 3 The exponential distribution range ED of the topdiff data is: ED = maxE - minE That is, ED = (-10) - (-70) = 60. The exponent distribution range ED reflects the exponent range to be fully represented by this set of topdiff data. Since 2 to the power of 5 is 32, which is less than 60, and 2 to the power of 6 is 64, which is greater than 60, the exponent bits need to be 6 bits to fully represent the exponent range of this set of topdiff data.
[0035] In some cases, neural network models can only accept a few preset and fixed exponential bit widths. For example, Figure 3 The Transformer neural network model can only accept exponent widths of 3, 4, or 5, where an exponent width of 3 corresponds to a bit range of [0, 15], an exponent width of 4 corresponds to a bit range of [16, 31], and an exponent width of 5 corresponds to a bit range of [32, 63]. In this case, another way to set the exponent width in this embodiment is through a selection method, that is, specifying one of several acceptable choices based on the exponent distribution range. Specifically, it is known that... Figure 3 The example has an exponent distribution range ED of 60, which falls within the interval [32, 63]. Therefore, in this step, the exponent width is selected as 5 from the preset and fixed exponent widths of 3, 4, and 5.
[0036] Another method for setting the exponent bit width in this embodiment is the empirical method. This involves combining the formula with hyperparameters derived from empirical values, calculating the product of the exponent distribution range and the hyperparameters, and then rounding off the product. The rounded result is the exponent bit width. The specific formula is as follows: E = ceil(ED·α) Where E is the exponential bit width, ceil represents rounding up, ED represents the exponential distribution range of the data, and α is the first hyperparameter, with an empirical value of 0.1 in this embodiment. Figure 3 The example is based on the empirical method, where the exponent width E is calculated as ceil(60·0.1)=6.
[0037] Regardless of whether the above-mentioned exponential distribution range method, selection method, or empirical value method is used, the exponential bit width that fits the exponential distribution range of the target data can be obtained in this step.
[0038] In step 203, the mantissa bit width of the target data is set according to the exponential value distribution. This embodiment identifies the exponential bit width with the maximum number of distributions, calculates the ratio of this maximum distribution number to the total distribution number, and calculates the product of this ratio and a second hyperparameter obtained empirically. Finally, the product is rounded down, and the rounded result is the mantissa bit width. An exemplary formula is as follows: Where M represents the mantissa width, ceil represents rounding up, E1 is the ratio of the maximum distribution number to the total distribution number, and β is the second hyperparameter. Continuing with... Figure 3 Taking the topdiff data as an example, the data with the largest number of exponent bits is data 301 in the figure, and its corresponding maximum number of bits is 354459. Assuming that the total number of bits in the topdiff data is 4718570, the ratio of the number of bits E1 is 354459 / 4718570 = 0.07512. In this embodiment, the empirical value of β is 0.06, so the mantissa bit width M = ceil(0.07512 / 0.06) = 2.
[0039] It is understood that in the embodiments disclosed herein, there is no strict execution order between steps 202 and 203. Step 202 can be executed first and then step 203, or step 203 can be executed first and then step 202. This embodiment does not limit this.
[0040] In step 204, the data type of the target data is determined based on the exponent bit width and the mantissa bit width. Specifically, the total bit width of the target data can be obtained by directly summing the sign bit width, exponent bit width, and mantissa bit width. Let's take... Figure 3 Taking the topdiff data as an example, in step 202, a 6-bit exponent width is obtained using the exponent distribution range method, a 5-bit exponent width is obtained using the selection method, and a 6-bit exponent width is obtained using the empirical value method. In step 203, a 2-bit mantissa width is obtained, while the sign width is fixed at 1 bit. Therefore, the total bit width obtained using the exponent distribution range method is 6 + 2 + 1 = 9 (FP9), the total bit width obtained using the selection method is 5 + 2 + 1 = 8 (FP8), and the total bit width obtained using the empirical value method is 6 + 2 + 1 = 9 (FP9). This embodiment uses FP8 or FP9 data types to represent the data. Figure 3 The fully connected layer is trained using the topdiff data.
[0041] This embodiment dynamically sets the exponent and mantissa bit widths of the target data by statistically analyzing the exponent distribution range and exponent value distribution of the target data in the target network layer, thereby determining the data type of the target data. In other words, if multiple sets of target data have different exponent distribution ranges and / or exponent value distributions, even within the same network layer, the data type of the target data may differ. Because this embodiment considers the data distribution of the target data during training, the total bit width of the data can effectively represent each set of target data, balancing computational efficiency and accuracy.
[0042] In practical applications, the proportion of data within certain exponential distribution ranges is very small, for example... Figure 3 Data with index values between -70 and -56 will not have a substantial impact on training results even if these data are ignored when determining the data type. Another embodiment disclosed herein is a method for selecting data types based on a specific index value range, the flowchart of which is shown below. Figure 4 As shown. This embodiment is also based on Figure 3 Explanation of the topdiff data pairing.
[0043] In step 401, the exponential distribution information of the target data in the target network layer is statistically analyzed, whereby the exponential distribution information includes the exponential distribution range and the distribution magnitude of the exponential values. This step is the same as step 201, so it will not be described again.
[0044] In step 402, when setting the exponential bit width of the target data according to the exponential distribution range, the exponential distribution interval within the distribution proportion threshold is identified, and the bit width value corresponding to the exponential distribution interval is used as the exponential bit width.
[0045] In this step, a distribution percentage threshold needs to be set first. This threshold can be determined according to actual needs, such as 70%, 80%, or 90%. That is, the continuous area of 70%, 80%, or 90% of the exponential distribution range is used as the benchmark to obtain the exponential bit width. The part of the exponential distribution range that exceeds the distribution percentage threshold is not included in the calculation.
[0046] Taking a distribution percentage threshold of 90% as an example, Figure 3 If the exponential distribution range ED = 60, then the exponential distribution interval is 60 * 90% = 54. Using 54 as a reference value, that is, ED is 54 instead of 60, then use any of the exponential bit width setting methods in step 202 to set the exponential bit width.
[0047] In step 403, the mantissa bit width of the target data is set according to the distribution of the index value. This step is no different from step 203. It will not be described again here.
[0048] In step 404, the data type of the target data is determined based on the exponent bit width and the mantissa bit width. In this embodiment, the sign bit width, exponent bit width, and mantissa bit width are first summed to obtain the total bit width of the target data, and the operational details are no different from step 204.
[0049] Next, the bit width range within which the total bit width falls is identified to select the appropriate data type from among the multiple data types. Specifically, this embodiment defines multiple acceptable data types for the target network layer, each corresponding to a different bit width range. For example, acceptable data types are FP16 and FP8. If the total bit width calculated in this step is less than or equal to 8, although both FP16 and FP8 meet the precision requirements of the target data, this embodiment will select the smaller total bit width, i.e., select data type FP8. If the total bit width is between 8 and 16, FP16 will be selected because FP8 cannot meet the requirements.
[0050] This embodiment selects a data type with the required precision from several preset data types, allowing the neural network model to be debugged in advance. The hardware is specially designed to adapt to several preset data types, and one of the preset data types is selected based on the exponential distribution information, which helps to improve data processing efficiency.
[0051] Another embodiment of this disclosure is a method for selecting a data type, this embodiment is based on Figure 2 , Figure 4 Among the various data types determined in the corresponding embodiments, the minimum total bit width is selected as the data type of the final target data, which further ensures that the floating-point number operation efficiency is the best among multiple schemes.
[0052] Another embodiment of this disclosure is a computer-readable storage medium storing computer program code for a data type selection method. When the computer program code is run by a processor, it executes the methods described in the preceding embodiments. In some implementation scenarios, the integrated units described above can be implemented as software program modules. If implemented as software program modules and sold or used as independent products, the integrated units can be stored in a computer-readable memory. Based on this, when the solution disclosed herein is embodied in the form of a software product (e.g., a computer-readable storage medium), the software product can be stored in a memory, which may include several instructions to cause a computer device (e.g., a personal computer, server, or network device) to execute some or all of the steps of the methods described in the embodiments of this disclosure. The aforementioned memory may include, but is not limited to, various media capable of storing program code, such as USB flash drives, flash drives, read-only memory (ROM), random access memory (RAM), portable hard drives, magnetic disks, or optical disks.
[0053] Another embodiment of this disclosure is a computer program product, including a computer program for a data type selection method, which, when executed by a processor, implements the steps of the methods shown in the foregoing embodiments.
[0054] Another embodiment of this disclosure is a computer device including a memory, a processor, and a computer program stored in the memory, wherein the processor executes the computer program to implement the steps of the methods shown in the foregoing embodiments.
[0055] The above embodiments set the data type and train it in a specific way. After training is completed, the actual target data (such as real image data and voice data) is imported into the trained neural network model for inference to obtain the inference result.
[0056] The above embodiments can be implemented using computer programs. The purpose of executing these computer programs is to address the technical problem of insufficient data accuracy requirements for neural network training in many application scenarios. Running computer programs on a computer to control or process external objects (the exponential distribution information of target data) reflects a technical approach that follows natural laws. This allows data types to dynamically adapt to the composition of different target data and effectively represent the target data, thereby achieving a balance between accuracy and efficiency—technical effects that conform to natural laws. Furthermore, the computer program solutions in the above embodiments aim to process target data. By executing a technical data processing program on a computer to analyze its exponential distribution information, a series of technical processes are performed on the target data according to natural laws to determine the data type, thus achieving a technical data processing effect that balances accuracy and efficiency—effects that conform to natural laws.
[0057] Figure 5 Another embodiment of this disclosure is shown, which is a data type selection device. For example... Figure 5 As shown, the data type selection device includes a statistics module 501, a setting module 502, and a decision module 503.
[0058] The statistics module 501 is used to statistically analyze the exponential distribution information of the target data in the target network layer. This exponential distribution information includes the exponential distribution range and the distribution of exponential values. The exponential distribution information refers to the result of statistical analysis of the exponential values corresponding to a set of target data and the number of times each exponential value appears in the set of target data.
[0059] The setting module 502 sets the exponent width of the target data according to the exponent distribution range. In this embodiment, there are several ways to set the exponent width, including the exponent distribution range method, the selection method, and the empirical value method mentioned above. Regardless of the method used, the statistics module 501 obtains the exponent width that adapts to the exponent distribution range of the target data.
[0060] In another scenario, when setting the exponential bit width of the target data based on the exponential distribution range, the setting module 502 identifies the exponential distribution interval within the distribution proportion threshold and uses the bit width value corresponding to that interval as the exponential bit width. The setting module 502 first needs to set the distribution proportion threshold, which can be determined according to actual needs, such as 70%, 80%, or 90%. That is, it uses a continuous region of 70%, 80%, or 90% of the exponential distribution range as a benchmark to obtain the exponential bit width; the portion of the exponential distribution range exceeding the distribution proportion threshold is not included in the calculation.
[0061] The setting module 502 then sets the mantissa bit width of the target data based on the exponent value distribution. First, it identifies the exponent bit width with the maximum number of distributions, calculates the ratio of this maximum distribution number to the total distribution number, and then calculates the product of this ratio and a second hyperparameter derived empirically. Finally, it rounds down the product; the rounded result is the mantissa bit width. An example formula is as follows: Where M represents the mantissa bit width, ceil represents rounding up, E1 is the ratio of the maximum distribution number to the total distribution number, and β is the second hyperparameter.
[0062] The decision module 503 determines the data type of the target data based on the exponent bit width and the mantissa bit width. In one case, the decision module 503 can obtain the total bit width of the target data by directly summing the sign bit width, exponent bit width, and mantissa bit width.
[0063] In another scenario, the decision module 503 first sums the sign bit width, exponent bit width, and mantissa bit width to obtain the total bit width of the target data. Then, it identifies the bit width value range within which this total bit width falls, in order to select the corresponding data type from among the multiple data types. Specifically, the decision module 503 sets multiple acceptable data types for the target network layer, each corresponding to a different bit width value range.
[0064] This embodiment can further determine a variety of acceptable data types based on the above methods, and select the minimum total bit width from these acceptable data types as the data type of the final target data.
[0065] Depending on the application scenario, the electronic devices or apparatus disclosed herein may include servers, cloud servers, server clusters, data processing devices, robots, computers, printers, scanners, tablets, smart terminals, PC devices, IoT terminals, mobile terminals, mobile phones, dashcams, navigators, sensors, cameras, video cameras, projectors, watches, headphones, mobile storage, wearable devices, visual terminals, autonomous driving terminals, vehicles, home appliances, and / or medical devices. Vehicles include airplanes, ships, and / or vehicles; home appliances include televisions, air conditioners, microwave ovens, refrigerators, rice cookers, humidifiers, washing machines, lights, gas stoves, and range hoods; medical devices include MRI scanners, ultrasound machines, and / or electrocardiographs. The electronic devices or apparatus disclosed herein can also be applied in fields such as the Internet, IoT, data centers, energy, transportation, public management, manufacturing, education, power grids, telecommunications, finance, retail, construction sites, and healthcare. Furthermore, the electronic devices or apparatus disclosed herein can also be used in cloud, edge, and terminal applications related to artificial intelligence, big data, and / or cloud computing. In one or more embodiments, the high-computing-power electronic devices or apparatuses according to the present disclosure can be applied to cloud devices (e.g., cloud servers), while the low-power electronic devices or apparatuses can be applied to terminal devices and / or edge devices (e.g., smartphones or cameras). In one or more embodiments, the hardware information of the cloud devices and the hardware information of the terminal devices and / or edge devices are compatible with each other, so that suitable hardware resources can be matched from the hardware resources of the cloud devices to simulate the hardware resources of the terminal devices and / or edge devices based on the hardware information of the terminal devices and / or edge devices, so as to complete the unified management, scheduling and collaborative work of end-to-cloud or cloud-edge-end integration.
[0066] It should be noted that, for the sake of brevity, this disclosure describes some methods and their embodiments as a series of actions and combinations thereof. However, those skilled in the art will understand that the solutions disclosed herein are not limited by the order of the described actions. Therefore, based on the disclosure or teachings of this document, those skilled in the art will understand that some steps can be performed in a different order or simultaneously. Furthermore, those skilled in the art will understand that the embodiments described in this disclosure can be considered optional embodiments, that is, the actions or modules involved are not necessarily essential for the implementation of one or more solutions disclosed herein. In addition, depending on the solution, the description of some embodiments in this disclosure may have different emphases. In view of this, those skilled in the art will understand that parts not described in detail in a certain embodiment of this disclosure can also be referred to the relevant descriptions of other embodiments.
[0067] In terms of specific implementation, based on the disclosure and teachings of this document, those skilled in the art will understand that the several embodiments disclosed herein can also be implemented in other ways not disclosed herein. For example, regarding the various units in the aforementioned electronic device or apparatus embodiments, this document has divided them based on logical functions, but in actual implementation, there may be other ways of division. As another example, multiple units or components can be combined or integrated into another system, or some features or functions in a unit or component can be selectively disabled. Regarding the connection relationships between different units or components, the connections discussed above in conjunction with the accompanying drawings can be direct or indirect couplings between units or components. In some scenarios, the aforementioned direct or indirect couplings involve communication connections utilizing interfaces, where the communication interface can support electrical, optical, acoustic, magnetic, or other forms of signal transmission.
[0068] In this disclosure, the units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units. The aforementioned components or units may be located in the same location or distributed across multiple network units. Furthermore, depending on actual needs, some or all of the units can be selected to achieve the purpose of the solution in this disclosure embodiment. Additionally, in some scenarios, multiple units in this disclosure embodiment may be integrated into one unit or each unit may exist physically independently.
[0069] In other implementation scenarios, the integrated unit described above can also be implemented in hardware, i.e., as a specific hardware circuit, which may include digital circuits and / or analog circuits. The physical implementation of the circuit's hardware structure may include, but is not limited to, physical devices, which may include, but are not limited to, transistors or memristors. Therefore, the various devices (e.g., computing devices or other processing devices) described herein can be implemented using appropriate hardware processors, such as central processing units, GPUs, FPGAs, DSPs, and ASICs. Furthermore, the aforementioned storage unit or storage device can be any suitable storage medium (including magnetic storage media or magneto-optical storage media).
[0070] The foregoing can be better understood in accordance with the following terms:
[0071] Clause A1. A data type selection method, comprising: statistically analyzing the exponential distribution information of target data in a target network layer, the exponential distribution information including the exponential distribution range and the exponential value distribution magnitude; setting the exponential bit width of the target data according to the exponential distribution range; setting the mantissa bit width of the target data according to the exponential value distribution magnitude; and determining the data type of the target data according to the exponential bit width and the mantissa bit width.
[0072] Clause A2, the method described in Clause A1, wherein the step of setting the exponential bit width of the target data includes: calculating the product of the exponential distribution range and the first hyperparameter; rounding the product; wherein the rounded result is the exponential bit width.
[0073] Clause A3, according to the method of Clause A1 or A2, wherein the range of the index distribution is the maximum value of the index bit minus the minimum value of the index bit in the target data.
[0074] Clause A4, according to the method of Clause A1, wherein the step of setting the exponential bit width of the target data includes: identifying an exponential distribution interval within the exponential distribution range that is within a distribution proportion threshold; wherein the bit width value corresponding to the exponential distribution interval is the exponential bit width.
[0075] Clause A5. According to the method described in Clause A1, the step of setting the mantissa width of the target data includes: identifying the exponent number of the maximum distribution number; calculating the distribution ratio of the maximum distribution number to the total distribution number; calculating the product of the distribution ratio and the second hyperparameter; and rounding the product; wherein the rounded result is the mantissa width.
[0076] Clause A6, the method described in Clause A2 or A5, wherein the rounding step is rounding up.
[0077] Clause A7. The method described in Clause A1, wherein the step of determining the data type of the target data includes: summing the sign bit width, the exponent bit width, and the mantissa bit width to obtain the total bit width of the target data.
[0078] Clause A8. According to the method described in Clause A7, the target network layer can accept multiple data types, each corresponding to a different bit width value range. The step of determining the data type of the target data includes: identifying the bit width value range in which the total bit width is located, so as to select the corresponding data type among the multiple data types.
[0079] Clause A9. A computer-readable storage medium having stored thereon computer program code of a data type selection method, which, when executed by a processing device, performs the method described in any one of Clauses A1 to A8.
[0080] Clause A10. A computer program product including a computer program for a data type selection method, which, when executed by a processor, implements the steps of the method described in any one of Clauses A1 to A8.
[0081] Clause A11. A computer apparatus comprising a memory, a processor, and a computer program stored in the memory, the processor executing the computer program to perform the steps of the method described in any one of Clauses A1 to A8.
[0082] Clause A12. A data type selection device, comprising: a statistics module for statistically analyzing the exponential distribution information of target data in a target network layer, the exponential distribution information including the exponential distribution range and the exponential value distribution magnitude; a setting module for setting the exponential bit width of the target data according to the exponential distribution range; and setting the mantissa bit width of the target data according to the exponential value distribution magnitude; and a determination module for determining the data type corresponding to the target data according to the exponential bit width and the mantissa bit width.
[0083] The embodiments of this disclosure have been described in detail above. Specific examples have been used to illustrate the principles and implementation methods of this disclosure. The descriptions of the above embodiments are only for the purpose of helping to understand the methods and core ideas of this disclosure. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of this disclosure. Therefore, the content of this specification should not be construed as a limitation of this disclosure.
Claims
1. A data type selection method, characterized in that, include: The exponential distribution information of the target data in the target network layer is statistically analyzed. The exponential distribution information includes the exponential distribution range and the distribution of exponential values. The target data is image data and / or voice data. The exponent bit width of the target data is set according to the exponent distribution range; The step of setting the exponent width of the target data includes: Calculate the product of the range of the exponential distribution and the first hyperparameter; The product is rounded down; The rounded result is the exponent width; or The step of setting the exponent width of the target data includes: Identify the exponential distribution intervals within the distribution proportion threshold of the exponential distribution range; Wherein, the bit width value corresponding to the exponential distribution interval is the exponential bit width; The mantissa bit width of the target data is set according to the distribution of the exponent value; The step of setting the mantissa bit width of the target data includes: Identify the exponent with the largest number of distributions; Calculate the ratio of the maximum distribution number to the total distribution number; Calculate the product of the distribution ratio and the second hyperparameter; The product is rounded down; The rounded result is the mantissa bit width; The data type of the target data is determined based on the exponent bit width and the mantissa bit width.
2. The method according to claim 1, wherein the range of the exponent distribution is the maximum value of the exponent bit minus the minimum value of the exponent bit in the target data.
3. The method according to claim 1, wherein the rounding step is rounding up.
4. The method according to claim 1, wherein the step of determining the data type of the target data includes: The sign bit width, the exponent bit width, and the mantissa bit width are summed to obtain the total bit width of the target data.
5. The method according to claim 4, wherein the target network layer can accept multiple data types, each corresponding to a different bit width range, and the step of determining the data type of the target data includes: Identify the bit width value range in which the total bit width is located, in order to select the corresponding data type among the multiple data types.
6. A computer-readable storage medium having stored thereon computer program code of a data type selection method, which, when executed by a processing device, performs the method according to any one of claims 1 to 5.
7. A computer program product comprising a computer program of a data type selection method, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 5.
8. A computer device comprising a memory, a processor, and a computer program stored in the memory, characterized in that, The processor executes the computer program to implement the steps of the method according to any one of claims 1 to 5.
9. A data type selection apparatus characterized by comprising: include: The statistics module is used to statistically analyze the exponential distribution information of the target data in the target network layer. The exponential distribution information includes the exponential distribution range and the distribution of exponential values. The target data is image data and / or voice data. The configuration module is used to: The exponent bit width of the target data is set according to the exponent distribution range; The step of setting the exponent width of the target data includes: Calculate the product of the range of the exponential distribution and the first hyperparameter; The product is rounded down; The rounded result is the exponent width; or The step of setting the exponent width of the target data includes: Identify the exponential distribution intervals within the distribution proportion threshold of the exponential distribution range; Wherein, the bit width value corresponding to the exponential distribution interval is the exponential bit width; The mantissa bit width of the target data is set according to the distribution of the exponent value; The step of setting the mantissa bit width of the target data includes: Identify the exponent with the largest number of distributions; Calculate the ratio of the maximum distribution number to the total distribution number; Calculate the product of the distribution ratio and the second hyperparameter; The product is rounded down; The rounded result is the mantissa bit width; The decision module is used to determine the data type corresponding to the target data based on the exponent bit width and the mantissa bit width.
Citation Information
Patent Citations
Data processing method and device based on neural network
CN106570559A
Data processing method and device, computer equipment and storage medium
CN110889503A