# US 2019/0378001 A1 · Neural network hardware acceleration with stochastic adaptive resource allocation

> Agents: this data is available as JSON from the patentgrep API and MCP server — see https://patentgrep.com/llms.txt

- Number: US 2019/0378001 A1
- Document ID: US20190378001A1
- Status: Published application
- Kind: A1
- Application number: 16/006,497
- Filed: 2018-06-12
- Published: 2019-12-12
- Earliest claimed: 2018-06-12
- Assignees: Samsung Electronics Co., Ltd.
- Applicants: Samsung Electronics Co., Ltd.
- Inventors: Shai Litvak
- Web page: https://patentgrep.com/patent/US20190378001A1

## CPC

- G06N 3/063: using electronic means
- G06F 9/5044: {considering hardware capabilities}
- G06N 3/045: Combinations of networks
- G06N 3/0464: Convolutional networks [CNN, ConvNet]
- G06N 3/047: Probabilistic or stochastic networks
- Y02D 10/00: Energy efficient computing, e.g. low power processors, power management or thermal management
- G06N: COMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)
- Y02D: CLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE

## Abstract

A digital circuit for accelerating computations of an artificial neural network model includes a pairs selection unit that selects different subsets of pairs of input vector values and corresponding weight vector values to be processed simultaneously at each time step; a sorting unit that simultaneously processes a vector of input-weight pairs wherein pair values whose estimated product is small are routed with a high probability to small multipliers, and pair values whose estimated product is greater are routed with a high probability to large multipliers that support larger input and output values; and a core unit that includes a plurality of multiplier units and a plurality of adder units that accumulate output results of the plurality of multiplier units into one or more output values that are stored back into the memory, where the plurality of multiplier units include the small multipliers and the large multipliers.

## Claims

### Claim 1

A digital circuit for accelerating computations of an artificial neural network model, comprising:
a memory that stores an input vector, a weight vector, and an output value;
a pairs selection unit that selects different subsets of pairs of input vector values and corresponding weight vector values from the memory, to be processed simultaneously at each time step;
a sorting unit that simultaneously processes a vector of input-weight pairs wherein pair values whose estimated product is small are routed with a high probability to small multipliers, and pair values whose estimated product is greater are routed with a high probability to large multipliers that support larger input and output values; and
a core unit that includes a plurality of multiplier units and a plurality of adder units that accumulate output results of the plurality of multiplier units into one or more output values that are stored back into the memory, wherein the plurality of multiplier units include the small multipliers and the large multipliers.

### Claim 2 (depends on 1)

The digital circuit of claim 1, wherein the sorting unit comprises:
a plurality of function units, wherein each function unit implements a monotone non-decreasing function of an absolute value of a product of the one of the input vector values and a corresponding weight vector value, wherein each function unit outputs a result; and
a plurality of flip units, wherein each flip compares a first result of a first function unit and a second result of a second function unit and outputs the first result and the second result, wherein
when the second result is greater than the first result, the first result and second result are respectively output to a first receiving unit and a second receiving unit, and when the second result is less than the first result, the first result and second result are respectively output to the second receiving unit and the first receiving unit.

### Claim 3 (depends on 2)

The digital circuit of claim 2, wherein each function unit includes an adder that adds an index of a non-zero most-significant-bit (MSB) of |v|, an absolute value of one of the input vector values and an index of a non-zero MSB of |w|, an absolute value of the corresponding weight vector value.

### Claim 4 (depends on 3)

The digital circuit of claim 3, wherein each function unit further includes a conditional zero-unit that sets an output of the adder to zero if either or both of the indices of the MSBs of the absolute values of the input vector and corresponding weight vector are zero.

### Claim 5 (depends on 2)

The digital circuit of claim 2, wherein the sorting unit comprises a layer of function units and one or more layers of flip units,
wherein input values to the flip units of a first layer are the results of two function units, and when there are two or more layers of flip units, input values of each flip unit of a successive layer of flip units are output values from different flip-units in a previous layer of flip units.

### Claim 6 (depends on 1)

The digital circuit of claim 1, wherein the small multiplier is an N bit multiplier whose inputs are each N bits and whose output is 2N bits, wherein the multiplier calculates an exact product when the product is representable in K bits, K<2N, and the multiplier calculates an approximation to the exact product when a representation of the exact product is more than K bits.

### Claim 7 (depends on 6)

The digital circuit of claim 6, wherein N=8 and K=8.

### Claim 8 (depends on 6)

The digital circuit of claim 6, wherein the small multiplier takes as input an N-bit input value v, a corresponding N-bit weight value w and includes a multiplier that calculates the exact product v×w when the exact product is representable in K bits, K<2N, and shift and adder units that calculate 1<<(M−1), wherein M=MSB(|v|)+MSB(|w|), wherein MSB(x) is an index of a most significant non-zero bit in a binary representation of x and << is a left-shift bit-wise binary operation, when the exact product's representation requires more than K bits.

### Claim 9 (depends on 6)

The digital circuit of claim 6, wherein the small multiplier takes as input an N-bit input value v, a corresponding N-bit weight value w and includes a multiplier that calculates the exact product v×w when the exact product is representable in K bits, K<2N, and shift and adder units that calculates (1<<(M−3))+(1<<(M−1))−(1<<┌M/2┐), wherein M=MSB(|v|)+MSB(|w|), wherein MSB(x) is an index of a most significant non-zero bit in a binary representation of x and << is a left-shift bit-wise binary operation, when the exact product's representation require more than K bits.

### Claim 10 (depends on 1)

The digital circuit of claim 1, wherein:
the sorting unit calculates a function of each pair of values and then sorts the pair values into a plurality of categories based on results of the calculated function of the pairs,
the core unit includes a plurality of categories of multipliers wherein each category of multipliers is associated with a category of pair values, and
the sorting unit routes pair values of a given category to an appropriate multiplier for that given category.

### Claim 11

A method of processing a layer in an artificial neural network model, comprising the steps of:
receiving a plurality of pairs of input vector component values and corresponding weight vector component values and forming a vector of activation-weight pairs of an input vector component value v and a corresponding weight vector component value w;
calculating, for each activation-weight pair, a value of a function g(v,w) of v and w;
partially sorting the activation-weight pairs vector by repeatedly comparing pairs of function values g(v,w), and conditionally swapping corresponding activation-weight pairs in the vector based on a comparison result, wherein a number of comparisons is less than or equal to a number of all possible activation-weight pair combinations, wherein activation-weight pairs (v,w) with a smaller function value g(v,w) among the function values g(v,w) are moved with high probability to a first side of the vector, while activation-weight pairs (v,w) with a large function value g(v,w) among the function values g(v,w) are moved with high probability to a second side of the vector opposite form the first side;
routing the partially sorted activation-weight pairs (v,w) based on the comparison result wherein activation-weight pairs (v,w) from the first side of the vector are routed to small multipliers, and activation-weight pairs (v,w) from the second side of the vector are routed to a large multiplier; and
processing the activation pairs routed to the multipliers by multiplying the pairs of values and then accumulating the product results of the multiplications to obtain an output vector value for a current layer, wherein those activation-weight pairs whose function value is small are with a high probability multiplied by a small multiplier to yield a small product, and those activation-weight pairs whose function value is large are with a high probability multiplied by a large multiplier to yield a large product

### Claim 12 (depends on 11)

The method of claim 11, wherein the function g is a monotone non-decreasing function of |v×w|, an absolute value of v×w, wherein if |v1×w1|≥|v2×w2| then g(v1, w1)≥g(v2,w2).

### Claim 13 (depends on 12)

The method of claim 12, wherein the monotone non-decreasing function is a sum of an index of a most-significant-bit (MSB) of |v|, an absolute value of an input vector value v and the index of the MSB of |w| the corresponding weight vector value w.

### Claim 14 (depends on 13)

The method of claim 13, further comprising setting the monotone non-decreasing function output to zero if the indices of the MSBs of the absolute input vector value |v| or the corresponding weight vector value |w| are zero.

### Claim 15 (depends on 11)

The method of claim 11, wherein sorting the activation-weight pairs vector outputs an exact order of the pairs, based on values of the corresponding g(v,w).

### Claim 16 (depends on 11)

The method of claim 11, wherein multiplying a weight-activation pair whose estimated product is small comprises calculating an exact product when the exact product is representable in K bits, or calculating an approximation to the exact product when the representation of the exact product is more than K bits, wherein K<2N, wherein N is a number of number of bits in an input value and a corresponding weight value.

### Claim 17 (depends on 16)

The method of claim 16, wherein multiplying a weight-activation pair whose estimated product is small comprises:
calculating an exact product x=v×w of an N-bit input value v and a corresponding N-bit weight value w, when the exact product x is representable in K bits;
calculating a result of y=1<<(M−1) wherein M=MSB(|v|)+MSB(|w|), wherein MSB(x) is an index of a most significant bit in a binary representation of x and << is a left-shift bit-wise binary operation, when the exact product x in not representable in K bits;
determining whether the exact product of v×w is representable in K bits, and
outputting the exact product x in N least significant bits of a 2N-bit output result when the exact product is representable in K bits, or outputting the 2N-bit output result y when the exact product's representation requires more than K bits.

### Claim 18 (depends on 16)

The method of claim 16, wherein multiplying a weight-activation pair whose estimated product is small comprises:
calculating an exact product x=v×w of an N-bit input value v and a corresponding N-bit weight value w, when the exact product x is representable in K bits;
calculating a result of y=1<<(M−3)+1<<(M−1)−1<<┌M/2┐, wherein M=MSB(|v|)+MSB(w|), wherein MSB(x) is an index of a most significant bit in a binary representation of x and << is a left-shift bit-wise binary operation, when the exact product x in not representable in K bits;
determining whether the exact product of v×w is representable in K bits; and
outputting the exact product x in N least significant bits of a 2N-bit output result when the exact product is representable in K bits, or outputting the 2N-bit output result y when the exact product's representation requires more than K bits.

### Claim 19 (depends on 11)

The method of claim 11, further comprising repeating the steps of, for a predetermined number of iterations, simultaneously comparing pairs of function values g(v,w) and conditionally swapping corresponding activation-weight pairs in the vector based on a comparison result.

### Claim 20 (depends on 11)

The method of claim 11, wherein comparing pairs of g(v,w) further comprises partially sorting the pair values into a plurality of categories based on a size of the g(v,w) of each pair, and routing each activation-weight pair based on its category to an appropriate multiplier, wherein the routed activation-weight pairs is multiplied by the appropriate multiplier to yield an exact product or an approximate product based on g(v,w).
