Arithmetic logic unit, data processing system, method and module
11169782 · 2021-11-09
Assignee
Inventors
Cpc classification
G06F7/57
PHYSICS
G06F7/5235
PHYSICS
International classification
G06F7/57
PHYSICS
G06F7/483
PHYSICS
Abstract
An arithmetic logic unit, comprising an addition unit for determining a sum of a first input and a second input; and a logarithmic addition unit for determining an output using the sum and a third input. The output is a multiply-accumulate output represented in a logarithmic domain when the first, second and third inputs are represented in the logarithmic domain.
Claims
1. An arithmetic logic unit for generating an output in a logarithmic domain, comprising: an addition unit for determining a sum of a first logarithmic input and a second logarithmic input; and a logarithmic addition unit for determining the output using the sum and a third logarithmic input, the logarithmic addition unit comprising: a maximum detection unit, for determining a maximum value between the sum and the third logarithmic input; a difference unit, for determining a difference between the sum and the third logarithmic input; a fractional separation unit for determining an integer portion and a fractional portion of the difference, an inversion unit for determining an inverse of the fractional portion; a shifting unit for shifting the inverse by the integer portion to produce a shifted value; and an addition unit for determining the output, wherein the output is a sum of the shifted value and the maximum value.
2. The arithmetic logic unit of claim 1, comprising a logarithmic conversion unit, for converting data from a linear domain into the logarithmic domain to generate at least one of the first logarithmic input and second logarithmic input.
3. The arithmetic logic unit of claim 1, comprising one or more registers arranged to receive the output, the one or more registers comprising a plurality of single-bit storage devices.
4. The arithmetic logic unit of claim 3, wherein the third logarithmic input is derived from the one or more registers.
5. The arithmetic logic unit of claim 1, the fractional separation unit comprises logic elements determining the integer portion and the fractional portion of the difference represented in the logarithmic domain.
6. A neural network accelerator comprising the arithmetic logic unit of claim 1.
7. The arithmetic logic unit of claim 1, wherein the difference unit of the logarithmic addition unit comprises a modulus unit for determining an absolute value of the difference.
8. The arithmetic logic unit of claim 1, wherein the fractional separation unit of the logarithmic addition unit comprises a rounding module for rounding the difference, and a second subtraction unit, for determining a second difference between the first difference and the rounded difference.
Description
BRIEF DESCRIPTION OF THE DRAWINGS
(1) Further features will become apparent from the following description, given by way of example only, which is made with reference to the accompanying drawings, in which like reference numerals are used to denote like features.
(2)
(3)
(4)
(5)
(6)
(7)
(8)
DETAILED DESCRIPTION OF CERTAIN INVENTIVE EMBODIMENTS
(9) Details of methods, systems, modules and arithmetic logic units according to examples will become apparent from the following description, with reference to the Figures. In this description for the purpose of explanation, numerous specific details of certain examples are set forth. Reference in the specification to ‘an example’ or similar language means that a particular feature, structure or characteristic described in connection with the example is included in at least that one example, but not necessarily in other examples. It should further be noted that certain examples are described schematically with certain features omitted and/or necessarily simplified for ease of explanation and understanding of the concepts underlying the examples.
(10)
(11) At item 210 of the data processing method 200, a first and second input are received. The first and second inputs are bit values represented in the logarithmic domain. That is, a first input, such as the input 110a shown in
A=log.sub.2(a) (equation 2)
Similarly, a second input, such as the input 110b shown in
B=log.sub.2(b) (equation 3)
In some embodiments, it will be appreciated that one or more of the inputs may be the result of earlier processing, for example, one of the inputs may be the sum of two other inputs to a processing device or system.
(12) Upon receipt of the two inputs a maximum of the two inputs is determined at step 220, such that:
M=max(A,B) (equation 4)
(13) Furthermore, at step 230 the difference between the first and second inputs is also determined. In some embodiments, at step 230, an absolute value of the difference is calculated. It will be appreciated that depending on the inputs to the method, the difference calculated may be less than zero, in this case an absolute value of the difference may be obtained. Such that:
S=|A−B| (equation 5)
(14) At step 240, an integer and fractional portion of the difference calculated at step 230 is determined. In some embodiments, this is determined by rounding the result of the difference from step 230 down to the nearest whole value, and subtracting the rounded result from the difference calculated at step 230 to determine the fraction portion. That is:
I=└S┘ (equation 6)
F=S−I (equation 7)
(15) At step 250, the fractional portion of the difference is inverted. That is when operating in a binary base, the inversion step at 250 acts as a logic NOT. For example, where the fraction portion equals 00110011, the inverted factional portion will equal 11001100. That is:
F′=¬F (equation 8)
(16) The inverted fractional portion is then bit-shifted right by a number of bits equal to the integer portion of the difference at step 260. In binary this is represented by a bit-shift right however when operating in base 10 (i.e. decimal) this is representative of a division by two to the power of the integer portion. That is in binary:
E=¬F>>I (equation 9)
Or in decimal:
(17)
(18) At step 270, the shifted value calculated at step 260 and the maximum value calculated at step 220 are added together and outputted to a data processor at step 280. That is:
D=M+E (equation 11)
(19) In summary, whilst each of the steps 210 to 280 of the method 200 are represented using mathematical equations, each of the equations 2 through 11 may be implemented in hardware, for example through the use of logic gates, such as AND, OR, NOR, XOR, and NOT so as to undertake an addition in the logarithmic domain, such that:
D=max(A,B)+(¬(|A−B|−└|A−B|┘)>>└|A−B|┘) (equation 12)
(20)
log(a×b)=log(a)+log(b) (equation 13)
Therefore, operating in the logarithmic domain removes the requirement for a multiplication portion, such as the multiplication portion 120 of
(21) However, as the MAC unit 300 operates in the logarithmic domain, the addition portion 130 of the MAC unit 100 of
(22) In one embodiment, the logarithmic addition module 330 may be implemented in hardware, such as the in
(23) As mentioned above, the logarithmic addition module 330 may receive a third input 310c and the intermediary output 320i of the first module 320 of a MAC unit 300 of
(24) The third input 310c and the intermediary output 320i may be provided to a maximum detection unit 410. The maximum detection unit 410 comprises hardware, for example logic gates such as AND, OR, NOR, XOR, and NOT, for determining the maximum of the third input 310c and the intermediary output 320i.
(25) The third input 310c and the intermediary output 320i may also be provided to a difference unit 420 capable of determining the difference between the third input 310c and the intermediary output 320i. The difference unit 420 may comprise logic gates and/or other components for first subtracting the intermediary output 320i from the third input 310c, to calculate the difference. The difference unit 420 may also comprise logic gates and/or other components for determining the modulus of a particular input, and/or determining which of the third input 310c and intermediary output 320i is larger. For example, where the intermediary output 320i is greater than the third input 310c, this is then output to a fractional separation unit 430. In other examples where the third input 310c is greater than the intermediary output 320i, the values maybe reversed such that the difference unit 420 subtracts the intermediary output 320i from the third input 320c, or alternatively perform the same subtraction as above (i.e. subtract the third input 320c from the intermediary output 320i) and then calculate an absolute value of the result using the logic for determining the modulus. In either example, the result is the same and is provided to the fractional separation unit 430.
(26) The fraction separation unit 430 produces an integer portion and a fractional portion from the output of the difference unit 420. The fractional separation unit 430 may comprise an integer determination unit 432 and a fractional determination unit 434 for producing the integer portion and fractional portion respectively. Both the integer 432 and fractional 434 determination units comprise logic gates and/or other components for producing the integer and fractional portions.
(27) The integer determination unit 432 comprises logic gates and/or components for rounding the input value, the input value being the output of the difference unit 420, down to the nearest integer. That is the integer determination unit 432 applies the equivalent of a floor function to the output of the difference unit 420.
(28) The fractional determination unit 434 comprises logic capable of determining the difference between the output of the difference unit 420 and the output of the integer determination unit 432. This is achieved by subtracting the output of the integer determination unit 432 and the difference unit 420.
(29) The output of the fractional determination unit 434 is then provided to an inversion unit 440. The inversion unit 440 comprises a logic not gate for inverting the output of the fractional determination unit 434. For example, where the output of the fractional determination unit 434 is 01110110 the output of the inversion unit 440 will be 10001001.
(30) The output of the inversion unit 440 is then provided to a shifting unit 450, along with the output of the integer determination unit 432 of the fractional determination unit 430. The shifting unit 450 comprises logic gates and/or other components such as registers for performing a bit-shift right, wherein the output of the inversion unit 440 is shifted right by a number of bits representing the output of the integer determination unit. Continuing the example above where the output of the inversion unit 440 is 10001001, if the output of the integer determination unit 432 was four (4), then the output of the shifting unit 450 will be 00001000, wherein 10001001 has been shifted right 4 bits.
(31) The output of the shifting unit 450 is then provided to an addition unit 460 along with the maximum value of the third input 310c and intermediary output 320i, outputted by the maximum detection unit 410. The addition unit 460 comprises logic gates and/or other components to determine the output of the maximum detection unit 410 and the shifting unit 450. The output 340 of the addition unit 460 may then be provided for use in a data processor, or other component such as a neural network accelerator (as will be described below in relation to
(32) When used as part of a multiplier-accumulator, such as 300 of
(33)
(34) In examples described herein, an ALU 500 may include a register arranged to receive an output of the data processing operation, the register comprising a plurality of single-bit storage devices arranged to storage binary data of a predetermined data size. For example, where the ALU 500 comprises a MAC unit, such as the MAC unit 300 described above in relation to
(35) In the example of
(36) The inputs 510a, 510b, 510c may be stored in the linear domain, and therefore will be incompatible with the MAC unit 300. As such, the inputs 510a, 510b, 510c will need to be transformed into the logarithmic domain. Accordingly, the ALU 500 may also comprise a logarithmic conversion unit 520 for converting inputs 510a, 510b, 510c in the linear domain into the logarithmic domain so that they may be used as inputs 310a, 310b, 310a to the MAC unit 300 of the ALU 500. It will be appreciated that whilst the ALU 500 of
(37) In some examples, the ALU 500 may include a plurality of registers, each arranged to store data at various stages. For example, each of the inputs 510a, 510b, 510c may be transferred from storage one or more input registers. The input registers provide inputs (sometimes referred to as operands) to a data processing operation, such as a logarithmic conversion. The ALU 500, may also comprise a plurality of intermediary registers for receiving the logarithmic conversion outputs from the logarithmic conversion unit 520, and arranged to provide inputs to further data processing operations, in this example an addition operation implemented by a first module 310 of the MAC unit 300. The addition operation may be considered to be a first data processing operation, as in this example the ALU is capable of a plurality of data processing operations.
(38) The output 340 of the MAC unit 300 may also be stored in one or more registers for use in further data processing operations. In some embodiments, the output 340 may also be/alternatively stored in storage, which may or may not be the same storage as the inputs 510a, 510b, 510c as described above.
(39) Whilst it will be appreciated that the ALU 500 shown in
(40) Due to the high-power consumption of neural networks, for example during the classification of an image, or other data, the processing of neural networks, may be performed using a neural network accelerator 600 which is dedicated to this process. Internal components of the neural network accelerator 600 are shown schematically in
(41) The neural network accelerator 600 includes a plurality of ALUs 500a, 500b, 500c. Components of one of the ALUs 500a is shown in more detail in
(42) The neural network accelerator 600 includes an interface 630, via which inputs to a neural network may be received, for example from other components of a computer device (such as the computer device described below in relation to
(43) Other inputs which may be received by the neural network accelerator 600 via the interface 630 include image data representative of an image to be classified using the neural network and kernel data representative of a kernel associated with the neural network after training. For example, the neural network may be trained either by the computer device or by an external computer device or computer system, for example using a GPU. The output of the training may be a plurality of kernels associated with a predetermined neural network architecture (for example with different kernels being associated with different respective layers of a multi-layer neural network architecture). The kernel data may be considered to correspond to weight data representative of weights to be applied to image data, as each element of a kernel may be considered to correspond to a weight, respectively. Each of these weights may be multiplied by a corresponding pixel value of an image patch, as part of the convolution of the kernel with the image patch.
(44) The neural network accelerator 600 of
(45) The neural network accelerator 600 includes static random-access memory (SRAM) 610, which may be used to store inputs to the classification process implemented by the ALUs 500a, 500b, 500c. For example, the SRAM may be on-chip or local memory of the neural network accelerator 600, which is generally quicker to access than the storage. The SRAM may include a plurality of separate storage areas. For example, the image data may be stored in a different storage area from the kernel data (although, in some cases, they may be stored in the same storage area).
(46) An example of a computer device 700 for use with the data processing method according to examples, such as the method of
(47) The computer device 700 includes at least one processor. In this example, the computer device 700 includes a central processor unit (CPU) 710. The computer device 700 also includes a neural network accelerator 600, which is a processor dedicated to implementing at least classification of data using a neural network. In other examples, though, the computer device 700 may include other or alternative processors such as a microprocessor, a general purpose processor, an image signal processor (ISP), a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic device, a discrete gate or transistor logic, discrete hardware components, or any suitable combination thereof designed to perform the functions described herein. The computer device 700 may also or alternatively include a processor implemented as a combination of computing devices, e.g., a combination of a DSP and a microprocessor, a plurality of microprocessors, one or more microprocessors in conjunction with a DSP core, or any other such configuration. The computer device may also or alternatively include at least one graphics processing unit (GPU).
(48) The CPU 710 of
(49) The computer device 700 of
(50) The components of the computer device 700 in the example of
(51) As explained above, the computer device 700 in the example of
(52) The order of processing steps in the examples described above are merely examples. In other examples, these processing steps may be performed in a different order.
(53) It is to be understood that any feature described in relation to any one example may be used alone, or in combination with other features descried, and may also be used in combination with one or more features of any other examples, or any combination of any other examples. Furthermore, equivalents and modifications not described above may also be employed without departing from the scope of the accompanying claims.