Accumulation apparatus, method and readable storage medium

By identifying the base exponent of floating-point numbers and filtering accumulation clusters, the problems of large layout area and unsatisfactory accuracy of floating-point accumulation trees are solved, realizing efficient and low-power floating-point accumulation, which is suitable for convolutional and fully connected layer operations in neural networks.

CN114546331BActive Publication Date: 2026-01-02CAMBRICON TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202011364680.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-11-27
Publication Date
2026-01-02
Estimated Expiration
2040-11-27

AI Technical Summary

Technical Problem

In existing technologies, floating-point accumulation trees have a large layout area and unsatisfactory accuracy, especially in the convolutional and fully connected layers of neural networks. The results of floating-point accumulation need to be quantized into fixed-point numbers before multiplication, which affects the continuity of the operation.

Method used

An accumulation device and method are adopted to identify the reference exponent of floating-point numbers, filter out accumulation clusters whose exponent differences are within a threshold range, and directly accumulate these floating-point numbers using an addition module. Finally, a Wallace tree adder is used to perform fixed-point number accumulation to ensure accuracy.

Benefits of technology

It achieves floating-point number accumulation with small circuit area, low power consumption and high precision, and is suitable for convolutional and fully connected layer operations in neural networks.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114546331B_ABST
    Figure CN114546331B_ABST
Patent Text Reader

Abstract

The application is an accumulation device, method and readable storage medium, which are used to accumulate a plurality of floating-point numbers. First, a reference exponent is identified, then an accumulation cluster is selected according to the reference exponent, and the floating-point numbers in the accumulation cluster are accumulated. The application has small circuit area, low power consumption and high precision.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the field of computers. More particularly, the present application relates to an accumulation device, method and computer readable storage medium. BACKGROUND

[0002] Computers often need to perform accumulation of floating point numbers, which is done by using a multi-stage accumulation tree. Take accumulation of 8 floating point numbers as an example, the first stage needs 4 adders, two by two to do addition, to get 4 numbers, the second stage needs 2 adders, again two by two to do addition, to get 2 numbers, the third stage needs 1 adder to add the two numbers to get the final accumulation result. The layout area of such accumulation tree is large, and the accuracy is not ideal.

[0003] Furthermore, in some special applications, such as the convolution layer and the fully connected layer of neural networks, the result of accumulation of floating point numbers needs to be quantized into fixed point numbers before being input to the Wallace tree for multiplication. The result of the aforementioned accumulation tree is still a floating point number, which still needs to be converted into a fixed point number to be accepted by the Wallace tree, which is not conducive to the continuity of the operation.

[0004] Therefore, an effective floating point number accumulation scheme is urgently needed. SUMMARY

[0005] In order to at least partially solve the technical problems mentioned in the background, the present application provides an accumulation device, method and computer readable storage medium.

[0006] In one aspect, the present application discloses an accumulation device for accumulating a plurality of floating point numbers in an identified cluster, each floating point number being represented by an exponent and a mantissa. The accumulation device comprises an identification module, a screening module and an addition module. The identification module is configured to identify a reference exponent, the reference exponent being the maximum value of the exponents in the plurality of floating point numbers. The screening module is configured to screen an accumulation cluster from the identified cluster according to the reference exponent, the accumulation cluster being a subset of the identified cluster. The addition module is configured to perform accumulation on the floating point numbers in the accumulation cluster.

[0007] In another aspect, the present application discloses a method for accumulating a plurality of floating point numbers in an identified cluster, each floating point number being represented by an exponent and a mantissa. The method comprises: identifying a reference exponent, the reference exponent being the maximum value of the exponents in the plurality of floating point numbers; screening an accumulation cluster from the identified cluster according to the reference exponent, the accumulation cluster being a subset of the identified cluster; and performing accumulation on the floating point numbers in the accumulation cluster.

[0008] In another aspect, the present application discloses a computer readable storage medium having stored thereon computer program code for accumulating a plurality of floating point numbers, the computer program code, when executed by a processing device, performs the aforementioned method.

[0009] The circuit of the present application has small area, low power consumption and high precision. BRIEF DESCRIPTION OF DRAWINGS

[0010] The above and other objects, features and advantages of the present application will become more apparent from the following detailed description read in conjunction with the accompanying drawings, in which:

[0011] Figure 1 is a number sequence showing single-precision floating-point numbers;

[0012] Figure 2 is a schematic diagram showing the accumulation device of the embodiment of the present application;

[0013] Figure 3 is a schematic diagram showing the identification module of the embodiment of the present application;

[0014] Figure 4 is a schematic diagram showing the screening module of the embodiment of the present application;

[0015] Figure 5 is a schematic diagram showing the addition module of the embodiment of the present application;

[0016] Figure 6 is a schematic diagram showing a five-stage Wallace tree adder;

[0017] Figure 7 is a flowchart showing the method for accumulating multiple floating-point numbers of the embodiment of the present application;

[0018] Figure 8 is a flowchart showing the screening of accumulation clusters of the embodiment of the present application; and

[0019] Figure 9 is a flowchart showing the execution of accumulation on floating-point numbers of the embodiment of the present application. DETAILED DESCRIPTION

[0020] The technical solutions in the embodiments of the present application will be apparently and completely described below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are part of, rather than all of, the embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without any creative work fall within the protection scope of the present application.

[0021] It should be understood that the terms "first", "second", "third", and "fourth" and the like in the description and in the claims of the present application are used for distinguishing between similar objects and not necessarily for describing a particular sequential or chronological order. The terms "comprises", "comprising", "includes", "including" and the like used in the present specification

[0022] It is also to be understood that the terminology used herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the present application. As used in this specification and the claims, the singular forms "a", "an" and "the" include plural referents unless the content clearly dictates otherwise. It should also be understood that the term "and / or" as used herein refers to and encompasses any and all possible combinations of one or more of the associated listed items.

[0023] As used in this specification and claim(s), the terms "if' and "when" can be construed to mean "when" or "if’ or "in response to a determination” or “in response to a detection” depending on the context.

[0024] The specific embodiments of the present application will now be described in detail with reference to the following figures.

[0025] The format of expressing floating point numbers in computers is specified in IEEE 754. Accumulation of floating point numbers is a common basic operation in the field of computers, especially in the convolution layer and fully connected layer of neural networks after the advent of the era of artificial intelligence, a large number of accumulation operations are required. Taking a 32-bit single-precision floating point number as an example, it is composed of 1 bit of sign, 8 bits of exponent and 23 bits of mantissa, arranged as a number sequence as shown in Figure 1 The value represented by the number sequence is:

[0026] Value = sign x mantissa x 2 exp-127

[0027] The 8-bit exponent can represent a range of 0 to 255, which will make the exponent very large, so the IEEE 754 specification offsets the exponent by 127, which makes the exponent range shift to -127 to 128, which is more reasonable. IEEE 754 further stipulates that there is one bit hidden to the left of the decimal point, and this bit is usually 1, so the mantissa of the above single-precision floating point number is actually 24 bits.

[0028] For example, the conversion of the decimal number 176.0625 into a binary floating-point number is shown below. The number 176.0625 is split into the integer part "176" and the fractional part ".0625". The integer part "176" is converted into binary as "10110000", which is 2 7 + 2 5 + 2 4 = 127. The fractional part is converted by multiplying the fractional part by 2 and taking the integer part until the product is 0. That is, 0.0625 x 2 = 0.125, the integer part is 0; 0.125 x 2 = 0.25, the integer part is still 0; 0.25 x 2 = 0.50, the integer part is still 0; and finally 0.5 x 2 = 1.0, the integer part is 1. Thus, the binary representation of the fractional part is "0001". Therefore, the binary single-precision floating-point number of the decimal number 176.0625 is "10110000.0001", which is expressed in exponential form as 1.01100000001 x 2 7 .

[0029] Since the IEEE 754 convention is that the single-precision exponent offset is 127, the binary single-precision floating-point number 1.01100000001 x 2 7 is expressed in IEEE 754 standard as 10000110 for the exponent offset, 01100000001000000000000 for the mantissa, and 0 for the sign bit. Thus, the binary single-precision floating-point number (FB32) of the decimal number 176.0625 is shown in Table 1. Figure 1

[0030] Since the above representation method limits the range and precision of the floating-point number, the floating-point number can only be approximately represented for operation, and the rounding problem has to be considered. In the decimal system, suppose that two decimal digits are to be retained, i.e., the digits in the tenths and hundredths places are to be retained. The lowest digit, i.e., the digit in the hundredths place, is the retained digit, the first discarded digit, i.e., the digit in the thousandths place, is the approximate digit, and all the digits in the thousandths place and beyond are the sticky digits, the information of which is lost.

[0031] ​To this end, IEEE 754 defines four different rounding modes: rounding to even, rounding to zero, rounding down or rounding up, and IEEE 754 adopts rounding to even by default. Rounding to even is rounding to the nearest value. If the nearest value is unique, it is directly rounded to the nearest value; if the floating-point number is exactly in the "middle value", then see if the reserved bit is even, if it is even, directly round off the following number without carry, if it is odd, then carry and then round off the following number.

[0032] For the operation needs, the floating-point number can be represented by the original code, the inverse code or the complement code. The original code is the sign bit plus the true value, that is, the representation shown in the formula (1). When represented by the inverse code, the inverse code of the positive number is the same as its original code, and the inverse code of the negative number is the inverse of its original code bit by bit, but the sign bit is excluded. When represented by the complement code, the complement code of the positive number is the same as the original code, and the complement code of the negative number is equal to the last bit of its inverse code plus 1. Figure 1

[0033] When the floating-point number is added, the first step is to align the exponents, that is, to align the exponents of the two floating-point numbers to be operated. The purpose is to enable the tail numbers of the two floating-point numbers to be operated. Because only when the exponent values of the two floating-point numbers are the same, the same exponent value can be taken out as a common factor, and then the tail number is added.

[0034] The specific method of aligning the exponents is as follows: the difference between the exponents of the two floating-point numbers is found out, the small exponent is added to the found difference to make it equal to the large exponent, and the tail number of the floating-point number corresponding to the small exponent is right shifted by the corresponding number of bits to ensure that the value of the floating-point number is unchanged. It should be noted that the principle of aligning the exponents is that the small exponent is aligned to the large exponent. The reason for this is that if the large exponent is aligned to the small exponent, the high bits of the tail number of the floating-point number of the large exponent will be shifted out. The information amount of the high bits is large, and the precision loss is large if the high bits are shifted out. On the contrary, the low bits of the tail number of the floating-point number of the small exponent are shifted out, the information amount of the low bits is small, and the precision loss is small.

[0035] One embodiment of the present application is an accumulation device for accumulating a plurality of floating-point numbers. The floating-point numbers to be accumulated are referred to as the identification cluster in this embodiment. The accumulation device finds out the maximum value of the exponents (exponent bits) of the floating-point numbers, takes the maximum value as the reference exponent, and screens out the accumulation cluster. The floating-point numbers in the accumulation cluster have close exponent bit numbers, and can be directly accumulated without affecting the precision. Therefore, the floating-point numbers in the accumulation cluster are directly accumulated in this embodiment. After the accumulation, the floating-point numbers in the identification cluster are updated, and the operation is repeated until all the floating-point numbers are accumulated.

[0036] Figure 2 A schematic diagram of the accumulation device of this embodiment is shown. The accumulation device includes an identification module 201, a screening module 202, an addition module 203 and a cluster module 204.

[0037] ​The identification module 201 is used to identify the reference exponent, which is the maximum value of the exponents of the floating-point numbers in the identification cluster, i.e., finding the maximum value of the exponents of all the floating-point numbers in the identification cluster, and taking this maximum value as the reference exponent. The screening module 202 is used to compare the reference exponent with the exponents of all the floating-point numbers in the identification cluster, and if the difference is within a certain range, the floating-point numbers are screened into the accumulation cluster, so the accumulation cluster is a subset of the identification cluster. The addition module 203 is used to perform accumulation on the floating-point numbers in the accumulation cluster. After the accumulation is completed, the cluster module 204 removes the floating-point numbers in the accumulation cluster from the identification cluster and clears the accumulation cluster. The identification module 201, the screening module 202, and the addition module 203 find the reference exponent, screen the accumulation cluster, and accumulate the floating-point numbers in the accumulation cluster based on the updated identification cluster until all the floating-point numbers are accumulated.

[0038] In order to identify the reference exponent, the identification module 201 includes a multi-stage two-input comparator, Figure 3 An embodiment of an identification module is shown, which is a five-stage two-input comparator used to compare the exponents of 32 floating-point numbers at the same time. The five-stage two-input comparator includes a first-stage comparison unit 301, a second-stage comparison unit 302, a third-stage comparison unit 303, a fourth-stage comparison unit 304, and a fifth-stage comparison unit 305. Each comparison unit includes multiple two-input comparators that compare the exponents of floating-point numbers two by two, and output the larger exponent to the next stage of comparators. In more detail, the first-stage comparison unit 301 can compare the exponents of 32 floating-point numbers at the same time, and output the 16 larger ones to the second-stage comparison unit 302. The second-stage comparison unit 302 receives and compares the exponents of the 16 floating-point numbers, and outputs the 8 larger ones to the third-stage comparison unit 303. The third-stage comparison unit 303 receives and compares the exponents of the 8 floating-point numbers, and outputs the 4 larger ones to the fourth-stage comparison unit 304. The fourth-stage comparison unit 304 receives and compares the exponents of the 4 floating-point numbers, and outputs the 2 larger ones to the fifth-stage comparison unit 305. The fifth-stage comparison unit 305 receives and compares the exponents of the 2 floating-point numbers, and finally outputs the larger one. The output of the fifth-stage comparison unit 305 is the largest exponent among the 32 floating-point numbers.

[0039] Figure 3 The five-stage two-input comparator is an example of comparing the exponents of 32 floating-point numbers at the same time. The identification module 201 is not limited to this structure, and those skilled in the art can make appropriate changes according to actual conditions, such as setting an eight-to-one comparator, comparing the floating-point numbers in the identification cluster in groups of 8, and sequentially finding the reference exponent.

[0040] Figure 4A schematic diagram of the screening module 202 is shown, which includes a subtractor 401, a comparator 402, a first temporary storage 403 and a second temporary storage 404.

[0041] The subtractor 401 is used to obtain the difference between each exponent and the reference exponent based on the result of the identification module 201 (i.e. the reference exponent). The subtractor 401 has several implementations, for example: the subtractor 401 has N subtractor units, receives the exponents of N floating-point numbers in the identified cluster and the reference exponent at one time, and performs subtraction between the exponents of all floating-point numbers in the identified cluster and the reference exponent to obtain the difference between each exponent and the reference exponent; or receives one floating-point number in the identified cluster and the reference exponent at one time, and performs subtraction between the floating-point number and the reference exponent until all floating-point numbers in the identified cluster are processed. The present application does not limit the implementation of the subtractor 401.

[0042] The comparator 402 receives the difference from the subtractor 401 to determine whether the difference is less than a threshold value, that is, to determine whether the difference between the exponent of each floating-point number and the reference exponent is within the threshold value range. The threshold value can be any number, for example, 32. If the floating-point number is less than the threshold value, the floating-point number is sent to the first temporary storage 403 for storage. If the floating-point number is not less than the threshold value, the floating-point number is sent to the second temporary storage 404 for storage. In other words, the comparator 402 divides the floating-point numbers into two categories according to the size of the exponents, the first temporary storage 403 is used to store the floating-point numbers whose difference is less than the threshold value, and the second temporary storage 404 is used to store the floating-point numbers whose difference is not less than the threshold value.

[0043] Since the floating-point numbers stored in the first temporary storage 403 have a difference less than the threshold value, it means that the exponents of the floating-point numbers in the first temporary storage 403 do not differ much from the reference exponent, and when performing accumulation, the floating-point numbers will not lose too much precision when the mantissa is shifted. All floating-point numbers in the first temporary storage 403 are referred to as an accumulation cluster in the present application, and are ready to be accumulated in the addition module 203. The floating-point numbers stored in the second temporary storage 404 have a difference too large from the reference exponent, and if accumulated, the floating-point numbers will lose too much precision when the mantissa is shifted. Therefore, the floating-point numbers in the second temporary storage 404 will not be sent to the addition module 203 for accumulation at this stage. The processing method of the floating-point numbers in the second temporary storage 404 will be described later.

[0044] Figure 5 A schematic diagram of the addition module 203 is shown, which includes a shifter 501, a first converter 502, a Wallace tree adder 503 and a second converter 504.

[0045] The shifter 501 includes a plurality of barrel shifter units, which is a kind of combinational logic circuit, having a plurality of data inputs and a plurality of data outputs, and control inputs that specify how to shift the data. The barrel shifter units are respectively used to shift the corresponding mantissas based on the difference values. First, the mantissas are restored and zeros are appended after the mantissas, and all the shifted mantissas have a threshold minus one bit, i.e., each mantissa is 31 bits. More specifically, if the accumulation cluster includes 32 floating-point numbers, the shifter 501 can include 32 shifter units, each of which is used to shift the mantissa bits of one floating-point number in the first temporary register 403. Since the reference exponent is the maximum exponent among the 32 floating-point numbers, the exponents of the floating-point numbers in the accumulation cluster are all aligned to the reference exponent, and the mantissa bits are correspondingly shifted. If the threshold is set to 32, there will be no floating-point number in the accumulation cluster whose exponent difference is greater than 32, so after shifting, the mantissa bits of all floating-point numbers are 31 bits, which is the threshold minus one bit.

[0046] When the shifter unit determines that the shifted mantissa has all bits shifted out as 0, then according to the IEEE 754 principle of rounding to the nearest even number, the shifter unit sets all the sticky bits of the shifted mantissa to 0; when the shifter unit determines that the shifted mantissa has all bits shifted out as 1, then all the sticky bits are set to 1. In this way, the shifter 501 has completed the alignment of all floating-point numbers in the accumulation cluster.

[0047] The first converter 502 is used to convert the shifted mantissa into a complement. Since the Wallace tree adder 503 only supports complement operation, and the operations before the shifter 501 are all completed in the original code, the first converter 502 converts the shifted mantissa into a complement for the Wallace tree adder 503 to perform fixed-point number accumulation operation.

[0048] The Wallace tree adder 503 is used to accumulate all the complements in the accumulation cluster to generate an accumulated value complement. The Wallace tree adder 503 is a multi-stage two-input adder unit, Figure 6 The Wallace tree adder 503 shown in the five-stage two-input adder unit includes a first-stage adder unit 601, a second-stage adder unit 602, a third-stage adder unit 603, a fourth-stage adder unit 604, and a fifth-stage adder unit 605. Each stage of the adder unit adds two fixed-point numbers, so the fifth-stage adder unit 605 obtains the accumulation sum of 32 fixed-point numbers.

[0049] The second converter 504 is used to convert the accumulated value complement into an accumulated value original code. In this way, the accumulation of all floating-point numbers in the accumulation cluster has been completed.

[0050] The accumulation device then processes the floating-point numbers in the second temporary register 404. Returning to Figure 2The cluster module 204 is used to update the floating-point numbers in the second temporary register 404 to the floating-point numbers in the identified cluster, that is, the cluster module 204 replaces the floating-point numbers in the second temporary register 404 with the floating-point numbers in the original identified cluster, so that the floating-point numbers in the updated identified cluster are not all the floating-point numbers to be accumulated, but only the floating-point numbers in the second temporary register 404 that have not been accumulated. The cluster module 204 sends the updated identified cluster to the identification module 201, and the identification module 201, the screening module 202 and the addition module 203 perform the operations of identification, screening and accumulation based on the updated identified cluster. The operations are repeated in this way until all the floating-point numbers enter the addition module 203 for accumulation.

[0051] Another embodiment of the present application is a method for accumulating a plurality of floating-point numbers in an identified cluster, Figure 7 A flowchart of the method is shown.

[0052] In step 701, the reference exponent is identified, that is, the maximum value of the exponents of all the floating-point numbers in the identified cluster is found, and this maximum value of the exponent is taken as the reference exponent. The specific identification method can compare the exponents of all the floating-point numbers in the identified cluster two by two, and output the larger one.

[0053] In step 702, the accumulation cluster is screened according to the reference exponent, and the accumulation cluster is a subset of the identified cluster. The detailed operation of this step is shown in Figure 8 .

[0054] In step 801, the difference between each exponent and the reference exponent is obtained based on the reference exponent identified in step 701. In step 802, it is determined whether the difference is less than a threshold value, that is, it is determined whether the difference between the exponent of each floating-point number and the reference exponent is within the threshold value range, and the threshold value can be any number. If the floating-point number whose difference is less than the threshold value, then step 803 is performed to set its floating-point number to the accumulation cluster; if the floating-point number whose difference is not less than the threshold value, then step 804 is performed to temporarily store its floating-point number in the temporary register. Since the floating-point numbers in the accumulation cluster have a difference in exponents less than the threshold value, it means that the difference between the exponents of the floating-point numbers and the reference exponent is not large, and when the accumulation is performed, the floating-point numbers will not lose too much precision when the mantissa is shifted. The floating-point numbers stored in the temporary register have a difference in exponents too large from the reference exponent, and if the accumulation is performed, the floating-point numbers will lose too much precision when the mantissa is shifted, so the accumulation is not performed at this stage.

[0055] In step 703, the accumulation is performed on the floating-point numbers in the accumulation cluster. The detailed operation of this step is shown in Figure 9 .

[0056] In step 901, the corresponding mantissas are shifted based on the exponent difference. First, the mantissas are restored and zeros are appended to the mantissas, and all the shifted mantissas have a threshold minus one bit. In step 902, it is determined whether the shifted mantissas are all zeros; if yes, step 903 is performed to set all the sticky bits of the shifted mantissas to zero; if no, step 904 is performed to set all the sticky bits of the shifted mantissas to one. Thus, the scaling of all the floating-point numbers in the accumulation cluster is completed.

[0057] In step 905, the shifted mantissas are converted into complements. In step 906, all the complements in the accumulation cluster are accumulated to generate an accumulated value complement. In step 907, the accumulated value complement is converted into an accumulated value true code. Thus, the accumulation of all the floating-point numbers in the accumulation cluster is completed.

[0058] Then, step 704 is performed to determine whether all the floating-point numbers have been accumulated. If no, step 705 is performed to update the floating-point numbers stored in the temporary register to the floating-point numbers in the identification cluster, that is, the floating-point numbers in the temporary register are updated to the floating-point numbers in the identification cluster, so that the floating-point numbers in the updated identification cluster are not all the floating-point numbers to be accumulated, but only the floating-point numbers in the temporary register that have not been accumulated. After step 705 is performed, steps 701, 702 and 703 are returned to, and the identification, screening and accumulation operations are performed based on the updated identification cluster. The operations are repeated until all the floating-point numbers have been accumulated, and then step 706 is performed to end the flow.

[0059] Another embodiment of the present application is a computer readable storage medium having stored thereon computer program codes for accumulating a plurality of floating-point numbers, which, when executed by a processor, perform the method shown in Figure 7 、 Figure 8 、 Figure 9 In some implementation scenarios, the integrated unit described above can be implemented in the form of a software program module. If implemented in the form of a software program module and sold or used as an independent product, the integrated unit can be stored in a computer readable memory. Based on this, when the scheme of the present application is embodied in the form of a software product (for example, a computer readable storage medium), the software product can be stored in a memory, which can include a plurality of instructions for causing a computer device (for example, a personal computer, a server or a network device, etc.) to execute some or all steps of the method described in the embodiments of the present application. The aforementioned memory can include, but is not limited to, a U disk, a flash disk, a read-only memory (Read Only Memory, ROM), a random access memory (Random Access Memory, RAM), a mobile hard disk, a magnetic disk or an optical disk, etc. various media that can store program codes.

[0060] The application provides a floating point number accumulation scheme, which compares the exponent of a floating point number with a reference exponent, accumulates the floating point number whose difference is less than a threshold, and finds the reference exponent again, compares and accumulates the floating point number whose difference is not less than the threshold, until all the floating point numbers are accumulated, and the circuit area is small, the power consumption is low, and the precision is high.

[0061] It should be noted that, for the purpose of simplicity, the application describes some methods and embodiments thereof as a series of actions and combinations thereof, but those skilled in the art can understand that the solutions of the application are not limited by the order of the described actions. Therefore, those skilled in the art can understand that some steps can be executed in other orders or simultaneously according to the disclosure or teaching of the application. Further, those skilled in the art can understand that the described embodiments of the application can be regarded as optional embodiments, that is, the actions or modules involved are not necessarily essential for the implementation of one or more solutions of the application. In addition, the description of some embodiments of the application is also focused on different solutions. Therefore, those skilled in the art can understand that the parts not described in detail in some embodiments of the application can also refer to the relevant description of other embodiments.

[0062] In terms of specific implementation, those skilled in the art can understand that the several embodiments disclosed by the application can also be implemented by other ways not disclosed herein based on the disclosure and teaching of the application. For example, as for each unit in the electronic device or apparatus embodiments described above, the units are split based on the consideration of logical functions, and there can be another splitting way when actually implemented. For another example, a plurality of units or components can be combined or integrated into another system, or some features or functions of the units or components can be selectively disabled. As for the connection relationship between different units or components, the connection discussed above in combination with the drawings can be direct or indirect coupling between the units or components. In some scenarios, the aforementioned direct or indirect coupling involves a communication connection using an interface, where the communication interface can support electrical, optical, acoustic, magnetic or other forms of signal transmission.

[0063] In the application, the units described as separate components can or can not be physically separated, and the components shown as units can or can not be physical units. The aforementioned components or units can be located in the same place or distributed on multiple network units. In addition, according to the actual needs, some or all of the units can be selected to achieve the purpose of the solutions described in the embodiments of the application. In addition, in some scenarios, multiple units in the embodiments of the application can be integrated into one unit or physically exist separately.

[0064] The foregoing can be better understood in light of the following clauses:

[0065] Clause A1, an accumulation apparatus for accumulating a plurality of floating-point numbers in an identification cluster, each floating-point number being represented by an exponent and a mantissa, the accumulation apparatus comprising: an identification module for identifying a reference exponent, the reference exponent being a maximum value of the exponents in the plurality of floating-point numbers; a screening module for screening out an accumulation cluster from the identification cluster according to the reference exponent, the accumulation cluster being a subset of the identification cluster; and an addition module for performing accumulation on the floating-point numbers in the accumulation cluster.

[0066] Clause A2, the accumulation apparatus according to Clause A1, wherein the identification module comprises a plurality of stages of two-input comparators, each stage of comparators comparing the exponents of the plurality of floating-point numbers two by two, and outputting a larger exponent to a next stage of comparators.

[0067] Clause A3, the accumulation apparatus according to Clause A1, wherein the screening module comprises: a subtractor for obtaining a difference between each exponent and the reference exponent; a comparator for determining whether the difference is less than a threshold value; a first temporary storage for storing the floating-point numbers whose differences are less than the threshold value; and a second temporary storage for storing the floating-point numbers whose differences are not less than the threshold value; wherein the accumulation cluster comprises all the floating-point numbers in the first temporary storage.

[0068] Clause A4, the accumulation apparatus according to Clause A3, further comprising: a cluster module for updating the floating-point numbers in the second temporary storage as the floating-point numbers in the identification cluster; wherein the identification module, the screening module and the addition module perform the operations of identification, screening and accumulation based on the updated identification cluster.

[0069] Clause A5, the accumulation apparatus according to Clause A3, wherein the addition module comprises a plurality of shift units respectively for shifting the corresponding mantissas based on the differences, all the shifted mantissas having the threshold value minus one bit.

[0070] Clause A6, the accumulation apparatus according to Clause A5, wherein when the shift units determine that the number of shifted-out bits of the shifted mantissas are all 0, then setting a sticky bit of the shifted mantissas to 0, and when the shift units determine that the number of shifted-out bits of the shifted mantissas are all 1, then setting the sticky bit to 1.

[0071] Clause A7, the accumulation apparatus according to Clause A5, wherein the addition module further comprises a first converter for converting the shifted mantissas into complements.

[0072] Clause A8, the accumulation apparatus according to Clause A7, wherein the addition module further comprises a Wallace tree adder for accumulating all the complements in the accumulation cluster to generate a sum complement.

[0073] Clause A9, the accumulation apparatus of clause A8, wherein the adding module further comprises a second converter to convert the accumulated value’s complement to an accumulated value’s true.

[0074] Clause A10, a method to accumulate a plurality of floating-point numbers in an identified cluster, each floating-point number represented by an exponent and a mantissa, the method comprising: identifying a reference exponent, the reference exponent being a maximum value of exponents in the plurality of floating-point numbers; screening an accumulation cluster from the identified cluster according to the reference exponent, the accumulation cluster being a subset of the identified cluster; and performing accumulation on floating-point numbers in the accumulation cluster.

[0075] Clause A11, the method of clause A10, wherein the identifying step comprises: comparing exponents of the plurality of floating-point numbers two by two, outputting a larger exponent.

[0076] Clause A12, the method of clause A10, wherein the screening step comprises: obtaining a difference value of each exponent and the reference exponent; and setting a floating-point number whose difference value is less than a threshold value as the accumulation cluster.

[0077] Clause A13, the method of clause A12, further comprising: updating a floating-point number whose difference value is not less than the threshold value as a floating-point number in the identified cluster; wherein the identifying step, the screening step, and the accumulating step are performed based on the updated identified cluster.

[0078] Clause A14, the method of clause A12, wherein the accumulating step comprises: shifting mantissas based on the difference value, all shifted mantissas having the threshold value minus one bit.

[0079] Clause A15, the method of clause A14, wherein the accumulating step comprises: determining whether bits shifted out of the shifted mantissas are all zeros; if yes, setting a sticky bit of the shifted mantissas as zero; and if no, setting the sticky bit as one.

[0080] Clause A16, the method of clause A14, wherein the accumulating step further comprises: converting the shifted mantissas to complements.

[0081] Clause A17, the method of clause A16, wherein the accumulating step further comprises: accumulating all complements in the accumulation cluster to generate an accumulated value’s complement.

[0082] Clause A18, the method of clause A17, wherein the accumulating step further comprises: converting the accumulated value’s complement to an accumulated value’s true.

[0083] Clause A19. A computer-readable storage medium having stored thereon computer program code which, when executed by a processing apparatus, performs the method of any of clauses A10 to A18.

[0084] The above has carried on the detailed introduction to the embodiment of the present application, the principle and implementation mode of the present application have been set forth by applying the specific example in this article, the above embodiment explanation is only for helping understanding the method of the present application and its core thought;At the same time, for the general technical personnel in the field, according to the idea of the present application, there will be changes in specific implementation mode and application scope, and the above is described, the content of the specification should not be understood as the limitation of the present application.

Claims

1. An accumulation device for accumulating and identifying multiple floating-point numbers in a cluster, each floating-point number being represented by an exponent and a mantissa, the accumulation device comprising: The identification module is used to identify the base exponent, which is the maximum value of the exponents among the plurality of floating-point numbers; A filtering module is used to filter out the cumulative clusters based on the base exponent, wherein the cumulative clusters are a subset of the identified clusters; as well as The addition module is used to perform accumulation on the floating-point numbers in the accumulation cluster; The filtering module includes: A subtractor is used to obtain the difference between each exponent and the base exponent; A comparator is used to determine whether the difference is less than a threshold. A first temporary register is used to store floating-point numbers whose difference is less than the threshold; and The second temporary register is used to store the floating-point number whose difference is not less than the threshold. The accumulation cluster includes all floating-point numbers in the first register; The accumulation device further includes: a cluster module, used to update the floating-point number in the second temporary register to the floating-point number in the identification cluster; The identification module, the filtering module, and the addition module perform identification, filtering, and accumulation operations based on the updated identification cluster.

2. The accumulation device according to claim 1, wherein the identification module includes a multi-stage two-input comparator, each stage comparator comparing the exponents of the plurality of floating-point numbers pairwise and outputting the larger exponent to the next stage comparator.

3. The accumulation device according to claim 1, wherein the addition module includes a plurality of shift units, each used to shift the corresponding mantissa based on the difference, wherein all mantissas after shifting have the threshold minus one bit.

4. The accumulation device according to claim 3, wherein when the shift unit determines that all the bits shifted out of the mantissa after the shift are 0, the sticky bit of the mantissa after the shift is set to 0, and when the shift unit determines that all the bits shifted out of the mantissa after the shift are 1, the sticky bit is set to 1.

5. The accumulation device according to claim 3, wherein the addition module further includes a first converter for converting the shifted mantissa into two's complement.

6. The accumulation device according to claim 5, wherein the addition module further comprises a Wallace tree adder for accumulating all two's complements in the accumulation cluster to generate the two's complement of the accumulated value.

7. The accumulation device according to claim 6, wherein the addition module further includes a second converter for converting the two's complement of the accumulated value into the original code of the accumulated value.

8. A method for accumulating and identifying multiple floating-point numbers in a cluster, each floating-point number being represented by an exponent and a mantissa, the method comprising: Identify the base exponent, which is the maximum value of the exponents among the plurality of floating-point numbers; Accumulated clusters are selected based on the reference exponent, and the accumulated clusters are a subset of the identified clusters; as well as Perform accumulation on the floating-point numbers in the accumulation cluster; The screening steps include: Obtain the difference between each exponent and the reference exponent; and The floating-point numbers whose differences are less than a threshold are defined as the accumulated cluster; The method further includes: Update the floating-point number whose difference is not less than the threshold to the floating-point number in the identification cluster; The identification step, the filtering step, and the accumulation step are executed based on the updated identification cluster.

9. The method according to claim 8, wherein the identification step comprises: The exponents of the multiple floating-point numbers are compared pairwise, and the larger exponent is output.

10. The method of claim 8, wherein the accumulation step comprises: This is used to shift the corresponding mantissa based on the difference, and all the shifted mantissas have the threshold minus one bit.

11. The method of claim 10, wherein the accumulation step comprises: Determine if all the bits shifted out of the mantissa after the shift are 0; If so, set the sticky bit of the shifted mantissa to 0; as well as If not, set the viscosity bit to 1.

12. The method of claim 10, wherein the accumulation step further comprises: Convert the shifted mantissa into two's complement.

13. The method of claim 12, wherein the accumulation step further comprises: All two's complements in the accumulator cluster are summed to produce the summed value in two's complement.

14. The method of claim 13, wherein the accumulation step further comprises: Convert the two's complement of the accumulated value into the original code of the accumulated value.

15. A computer-readable storage medium having stored thereon computer program code that accumulates a plurality of floating-point numbers, wherein when the computer program code is run by a processing device, it performs the method of any one of claims 8 to 14.

Citation Information

Patent Citations

  • Processing method and computer system for summation of floating point data

    CN101042638A

  • Device and method for adding multiple floating-point numbers

    CN107305485A