Multi-input floating point adder
By grouping inputs with the same sign in the adder circuit and using a combination of unsigned adders and normalized adders, the problem of excessive area and power consumption of existing adder circuits is solved, and efficient multi-input floating-point addition operations are realized.
Patent Information
- Application Number
- CN201980036125.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Priority Date
- 2018-08-27
- Filing Date
- 2019-08-07
- Publication Date
- 2024-11-19
- Estimated Expiration
- 2039-08-07
AI Technical Summary
Existing adder circuits are insufficient in terms of computational throughput and power consumption, and occupy too much circuit die area, making it difficult to meet the needs of certain computing applications.
By employing a multi-input floating-point adder circuit, inputs with the same sign are grouped through an input selector, and an unsigned adder is used to perform addition operations. Only one normalized adder is needed to generate the sum, reducing circuit area and power consumption.
It effectively reduces the area and power consumption of the circuit die while improving the calculation speed and efficiency, making it suitable for the calculation unit of multi-layer neural networks.
Smart Images

Figure CN112204517B_ABST
Abstract
Description
Background Art
[0001] This specification relates to hardware circuits for performing mathematical calculations.
[0002] A computational circuit may include multiple adder circuits for adding numerical inputs such as integers and floating point numbers. Adder circuits can be expensive to purchase and integrate into existing computational circuits, and some adder circuits are not sized to meet the needs of some applications. These circuits can occupy a large circuit die area, but despite their large size, offer no advantage in computational throughput. Adder circuits that are too large for some computational applications can result in low power consumption and utilization.
[0003] The hardware circuit may be used to implement a neural network. A neural network having multiple layers may be used to compute inferences using a computational circuit including multiple adder circuits. The computational circuit of the hardware circuit may also represent a computational unit for performing neural network computations for a given layer. For example, given an input, the neural network may compute an inference of the input by performing a dot product operation using one or more of the multiple adders in the computational unit of the hardware circuit. Summary of the invention
[0004] Methods, systems and apparatus for a circuit configured to perform a computation using a plurality of inputs, including a computer program encoded on a computer storage medium. The circuit includes a plurality of adder circuits and a selection circuit including a plurality of input selectors. Each adder circuit performs an addition operation using a set of inputs derived from the plurality of inputs. The input selector is configured to select one or more inputs from a set of inputs derived from the plurality of inputs based on a sign bit of the inputs in the set, and pass the selected inputs to an adder circuit that generates a sum using the selected inputs. The circuit determines the routing of the sum to another adder circuit based in part on the sign bit of the input in the set of inputs.
[0005] One aspect of the subject matter described in this specification can be embodied in a circuit configured to add multiple inputs. The circuit includes: a plurality of unsigned adders, each unsigned adder configured to perform an addition operation using a set of inputs derived from the plurality of inputs; and a corresponding input selector for each unsigned adder. The corresponding input selector is configured to: select at least two inputs from a first set of inputs derived from the plurality of inputs, select at least two inputs based on a sign bit of the inputs of the first set, wherein the selected at least two inputs in the first set have the same sign; provide the first set of inputs to the corresponding unsigned adder to generate a first sum using the at least two inputs selected from the first set. The circuit also includes a normalizing adder configured to: generate a final sum based on one or more sums generated using the plurality of unsigned adders, each of the plurality of unsigned adders receiving at least two inputs having the same sign, wherein the final sum corresponds to the sum of the plurality of inputs.
[0006] These and other embodiments may each optionally include one or more of the following features. For example, in some embodiments, the normalized adder is further configured to: receive an input related to a result of an addition operation performed by one or more unsigned adders of the plurality of unsigned adders; and, use the input related to the result of the addition operation of the one or more unsigned adders to generate a normalized output.
[0007] In some embodiments, the second input selector is configured to: receive two or more remaining inputs derived from the plurality of inputs but not included in the first set of inputs; and provide the two or more remaining inputs to a corresponding second unsigned adder to generate a second sum, wherein at least two of the two or more remaining inputs are provided based on respective signs of the two or more remaining inputs. In some embodiments, the corresponding input selector is further configured to: select an input to provide to another unsigned adder, and route the remaining input to at least one other unsigned adder.
[0008] In some embodiments, the sum of the plurality of inputs is a normalized result that represents the sum of adding each of the plurality of inputs regardless of the sign of each of the plurality of inputs. In some embodiments, each of the plurality of inputs is a floating point number, and a sign bit of each input indicates the sign of the input and identifies the value of the floating point number as greater than zero or less than zero.
[0009] In some embodiments, each respective input selector is configured to: determine whether an input has a value greater than zero or less than zero based on a sign bit of the input; and select two or more inputs, each having a value greater than zero, or each having a value less than zero.
[0010] In some embodiments, each of the corresponding input selectors is further configured to: communicate with a first input port of a specific unsigned adder; and, communicate with a second input port of the specific unsigned adder; provide a first input of the selected two or more inputs to the specific unsigned adder using the first input port of the specific unsigned adder; and provide a second input of the selected two or more inputs to the specific unsigned adder using the second input port of the specific unsigned adder.
[0011] In some embodiments, each of the corresponding input selectors is further configured to: communicate with a bypass port of a specific unsigned adder; and route remaining inputs not included in the selected two or more inputs using the bypass port of the specific unsigned adder.
[0012] One aspect of the subject matter described in this specification can be embodied in a computer-implemented method for adding multiple inputs using a hardware circuit including multiple input selectors and multiple unsigned adders. The method includes: obtaining multiple inputs through the hardware circuit, each input having a respective sign; and selecting at least two inputs of a first set of inputs from the multiple inputs by a first input selector, selecting the at least two inputs based on the sign bits of the inputs in the first set. The method includes: providing the first set of inputs to a first unsigned adder by the first input selector, wherein at least two inputs in the first set have the same sign; and, generating a first sum using the selected at least two inputs by the first unsigned adder, and passing the remaining inputs of the first set that are not included in the selected at least two inputs.
[0013] The method includes: receiving at least two other inputs by a second input selector corresponding to a second unsigned adder to generate a second sum using the second unsigned adder, selecting at least two other inputs from the first sum and the remaining inputs based on the sign of the first sum and the signs of the remaining inputs; generating a final sum based on one or more sums generated using a plurality of unsigned adders through a normalizing adder, wherein each of the plurality of unsigned adders receives at least two inputs having the same sign, wherein the final sum corresponds to the sum of the plurality of inputs.
[0014] These and other embodiments may each optionally include one or more of the following features. For example, in some embodiments, the method further includes: using a normalized adder to generate a normalized output using at least the first sum and the second sum, wherein the normalized output corresponds to the sum of the plurality of inputs.
[0015] In some embodiments, the method further includes: receiving, by a third input selector, two or more remaining inputs derived from the plurality of inputs and not included in the first set of inputs; and providing, using the third input selector, the two or more remaining inputs to a third unsigned adder to generate a third sum, wherein at least two remaining inputs are provided based on respective signs of the two or more remaining inputs.
[0016] In some embodiments, the method further comprises: determining, based on a sign bit of the input, whether the input has a value greater than zero or less than zero; and selecting two or more inputs, each of which has a value greater than zero, or each of which has a value less than zero.
[0017] In some embodiments, the method further includes: providing a first input of the selected two or more inputs to the first unsigned adder using a first input port of the first unsigned adder; and providing a second input of the selected two or more inputs to the first unsigned adder using a second input port of the first unsigned adder, wherein the second inputs have the same sign.
[0018] In some embodiments, the sum of the plurality of inputs is a normalized result that represents the sum of adding each of the plurality of inputs regardless of the sign of each of the plurality of inputs. In some embodiments, each of the plurality of inputs is a floating point number, and a sign bit of each input indicates the sign of the input and identifies the value of the floating point number as greater than zero or less than zero.
[0019] Other embodiments of this and other aspects include corresponding systems, devices, and computer programs encoded on computer storage devices that are configured to perform the actions of the method. A computing system of one or more computers or hardware circuits can be configured by means of software, firmware, hardware, or a combination thereof installed on the system, which software, firmware, hardware, or a combination thereof causes the system to perform the actions in operation. One or more computer programs can be configured by having instructions that, when executed by a data processing device, cause the device to perform the actions.
[0020] The subject matter described in this specification can be implemented in certain embodiments to achieve one or more of the following advantages. The described techniques can be used to implement a computational unit that can efficiently sum multiple floating-point inputs. The computational unit can form a multi-input floating-point adder circuit having a hardware configuration based on a cascade structure of input selectors and adders.
[0021] Compared to a conventional adder circuit capable of adding the same number of inputs as the described adder circuit, the adder circuit described in this specification uses a smaller circuit die area to add N inputs. This is because a multi-input floating-point adder circuit only requires one normalizing adder to normalize the addition result and generate the sum of multiple inputs, while a conventional adder circuit may require multiple normalizing adders because the inputs are not grouped using the method described herein. In particular, due to the described grouping method, the described adder circuit may include multiple unsigned adders and only a single normalizing adder. Because an unsigned adder does not have a normalization function, the unsigned adder (and thus the entire described circuit) uses a smaller area than a conventional normalizing adder.
[0022] Based on the described techniques, power consumption at the circuit can also be reduced while increasing computation speed by reducing the size of the normalized components of the circuit. To achieve a certain efficiency, the computation unit uses a specific hardware configuration of adders and input selectors to select and add inputs with the same sign and route inputs with different signs to at least one other adder in a cascaded hardware structure.
[0023] The details of one or more implementations of the subject matter described in this specification are set forth in the accompanying drawings and the description below. Other potential features, aspects, and advantages of the subject matter will become apparent from the description, drawings, and claims. BRIEF DESCRIPTION OF THE DRAWINGS
[0024] Figure 1A A diagram showing an example hardware circuit for performing the calculations.
[0025] Figure 1B A diagram of an example hardware adder circuit is shown.
[0026] Figure 2 An example arrangement of hardware circuit components for performing mathematical calculations using an input group is shown.
[0027] Figure 3 A flow chart of an example process for performing mathematical calculations using an input group is shown.
[0028] Like reference numerals and designations in the various drawings indicate like elements. DETAILED DESCRIPTION
[0029] In example embodiments, a multi-layer neural network may be implemented using hardware circuitry and performs computations (e.g., neural network computations) by processing inputs through each layer of the neural network. In particular, the layers of the neural network may each have a respective set of parameters. Each layer receives an input and processes the input according to the parameter set of the layer to generate an output based on computations performed using one or more adder circuits of an example computation unit. For example, a neural network layer may sum multiple inputs as part of computing a matrix multiplication of an input array with a parameter array, or as part of computing a convolution between an input array and a parameter kernel array.
[0030] Typically, processing inputs passing through a layer of a neural network is accomplished by performing mathematical operations such as multiplication and addition. The hardware circuit may include multiple adder circuits for performing mathematical calculations. The adder circuits may be grouped to form computational units of the hardware circuit, such as for matrix or vector processing units. When the hardware circuit, for example, performs neural network calculations associated with processing inputs passing through a layer of a neural network, the computational units are used to add numerical inputs such as integers and floating point numbers.
[0031] This document describes a dedicated hardware circuit configured to add multiple inputs using a technique for grouping subsets of the multiple inputs based on the sign bit of each input. The circuit includes at least one selection circuit, which in turn includes multiple input selectors. Each input selector has one or more multiplexers (mux). Each multiplexer selects and / or groups inputs based on the sign bit of each input. The circuit also includes multiple separate adders, each adder including an input port and a bypass port. The input selector communicates with the adder and passes one or more inputs to the adder using the input port or bypass port of the adder. The size of the multiple adders is appropriately determined to receive a set of multiple inputs, each set of which may include at least two inputs that are added together to generate a result.
[0032] The dedicated circuit can receive multiple inputs from an external source. Each input can be a numerical input (e.g., a floating point number or another data type including a sign bit), wherein each input is represented by a data structure of multiple bits. Typically, each numerical input such as a floating point number has at least one sign bit in the data structure, which indicates whether the number is greater than zero (e.g., a positive number) or less than zero (e.g., a negative number). In some cases, the data structure uses one or more zero bits ("0") to indicate a numerical input of zero. The input selector can select an input from a plurality of inputs to form a first set of inputs that are passed to the adder using an input port of the adder. The selected inputs all have the same sign bit. For example, the input selector can select two inputs that are both positive floating point numbers, and pass or route these selected inputs to the adder using the input port of the adder. The adder performs an addition operation to add two inputs and generate a result. In some embodiments, for a group of three inputs, the input selector selects two inputs with the same sign, passes each of the selected two inputs to the adder using the corresponding input port of the adder, and passes the remaining inputs to the adder using the bypass port of the adder. In some cases, the sign of the remaining input may be the same as the sign of the selected two inputs, or the sign of the remaining input may be different from the sign of the selected two inputs.
[0033] Based on the above design and processing technology, the dedicated hardware circuit described in this article can be configured as a multi-input floating-point adder circuit. By grouping the inputs based on the respective sign bits of the inputs, and using each of the multiple adders to perform addition operations using at least two inputs in the set of inputs, the multi-input adder circuit can be optimized for processing a set of multiple inputs. Unlike traditional adder circuits that require a larger circuit area and have multiple normalized adders to add numerical values of different signs, the hardware adder circuit described in this document avoids the need for multiple normalized adders by adding multiple inputs with the same sign. Based on the grouping of inputs with the same sign, the circuit can perform these addition operations, while using only a single normalized adder to normalize the addition result and generate the sum of multiple inputs. In this way, relative to existing adder circuits, the calculation and operation efficiency of the hardware circuit is increased, while the area and power consumption of the hardware circuit are reduced.
[0034] Figure 1AAn example circuit 100 for grouping inputs to perform mathematical calculations is shown. The circuit 100 may include one or more input selectors, each configured to receive and process a plurality of inputs 102. Each input 102 is a numerical input representing a respective operand for calculation. The circuit 100 may also include a plurality of adder circuits (or a plurality of adders), each of which is configured to receive a set of inputs selected from the plurality of inputs 102. As described in more detail below, the adder performs an addition operation using at least two inputs from the set of inputs.
[0035] Circuit 100 may have at least one normalizing adder that generates a final sum by normalizing the result of adding two numbers with different signs. A normalizing adder may require additional circuitry to adjust or normalize the digital format of certain inputs in order to generate an addition result, especially when the addition operation involves adding two inputs with different signs. In some embodiments, all of the multiple adders at circuit 100 except one (e.g., a normalizing adder) are unsigned adders that are configured to add inputs with the same sign. Unsigned adders differ from normalizing adders in that they do not require additional normalizing circuitry because they only operate on inputs with the same sign. In some cases, an unsigned adder uses the same sign as the sign of at least two inputs received by the unsigned adder to calculate the sum.
[0036] The hardware circuit may include a plurality of input selectors 104, 114, each receiving a specific number of inputs. Each input selector 104, 114 is configured to form a corresponding set of inputs based on the number of inputs received. Each input selector is coupled to at least one adder and is configured to pass the set of inputs to at least one adder. Although two input selectors 104, 114 are shown in FIG. 1, the circuit 100 may be configured to include a plurality of input selectors (e.g., 5, 20, or 100 input selectors).
[0037] The circuit 100 may also have a predetermined number of input selectors 104, 114 and a predetermined number of adders 108, 118. The predetermined number may be based on the design requirements of the system using the circuit 100 to perform certain mathematical operations. As described in more detail below, the adders 108, 118 may be corresponding unsigned adders. In some embodiments, the circuit 100 may have a portion of the circuit that can be dynamically configured (e.g., in software) to provide one or more additional adders (e.g., unsigned adders) to supplement the predetermined number of adders. In other embodiments, the number of input selectors 104, 114 and adders 108, 118 at the circuit 100 is determined based on the number of inputs 102 to be processed using the circuit 100.
[0038] Each input 102 may be a corresponding floating point number, wherein each input is represented by a data structure of multiple bits, such as a 32-bit data word. Each floating point number has a sign bit in the data structure, which indicates whether the number is greater than zero (e.g., a positive number) or less than zero (e.g., a negative number).
[0039] The input selectors 104, 114 are configured to select or group at least two numerical inputs each having the same sign. For example, the input selector 104 is configured to identify the sign of at least one input in a set of inputs and select two or more inputs in the set each having the same sign. The input selector 104 can identify the sign of the numerical input 102 by analyzing a data structure representing the bits of the numerical input to detect the sign bit of the data structure. The value of the sign bit in the data structure can indicate the sign of the numerical input represented by the data structure. The selected two or more inputs are provided to the adder 108 to generate a sum, such as a result 109.
[0040] In general, each input selector 104, 114 of the circuit 100 is configured to identify the number of inputs in the set of inputs that each have the same sign. In response to identifying the inputs, the input selector is configured to select a plurality of inputs in the set of inputs that each have the same sign and provide the selected inputs to a particular adder of the circuit 100. The adder 108 receives the selected inputs and adds the inputs to generate a result 109 that is the sum of the selected inputs. In some embodiments, each input selector 104, 114 selects a plurality of inputs in the set of inputs that each have the same sign based on the configuration of the adders 108, 118 of the circuit 100.
[0041] For example, the adder 108 can be a 3-input adder that receives each of the two inputs via the corresponding input port 110 of the adder 108 and receives one input via the bypass port 112 of the adder 108. In this case, the set of inputs can include three floating point value inputs. As described above, in some cases, the input received using the bypass port 112 of the adder 108 can have the same sign as each of the two inputs received using the corresponding input port 110, such as a positive number. Alternatively, the input received using the bypass port 112 of the adder 108 can have a different sign from the sign of the two inputs received using the corresponding input port 110, such as a negative number. The input received using the bypass port of the adder is also referred to as the remaining input in this article.
[0042] Each input selector 104, 114 of the circuit 100 can be configured to communicate with two or more input ports (e.g., port 110) of the adders 108, 118 of the circuit 100 and bypass ports (e.g., port 112) of the adders 108, 118. Each input selector has one or more multiplexers, and each multiplexer is configured to select an input based on a sign bit of the input. For example, each multiplexer 106, 116 can have a selection setting based on the sign of the input (e.g., positive or negative), and the selection setting is used to select and pass a specific input in a set of two inputs. Typically, each input selector uses its multiplexer to select two or more inputs. Each input selector can select a certain number of inputs based on the configuration of the adder that will receive the selected input. For example, when providing inputs to a 3-input adder, the input selector 104 will: i) select the first input and pass it to the first input port 110 of the 3-input adder 108; ii) select the second input and pass it to the second input port 110 of the 3-input adder 108; and, iii) select the third input and pass it to the bypass port 112 of the 3-input adder 108.
[0043] Each multiplexer in the respective set 106, 116 of multiplexers included in the respective input selectors 104, 114 may include: i) a first 2:1 multiplexer configured to select and pass values having a particular sign (e.g., positive), ii) a second 2:1 multiplexer configured to select and pass values having a particular sign (e.g., positive) that is the same as the sign of the input selected by the first 2:1 multiplexer, and, iii) a third 3:1 multiplexer configured to select and pass the remaining values. In some cases, the remaining values have a sign that is the same as or different from the sign of the input selected using one of the 2:1 multiplexers.
[0044] A first 2:1 multiplexer receives a set of two inputs, identifies the signs of the two numerical inputs in the set, and selects and passes a single numerical input of the set having a sign that matches a specific symbol that the first multiplexer is configured or encoded to pass. A second 2:1 multiplexer functions in a substantially similar manner to the first 2:1 multiplexer. A third 3:1 multiplexer receives a set of three inputs, identifies the signs of the three numerical inputs in the set, and then selects and passes a single numerical input of the set of inputs having a sign that matches a specific symbol that the third multiplexer is configured or encoded to pass (or a symbol that is different from the symbol encoded at the first multiplexer or the second multiplexer). In this manner, if the first multiplexer is encoded to select and pass a positive numerical input, the third multiplexer is encoded to select and pass a negative numerical input.
[0045] The input selectors use their respective multiplexers to provide inputs to the various adders of the circuit 100. For example, the input selector 104 may route inputs A and B to the input port 110 of the adder 108, where the adder 108 adds the two inputs A and B to generate a sum represented by the result 109. Similarly, the input selector 114 may route inputs C and E to the input port 110 of the adder 118, where the adder 118 adds the two inputs C and E to generate a sum represented by the result 119. The inputs C, D, and E each correspond to the remaining or unselected inputs, which will be described in detail below.
[0046] In some implementations, the result 109 or 119 is provided as an input to another adder downstream of the adder 108 or the adder 118 (e.g., a third adder of the circuit 100). For example, the result 109 can be provided as an input to another adder downstream using a wired connection 124 (e.g., a hardwired connection) between an output port of the first adder (upstream) and an input port of the second adder (downstream).
[0047] The input selector 104 may also route the input (C) to the bypass port 112 of the adder 108. Similarly, the input selector 114 may also route the input (D) to the bypass port 112 of the adder 118. In some embodiments, the bypass ports of the adders 108, 118 are used to route one or more remaining inputs to at least one other adder of the circuit 100. The inputs routed via the bypass port of the adder correspond to the remaining inputs that are not included in the selected set of two or more inputs provided to the input port of the adder. For example, the remaining input (C) routed via the bypass port of the adder may have a different sign (e.g., negative) than the sign (e.g., positive) of at least two inputs provided to the input port of the adder. In other embodiments, the remaining input (C) may have the same sign as the at least two inputs.
[0048] As referenced below Figure 2 As described, circuit 100 may include an exemplary hierarchy of N adders, such that the result and remaining input output by the adder upstream in the hierarchy are provided as inputs to the adder downstream in the hierarchy. In some embodiments, each level in the hierarchy corresponds to a corresponding level in an exemplary multi-level calculation for generating the sum of the plurality of inputs 102. For example, in addition to result 109 and input C, inputs D and E of FIG. 1 may also correspond to the remaining inputs from the first level of the calculation.
[0049] like Figure 1A As shown, inputs D and E are not provided as inputs to the example upstream adder, for example based in part on the number of inputs 102 (5) included in the plurality of inputs 102 and the 3-input configuration of the adder at the first adder stage of the circuit 100. In this case, the circuit 100 may include one or more example wired connections 120, 122 to pass one or more unselected or remaining inputs to the input selector 114 downstream in the hierarchy. Thus, the circuit 100 may be configured to use at least the connections 120, 122 to pass unused numerical inputs from the upstream adder stage to the subsequent adder stage downstream.
[0050] For clarity, although the description of components in FIG. 1 and throughout this document applies to adders configured to receive a specific number of inputs (e.g., three inputs), these descriptions are equally applicable to other types of adders, such as adders configured to receive more than three inputs.
[0051] Figure 1BA diagram of an example hardware unsigned adder circuit 130 is shown. As described above, the adder 108 (or 118) can be an unsigned adder, and the circuit 130 can represent a component of the unsigned adder 108. The circuit 130 is configured to receive and add at least two inputs 132, 134 having the same sign. For example, the inputs can be two positive floating point numbers.
[0052] As described above, unsigned adders differ from normalized adders in that they do not require additional normalization circuitry because they can be configured to operate only on inputs 132, 134 having the same sign. For example, the unsigned adder circuit 130 does not require additional circuit components typically found in a normalized adder, such as hardware components for performing a wide left shift operation, or a two's complement operation, or a leading zero detection operation that is typically required when the addition operation involves adding two inputs having different signs. Therefore, since the additional normalization circuitry is eliminated, the adder 108 including the unsigned adder circuit 130 requires less area on the circuit die than the normalized adder and can consume less power.
[0053] The unsigned adder circuit 130 includes adder logic that the unsigned adder circuit 130 uses to add, for example, two positive floating point value inputs 132, 134 and generate a result 136. In general, an example binary data structure for a floating point number may include portions of bits representing the mantissa, exponent, and sign of a number. In some cases, the exponent value of one input 132 may be smaller than the other input 134, and the adder 108 may have to perform a shift operation to align the binary point between the two inputs 132, 134. In this case, in order to align the binary point, the smaller exponent is incremented and the mantissa is shifted right until the exponents are equal. Once shifted, the circuit 130 uses its adder logic to add the inputs 132, 134, perform any desired operations related to rounding, shifting, or adding protection bits for fractional data values, and generate a result 136.
[0054] Figure 2An example hierarchy 200 of components (e.g., input selectors and adders) at a hardware circuit 100 for generating a sum of multiple inputs 102 is shown. Circuit 100 can be a multi-input floating-point adder circuit of an example hardware computational unit. A cascaded structure of input selectors and adders can be used to form a multi-input floating-point adder. In one embodiment, the computational unit is used in a machine learning system that processes inputs using an example neural network such as a multi-layer neural network that processes inputs (e.g., multiple inputs 102) through each layer of the neural network to compute inferences. For example, the neural network can be included in a hardware computing device such as a smart phone or a server collection. The hardware device can receive data (e.g., a collection of images) and use a neural network to process inputs related to the data to identify or discern information included in the data (e.g., an object in the image).
[0055] The hierarchical structure 200 may include N adders, such that the result output by the adder upstream of the hierarchical structure 200 and the remaining input are provided as input to the adder downstream of the hierarchical structure 200. Figure 2 As shown, the hierarchy 200 may include a plurality of levels corresponding to respective levels in the exemplary multi-level computation for generating a sum of the plurality of inputs 102 .
[0056] For example, in the first level 202 of the hierarchy 200, adders 214, 215 each receive a set of 3 inputs. Adder 214 generates a sum 219 using two of the three inputs in the set received by adder 214. A bypass port of adder 214 routes the unused input 216 to the second level 204 of the hierarchy 200. Similarly, adder 215 generates a sum 220 using two of the three inputs in the set received by adder 215. A bypass port of adder 215 routes the unused input 217 to the second level 204 of the hierarchy 200.
[0057] In the second stage 204, the adder 222 receives at least two inputs 216, 217. For example, the inputs 216, 217 may correspond to remaining inputs that are routed downstream in the hierarchy 200, for example, using corresponding bypass ports of the upstream adders 214, 215, for use in a subsequent stage of the example calculation. In some embodiments, the adder 222 is a 3-input adder that receives at least two inputs 216, 217 of the same sign and uses the at least two inputs to generate a sum 224. The adder 222 may also use the bypass port to route a third input 219 or 220 downstream to a subsequent stage in the hierarchy 200. In the second stage 204, the third input 219 or 220 may be the result of an addition operation performed using an adder upstream in the hierarchy 200. In some cases, the third input 219 or 220 is routed downstream to a subsequent stage 206 using an example wired connection 234.
[0058] In the third stage 206, the adder 226 receives a set of three inputs 219, 220, 224. In the third stage 206, the input 219 may be a corresponding first sum generated by a first adder upstream in the hierarchy 200, and the input 220 may be a corresponding second sum generated by a second adder upstream in the hierarchy 200. The circuit 100 may provide instructions or commands to the adder 226 to add the inputs 219 and 220 based on an input selector communicating with the adder 226 that has identified the inputs 219 and 220 as having the same sign. A bypass port of the adder 226 routes the input 224 to a subsequent stage of the hierarchy 200.
[0059] In the fourth stage 208, the adder 230 receives at least two inputs 224, 228. The input 224 may be a corresponding sum generated by an adder upstream in the hierarchy 200 but not used in the previous stage of the stage 208, and the input 228 may be a corresponding sum generated by an adder at the previous stage of the stage 208. Therefore, the inputs 224, 228 may not have the same sign. In this case, the adder 230 may be configured as a normalized adder that generates a normalized result 232. Using the hierarchy 200, the circuit 100 may be configured to generate a sum of the plurality of inputs 102 based on a normalized result representing a sum of each of the plurality of inputs 102 added together, regardless of the sign of each of the plurality of inputs.
[0060] In some embodiments, circuit 100 can receive N inputs and be configured to group the N inputs into floor(N / 3) sets and determine some of the remaining inputs that can form a final (or remaining) set of inputs. In some cases, the remaining inputs of the final set are passed downstream of hierarchy 200, such as from one stage to a subsequent stage, using wired connections of circuit 100. Circuit 100 can be configured such that at each stage, or any given stage, the circuit will have a specific number of adders based on the N inputs [floor(N / 3) adders] and a specific number of outputs based on the N inputs [2*floor(N / 3)+Mod(N / 3) outputs], where N corresponds to the number of inputs received for addition at a particular stage. In some embodiments, each stage in the example hierarchy 200 reduces the number of outputs by a ratio of 3:2.
[0061] Figure 3 A flow chart of an example process 300 for performing mathematical calculations using an input group is shown. The process 300 may be performed using circuit 100 including other devices and systems described herein.
[0062] Referring now to process 300, circuit 100 obtains a plurality of inputs (302). For example, a selection circuit of circuit 100 obtains or receives a plurality of inputs from an external source such as a host device or an external controller. In some embodiments, each received input is a corresponding floating point number, and each input has a corresponding sign associated with the number. The sign of each input indicates whether the input has a floating point value greater than zero (a positive number) or has a floating point value less than zero (a negative number).
[0063] The first input selector of the selection circuit receives a first set of inputs formed by the plurality of inputs 102 and provides a certain number of the selected inputs to the first adder (304) of the hardware circuit. More specifically, the input selector 104 provides at least two inputs (e.g., inputs A and B of FIG. 1 ) to the adder 108 to generate a first sum corresponding to the result 109. In some embodiments, the at least two inputs are at least two inputs selected from the first set of inputs formed by the plurality of inputs 102. The input selector 104 selects the at least two inputs based on the corresponding signs of each input in the first set of inputs. The selected two inputs are provided to the adder 108 to generate the first sum (e.g., the result 109 of FIG. 1 ).
[0064] The second input selector of the selection circuit receives two or more inputs. The two or more inputs received may include the first sum generated by the first adder, one or more remaining inputs of the plurality of inputs 102 that are not included in the first set of inputs, or a combination of each. The second input selector then provides at least two other inputs to the second adder to generate a second sum using the second adder (306). For example, the input selector 114 may receive the remaining inputs C, D, and E of FIG. 1 and select at least two of these inputs based on the sign of each input.
[0065] In order to identify the sign of each input, the input selector 114 can analyze information about each of the two or more inputs received, such as a data structure representing each input. The input selector 114 then selects at least two inputs having the same sign based on the sign of each input identified, and provides the at least two inputs to the adder 118 to generate a second sum corresponding to the result 119.
[0066] The circuit 100 is configured to provide two or more inputs to the third adder. For example, the circuit 100 can be configured to provide at least the first sum and the second sum to at least the third adder (308). In some embodiments, the circuit 100 provides one or more inputs that are unselected or unused inputs and are passed downstream using a wired connection of the circuit or a bypass port of an adder located upstream of the third adder. In some cases, the third adder is a normalized adder that is configured to generate a normalized output using at least the first sum and the second sum. The normalized output may correspond to the sum of the plurality of inputs.
[0067] The circuit 100 is configured to generate a sum of the plurality of inputs 102 at least by adding a first sum to a second sum (310). For example, the circuit 100 may generate the sum using at least an exemplary normalized adder located at a level downstream of the hierarchy 200. The normalized adder is configured to receive an input corresponding to a result of an addition operation performed by one or more adders upstream of the normalized adder (or an input routed downstream as an unused input). The normalized adder generates the sum as a normalized output using the received input corresponding to the addition or routing operation performed by the upstream adder.
[0068] A number of embodiments have been described. However, it will be appreciated that various modifications may be made without departing from the scope of the invention. For example, various forms of the processes shown above may be used, and the steps reordered, added, or deleted. Therefore, other embodiments are within the scope of the appended claims. Although this specification contains many specific implementation details, these should not be interpreted as limitations on the scope of what is claimed, but rather as descriptions of features that may be specific to a particular embodiment. Certain features described in this specification in the context of independent embodiments may also be implemented in combination in a single embodiment.
[0069] Conversely, various features described in the context of a single embodiment may also be implemented separately in multiple embodiments or in any suitable subcombination. Moreover, although features may be described above as functioning in certain combinations and even initially claimed as such, in some cases one or more features in the claimed combination may be excised from the combination, and the claimed combination may be directed to subcombinations or variations of the subcombinations.
[0070] Similarly, although operations are depicted in a particular order in the accompanying drawings, this should not be understood as requiring that such operations be performed in the particular order shown or in a continuous order, or that all of the operations shown be performed to achieve the desired results. In some cases, multitasking and parallel processing may be advantageous. In addition, the separation of various system modules and components in the above-described embodiments should not be understood as requiring such separation in all embodiments, and it should be understood that the described program components and systems can generally be integrated together in a single software product or packaged into multiple software products.
[0071] Specific embodiments of the subject matter have been described. Other embodiments are within the scope of the following claims. For example, the actions recited in the claims can be performed in a different order and still achieve the desired results. As an example, the processes depicted in the accompanying drawings do not necessarily require the particular order shown or sequential order to achieve the desired results. In some cases, multitasking and parallel processing may be advantageous.
Claims
1. A circuit configured to add a plurality of inputs, the circuit comprising: a plurality of unsigned adders, each unsigned adder configured to perform a respective addition operation using a respective set of inputs derived from the plurality of inputs; A plurality of input selectors, each unsigned adder being associated with a corresponding input selector, wherein the corresponding input selector is configured to: receiving a first set of inputs derived from the plurality of inputs; selecting at least two inputs from the first set of inputs, the at least two inputs being selected based on sign bits of inputs in the first set of inputs such that the selected at least two inputs have the same sign; providing the first set of inputs to an associated unsigned adder to generate a first sum of the selected at least two inputs; as well as Normalized adder, configured as: A final sum is generated based on one or more sums generated using the plurality of unsigned adders, each unsigned adder summing at least two inputs having the same sign, wherein the final sum corresponds to the sum of the plurality of inputs.
2. The circuit according to claim 1, wherein The normalized adder is further configured to: receiving input related to a result of an addition operation performed by one or more unsigned adders of the plurality of unsigned adders; and The normalized output is generated using an input related to the result of the addition operation of the one or more unsigned adders.
3. The circuit according to claim 1, wherein: A second input selector of the plurality of input selectors is configured as: receiving a second set of inputs including two or more remaining inputs derived from the plurality of inputs, wherein the two or more remaining inputs are not among the at least two inputs of the first set of inputs from which the first sum was generated; selecting at least two inputs from the second set of inputs, the at least two inputs being selected based on sign bits of inputs in the second set of inputs such that the at least two inputs selected from the second set of inputs have the same sign; and The second set of inputs is provided to an associated second unsigned adder to generate a second sum of the at least two inputs selected from the second set of inputs.
4. The circuit according to claim 3, wherein: The corresponding input selector is further configured to: selecting the remaining input to be provided to another unsigned adder; and The selected remaining input is routed to another unsigned adder, wherein the selected remaining input (i) is not among the at least two inputs summed to generate the first sum and (ii) is not among the at least two inputs summed to generate the second sum.
5. The circuit according to claim 1, wherein: The sum of the plurality of inputs is a normalized result representing a sum of adding each of the plurality of inputs regardless of a sign of each of the plurality of inputs.
6. The circuit according to any one of claims 1 to 5, wherein: Each of the plurality of inputs is a floating point number, and a sign bit of each input indicates a sign of the input and identifies a value of the floating point number as being greater than zero or less than zero.
7. The circuit according to claim 6, wherein: The corresponding input selector is further configured to: determining, based on a sign bit of an input, whether the input has a value greater than zero or less than zero; as well as Two or more inputs are selected that each have a value greater than zero, or that each have a value less than zero.
8. The circuit according to claim 7, wherein: The corresponding input selector is further configured to: communicating with a first input port of the associated unsigned adder; in communication with a second input port of the associated unsigned adder; providing a first input of the selected two or more inputs to the associated unsigned adder using the first input port of the associated unsigned adder; as well as A second input of the selected two or more inputs is provided to the associated unsigned adder using the second input port of the associated unsigned adder.
9. The circuit according to claim 8, wherein The corresponding input selector is further configured to: in communication with a bypass port of the associated unsigned adder; and Remaining inputs not included in the selected two or more inputs are routed using the bypass port of the associated unsigned adder.
10. A computer-implemented method for adding a plurality of inputs using a hardware circuit including a plurality of input selectors and a plurality of unsigned adders, the method comprising: Obtaining multiple inputs through the hardware circuit, each input having a corresponding sign; selecting, by a first input selector, at least two inputs from a first set of inputs derived from the plurality of inputs, the at least two inputs being selected based on sign bits of inputs in the first set of inputs such that the selected at least two inputs have the same sign; providing the first set of inputs to a first unsigned adder of a plurality of unsigned adders via the first input selector; generating a first sum of the selected at least two inputs by the first unsigned adder and passing a remaining input from the first set of inputs, wherein the remaining input is not included in the selected at least two inputs; receiving at least two other inputs through a second input selector associated with a second unsigned adder to generate a second sum using the second unsigned adder, the at least two other inputs being selected from a second set of inputs derived from the plurality of inputs, the second set of inputs including the first sum and the remaining inputs and excluding the selected two inputs from the first set of inputs, the at least two other inputs being selected based on sign bits of inputs in the second set of inputs such that the selected at least two other inputs have the same sign; and A final sum is generated by a normalizing adder based on one or more sums generated using the plurality of unsigned adders, each unsigned adder summing at least two inputs having the same sign, wherein the final sum corresponds to the sum of the plurality of inputs.
11. The method according to claim 10, further comprising: A normalized output is generated using a normalized adder, wherein the normalized output corresponds to a sum of the plurality of inputs.
12. The method according to claim 10, further comprising: Two or more remaining inputs are received by a third input selector associated with a third unsigned adder to generate a third sum using the third unsigned adder, the two or more inputs being selected from a third set of inputs derived from the plurality of inputs, the third set of inputs excluding both the selected at least two inputs from the first set of inputs and the selected at least two other inputs from the second set of inputs, the two or more remaining inputs being selected based on sign bits of the inputs in the third set of inputs so that the selected two or more remaining inputs have the same sign.
13. The method according to claim 10, further comprising: determining, based on a sign bit of an input, whether the input has a value greater than zero or less than zero; as well as Two or more inputs are selected that each have a value greater than zero, or that each have a value less than zero.
14. The method according to claim 13, further comprising: providing a first input of the selected two or more inputs to the first unsigned adder using a first input port of the first unsigned adder; as well as A second input of the selected two or more inputs is provided to the first unsigned adder using a second input port of the first unsigned adder, wherein the second input has the same sign as the first input.
15. The method according to claim 10, wherein: The sum of the plurality of inputs is a normalized result representing a sum of adding each of the plurality of inputs regardless of a sign of each of the plurality of inputs.
16. The method according to claim 10, wherein: Each of the plurality of inputs is a floating point number, and a sign bit of each input indicates a sign of the input and identifies a value of the floating point number as being greater than zero or less than zero.
17. One or more non-transitory machine-readable storage devices for storing instructions executable by one or more processing devices to cause the method of any one of claims 10 to 16 to be performed.
