Approximate computation in digital systems using bit partitioning
11914447 ยท 2024-02-27
Assignee
Inventors
Cpc classification
G06F9/5027
PHYSICS
G06F7/74
PHYSICS
International classification
Abstract
A computing methodology in digital systems for performing computationally expensive operations while lowering the required computing resources, the power consumed to accomplish the computation, and maximizing the system throughput. Intermediate computations within the operation may be analyzed and those that have low gain values are identified and may be either removed from the computation or calculated with lower precision.
Claims
1. A method for reducing power consumed in processing units used to calculate computationally expensive operations, the method comprising: receiving a dot-product computation to be calculated at a specified number of bits; breaking down the dot-product computation into a plurality of intermediate operations having 1-bit or 2-bit element input vectors; assigning a gain value to each intermediate operation in the plurality of intermediate operations, wherein the gain value assigned to each intermediate operation is based on an analysis of the 1-bit or 2-bit element input vectors; determining a threshold gain value; and reducing the calculation precision for the intermediate operations that do not meet or exceed the threshold gain value.
2. The method of claim 1, wherein the threshold gain value is based on the number of bits at which the dot-product computation is to be calculated.
3. The method of claim 1, wherein the threshold gain value is based on a number of elements in the input vectors in the intermediate operations.
4. The method of claim 1, wherein the threshold gain value is based on a number of bits at which the elements of the input vectors are represented.
5. The method of claim 1, wherein a simple logic AND gate is used to calculate the intermediate operations having 1-bit element vectors.
6. The method of claim 1, wherein a single hardware is used to implement all of the intermediate operations.
7. The method of claim 1, wherein multiple modules are used in parallel to implement the intermediate operations.
8. The method of claim 1, wherein intermediate operations that do not meet or exceed the threshold gain value are either removed from the dot-product computation or calculated at lower precision.
9. The method of claim 1, wherein multiplications between 2-bit elements of input vectors are performed by using adder/subtractor and shifter without using multiplication.
10. An accelerator architecture system comprising: a memory; and a processor coupled to the memory, the processor being configured to: receive a dot-product computation to be calculated at a specified number of bits; break down the dot-product computation into a plurality of intermediate operations having 1-bit or 2-bit element input vectors; assign a gain value to each intermediate operation in the plurality of intermediate operations, wherein the gain value assigned to each intermediate operation is based on an analysis of the 1-bit or 2-bit element input vectors; determine a threshold gain value; and reduce the calculation precision for the intermediate operations that do not meet or exceed the threshold gain value.
11. The system of claim 10, wherein the threshold gain value is based on the number of bits at which the dot-product computation is to be calculated.
12. The system of claim 10, wherein the threshold gain value is based on a number of elements in the input vectors in the intermediate operations.
13. The system of claim 10, wherein the threshold gain value is based on the number of bits at which the elements of the input vectors are represented.
14. The system of claim 10, wherein a simple logic AND gate is used to calculate the intermediate operations having 1-bit element vectors.
15. The system of claim 10, wherein a single hardware is used to implement all of the intermediate operations.
16. The system of claim 10, wherein multiple modules are used in parallel to implement the intermediate operations.
17. The system of claim 10, wherein intermediate operations that do not meet or exceed the threshold gain value are either removed from the dot-product computation or calculated at lower precision.
Description
BRIEF DESCRIPTION OF THE DRAWINGS
(1) Example embodiments will be described and explained with additional specificity and detail through the use of the accompanying drawings in which:
(2)
(3)
(4)
DETAILED DESCRIPTION
(5) This disclosure provides a computing methodology in digital systems that, instead of lowering the precision of input data or just throwing away the LSB bits of the result, analytically and intellectually recognizes unimportant internal computations which may mainly affect the eventually discarded LSB bits. By not executing these computations in the first place, computations may be performed faster at lower power consumptions. While this method of computation may impact the accuracy of the result (so the so-called approximate computing), the introduced degradation is both predictable and adjustable as needed. In addition, it introduces a method to perform a multiplication-based computation without using any multiplication operation and just by using addition operations and logical gates.
(6) While the innovation introduced here may be applied to any similar computation, for the sake of simplicity and clarity, the focus herein is placed on the implementation of dot-product operation mainly because most other operations such as vector-by-matrix, matrix-by-matrix, tensor-by-tensor multiplications can be easily expressed as multiple dot product operations running in parallel.
(7) One or more embodiments of the present disclosure may include a method or an accelerator architecture to reduce the power consumed in processing units like accelerators when used to calculate the computationally expensive operations, which may be expressed based on dot product. The accelerator may lower the amount of computation by performing internal computations at lower precisions or not implementing unimportant computations at all with minimum impact on the final result of the computation. The computing methodology may determine the importance of each internal computation and its impact on the result and decide whether to do the computation or not and with what precision.
(8) For example,
(9) In some embodiments, the gain value assigned to each intermediate operation may be based, at least in part, on an analysis of the 1-bit or 2-bit element input vectors. The decision on which term to keep or discard may also consider a resolution of elements in the input vectors, their statistics, the required output precision, the number of elements in each vector, etc.
(10) The gain of each intermediate dot product may depend on the precision (the number of bits) at which the dot product computation may be calculated. If the desired number of bits to represent the final dot product is much smaller than the maximum number of bits required to represent the dot product at maximum accuracy, more intermediate dot products may be removed from the calculation without affecting the output result. Avoiding unimportant computations may increase the speed and throughput of the digital system, while lowering its power consumption.
(11) The method may include, at action 18, determining a threshold gain value. This threshold gain value may be compared to the gain values assigned to each intermediate operation. The method may include, at action 20, reducing the calculation precision for the intermediate operations that do not meet or exceed the threshold gain value. In some embodiments, intermediate operations that do not meet or exceed the threshold gain value may be calculated at a lower precision. In some embodiments, intermediate operations that do not meet or exceed the threshold gain value may be removed from the calculation altogether.
(12) In some embodiments, the accelerator may use a single hardware to implement all the intermediate dot-products with low-precision elements or use multiple modules in parallel to accomplish the computations. Different terms or intermediate dot products may be added or removed from the computations on the fly depending on the desired output accuracy.
(13) In other embodiments, the method of implementing dot product operations based on intermediate low-precision dot products may be used to avoid using costly multipliers when implementing computationally complex operations.
(14) In some embodiments, a simple logic AND gate may be used to implement the multiplications between 1-bit elements.
(15) In some embodiments, the processing system may operate on unsigned numbers while in other embodiments the system may perform dot product on vectors with elements represented as 2's complement or sign-magnitude.
(16) In other embodiments, the approximate computing system may be used to implement computations of applications like deep neural networks and machine learning algorithms that can tolerate imprecise computations and errors at higher efficiencies minimizing the usage of resources and power.
(17) One or more embodiments of the present disclosure may include a computing system. The computing system may consist of a specialized engine or accelerator to perform a dot product operation between two input vectors X and W, each with m elements and producing the scalar output Y. Elements of input vectors X and W may be represented by N.sub.x and N.sub.w bits respectively. When performing error-free computation, the maximum possible value of Y may be equal to 2 to the power of N.sub.x+N.sub.w+log 2(m) having N.sub.x+N.sub.w+log 2(m) bits. The accelerator may reduce the output precision to N.sub.y bits where N.sub.y may be much smaller than N.sub.w+N.sub.w+log 2(m).
(18) In some embodiments, the input vectors may be represented as binary numbers and the dot product operation may be expressed based on the base-2 numeral representations of vectors X and W like:
(19)
(20) Where Y may have at most N.sub.x+N.sub.w+log 2(m) bits in its binary representation. The computation may further be simplified as:
(21)
(22) Where xb.sub.i.sup.k is the ith bits in the binary representation of the kth element of vector X, wb.sub.j.sup.k is the jth bits in the binary representation of the kth element of vector W, and AND is the logical AND function.
(23) In some embodiments, the precision of dot product result Y may be reduced from N.sub.x+N.sub.w+log 2(m) to N.sub.y using a scaling factor and a round(.) function as:
(24)
(25)
(26) Where in the scaling factor is the maximum value of output Y and 2.sup.Nx+Nw+log2(m) is the maximum value of the result of the dot product.
(27) Since the maximum value of term A.sub.ij in the above equation may be equal to 2.sup.log2(m), the maximum amplitude of the term C.sub.ij may be equal to
(28)
showing the importance of each A.sub.ij term in a given dot product computations. The higher the value of G.sub.ij, the higher the importance of the term A.sub.ij in the result of the dot product calculation.
(29) In some embodiments, the dot product between vectors X and W may be calculated approximately by just calculating (or implementing) the first L elements of C.sub.ij terms out of all N.sub.x*N.sub.y terms which has the highest G.sub.ij. Calculating more C.sub.ij terms with the highest G u s may improve the accuracy of the dot product result with the cost of performing more calculations and therefore burning more power in the underlying accelerator. On the other hand, less circuits with less power consumptions may be needed if a smaller number of C.sub.ij are calculated with the drawback of having less accurate dot product result.
(30) The maximum amount of error in the dot product result calculated approximately may be equal to the sum of the G.sub.ij terms not included in the calculation of the dot product. The exact amount of error may depend on the exact values of the vectors and may be equal to the sum of the C.sub.ij values not included in the calculation of the dot product.
(31) Any circuit with any configuration may be used to perform the calculations of A.sub.ij or C.sub.ij. Unimportant A.sub.ij or C.sub.ij terms with small G.sub.ij may be calculated imprecisely using imprecise digital circuits. Circuits used to calculate important C.sub.ij terms may also be configured to perform the calculations imprecisely.
(32) The dot product A.sub.ij happening between two 1-bit vectors may be implemented based on B.sub.ij which may be implemented using the digital AND gates.
(33) In some embodiments, the dot product may be calculated at any given precision based on the terms A.sub.ij, C.sub.ij or B.sub.ij to reach the minimum hardware while all the redundant internal computations have been avoided. The hardware may be implemented using just logic AND gate and adders.
(34) In some accelerators, all C.sub.ij terms may be implemented in the hardware and they may be turned on and off to change the precision of computation on the fly depending on the required accuracy and desired system power consumption.
(35) In some embodiments, there may be a single hardware inside the accelerator implementing all the A.sub.ij, C.sub.ij or B.sub.ij computations. In some other embodiments, multiple hardware may be working together executing these computations in parallel.
(36) In some embodiments, the same procedure may be repeated by breaking input binary vectors into vectors of binary numbers where this time each element of the vector has 2 bits instead of one like:
(37)
(38) This may reduce the dot product operation between the two original vectors X and W into the dot-product operations between multiple vectors with 2-bit elements (operation PO. Similar to other embodiments, when computing output Y at N.sub.y-bit precision, unimportant P.sub.ij terms may be removed from the computation or be computed at lower precision to calculate the approximated output while having more efficient hardware implementation. Moreover, calculation of dot product between vectors with 2-bit elements may be faster and more efficient since they may be implemented without using any multiplication operation and just with adders/subtractors and shifters.
(39) In some embodiments, the elements of input vectors X and W may be represented as 2's complement. In this case, based on the binary representations of these 2's complement elements, the dot product output Y may be written as:
(40)
Which may be written as:
(41)
Its precision can be reduced to N.sub.y bits as:
(42)
(43) In some embodiments, the dot product between two vectors X and W with elements represented as 2's complement may be implemented approximately by just calculating those F) and/or H.sub.ij elements which has the highest impacts on the dot product results. More or less elements may be included in the computation to reach higher or lower precision respectively. The exact number of terms included in the computation may depend on the required precision, existing resources on the hardware, power budget and the distribution of signals X and W.
(44) The importance of each E.sub.i element may be equal to
(45)
the importance of element F.sub.j may be equal to
(46)
and the importance of each H.sub.ij element may be equal to
(47)
on the final dot product result. Different numbers of elements may be removed from E.sub.j, F.sub.j, or H.sub.ij to reduce the amount of computation required for the calculation of the dot product without a remarkable impact on the result accuracy.
(48) The error on the calculated dot product may be computed by adding up the omitted terms per each given set of input signals.
(49) Each term of D, E.sub.i, F.sub.j, H.sub.ij themselves may be calculated with imprecise hardware at lower precisions or may be calculated precisely. These terms may also be implemented using the AND gates similar to the computations performed for dot product between unsigned vectors.
(50) The term D may be calculated at its highest precision since it does computation on MSB bits of vectors X and W.
(51) Any other operation which can be expressed as a set of dot product operations may be implemented approximately using the method explained in these embodiments.
(52) Operations like convolution, vector-by-matrix, or matrix-by-matrix multiplication in applications like deep neural networks and machine learning algorithms which can tolerate imprecise computations can be expressed as dot products and implemented approximately as explained in this disclosure.
(53) Deciding which terms to include in the computation and which terms to omit may depend on the statistics of the data in the X and W vectors and the precision (number of bits) at which these vectors are represented at. For example, if X elements has 4 bits and W elements has 8 bits, it may be better to omit only those terms which do computations on LSB bits of the signal W which has been represented with a higher number of bits.
(54)
(55)
(56) In some embodiments, multiple of modules shown in
(57) In some embodiments, the approximate adder may be implemented by keeping the maximum number of bits the summation result may have fixed and smaller than the maximum number of bits the maximum summation result may have. Whenever the summation result becomes larger than what can be represented by the adder, only the MSBs of the result may be kept while LSB bits may be discarded.
(58) In accordance with common practice, the various features illustrated in the drawings may not be drawn to scale. The illustrations presented in the present disclosure are not meant to be actual views of any particular apparatus (e.g., device, system, etc.) or method, but are merely example representations that are employed to describe various embodiments of the disclosure. Accordingly, the dimensions of the various features may be arbitrarily expanded or reduced for clarity. In addition, some of the drawings may be simplified for clarity. Thus, the drawings may not depict all of the components of a given apparatus (e.g., device) or all operations of a particular method.
(59) Terms used herein and especially in the appended claims (e.g., bodies of the appended claims) are generally intended as open terms (e.g., the term including should be interpreted as including, but not limited to, the term having should be interpreted as having at least, the term includes should be interpreted as includes, but is not limited to, etc.).
(60) Additionally, if a specific number of an introduced claim recitation is intended, such an intent will be explicitly recited in the claim, and in the absence of such recitation no such intent is present. For example, as an aid to understanding, the following appended claims may contain usage of the introductory phrases at least one and one or more to introduce claim recitations. However, the use of such phrases should not be construed to imply that the introduction of a claim recitation by the indefinite articles a or an limits any particular claim containing such introduced claim recitation to embodiments containing only one such recitation, even when the same claim includes the introductory phrases one or more or at least one and indefinite articles such as a or an (e.g., a and/or an should be interpreted to mean at least one or one or more); the same holds true for the use of definite articles used to introduce claim recitations.
(61) In addition, even if a specific number of an introduced claim recitation is explicitly recited, it is understood that such recitation should be interpreted to mean at least the recited number (e.g., the bare recitation of two recitations, without other modifiers, means at least two recitations, or two or more recitations). Furthermore, in those instances where a convention analogous to at least one of A, B, and C, etc. or one or more of A, B, and C, etc. is used, in general such a construction is intended to include A alone, B alone, C alone, A and B together, A and C together, B and C together, or A, B, and C together, etc. For example, the use of the term and/or is intended to be construed in this manner.
(62) Further, any disjunctive word or phrase presenting two or more alternative terms, whether in the summary, detailed description, claims, or drawings, should be understood to contemplate the possibilities of including one of the terms, either of the terms, or both terms. For example, the phrase A or B should be understood to include the possibilities of A or B or A and B.
(63) Additionally, the use of the terms first, second, third, etc., are not necessarily used herein to connote a specific order or number of elements. Generally, the terms first, second, third, etc., are used to distinguish between different elements as generic identifiers. Absence a showing that the terms first, second, third, etc., connote a specific order, these terms should not be understood to connote a specific order. Furthermore, absence a showing that the terms first, second, third, etc., connote a specific number of elements, these terms should not be understood to connote a specific number of elements. For example, a first widget may be described as having a first side and a second widget may be described as having a second side. The use of the term second side with respect to the second widget may be to distinguish such side of the second widget from the first side of the first widget and not to connote that the second widget has two sides.
(64) The foregoing description, for purpose of explanation, has been described with reference to specific embodiments. However, the illustrative discussions above are not intended to be exhaustive or to limit the invention as claimed to the precise forms disclosed. Many modifications and variations are possible in view of the above teachings. The embodiments were chosen and described to explain practical applications, to thereby enable others skilled in the art to utilize the invention as claimed and various embodiments with various modifications as may be suited to the particular use contemplated.