KR20200050895A - Log-quantized mac for stochastic computing and accelerator comprising the same - Google Patents

Log-quantized mac for stochastic computing and accelerator comprising the same Download PDF

Info

Publication number
KR20200050895A
KR20200050895A KR1020190138779A KR20190138779A KR20200050895A KR 20200050895 A KR20200050895 A KR 20200050895A KR 1020190138779 A KR1020190138779 A KR 1020190138779A KR 20190138779 A KR20190138779 A KR 20190138779A KR 20200050895 A KR20200050895 A KR 20200050895A
Authority
KR
South Korea
Prior art keywords
counter
bit
width
block
weight
Prior art date
Application number
KR1020190138779A
Other languages
Korean (ko)
Other versions
KR102340412B1 (en
Inventor
이종은
심현욱
Original Assignee
울산과학기술원
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 울산과학기술원 filed Critical 울산과학기술원
Publication of KR20200050895A publication Critical patent/KR20200050895A/en
Application granted granted Critical
Publication of KR102340412B1 publication Critical patent/KR102340412B1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/06Physical realisation, i.e. hardware implementation of neural networks, neurons or parts of neurons
    • G06N3/063Physical realisation, i.e. hardware implementation of neural networks, neurons or parts of neurons using electronic means
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/04Architecture, e.g. interconnection topology
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/08Learning methods

Landscapes

  • Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Health & Medical Sciences (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • Biomedical Technology (AREA)
  • Biophysics (AREA)
  • Evolutionary Computation (AREA)
  • Computational Linguistics (AREA)
  • Data Mining & Analysis (AREA)
  • Artificial Intelligence (AREA)
  • General Health & Medical Sciences (AREA)
  • Molecular Biology (AREA)
  • Computing Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Mathematical Physics (AREA)
  • Software Systems (AREA)
  • Neurology (AREA)
  • Complex Calculations (AREA)

Abstract

The present invention relates to a log-quantized multiply-accumulator for stochastic calculation and an accelerator including the same. According to an embodiment of the present invention, the multiply-accumulator comprises: an input providing part providing input data; a weight providing part that receives a weight and outputs a log-quantized weight; a log-to-linear converter that receives the log-quantized weight and outputs a linearly transformed weight; an inverse counter that outputs a window width from the linearly converted weight; a 1 counter counting a value of 1 in the window width from the number of stochastics corresponding to the input data; and an accumulator that accumulates and outputs the value output by the 1 counter.

Description

스토캐스틱 연산을 위한 로그-양자화된 곱셈 및 누적기와 이를 포함하는 가속기{LOG-QUANTIZED MAC FOR STOCHASTIC COMPUTING AND ACCELERATOR COMPRISING THE SAME}Log-QUANTIZED MAC FOR STOCHASTIC COMPUTING AND ACCELERATOR COMPRISING THE SAME}

본 기술은 로그-양자화된 가중치 값을 이용하여 스토캐스틱 연산을 수행하는 MAC 및 이를 포함하는 가속기와 관련된다.The present technology relates to a MAC performing a stochastic operation using a log-quantized weight value and an accelerator including the same.

스토캐스틱 컴퓨팅(stochastic computing)은 비트 스트림(bitstream)에서 1의 등장 빈도를 이용하여 숫자를 표현하는 방법을 이용하는 컴퓨팅 방법으로, 종래의 2의 보수(2's complement)에 기초한 디지털 구현예들에 비하여 저비용, 낮은 전력 소모, 높은 내오류 특성 및 점진적 정밀도를 갖는 등 많은 장점을 가진다. 최근 스토캐스틱 컴퓨팅은 저전력 이미지 처리와 같은 다른 응용분야 뿐만 아니라 딥 뉴럴 네트워크(DNN, deep neural network) 가속에 효과적인 것으로 나타났다.Stochastic computing (stochastic computing) is a computing method using a method of expressing a number using an appearance frequency of 1 in a bitstream, which is lower cost than digital implementations based on 2's complement. It has many advantages such as low power consumption, high error-resistance characteristics, and gradual precision. Stochastic computing has recently been shown to be effective for accelerating deep neural networks (DNNs) as well as other applications such as low-power image processing.

스토캐스틱 컴퓨팅은 근사 컴퓨팅(approximate computing)의 맥락에서 환경, 입력 또는 컴퓨팅 상황(예를 들어, DNN의 다른 계층)에 따라 처리 시간 및 에너지 소모와 결과 품질을 트레이드 오프(trade-off)할 수 있는 유용한 프레임워크를 제공한다. 이러한 런타임 조절은 매우 자연스러우며, 스토캐스틱 컴퓨팅에서 과부하(overhead)를 발생시키지 않는다. Stochastic computing is useful in the context of approximate computing to trade-off processing time and energy consumption and resulting quality depending on the environment, input or computing situation (e.g., different layers of DNN). Provide a framework. This run-time adjustment is very natural and does not introduce overhead in stochastic computing.

한편, 사람의 뇌에서는 뉴런들이 이어져 네트워크를 형성하는데, 그 과정에서 학습, 추론 및 사고한다. 뉴럴 네트워크는 그 학습 활동을 모방하여 형성된다. 뉴럴 네트워크의 구성 요소로는 뉴런과 시냅스가 있을 수 있으며, 시냅스는 뉴런과 뉴런이 연결되는 부분으로, 뉴런 사이의 시냅스 연결도의 강하고, 약한 정도를 가중치(weight)라고 한다. On the other hand, in the human brain, neurons connect to form a network, in the process of learning, reasoning and thinking. Neural networks are formed by imitating the learning activities. The components of the neural network may be neurons and synapses, and synapses are the parts where neurons and neurons are connected, and the strong and weak degree of synaptic connection between neurons is called weight.

뉴럴 네트워크를 학습한다고 하는 것은 네트워크를 만들고, 학습을 시키고 싶은 데이터를 주었을 때, 목적하는 데이터에 상응하는 값이 입력되고, 가중치 값과 곱하여 목적하는 값을 얻을 때까지 가중치 값을 변화시켜 출력될 때까지 학습을 시키는 것이며, 결과적으로, 학습이라는 과정은 가중치를 얻어내는 과정이다. Learning a neural network is when a network is created and given data that you want to learn, when a value corresponding to the desired data is entered, and multiplied by the weight value until the desired value is changed and output. As far as learning is done, as a result, the process of learning is a process of obtaining weights.

가속기(accelerator)를 이용하여 뉴럴 네트워크 학습 및 추론을 수행하는데, 그 이유는 뉴럴 네트워크라는 학습 프로그램(및 추론 프로그램)을 수행하는 것은 수많은 병렬적 연산을 수행하는 것이다. 즉, 뉴런과 뉴런 사이의 가중치 뉴런을 가중치 매트릭스로 표현하고, 입력 벡터와 가중치 매트릭스를 곱하여 출력 벡터를 얻는 과정으로 표현할 수 있으나, 수행하는 연산의 횟수가 많다. The neural network learning and inference is performed using an accelerator, because performing a learning program (and inference program) called a neural network performs a number of parallel operations. That is, a weighted neuron between a neuron and a neuron can be expressed as a weighting matrix, and multiplied by an input vector and a weighting matrix to obtain an output vector, but the number of operations performed is large.

스토캐스틱 컴퓨팅의 가장 중요한 문제 중 하나는 정밀도와 관련하여 런 타임 및 에너지 소비가 기하급수적으로 증가한다는 것이다. 스토캐스틱 컴퓨팅은 N 비트 바이너리와 유사한 정밀도를 달성하기 위해 길이 2N의 비트 스트림을 필요로하기 때문이며, 이러한 점은 높은 정밀도를 달성하기 위한 SC의 지수적 복잡성은 계산 및 스토리지 요구 사항 모두에 영향을 미치고, 대규모 SC 기반 DNN과 같은 큰 문제에 SC를 적용하는 데 심각한 문제가 된다. 비트 병렬화(bit-parallelism)는 지연 시간(latency)을 줄일 수 있는 방법 중 하나이나, 비용이 많이 소모된다.One of the most important problems of stochastic computing is that run time and energy consumption increase exponentially with respect to precision. Stochastic computing requires a bit stream of length 2 N to achieve precision similar to N-bit binaries, which is why the exponential complexity of SC to achieve high precision affects both computational and storage requirements, However, it becomes a serious problem to apply SC to large problems such as large-scale SC-based DNN. Bit-parallelism is one of the ways to reduce latency, but it is expensive.

본 실시예에 의한 곱셈 누적기(multiply-accumulator)는 입력 데이터를 제공하는 입력 제공부와, 가중치 입력을 제공받아 로그로 양자화된 가중치를 출력하는 가중치 제공부와, 로그로 양자화된 가중치를 제공받고, 선형으로 변환된 가중치를 출력하는 로그 대 선형 변환기와, 선형으로 변환된 가중치로부터 윈도우 너비를 출력하는 역 계수기와, 입력 데이터에 상응하는 스토캐스틱 수에서 윈도우 너비 내의 1의 값을 계수하는 1 계수기 및 1 계수기가 출력한 값을 누적하여 출력하는 누적기를 포함한다.The multiply-accumulator according to the present embodiment is provided with an input providing unit providing input data, a weight providing unit receiving weight input and outputting quantized weights to a log, and a log quantized weight , A log-to-linear converter that outputs linearly converted weights, an inverse counter that outputs a window width from linearly converted weights, a 1 counter that counts a value of 1 in the window width from the number of stochastics corresponding to the input data, and 1 Includes an accumulator that accumulates and outputs the values output by the counter.

본 실시예에 의한 매트릭스 벡터 곱셈기(matrix-vector multiplier)는 복수의 입력 데이터 벡터들을 제공하는 입력 제공부와, 가중치 입력을 제공받아 로그로 양자화된 가중치를 출력하는 가중치 제공부와, 로그로 양자화된 가중치를 제공받고, 선형으로 변환된 가중치를 출력하는 로그 대 선형 변환기와, 선형으로 변환된 가중치로부터 윈도우 너비를 출력하는 역 계수기와, 입력 데이터 벡터에 각각에 상응하는 스토캐스틱 수에서 윈도우 너비 내의 1의 값을 계수하는 복수의 1 계수기들 및 1 계수기가 출력한 값을 누적하여 출력하는 복수의 누적기들을 포함한다.The matrix vector multiplier according to the present embodiment includes an input providing unit providing a plurality of input data vectors, a weight providing unit receiving a weight input and outputting quantized weights to a log, and quantized with a log A log-to-linear transformer that receives weights and outputs linearly converted weights, an inverse counter that outputs window widths from linearly converted weights, and 1 in the window width in the number of stochastics corresponding to each input data vector. It includes a plurality of 1 counters for counting values and a plurality of accumulators for accumulating and outputting values output by 1 counter.

본 실시예에 의하면 작은 면적으로 높은 에너지 효율을 가지는 곱셈 및 누적기와 이를 이용하는 가속기가 제공된다.According to the present embodiment, a multiplication and accumulator having high energy efficiency with a small area and an accelerator using the same are provided.

도 1은 본 실시예에 의한 로그 양자화를 이용하는 곱셈 및 누적기의 개요를 도시한 도면이다.
도 2(a)는 스토캐스틱 수 제너레이터의 동작을 설명하기 위한 개요적인 도면이고, 도 2(b)는 비트 병렬화에 따른 스토캐스틱 수 제너레이터의 동작 개요를 설명하기 위한 도면이며, 도 2(c)는 비트 병렬화에 따른 스토캐스틱 수 제너레이터(120) 동작의 다른 예를 설명하기 위한 도면이다.
도 3(a)는 비트 병렬화에 따라 동작하는 1 계수기에 제공된 윈도우 너비가 8인 경우를 예시한 도면이고, 도 3(b)는 비트 병렬화에 따라 동작하는 1 계수기에 제공된 윈도우 너비가 2 경우를 예시한 도면이다,
도 4는 본 실시예에 의한 1 계수기의 개요를 도시한 블록도이다.
도 5은 본 실시예에 의한 곱셈 및 누적기를 포함하는 가속기의 개요를 도시한 블록도이다.
도 6는 스토캐스틱 컴퓨팅 가속기의 평균 제곱 오차(mean square error)로 표시된 곱셈 오차를 도시한다.
도 7(a)는 가속기의 면적, 도 7(b)는 전력 소모를 비교 도시한 도면이다.
도 8은 5000회 반복하여 미세 조정된 대상 신경 네트워크에 인식 테스트 결과를 도시한 도면으로, 도 8(a)는 10-클래스 이미지 분류 결과이고, 도 8(b)는 1000 클래스 이미지 분류 결과이다.
1 is a diagram showing an outline of a multiplication and accumulator using log quantization according to the present embodiment.
FIG. 2 (a) is a schematic diagram for explaining the operation of the stochastic number generator, and FIG. 2 (b) is a diagram for explaining the operation outline of the stochastic number generator according to bit parallelization, and FIG. 2 (c) is a bit. A diagram for explaining another example of the operation of the stochastic number generator 120 according to parallelization.
FIG. 3 (a) is a diagram illustrating a case in which the window width provided in 1 counter operating according to bit parallelization is 8, and FIG. 3 (b) shows a case in which window width provided in 1 counter operating according to bit parallelization is 2 It is an illustrative drawing,
4 is a block diagram showing the outline of one counter according to the present embodiment.
5 is a block diagram showing an outline of an accelerator including a multiplier and an accumulator according to the present embodiment.
FIG. 6 shows the multiplication error expressed as the mean square error of the stochastic computing accelerator.
FIG. 7 (a) is a view illustrating an area of an accelerator, and FIG. 7 (b) is comparing power consumption.
FIG. 8 is a diagram showing the result of recognition test on a target neural network fine-tuned 5000 times, and FIG. 8 (a) is a 10-class image classification result, and FIG. 8 (b) is a 1000 class image classification result.

이하에서는 첨부된 도면들을 참조하여 본 실시예를 설명한다. 도 1은 본 실시예에 의한 로그 양자화를 이용하는 곱셈 및 누적기(MAC, multiply and accumulator, 100)의 개요를 도시한 도면이다. 도 1을 참조하면, 본 실시예에 의한 곱셈 및 누적기(100)는 입력(x)을 제공하는 입력 제공부(110)와, 입력(x)에 상응하는 스토캐스틱 수(stochastic number)를 출력하는 스토캐스틱 수 제너레이터(120, SNG, stochastic number generator) 및 스토캐스틱 수에 포함된 1을 계수하는 1 계수기(130, 1s cnt) 및 가중치(weight)에 로그(logarithm)를 취하여 출력하는 가중치 제공부(150, weight provider), 입력된 로그 양자화 된 수를 선형으로 변환하는 로그 대 선형 변환기(log-to-linear converter, 160)와, 미리 정해진 수에서 감산하는 역계수기(170, down-cnt) 및 가중치(~w)와 입력(x)으로부터 곱셈 결과의 부호를 연산하여 출력하는 XOR 게이트를 포함한다.Hereinafter, this embodiment will be described with reference to the accompanying drawings. 1 is a diagram showing an outline of a multiply and accumulator (MAC) 100 using log quantization according to the present embodiment. Referring to FIG. 1, the multiplication and accumulator 100 according to this embodiment outputs an input providing unit 110 providing an input (x) and a stochastic number corresponding to the input (x). Stochastic number generator (120, SNG, stochastic number generator) and 1 counter (130, 1s cnt) for counting 1 included in the number of stochastics, and a weight providing unit (150, for outputting a logarithm) weight provider), a log-to-linear converter (160) that linearly converts the input log quantized number, and an inverse counter (170, down-cnt) and weight (~) subtracted from a predetermined number. and an XOR gate that computes and outputs the sign of the multiplication result from w) and input (x).

입력 제공부(110)는 뉴럴 네트워크(미도시)에 제공되는 입력(x)을 제공한다. 일 예로, 입력(x)는 이진수(binary)로 뉴럴 네트워크에 제공되는 입력 벡터의 일 성분일 수 있다. 일 실시예로, 입력 제공부(110)는 본 실시예에 의한 곱셈 및 누적기(100)의 외부에서 제공된 입력(x)을 출력한다. The input providing unit 110 provides an input (x) provided to a neural network (not shown). As an example, the input (x) may be a binary component of an input vector provided to a neural network. In one embodiment, the input providing unit 110 outputs the input x provided outside the multiplier and accumulator 100 according to the present embodiment.

도 2(a)는 스토캐스틱 수 제너레이터(120)의 동작을 설명하기 위한 개요적인 도면이다. 도 2를 참조하면 스토캐스틱 수 제너레이터(120)는 스토캐스틱 수 제너레이터(120)는 입력(x)의 확률에 상응하는 스토캐스틱 수를 형성하여 비트 스트림(bit-stream)의 형태로 출력한다. 일 실시예로, x가 십진수로 (0.5)dec이고, 16비트를 가정하면 스토캐스틱 수 제너레이터(120)는 x3를 1로, x2, x1, x0를 0으로 설정하고, 선택 FSM(selector FSM, Finite State Machine)을 통해 다중화기(MUX)를 제어하여 비트 스트림 (1010 1010 1010 1010)bin을 출력하도록 제어한다. FIG. 2A is a schematic diagram for explaining the operation of the stochastic male generator 120. Referring to FIG. 2, the number of stochastic generators 120 forms the number of stochastics corresponding to the probability of the input (x) and outputs in the form of a bit-stream. In one embodiment, assuming that x is (0.5) dec in decimal and 16 bits, the stochastic number generator 120 sets x3 to 1, x2, x1, and x0 to 0, and select FSM (selector FSM, Finite). State Machine) to control the multiplexer (MUX) to control the output of the bit stream (1010 1010 1010 1010) bin.

다른 실시예로, x의 값이 (0.625)dec인 경우에, 0.625 = 0.5 + 0.125 이므로, 스토캐스틱 수 제너레이터(120)는 x3 = x1 = 1로 설정하고, x2 = x0 = 0으로 설정한다. 선택 FSM을 통해 다중화기(MUX)를 제어하여 비트 스트림 (1011 1010 1011 1010)bin을 출력하도록 제어한다. In another embodiment, when the value of x is (0.625) dec, since 0.625 = 0.5 + 0.125, the stochastic number generator 120 is set to x3 = x1 = 1, and x2 = x0 = 0. The multiplexer (MUX) is controlled through the selected FSM to output the bit stream (1011 1010 1011 1010) bin.

도 2(b)는 비트 병렬화에 따른 스토캐스틱 수 제너레이터(120)의 동작 개요를 설명하기 위한 도면이다. 도 2(b)를 참조하면, 비트 병렬화 방식에 의하면 1 계수기(130)는

Figure pat00001
사이클로 수행된다. 도 2(b)로 예시된 실시예에서, N이 총 16 비트이고, n은 비트 병렬화 매개변수이다. 비트 병렬화가 22 (n=2) 만큼 이루어진 바, 총 4 사이클로 수행된다. FIG. 2 (b) is a diagram for explaining the operation overview of the stochastic number generator 120 according to bit parallelization. Referring to Figure 2 (b), according to the bit parallelization method 1 counter 130
Figure pat00001
Cycle. In the embodiment illustrated in Figure 2 (b), N is a total of 16 bits and n is a bit parallelization parameter. Bit parallelism is 2 2 (n = 2) As it is made, it is performed in a total of 4 cycles.

1 계수기(130)가 총 4 사이클로 수행되며, 스토캐스틱 수 제너레이터(120)는 x의 16비트를 각 블록은 4 비트를 가지는 b1 내지 b4의 4 블록으로 분할한다. 각 블록의 첫 세 비트는 점선으로 표시된 것과 같이 모두 x3, x2, x3 순으로 동일하다. 마지막 비트는 선택 FSM에 의하여 x1과 x0 중에서 선택된다. 따라서, b1, b2, b3 및 b4의 네 블록들의 세 비트에는 설정된 x3 및 x2 값이 그대로 기입될 수 있다.1 counter 130 is performed in a total of 4 cycles, and the stochastic number generator 120 divides 16 bits of x into 4 blocks of b1 to b4 each block having 4 bits. The first three bits of each block are the same in the order of x3, x2, and x3, as indicated by the dotted line. The last bit is selected from x1 and x0 by the selection FSM. Accordingly, the set values of x3 and x2 can be written to the three bits of the four blocks b1, b2, b3, and b4 as they are.

일 예로, x가 십진수로 (0.5)dec일 때, 스토캐스틱 수 제너레이터(120)는 x3를 1로, x2, x1 및 x0를 0으로 설정하고, 선택 FSM(selector FSM, Finite State Machine)을 통해 다중화기(MUX)를 제어하여 첫 번째 블록(b1)은 (1010)bin, 두 번째 블록(b2)은 (1010)bin, 세 번째 블록(b3)은 (1010)bin, 네 번째 블록(b4)은 (1010)bin을 출력하도록 한다. For example, when x is (0.5) dec in decimal, the stochastic number generator 120 sets x3 to 1, x2, x1 and x0 to 0, and multiplexes through a selector FSM (Finite State Machine). By controlling the firearm (MUX), the first block (b1) is (1010) bin, the second block (b2) is (1010) bin, the third block (b3) is (1010) bin, and the fourth block (b4) is Print (1010) bin.

다른 예로, x가 십진수로 (0.625)dec일 때, 스토캐스틱 수 제너레이터(120)는 x3와 x1을 1로, x2 및 x0 를 0으로 설정한다. 선택 FSM(selector FSM, Finite State Machine)을 통해 다중화기(MUX)를 제어하여 첫 번째 블록(b1)은 (1011)bin, 두 번째 블록(b2)은 (1010)bin, 세 번째 블록(b3)은 (1011)bin, 네 번째 블록(b4)은 (1010)bin을 출력하도록 한다. As another example, when x is (0.625) dec in decimal, the stochastic number generator 120 sets x3 and x1 to 1 and x2 and x0 to 0. The first block (b1) is (1011) bin, the second block (b2) is (1010) bin, and the third block (b3) by controlling the multiplexer (MUX) through the selector FSM (Finite State Machine). Prints (1011) bin, and the fourth block (b4) prints (1010) bin.

도 2(c)는 비트 병렬화에 따른 스토캐스틱 수 제너레이터(120) 동작의 다른 예를 설명하기 위한 도면이다. 도 2(c)를 참조하면, x가 총 16 비트이고, 1 계수기(130)가 2n (n=1) = 2 사이클로 수행되는 경우를 예시한다. 1 계수기(130)가 총 2 사이클로 수행되므로, 이에 부합하도록 스토캐스틱 수 제너레이터(120)는 x의 16비트를 b1과 b2의 2 블록으로 분할하며, 각 블록은 8 비트를 가진다. 2 (c) is a diagram for explaining another example of the operation of the stochastic number generator 120 according to bit parallelization. Referring to FIG. 2 (c), an example in which x is 16 bits in total and 1 counter 130 is performed in 2 n (n = 1) = 2 cycles is illustrated. Since 1 counter 130 is performed in 2 cycles in total, the stochastic number generator 120 divides 16 bits of x into 2 blocks of b1 and b2, and each block has 8 bits.

각 블록의 첫 일곱 비트는 점선으로 표시된 것과 같이 모두 x3, x2, x3, x1, x3, x2, x3 순으로 동일하다. 마지막 비트는 선택 FSM에 의하여 x0와 0 중에서 선택된다. 따라서, b1 및 b2의 두 블록들의 일곱 비트에는 설정된 x3, x2 및 x1 값이 그대로 기입될 수 있다.The first seven bits of each block are the same in the order of x3, x2, x3, x1, x3, x2, x3 as indicated by the dotted line. The last bit is selected from x0 and 0 by the selection FSM. Accordingly, the set x3, x2 and x1 values can be written to the seven bits of the two blocks b1 and b2 as they are.

도 1로 예시된 실시예는 스토캐스틱 수 제너레이터(120)가 입력된 데이터(x) 값에 따라 상응하는 확률의 스토캐스틱 수를 형성하여 1 계수기(130)에 제공하는 것을 예시한다. 그러나, 도 2(b) 및 도 2(c)로 예시된 실시예와 같이 스토캐스틱 수가 분할되여 형성된 블록에는, 블록 내의 비트 위치에 따라 정해진 값이 위치한다. The embodiment illustrated in FIG. 1 illustrates that the stochastic number generator 120 forms the corresponding stochastic number according to the input data (x) value and provides it to the 1 counter 130. However, in the block formed by dividing the number of stochastics as in the embodiment illustrated in FIGS. 2 (b) and 2 (c), values determined according to the bit positions in the blocks are located.

총 16비트 중에서, 어느 한 비트는 0으로 설정될 수 있다. 즉, x3는 0.5의 확률로 비트 스트림내에 위치하고, x2는 0.25의 확률로 비트 스트림내에 위치하고, x1는 0.125의 확률로 비트 스트림내에 위치하고, x0는 0.0625의 확률로 비트 스트림내에 위치한다. 이들을 다 도합하여도 확률이 1이 되지 않으므로 총 16비트 중 한 비트를 0으로 설정한다.Any one of the 16 bits may be set to 0. That is, x3 is located in the bit stream with a probability of 0.5, x2 is located in the bit stream with a probability of 0.25, x1 is located in the bit stream with a probability of 0.125, and x0 is located in the bit stream with a probability of 0.0625. Even if all of them are combined, the probability does not become 1, so one bit out of a total of 16 bits is set to 0.

가중치 제공부(150)는 뉴럴 네트워크(미도시)의 가중치를 제공받고, 이를 로그로 양자화(quantize)하여 출력한다. 가중치 제공부(150)에 제공된 가중치를 w라 하면, 가중치 제공부(150)는 실수인 가중치 w에 로그를 취하고 반올림하여 출력한다. 가중치 제공부(150)가 출력하는 값

Figure pat00002
은 아래의 수학식 1로 표시될 수 있다. 일 예로, 로그는 밑(base)이 2인 로그일 수 있다.The weight providing unit 150 receives the weight of the neural network (not shown), quantizes it into a log, and outputs it. If the weight provided to the weight providing unit 150 is w, the weight providing unit 150 logs a weight w that is a real number and rounds it up and outputs it. Value output by the weight providing unit 150
Figure pat00002
Can be represented by Equation 1 below. As an example, the log may be a log whose base is 2.

Figure pat00003
Figure pat00003

(round (): 반올림 함수, w: 실수 가중치)(round (): rounding function, w: real weight)

표 1은 십진수인 실수 가중치(weight)와

Figure pat00004
의 관계를 데이터 표시를 예시한다.Table 1 shows the decimal real weight
Figure pat00004
The relationship of data is illustrated.

Figure pat00005
Figure pat00005

일 예로, 실수 가중치(weight)가 0.25이면 부호 비트는 0이고, 밑이 2인 로그를 취하여 부호를 연산하면, 그 값은 십진수로 (2)dec 이며, 이진수로는 (0010)bin이다. For example, if the real weight is 0.25, the sign bit is 0, and if the sign is calculated by taking the base 2 logarithm, the value is (2) dec in decimal and (0010) bin in binary.

실수 가중치(weight)는 십진수 (-1,1)의 범위에 있으므로 그 절대값은 1보다 작다. 따라서, 0을 제외한 가중치(weight)의 절대값에 로그를 취하여 반올림한

Figure pat00006
는 0보다 크다. 부호 비트를 포함하는 16비트로 표현될 수 있는 최소한의 단위는
Figure pat00007
이고, 그때 가중치 제공부(150)의 출력
Figure pat00008
는 15이다. w가 0인 경우를 제외하고
Figure pat00009
는 [1,15]의 범위 내에 있으므로, 4 비트의 언사인드(unsigned) 정수로
Figure pat00010
를 표시할 수 있다. 따라서, 가중치 제공부(150)가 출력하는 로그 양자화된 가중치
Figure pat00011
는 1 비트의 부호 비트와 크기(magnitude)를 표시하는 4 비트를 포함하는 총 5 비트로 표시된다.Since the real weight is in the range of decimal (-1,1), its absolute value is less than 1. Therefore, the logarithm is rounded to the absolute value of the weight excluding zero
Figure pat00006
Is greater than 0. The minimum unit that can be expressed in 16 bits including a sign bit is
Figure pat00007
And then the output of the weight providing unit 150
Figure pat00008
Is 15. except when w is 0
Figure pat00009
Is within the range of [1,15], so as a 4-bit unsigned integer
Figure pat00010
Can be displayed. Therefore, the log quantized weight output by the weight providing unit 150
Figure pat00011
Is represented by a total of 5 bits including 1 bit sign bit and 4 bits indicating magnitude.

예시된 실시예와 같이 가중치(weight)를 로그 스케일로 양자화하며, 딥 뉴럴 네트워크에 있어서 부동 소수점 레벨 정확도(floating point level accuracy)를 얻도록 로그의 밑(base) 2를 취할 수 있다. 다른 실시예로,

Figure pat00012
,
Figure pat00013
등의 2의 거듭제곱으로 표시되며, 2보다 정밀한 밑(base)을 선택하여 가중치를 양자화 하면 뉴럴 네트워크 인식의 정밀도를 개선할 수 있다.As in the illustrated embodiment, the weight is quantized on a logarithmic scale, and in deep neural networks, the base 2 of the log may be taken to obtain floating point level accuracy. In another embodiment,
Figure pat00012
,
Figure pat00013
It is represented by a power of 2, etc., and the precision of neural network recognition can be improved by quantizing weights by selecting a base that is more precise than 2.

이하에서는 1 비트의 부호 비트 및 크기(magnitude)를 표시하는 15비트를 포함하는 16비트 데이터의 정밀도를 가정한다. 다만, 이는 설명의 편의를 위한 것이며, 본 발명의 범위를 제한하기 위한 것이 아니다. 로그 대 선형 변환기(160)는 로그로 양자화된 이진 가중치

Figure pat00014
를 제공받고, 이를 선형 이진수로 변환하여 출력한다. Hereinafter, it is assumed that the precision of 16-bit data including 1-bit sign bit and 15 bits indicating magnitude. However, this is for convenience of description and is not intended to limit the scope of the present invention. Log-to-linear converter 160 is a binary weight quantized to logarithmic
Figure pat00014
Is provided, converted to a linear binary number, and output.

일 예로, w=0.25이고 로그로 양자화된 값이 0 0010 이면, 로그 대 선형변환기(160) 출력값은 부호 비트(sign bit) + 15 bit 소수부 절대값 형태로 (0 010 0000 0000 0000)bin으로 표시된다. 또한, w= 0.0125(= 1/8)일 때 로그 양자값은 0 0011이고, 로그 대 선형 변환기(160) 출력값은 (0 001 0000 0000 0000)bin이다. 다른 예로, w= 0.0625(=1/16)일 때, 로그 양자값은 0 0100이며, 로그 대 선형 변환기(160) 출력값은 (0 000 1000 0000 0000)bin이다. 위에서 알 수 있는 바와 같이 선형으로 변환된 가중치 값은 로그로 양자화된 값이 선형으로 변환된 것이므로 가중치를 표현하는 여러 비트들 중 어느 한 자리만 "1"을 가진다.For example, if w = 0.25 and the log quantized value is 0 0010, the log-to-linear converter 160 output value is displayed as a sign bit + 15 bit decimal part absolute value (0 010 0000 0000 0000) bin do. In addition, when w = 0.0125 (= 1/8), the log quantum value is 0 0011, and the log-to-linear converter 160 output value is (0 001 0000 0000 0000) bin . As another example, when w = 0.0625 (= 1/16), the log quantum value is 0 0100, and the log-to-linear converter 160 output value is (0 000 1000 0000 0000) bin . As can be seen from the above, since the weight value converted to linear is a log-quantized value converted to linear, only one digit of the multiple bits representing the weight has "1".

일 실시예로, 상술한 바와 같이 16비트의 실수 가중치는 밑이 2인 로그가 취하여져서 부호 비트를 포함하는 5비트로 양자화된다. 로그 대 선형 변환기(160)는 5 비트의 양자화된 가중치를 제공받고 부호 비트를 포함하는 15비트의 선형으로 변환된 가중치를 역계수기(170)에 출력한다.In one embodiment, as described above, the real weight of 16 bits is taken as a log with a base 2 and quantized to 5 bits including a sign bit. The log-to-linear converter 160 receives a 5-bit quantized weight and outputs a 15-bit linearly converted weight including the sign bit to the inverse counter 170.

역계수기(170)는 로그-대-선형 변환기(160)가 출력한 15비트의 선형으로 변환된 가중치를 입력 받고, 선형으로 변환된 가중치에 상응하는 윈도우 너비를 연산하여 1 계수기(130)에 출력한다. 일 실시예로, 윈도우 너비(w)는 비트수와 선형으로 변환된 가중치를 곱하여 얻어진 수 일 수 있다. 일 예로, 선형으로 변환된 가중치에 상응하는 값이 부호 비트를 제외하고 010 0000 0000 0000 이면 이는 소수인 .25이다. 즉, 선형으로 변환된 가중치 값에는 0.25의 확률로 1이 포함되어 있는 것을 의미한다. 따라서, 가중치를 나타내는 비트 수가 16 이라 하면, 가중치에는 4 개의 "1"을 포함하며, 이 때의 윈도우 너비(width)는 4에 해당한다. 다른 예로, 선형으로 변환된 가중치 값 w= 0.0125(= 1/8)일 때 로그 양자값은 0 0011이고, 로그 대 선형 변환기(160) 출력값은 (0 001 0000 0000 0000)bin이다. 이 때 윈도우 너비(width)는 0.125*16 = 2이다. The inverse counter 170 receives a 15-bit linearly converted weight output from the log-to-linear converter 160, calculates a window width corresponding to the linearly converted weight, and outputs it to the 1 counter 130 do. In one embodiment, the window width w may be a number obtained by multiplying the number of bits by a weight linearly converted. For example, if the value corresponding to the linearly converted weight is 010 0000 0000 0000 excluding the sign bit, it is .25, which is a prime number. That is, it means that the linearly converted weight value contains 1 with a probability of 0.25. Therefore, if the number of bits representing the weight is 16, the weight includes four "1s", and the window width at this time corresponds to four. As another example, the logarithmic quantum value is 0 0011 when the linearly converted weight value w = 0.0125 (= 1/8), and the output value of the log-to-linear converter 160 is (0 001 0000 0000 0000) bin. At this time, the window width is 0.125 * 16 = 2.

역 계수기(170)가 비트 병렬화의 형태로 동작할 때, 역 계수기(170)는 윈도우 너비(width)를 2n 씩 감산하여 1 계수기(130)에 출력한다. 도 2(b)로 예시된 실시예와 같이 1 계수기(130)가 2n (n=2)인 4 사이클에 걸쳐 동작하고, 역 계수기(170)가 연산하여 출력한 윈도우 너비(width)가 8이라면 첫 사이클에서 역 계수기(170)가 출력하는 윈도우 너비(width)는 8이고, 다음 사이클에서는 4를 출력한다.When the inverse counter 170 operates in the form of bit parallelization, the inverse counter 170 subtracts the window width by 2 n and outputs it to the 1 counter 130. As shown in the embodiment illustrated in FIG. 2 (b), 1 counter 130 operates over 4 cycles of 2 n (n = 2), and the window width calculated and output by the inverse counter 170 is 8 If it is, the window width output by the inverse counter 170 in the first cycle is 8, and 4 is output in the next cycle.

1 계수기(130)는 역계수기(170)가 출력하는 윈도우 너비(width)와 스토캐스틱 수 제너레이터(120)가 제공하는 비트 스트림을 입력받고, 제공된 너비 만큼의 윈도우 내에서 1의 개수를 계수한다. The 1 counter 130 receives the window width output by the inverse counter 170 and the bit stream provided by the stochastic number generator 120, and counts the number of 1s in the window corresponding to the provided width.

1 계수기(130)가 비트 병렬화 형태로 동작하는 실시예로, 1 계수기(130)는 멀티 비트 입력을 제공 받을 수 있으며, 복수의 블록들로 분할된 비트 스트림에서, 각 블록에 포함된 비트들을 한 사이클 동안 읽어 각 블록에 포함된 1의 개수를 계수할 수 있다(bit-parallelism). 일 실시예로, 스토캐스틱 수 제너레이터(120)가 제공하는 비트 스트림이 총 16비트이고, 윈도우 너비(width)가 4인 경우에, 1 계수기는 한 사이클에 비트 스트림을 4개의 비트씩 읽는다. In an embodiment in which the 1 counter 130 operates in the form of bit parallelization, the 1 counter 130 may receive a multi-bit input, and in a bit stream divided into a plurality of blocks, one bit included in each block The number of 1s included in each block can be counted by reading during the cycle (bit-parallelism). In one embodiment, when the bit stream provided by the stochastic number generator 120 is a total of 16 bits, and the window width is 4, one counter reads the bit stream by four bits in one cycle.

일 실시예로, 1 계수기(130)는 윈도우의 너비(width)만큼의 데이터(x)의 비트들을 읽어서 1의 개수를 계수하고, 나머지는 처리하지 않는다. 일 실시예로, 1 계수기(130)에 제공된 데이터(x)가 이진수(1010 1011 1010 1010)bin이고, 역계수기(170)가 출력한 윈도우의 너비가 4비트이면, 1 계수기(130)는 비트 스트림의 최초 4 비트를 읽고, 포함된 1의 개수를 계수하여 결과인 십진수 (2)dec를 누적기(140)에 출력한다. In one embodiment, the 1 counter 130 reads bits of data x equal to the width of the window to count the number of 1s, and does not process the rest. In one embodiment, if the data (x) provided to the 1 counter 130 is a binary number (1010 1011 1010 1010) bin, and the width of the window output by the inverse counter 170 is 4 bits, the 1 counter 130 is a bit The first 4 bits of the stream are read, and the number of 1s included is counted and the resulting decimal (2) dec is output to the accumulator 140.

다른 예로, 1 계수기(130)에 제공된 데이터(x)가 (1010 1011 1010 1010)bin이고, 역계수기(170)가 출력한 윈도우의 너비가 8이면 1 계수기(130)은 비트 스트림의 최초 8 비트를 읽고, 포함된 1의 개수를 계수하여 결과인 십진수 (5)dec를 누적기(140)에 출력한다. 누적기(140)는 1 계수기(130)가 제공한 수를 누적하여 출력한다. As another example, if the data (x) provided to the 1 counter 130 is (1010 1011 1010 1010) bin, and the window width output by the inverse counter 170 is 8, the 1 counter 130 is the first 8 bits of the bit stream. Reads, counts the number of 1s included, and outputs the resulting decimal number (5) dec to the accumulator 140. The accumulator 140 accumulates and outputs the number provided by the 1 counter 130.

누적기(140)가 누적하여 출력한 결과는 입력 제공부(110)가 제공한 입력(x)와 가중치 제공부(150)가 출력한 가중치(weight)의 곱인 w×x에 상응한다. XOR 게이트는 곱셈 및 누적기(100)는 입력 제공부(110)가 제공하는 입력(x)의 부호 비트와 가중치 제공부(150)가 제공하는 양자화된 가중치의 부호 비트를 제공받아 곱셈 결과의 부호를 연산하여 부호 비트(sign)를 누적기(140)에 출력한다. 누적기(140)는 부호 비트(sign)에 따라 곱셈 결과를 양수 혹은 음수로 취급하여 누적한다.The result accumulated and output by the accumulator 140 corresponds to w × x, which is a product of an input (x) provided by the input providing unit 110 and a weight output by the weight providing unit 150. The XOR gate is multiplied and the accumulator 100 receives the sign bit of the input (x) provided by the input providing unit 110 and the sign bit of the quantized weight provided by the weight providing unit 150, and the sign of the multiplication result And outputs a sign bit to the accumulator 140. The accumulator 140 treats the multiplication result as a positive or negative number according to a sign bit and accumulates it.

도 3(a) 및 도 3(b)는 비트 병렬화로 동작하는 1 계수기(130)의 동작을 설명하기 위한 도면이다. 수학식 2는 1 계수기(130)의 동작을 설명하기 위한 수학식이다. 도 3을 참조하면, 1 계수기(130)의 입력이 {xN-1, ..., x0}인 N 비트에서 N = 16이고, , 1 계수기(130)는 16 / 2n (n=2) = 4 사이클의 비트 병렬화에 따라 수행된다고 가정한다. 3 (a) and 3 (b) are diagrams for explaining the operation of one counter 130 operating in bit parallelism. Equation 2 is an equation for explaining the operation of the 1 counter 130. Referring to FIG. 3, N = 16 in N bits where the input of 1 counter 130 is {x N-1 , ..., x 0 }, and 1 counter 130 is 16/2 n (n = 2) = 4 cycles of bit parallelism.

Figure pat00015
Figure pat00015

도 3(a)로 예시된 것과 같이 윈도우의 너비(width)가 8인 경우를 가정한다. 윈도우의 너비(width)가 22 = 4 보다 크거나 같으므로, 1 계수기(130)는 수학식 2에 따라 제1 블록(b1) 및 제2 블록(b2)에 포함된 "1"의 개수를 계수한다. 또한, 1 계수기(130)는 비트 병렬화로 동작하므로, 제1 블록(b1)내의 1의 개수를 계수한 후, 제2 블록(b2) 내의 1의 개수를 계수한다. 일 실시예로, 역계수기(170)이 최초사이클에서 제공한 윈도우 너비(width)은 8일 수 있고, 다음 사이클에서는 4일 수 있다. 비트 병렬화로 동작하는 1 계수기(130)는 최초 사이클에서 제1 블록(b1)에 포함된 1의 개수를 계수하고, 다음 사이클에서는 제2 블록에(b2)에 포함된 1의 개수를 계수한다.It is assumed that the width of the window is 8, as illustrated in FIG. 3 (a). Since the width of the window is greater than or equal to 2 2 = 4, the 1 counter 130 determines the number of “1s” included in the first block b1 and the second block b2 according to Equation (2). Count. In addition, since the 1 counter 130 operates by bit parallelization, the number of 1s in the first block b1 is counted, and then the number of 1s in the second block b2 is counted. In one embodiment, the window width provided by the inverse counter 170 in the first cycle may be 8, and may be 4 in the next cycle. The 1 counter 130 operating in bit parallelization counts the number of 1s included in the first block b1 in the first cycle, and the number of 1s included in the second block (b2) in the next cycle.

제1 블록(b1)의 최초 3 비트는 상술한 바와 같이 x3, x2, x3로 고정되며, 마지막 비트가 x1 혹은 x0로 변화할 수 있다. 이는 (x3x2)bin + mux(x1,xo)로 나타낼 수 있다. 예를 들어, x3는 1이고 x2가 0이며, 제1 블록(b1)에서 x1은 1인 경우에, 제1 블록(b1)에 포함된 "1"의 개수는 (10)bin + (1)bin = (11) bin = (3)dec 로 구할 수 있다. 상술한 바와 같이 다중화기(MUX)가 x1, x0를 선택하는 신호는 선택 유한 상태 기계(Finite State Machine, FSM)으로부터 제공될 수 있다. The first 3 bits of the first block b1 are fixed to x3, x2, and x3 as described above, and the last bit can be changed to x1 or x0. This can be expressed as (x3x2) bin + mux (x1, xo). For example, when x3 is 1, x2 is 0, and x1 is 1 in the first block (b1), the number of "1" included in the first block (b1) is (10) bin + (1) It can be calculated as bin = (11) bin = (3) dec. As described above, a signal for the multiplexer (MUX) to select x1 and x0 may be provided from a selected finite state machine (FSM).

두번째 사이클에서 1 계수기(130)는 제2 블록(b2)에 포함된 1의 개수를 계수한다. 제1 블록(b1)에서 1을 계수하는 방법과 유사하게 (x3x2)bin + mux(x1,xo)를 연산할 수 있으며, 제2 블록(b2)에서는 다중화기를 통하여 x0를 선택하도록 한다. 위의 예와 같이, x3는 1이고 x2가 0이며, 제2 블록(b1)에서 x0은 0인 경우에, 제2 블록(b2)에 포함된 "1"의 개수는 (10)bin + (0)bin = (10) bin = (2)dec 로 구할 수 있다. In the second cycle, the 1 counter 130 counts the number of 1s included in the second block b2. Similar to the method of counting 1 in the first block (b1), (x3x2) bin + mux (x1, xo) can be calculated, and in the second block (b2), x0 is selected through the multiplexer. As in the above example, when x3 is 1, x2 is 0, and x0 is 0 in the second block (b1), the number of "1" included in the second block (b2) is (10) bin + ( 0) bin = (10) bin = (2) dec.

도 3(b)로 예시된 것과 같이 윈도우의 너비(width)가 2n (n=2) = 4보다 작을 때 1의 개수를 계수하는 방법은 아래와 같다.The method of counting the number of 1 when the width of the window is less than 2 n (n = 2) = 4 as illustrated in FIG. 3 (b) is as follows.

Figure pat00016
Figure pat00016

즉, 도 3(b)에서, x3는 1이고, x2는 0인 경우를 보면, 제1 블록(b1)의 최초 3비트에서의 1의 개수는 수학식 3에 따르면

Figure pat00017
로 연산된다. 즉, 윈도우 너비(width)에 상응하는 비트 수를 x3가 나타내는 확률인 1/2에 곱하여 반올림(round)하면 윈도우 너비 내 x3가 포함된 개수를 얻을 수 있다. 마찬가지로, 윈도우 너비(width)인 2에 x2가 나타내는 확률인 1/4을 곱하여 반올림(round)하면 윈도우 너비 내 x2가 포함된 개수를 얻을 수 있다. 따라서, 이들 각각에 x3 값과 x2 값을 곱하면 윈도우 너비(width) 내의 1의 개수를 구할 수 있다.That is, in FIG. 3 (b), when x3 is 1 and x2 is 0, the number of 1s in the first 3 bits of the first block b1 is according to Equation (3).
Figure pat00017
Is calculated as That is, if the number of bits corresponding to the window width is multiplied by 1/2, which is the probability represented by x3, and rounded, the number of x3 in the window width can be obtained. Likewise, if you multiply the window width (2) by the probability that x2 represents 1/4, and round it up, you can get the number of x2 in the window width. Therefore, by multiplying each of these by the x3 value and the x2 value, the number of 1s in the window width can be obtained.

1의 개수를 계수할 수 있는 다른 방법은 아래와 같다. Another way to count the number of 1 is as follows.

Figure pat00018
Figure pat00018

(∧: 비트-와이즈 논리곱(bit-wise AND) 연산)(∧: bit-wise AND operation)

수학식 3에서

Figure pat00019
를 정수부와 소수부로 분할하여 고려한다. 정수부는 w를 i 번 우측으로 시프트 연산한 것과 동일하다. 즉, 정수부를 a라고 하면, a = w >> i 이다(>> : 시프트 연산). 나아가, 소수점 이하의 자리로 시프트되어 해당 수는 버려진다. 상기한 결과로부터 수학식 4의 첫 항이 도출된다. In Equation 3
Figure pat00019
Is considered by dividing into an integer part and a decimal part. The integer part is equivalent to the shift operation of w to the right of i times. That is, if the integer part is a, a = w >> i (>>: shift operation). Furthermore, the number is discarded because it is shifted to a decimal place. The first term of Equation 4 is derived from the above results.

또한, 수학식 3에서는 소수부의 값을 반올림한다. 반올림 연산은 이진수 소수의 첫 번째 자리가 1인 경우에는 정수부에 1을 더하고 이진수 소수 첫 번째 자리가 0인 경우에는 이하의 값을 버린다. 따라서, 소수점 이하로 시프트 되기 전의 값과 비트 와이즈 연산을 수행하여 반올림 연산을 수행할 수 있다. In addition, in Equation 3, the value of the fractional part is rounded up. The rounding operation adds 1 to the integer part when the first digit of the decimal number is 1, and discards the following value when the first digit of the decimal number is 0. Therefore, it is possible to perform a rounding operation by performing a bit-wise operation and a value before shifting to a decimal point.

이와 같이 수행하여 1의 개수를 구할 수 있다. The number of 1 can be obtained by performing in this way.

일 예로, x = {1100}bin 이고, 윈도우 너비(width)가 2dec = 0010bin 이라고 하자. 수학식 3을 연산하면 아래의 표 2와 같다.As an example, suppose x = {1100} bin, and the window width is 2dec = 0010bin. Equation 3 is calculated as shown in Table 2 below.

Figure pat00020
Figure pat00020

따라서, 윈도우 너비(width)에 상응하는 i=1,i=2 경우에 정수부와 소수부의 연산 결과를 더하면 십진수 2로, x에 포함된 1의 개수와 일치한다. 비록 윈도우 너비가 2이나, 하드웨어적 구성에 따르면 i=1, i=2, i=3, i=4인 경우 모두에 대하여 상기한 연산을 수행한다. Therefore, in the case of i = 1, i = 2 corresponding to the window width, adding the operation result of the integer part and the decimal part is 2 in decimal, which matches the number of 1 contained in x. Although the window width is 2, according to the hardware configuration, the above operation is performed for all cases where i = 1, i = 2, i = 3, and i = 4.

다만, 윈도우 너비(width)는 로그를 선형으로 변환한 값으로부터 얻어진 수로, 윈도우 너비(width)를 표현하는 이진수 값에는 오직 하나의 1 값만이 존재한다. 위의 예와 같이, x = {1100}bin 이고, 윈도우 너비가 2dec = 0010bin 이라고 하면 윈도우 너비(width) 내에서 1의 위치를 p라 하면, p=1 이다. 이로부터 수학식 4는 아래의 수학식 5와 같이 간단하게 정리된다. However, the window width is a number obtained by linearly converting the log, and there is only one 1 value in the binary value representing the window width. As in the above example, if x = {1100} bin, and the window width is 2dec = 0010bin, p is the position of 1 in the window width, p = 1. From this, Equation 4 is simply arranged as Equation 5 below.

Figure pat00021
Figure pat00021

이러한 연산 결과를 보면 아래의 표 3와 같다.Table 3 below shows the results of these calculations.

Figure pat00022
Figure pat00022

비록 윈도우 너비가 2이나, 하드웨어적 구성에 따르면 i=1, i=2, i=3, i=4인 경우 모두에 대하여 상기한 연산을 수행한다. Although the window width is 2, according to the hardware configuration, the above operation is performed for all cases where i = 1, i = 2, i = 3, and i = 4.

정수부와 소수부의 연산 결과를 더하면 십진수 2로, x에 포함된 1의 개수와 일치한다. If you add the result of the calculation of the integer and fractional parts, the decimal number is 2, which matches the number of 1s in x.

도 4는 1 계수기(130)의 개요를 도시한 도면이다. 도 4로 예시된 1 계수기(130)는 수학식 2와 수학식 5를 하드웨어로 구현한 예시이다. 도 4를 참조하면, 도 4에서 굵은 실선으로 도시된 경로는 수학식 1의 연산을 수행하는 경로이다. 윈도우 너비(width)가 2n 보다 크면 시프터(132)는 입력된 신호를 시프트하지 않고 그대로 출력하고, 다중화기(MUX)는 입력된 (xN-n-1, ..., x0) 중에서 블록에 포함하는 비트를 선택하여 출력한다. 4 is a diagram showing an outline of one counter 130. 1 counter 130 illustrated in FIG. 4 is an example in which Equation 2 and Equation 5 are implemented in hardware. Referring to FIG. 4, the path illustrated by the bold solid line in FIG. 4 is a path for performing the operation of Equation (1). If the window width is greater than 2 n , the shifter 132 outputs the input signal without shifting, and the multiplexer (MUX) is input to the block among the input (x Nn-1 , ..., x 0 ). Select the bit to be included and output it.

일 실시예로, 도 3에서 제1 블록(b1)에 포함된 1의 개수를 계수하는 것을 예시된 실시예에서, (x3 x2 x3)bin 은 시프터(132)를 거치나, 비트가 시프트되지 않고 덧셈기(134)에 제공된다. 제1 블록(b1)의 x1 비트는 다중화기(MUX)에서 선택되어 덧셈기(134)에 출력된다. 덧셈기(134)는 입력으로 제공된 값을 더하여 출력한다.In one embodiment, in the embodiment illustrated to count the number of 1 included in the first block (b1) in FIG. 3, (x3 x2 x3) bin passes through the shifter 132, but the bit is not shifted It is provided to the adder 134. The x1 bit of the first block b1 is selected by the multiplexer (MUX) and output to the adder 134. The adder 134 adds and outputs a value provided as an input.

도 4에서 점선으로 도시된 경로는 수학식 5을 연산하는 경로이다. (xN-1, ..., xN-n)은 시프터(132)로 입력되며, 윈도우 너비(width)에서 1의 위치(p)를 나타내는 신호(p)에 따라 순차적으로 시프트되어 덧셈기(134)에 제공된다. 도시된 경로에 따라 덧셈기(134)에 제공된 신호는

Figure pat00023
에 상응한다. (xN-1, ..., xN -n)에 포함된 비트들 중에서 다중화기(MUX)는 1의 위치(p)를 나타내는 신호(p)를 제공받고, xN-p-1에 상응 하는 비트를 선택하여 덧셈기(134)에 출력한다. 덧셈기(134)는 두 경로를 통해 입력된 값들을 더하여 출력한다. The path illustrated by the dotted line in FIG. 4 is a path for calculating Equation 5. (x N-1 , ..., x Nn ) are input to the shifter 132 and are sequentially shifted according to a signal p indicating a position p of 1 in the window width to adder 134 Is provided on. The signal provided to the adder 134 according to the illustrated path
Figure pat00023
Corresponds to Among the bits included in (x N-1 , ..., x N -n ), the multiplexer (MUX) is provided with a signal p indicating the position p of 1 , and corresponds to x Np-1 . The bits are selected and output to the adder 134. The adder 134 adds and outputs the values input through the two paths.

도 4에서 도시되지는 않았지만, 시프터(132)는 도시되지 않은 제어부로부터 시프트 신호를 제공받는다. 시프터(132)는 시프트 신호에 따라 입력 신호가 시프트되는 비트 수가 제어된다. 다중화기(MUX)는 도시되지 않은 제어부로부터 선택 신호를 제공받는다. 다중화기(MUX)는 선택 신호에 따라 입력된 신호 중 어느 하나를 선택하여 출력한다. Although not shown in FIG. 4, the shifter 132 is provided with a shift signal from a control unit not shown. The shifter 132 controls the number of bits in which the input signal is shifted according to the shift signal. The multiplexer (MUX) receives a selection signal from a control unit (not shown). The multiplexer (MUX) selects and outputs one of the input signals according to the selection signal.

도 5은 본 실시예에 의한 곱셈 및 누적기(100)를 포함하는 가속기(10)의 개요를 도시한 도면이다. 도 5를 참조하면, 본 실시예에 의한 가속기(10)는 입력 벡터들을 제공하는 입력 제공부(210)를 포함하며, 로그로 양자화된 가중치들을 제공하는 가중치 제공부(250)를 포함한다. 5 is a diagram showing an outline of the accelerator 10 including the multiplier and accumulator 100 according to the present embodiment. Referring to FIG. 5, the accelerator 10 according to the present embodiment includes an input providing unit 210 providing input vectors, and a weight providing unit 250 providing log quantized weights.

가중치 제공부(210)는 각 입력 벡터의 성분(xa, xb, xc, xd)을 스토캐스틱 수 제너레이터(120a, 120b, 120c, 120d)에 출력한다. 스토캐스틱 수 제너레이터들은 입력된 성분(xa, xb, xc, xd)에 상응하는 스토캐스틱 수의 비트 스트림을 형성하여 1 계수기(130a, 130b, 130c, 130d)에 제공한다. The weight providing unit 210 outputs components (xa, xb, xc, and xd) of each input vector to the stochastic number generators 120a, 120b, 120c, and 120d. Stochastic number generators form a bit stream of the number of stochastics corresponding to the inputted components (xa, xb, xc, xd) and provide them to 1 counter 130a, 130b, 130c, 130d.

가중치 제공부(250)가 제공하는 로그 양자화된 가중치 값은 각 성분별로 공통되고, 로그 대 선형 변환기(160)에 제공되며, 역계수기(170)는 윈도우 너비를 형성하여 각각의 1 계수기(130a, 130b, 130c, 130d)에 출력한다. 각각의 1 계수기(130a, 130b, 130c, 130d)는 각 비트 스트림의 제공된 윈도우 내에서 1을 계수하고, 각 누적기(140a, 140b, 140c, 140d)에 출력하며, 각 누적기(140a, 140b, 140c, 140d)들은 제공된 값들을 누적한다. 각 XOR 게이트는 가중치의 부호와 각 입력 벡터 성분(xa, xb, xc, xd)의 부호 비트로부터 곱셈 결과를 각 누적기(140a, 140b, 140c, 140d)에 출력하며, 각 누적기(140a, 140b, 140c, 140d)는 1 계수기(130a, 130b, 130c, 130d)가 제공한 결과에 부호를 부가하여 누적하여 결과를 출력한다.The log quantized weight value provided by the weight providing unit 250 is common to each component, is provided to the log-to-linear converter 160, and the inverse counter 170 forms a window width so that each 1 counter 130a, 130b, 130c, 130d). Each 1 counter 130a, 130b, 130c, 130d counts 1 within a provided window of each bit stream, outputs to each accumulator 140a, 140b, 140c, 140d, and each accumulator 140a, 140b , 140c, 140d) accumulate the provided values. Each XOR gate outputs a multiplication result to each accumulator 140a, 140b, 140c, 140d from the sign of the weight and the sign bit of each input vector component (xa, xb, xc, xd), and each accumulator 140a, 140b, 140c, 140d) adds a sign to the result provided by the 1 counter 130a, 130b, 130c, 130d and accumulates the result.

로그 양자화된 SC 곱셈 정확성 분석Log quantized SC multiplication accuracy analysis

도 6은 스토캐스틱 컴퓨팅 가속기의 평균 제곱 오차(mean square error)로 표시된 곱셈 오차를 도시한다. 부호 비트를 포함하는 균일하게 분포된 16비트의 소수와 Alexnet의 제1 레이어의 가중치에 곱하였다. 양자화 된 곱셈 오류의 경우, 실제 곱셈 출력은 부동 소수점 가중치를 곱하여 계산하였다. 이에 비하여 선형으로 양자화된 가중치 또는 선형 또는 로그 양자화된 가중치들은 곱셈 오차를 연산하기 위하여 실제 출력으로 곱해졌다. FIG. 6 shows the multiplication error expressed as the mean square error of the stochastic computing accelerator. The uniformly distributed 16-bit prime including the sign bit was multiplied by the weight of Alexnet's first layer. In the case of quantized multiplication error, the actual multiplication output was calculated by multiplying floating-point weights. In comparison, linearly quantized weights or linear or logarithmic weights were multiplied by the actual output to calculate the multiplication error.

선형 양자화된 스토캐스틱 컴퓨팅 가속기에서, 양자화된 곱셈 에러는 곱셈 에러와 유사하며, 이것은 선형 양자화된 경우의 곱셈 오류는 주로 잘못된 곱셈 자체에 의한 것임을 의미한다. 그러나, 본 실시예의 경우, 오류가 주로 로그 양자화 오류에서 발생했음을 나타내며, 곱셈 에러는 선형 양자화 된 경우보다 낮으며, 로그로 표현된 곱해지는 수(multiplicand)에 대한 고정 소수점 곱셈인 시프터 기반의 곱셈의 정확도에 이른다. 로그로 양자화 된 본 실시예 경우에 양자화된 곱셈 오류는 처음에는 감소하나, 높은 데이터 정밀도에 의하여 양자화 오류를 개선할 수 없기 때문에 포화되기 시작한다. 예를 들어, 데이터 정밀도가 증가하더라도 0.7은 항상 0.5로 양자화 된다. In a linear quantized stochastic computing accelerator, the quantized multiplication error is similar to the multiplication error, which means that the multiplication error in the linear quantization case is mainly due to the wrong multiplication itself. However, in the case of this embodiment, it indicates that the error mainly occurred in the log quantization error, and the multiplication error is lower than that in the linear quantization, and of the shifter based multiplication which is a fixed point multiplication for the multiplicand expressed in logarithm. Accuracy. In the case of the present embodiment quantized to log, the quantized multiplication error decreases at first, but it starts to saturate because the quantization error cannot be improved due to high data precision. For example, 0.7 is always quantized to 0.5 even if the data precision increases.

작은 비트 폭(bitwidth) 양자화 방법은 일반적으로 원래 네트워크 정확도를 복원하기 위해 재교육 또는 미세 조정이 필요하다. 스토캐스틱 컴퓨팅 MAC을 포함하는 근사가속기는 미세 조정으로 더 높은 네트워크 정확도를 달성할 수 있다. 네트워크 정확도는 곱셈 오류보다 로그 양자화 오류에 대해 더 탄력적이므로, 최신 SC와 비교하여 대수 양자화 된 SC에 대한 정밀도 요구 사항이 거의 동일하게 유지될 수 있다Small bitwidth quantization methods typically require retraining or fine tuning to restore the original network accuracy. A near accelerator including a stochastic computing MAC can achieve higher network accuracy with fine tuning. Network accuracy is more resilient to log quantization errors than multiplication errors, so the precision requirements for logarithmic quantized SCs can remain almost the same compared to modern SCs.

면적 및 전력 소모의 효율성 평가Evaluating the efficiency of area and power consumption

모든 비교 사례에 대해 256 개의 곱셈 및 누적기로 구성된 가속기를 평가하였다. 고정 소수점 이진 설계에 기반한 가속기(Fixed), 시프터 기반 가속기, 직렬 가속기, 비트 병렬 가속기들이 비교 대상 기술로, 로그 양자화를 이용하는 본 실시예에 의한 가속기와 비교하였다. 본 실시예에 의한 가속기는 로그 양자화 된 가중치를 사용하는 곱셈 및 누적기에 있어서 병목 현상이 경감된 1 계수기를 포함한다. 가속기는 Verilog RTL 코드로 구현하였으며, Synopsys Design Compiler를 사용하여 합성되었다. 대상 표준 셀 라이브러리는 TSMC 45nm이며 대상 주파수는 1GHz로 고정되었다. 일반적인 데이터 정밀도는 16 비트이다. 비트 병렬 설계가 있으며 이 평가를 위해 24 사이클로 병렬화 되었다(하드웨어 정밀도는 4). Accelerators consisting of 256 multipliers and accumulators were evaluated for all comparison cases. An accelerator based on a fixed-point binary design (Fixed), a shifter-based accelerator, a serial accelerator, and a bit parallel accelerator are compared technologies, and compared with the accelerator according to the present embodiment using log quantization. The accelerator according to the present embodiment includes a 1 counter in which a bottleneck is reduced in multipliers and accumulators using log quantized weights. The accelerator was implemented with Verilog RTL code and synthesized using Synopsys Design Compiler. The target standard cell library is TSMC 45nm and the target frequency is fixed at 1 GHz. Typical data precision is 16 bits. There is a bit parallel design and parallelized in 2 to 4 cycles for this evaluation (hardware precision is 4).

도 7(a)는 가속기의 면적, 도 5(b)는 전력 소모를 비교 도시한 표이다. 도 7(a)를 참조하면, 고정 소수점 이진 설계(Fixed)에는 전체 면적의 80 % 이상을 차지하는 곱셈기를 포함한다. 누적기의 면적(Cntr/Acc., 직렬 SC의 카운터)은 비교 대상 기술의 경우에 유사하다. 시프터 기반 가속기는 고정 소수점 이진 설계(Fixed)대비 여러 배 더 작다. Figure 7 (a) is an accelerator area, Figure 5 (b) is a table showing the power consumption comparison. Referring to FIG. 7 (a), the fixed-point binary design (Fixed) includes a multiplier that occupies 80% or more of the total area. The area of the accumulator (Cntr / Acc., Counter of the serial SC) is similar for the comparison technology. Shifter-based accelerators are several times smaller than fixed-point binary designs.

직렬 가속기의 면적은 카운터가 90% 가량 차지한다. 비트 병렬 가속기의 면적은 큰 1s 카운터에 의하여 거의 두 배에 인접하나, 시프트 기반 가속기의 면적(Shift)보다 작다. 본 실시예에서 1 계수기의 면적은 약 1/5이며 총 면적은 누적기의 면적(Cnt/Acc)에 좌우된다. 결과적으로, 면적은 비트 병렬 가속기에 비해 40 % 감소하였다.The area of the serial accelerator is about 90% of the counter. The area of the bit parallel accelerator is nearly twice as large by the large 1s counter, but smaller than the area of the shift-based accelerator (Shift). In this embodiment, the area of 1 counter is about 1/5, and the total area depends on the area of the accumulator (Cnt / Acc). As a result, the area was reduced by 40% compared to the bit parallel accelerator.

전력 소모를 비교하여 도시한 도 5b를 참조하면, 전력 소모는 면적 소모와 유사한 경향을 보인다. 본 실시예의 전력 소모는 고정 소수점 이진 설계(Fixed) 기반 가속기 및 시프트 기반 가속기의 경우에 비하여 각각 84% 및 39% 낮다. 비트 병렬 가속기와 비교하면, 본 실시예의 전력 소모는 비교 기술에 비하여 24% 낮으나, 직렬 가속기에 비하여는 17% 높다.Referring to FIG. 5B comparing power consumption, power consumption tends to be similar to area consumption. The power consumption of this embodiment is 84% and 39% lower, respectively, compared to the fixed point binary design (Fixed) based accelerator and the shift based accelerator. Compared to the bit parallel accelerator, the power consumption of this embodiment is 24% lower than the comparative technology, but 17% higher than the serial accelerator.

로그 양자화된 스토캐스틱 컴퓨팅의 DNN 적용의 효율성Efficiency of DNN application in log quantized stochastic computing

로그 양자화는 원래 값에 비하여 자연적으로 오차가 형성되므로, 명시적으로 허용되는 수준의 뉴럴 네트워크 성능이 보장되어야 한다. 카페 프레임워크(Caffe framework)를 확장한 시뮬레이션으로 이미지 분류 테스트를 수행하였다. 목표 이미지 분류 대부분의 연산을 수행하는 컨벌루션 레이어만이 가속되었다. 대상 DNN은 10 클래스 데이터 세트인 MNIST 및 CIFAR10 용 LeNet 및 AlexNet이다. 대규모 AlexNet은 1000개 클래스들의 LSVRC-2010 이미지넷 데이터세트에 의하여 실험되었다. 부동 소수점 학습 가중치는 공통적으로 5,000회 반복 미세 조정되었다.Since log quantization generates an error naturally compared to the original value, an explicitly acceptable level of neural network performance must be guaranteed. Image classification tests were performed with simulations that expanded the Caffe framework. Target Image Classification Only the convolutional layer, which performs most of the computation, has been accelerated. The target DNNs are LeNet and AlexNet for the 10 class data sets MNIST and CIFAR10. The large-scale AlexNet was tested with the 1000-class LSVRC-2010 ImageNet dataset. Floating-point learning weights were commonly fine-tuned 5,000 times.

도 8은 5000회 반복하여 미세 조정된 대상 신경 네트워크에 인식 테스트 결과를 도시한 도면으로, 도 8(a)는 10-클래스 이미지 분류 결과이고, 도 8(b)는 1000 클래스 이미지 분류 결과이다. 도 8(a)를 참조하면, 로그 양자화를 구현한 본 실시예는 비교 대상 기술들에 대하여 전반적으로 더 나은 인식률를 보인다(5 비트 및 9 비트는 엄격한 오류 제한 조건(12% 손실)에 대한 일반적 요구 사항임). 이것은 로그 양자화 가중치에 대해 양자화 오류가 더 크더라도 가중치를 미세 조정하여 인식률을 복구할 수 있음을 의미한다. 나아가, 미세 조정에서 곱셈 오류는 양자화 오류보다 더 큰 문제점이다. 이러한 현상은 도 8(b)로 도시된 더 크고 어려운 뉴럴 네트워크에서 더욱 향상되었다. 종래 기술의 SC는 10비트 정밀도에서 학습을 시작하고 로그 양자화의 본 실시예는 7비트에서 시작한다. 정확도 포화는 선형 양자화 된 이진 고정 소수점과 유사하게 8 비트에서 시작한다. 본 실시예는 더 작은 파라미터 크기 및 더 큰 양자화 에러에도 불구하고 선형 양자화 비교예보다 더 정확한 것으로 파악된다. FIG. 8 is a diagram showing the result of recognition test on a target neural network fine-tuned 5000 times, and FIG. 8 (a) is a 10-class image classification result, and FIG. 8 (b) is a 1000 class image classification result. Referring to FIG. 8 (a), the present embodiment implementing log quantization generally shows a better recognition rate for the technologies to be compared (5 bits and 9 bits are generally required for strict error limit conditions (12% loss)). Matter). This means that even if the quantization error is greater for the log quantization weight, the recognition rate can be restored by fine-tuning the weight. Furthermore, multiplication error in fine tuning is a bigger problem than quantization error. This phenomenon was further improved in the larger and more difficult neural network shown in Fig. 8 (b). The prior art SC starts learning at 10-bit precision and this embodiment of log quantization starts at 7-bit. Accuracy saturation starts at 8 bits, similar to a linear quantized binary fixed point. This embodiment is found to be more accurate than the linear quantization comparative example despite the smaller parameter size and larger quantization error.

그러나, 종래 기술의 스토캐스틱 컴퓨팅은 부호 비트 처리를 제외하고 동일한 입력에 대해 본 실시예와 동일하게 작동하므로 종래 기술의 스토캐스틱 컴퓨팅의 부호 크기 설계는 미세 조정된 가중치를 사용하여 본 실시예와 동일한 정확도를 달성할 수 있다. 따라서 본 실시예가 최종적으로 정밀 요구 사항 측면에서 종래 기술의 스토캐스틱 컴퓨팅을 능가한다고 말할 수는 없지만 본 실시예는 미세 조정 성능을 능가하며 종래 기술에 비해 인식률 저하가 없다.However, since the prior art stochastic computing works the same as the present embodiment for the same input except for the sign bit processing, the sign size design of the prior art stochastic computing uses the fine-tuned weights to achieve the same accuracy as the present embodiment. Can be achieved. Therefore, although it cannot be said that this embodiment finally surpasses the stochastic computing of the prior art in terms of precision requirements, the present embodiment surpasses the fine tuning performance and does not lower the recognition rate compared to the prior art.

10: 100: 곱셈 및 누적기
110: 입력 제공부 120: 스토캐스틱 수 제너레이터
130: 1 계수기 132: 시프터(shifter)
134: 덧셈기 140: 누적기
150: 가중치 제공부 160: 로그 대 선형 변환기
170: 역계수기
10: 100: multiplication and accumulator
110: input providing unit 120: stochastic number generator
130: 1 counter 132: shifter
134: adder 140: accumulator
150: weighting unit 160: log to linear converter
170: inverse counter

Claims (20)

입력 데이터를 제공하는 입력 제공부;
가중치 입력을 제공받아 로그로 양자화된 가중치를 출력하는 가중치 제공부;
상기 로그로 양자화된 가중치를 제공받고, 선형으로 변환된 가중치를 출력하는 로그 대 선형 변환기;
상기 선형으로 변환된 가중치로부터 윈도우 너비를 출력하는 역 계수기;
상기 입력 데이터에 상응하는 스토캐스틱 수에서 상기 윈도우 너비 내의 1의 값을 계수하는 1 계수기 및
상기 1 계수기가 출력한 값을 누적하여 출력하는 누적기를 포함하는 곱셈 누적기(multiply-accumulator).
An input providing unit providing input data;
A weight providing unit that receives a weight input and outputs a weight quantized into a log;
A log-to-linear converter that receives a quantized weight as the log and outputs a linearly converted weight;
An inverse counter for outputting a window width from the linearly converted weights;
1 counter for counting a value of 1 in the window width from the number of stochastics corresponding to the input data, and
A multiply-accumulator including an accumulator that accumulates and outputs the values output by the 1 counter.
제1항에 있어서,
상기 곱셈 누적기는,
상기 입력 데이터의 부호 비트와
상기 로그로 양자화된 가중치에서의 부호 비트로부터 상기 1 계수기가 출력한 값의 부호를 연산하는 배타적 논리 합(XOR, exclusive or) 게이트를 더 포함하는 곱셈 누적기.
According to claim 1,
The multiplication accumulator,
The sign bit of the input data and
The multiplicative accumulator further comprises an exclusive logical (XOR, exclusive or) gate for computing the sign of the value output by the 1 counter from the sign bit in the weight quantized with the logarithm.
제1항에 있어서,
상기 곱셈 누적기는,
상기 입력 데이터를 스토캐스틱 수로 변환하는 스토캐스틱 수 제너레이터(stochastic number generator)를 더 포함하는 곱셈 누적기.
According to claim 1,
The multiplication accumulator,
A multiplier accumulator further comprising a stochastic number generator that converts the input data into a stochastic number.
제1항에 있어서,
상기 1 계수기는
상기 입력 데이터에 상응하는 스토캐스틱 수를 형성하는 곱셈 누적기.
According to claim 1,
The 1 counter
A multiplicative accumulator forming a number of stochastics corresponding to the input data.
제1항에 있어서,
상기 1 계수기는,
상기 스토캐스틱 수가 미리 정해진 비트 수에 따라 분할되어 형성된 복수개의 블록 단위로 계수를 수행하는 곱셈 누적기.
According to claim 1,
The 1 counter,
A multiplier accumulator that performs counting in a plurality of block units formed by dividing the stochastic number according to a predetermined number of bits.
제5항에 있어서,
상기 윈도우의 너비가 상기 블록의 비트 너비보다 크거나 같을 때,
상기 1 계수기는,
수학식
Figure pat00024

을 연산하여 상기 블록 내의 1의 개수를 계수하는 곱셈 누적기.
The method of claim 5,
When the width of the window is greater than or equal to the bit width of the block,
The 1 counter,
Equation
Figure pat00024

A multiplicative accumulator that counts the number of 1s in the block by computing.
제5항에 있어서,
상기 윈도우의 너비가 상기 블록의 비트 너비보다 작을 때,
상기 1 계수기는,
수학식
Figure pat00025

를 연산하여 상기 윈도우 너비내 1의 개수를 계수하는 1 계수기를 포함하는 곱셈 누적기.
The method of claim 5,
When the width of the window is smaller than the bit width of the block,
The 1 counter,
Equation
Figure pat00025

A multiplier accumulator comprising a 1 counter that calculates and counts the number of 1s in the window width.
제5항에 있어서,
상기 윈도우의 너비가 상기 블록의 비트 너비보다 작을 때,
상기 1 계수기는,
수학식
Figure pat00026

을 연산하여 상기 윈도우 너비내 1의 개수를 계수하는 1 계수기를 포함하는 곱셈 누적기.
The method of claim 5,
When the width of the window is smaller than the bit width of the block,
The 1 counter,
Equation
Figure pat00026

A multiplier accumulator including a 1 counter that calculates and counts the number of 1s in the window width.
제5항에 있어서,
상기 윈도우의 너비가 상기 블록의 비트 너비보다 작을 때,
상기 1 계수기는,
Figure pat00027

를 연산하여 상기 윈도우 너비내 1의 개수를 계수하는 1 계수기를 포함하는 곱셈 누적기.
The method of claim 5,
When the width of the window is smaller than the bit width of the block,
The 1 counter,
Figure pat00027

A multiplier accumulator comprising a 1 counter that calculates and counts the number of 1s in the window width.
제5항에 있어서,
상기 1 계수기는,
블록의 최초 비트에서 최후 이전 비트 비트를 입력받아 우측 시프트 연산을 수행하는 시프터;
상기 블록의 최초 비트에서 최후 이전 비트 및 상기 블록의 최후 비트가 입력으로 제공되어 어느 하나를 선택하여 출력하는 다중화기;
상기 시프터와 상기 다중화기의 출력을 더하는 덧셈기; 및
상기 시프터가 시프트 연산하는 비트수와 상기 다중화기의 입력을 선택하는 제어부를 포함하는 1 계수기를 포함하는 곱셈 누적기.
The method of claim 5,
The 1 counter,
A shifter that receives a bit of the last bit from the first bit of the block and performs a right shift operation;
A multiplexer that selects and outputs one of the last previous bit and the last bit of the block as inputs from the first bit of the block;
An adder for adding the outputs of the shifter and the multiplexer; And
A multiplier accumulator comprising a counter that includes a control unit for selecting the number of bits shifted by the shifter and an input of the multiplexer.
복수의 입력 데이터 벡터들을 제공하는 입력 제공부;
가중치 입력을 제공받아 로그로 양자화된 가중치를 출력하는 가중치 제공부;
상기 로그로 양자화된 가중치를 제공받고, 선형으로 변환된 가중치를 출력하는 로그 대 선형 변환기;
상기 선형으로 변환된 가중치로부터 윈도우 너비를 출력하는 역 계수기;
상기 입력 데이터 벡터에 각각에 상응하는 스토캐스틱 수에서 상기 윈도우 너비 내의 1의 값을 계수하는 복수의 1 계수기들 및
상기 1 계수기가 출력한 값을 누적하여 출력하는 상기 복수의 누적기들을 포함하는 매트릭스 벡터 곱셈기(matrix-vector multiplier).
An input providing unit providing a plurality of input data vectors;
A weight providing unit that receives a weight input and outputs a weight quantized into a log;
A log-to-linear converter that receives a quantized weight as the log and outputs a linearly converted weight;
An inverse counter for outputting a window width from the linearly converted weights;
A plurality of 1 counters for counting a value of 1 in the window width from a number of stochastics corresponding to each of the input data vectors, and
A matrix-vector multiplier including the plurality of accumulators that accumulate and output the value output by the 1 counter.
제11항에 있어서,
상기 매트릭스 벡터 곱셈기(matrix-vector multiplier)는,
상기 입력 데이터 벡터 각각의 부호 비트와
상기 로그로 양자화된 가중치에서의 부호 비트로부터 상기 1 계수기가 출력한 값의 부호들을 연산하는 상기 복수의 배타적 논리 합(XOR, exclusive or) 게이트들을 더 포함하는 매트릭스 벡터 곱셈기(matrix-vector multiplier).
The method of claim 11,
The matrix vector multiplier (matrix-vector multiplier),
The sign bit of each of the input data vectors and
A matrix-vector multiplier further comprising the plurality of exclusive OR (XOR) gates that calculate the sign of the value output by the 1 counter from the sign bit in the log-quantized weight.
제11항에 있어서,
상기 곱셈 누적기는,
상기 입력 데이터 벡터 각각을 상응하는 스토캐스틱 수로 변환하는 상기 복수의 스토캐스틱 수 제너레이터(stochastic number generator)들을 더 포함하는 매트릭스 벡터 곱셈기(matrix-vector multiplier).
The method of claim 11,
The multiplication accumulator,
A matrix-vector multiplier further comprising the plurality of stochastic number generators that convert each of the input data vectors to a corresponding stochastic number.
제11항에 있어서,
상기 1 계수기는
상기 입력 데이터 벡터에 에 상응하는 스토캐스틱 수를 형성하는 매트릭스 벡터 곱셈기(matrix-vector multiplier).
The method of claim 11,
The 1 counter
A matrix-vector multiplier that forms a number of stochastics corresponding to the input data vector.
제11항에 있어서,
상기 1 계수기는,
상기 스토캐스틱 수가 미리 정해진 비트 수에 따라 분할되어 형성된 복수개의 블록 단위로 계수를 수행하는 매트릭스 벡터 곱셈기(matrix-vector multiplier).
The method of claim 11,
The 1 counter,
A matrix-vector multiplier that performs counting in a plurality of block units formed by dividing the number of stochastics according to a predetermined number of bits.
제15항에 있어서,
상기 윈도우의 너비가 상기 블록의 비트 너비보다 크거나 같을 때,
상기 1 계수기는,
수학식
Figure pat00028

을 연산하여 상기 블록 내의 1의 개수를 계수하는 매트릭스 벡터 곱셈기(matrix-vector multiplier).
The method of claim 15,
When the width of the window is greater than or equal to the bit width of the block,
The 1 counter,
Equation
Figure pat00028

A matrix-vector multiplier that calculates and counts the number of 1s in the block.
제15항에 있어서,
상기 윈도우의 너비가 상기 블록의 비트 너비보다 작을 때,
상기 1 계수기는,
수학식
Figure pat00029

를 연산하여 상기 윈도우 너비내 1의 개수를 계수하는 1 계수기를 포함하는 매트릭스 벡터 곱셈기(matrix-vector multiplier).
The method of claim 15,
When the width of the window is smaller than the bit width of the block,
The 1 counter,
Equation
Figure pat00029

A matrix-vector multiplier including 1 counter for counting the number of 1s in the window width by calculating.
제15항에 있어서,
상기 윈도우의 너비가 상기 블록의 비트 너비보다 작을 때,
상기 1 계수기는,
수학식
Figure pat00030

을 연산하여 상기 윈도우 너비내 1의 개수를 계수하는 1 계수기를 포함하는 매트릭스 벡터 곱셈기(matrix-vector multiplier).
The method of claim 15,
When the width of the window is smaller than the bit width of the block,
The 1 counter,
Equation
Figure pat00030

A matrix-vector multiplier including 1 counter for counting the number of 1s in the window width by calculating.
제15항에 있어서,
상기 윈도우의 너비가 상기 블록의 비트 너비보다 작을 때,
상기 1 계수기는,
Figure pat00031

를 연산하여 상기 윈도우 너비내 1의 개수를 계수하는 1 계수기를 포함하는 매트릭스 벡터 곱셈기(matrix-vector multiplier).
The method of claim 15,
When the width of the window is smaller than the bit width of the block,
The 1 counter,
Figure pat00031

A matrix-vector multiplier including 1 counter for counting the number of 1s in the window width by calculating.
제15항에 있어서,
상기 1 계수기는,
블록의 최초 비트에서 최후 이전 비트 비트를 입력받아 우측 시프트 연산을 수행하는 시프터;
상기 블록의 최초 비트에서 최후 이전 비트 및 상기 블록의 최후 비트가 입력으로 제공되어 어느 하나를 선택하여 출력하는 다중화기;
상기 시프터와 상기 다중화기의 출력을 더하는 덧셈기; 및
상기 시프터가 시프트 연산하는 비트수와 상기 다중화기의 입력을 선택하는 제어부를 포함하는 1 계수기를 포함하는 매트릭스 벡터 곱셈기(matrix-vector multiplier).
The method of claim 15,
The 1 counter,
A shifter that receives a bit of the last bit from the first bit of the block and performs a right shift operation;
A multiplexer that selects and outputs one of the last previous bit and the last bit of the block as inputs from the first bit of the block;
An adder for adding the outputs of the shifter and the multiplexer; And
A matrix-vector multiplier comprising 1 counter including a control unit for selecting the number of bits shifted by the shifter and an input of the multiplexer.
KR1020190138779A 2018-11-02 2019-11-01 Log-quantized mac for stochastic computing and accelerator comprising the same KR102340412B1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
KR20180133928 2018-11-02
KR1020180133928 2018-11-02

Publications (2)

Publication Number Publication Date
KR20200050895A true KR20200050895A (en) 2020-05-12
KR102340412B1 KR102340412B1 (en) 2021-12-17

Family

ID=70679704

Family Applications (1)

Application Number Title Priority Date Filing Date
KR1020190138779A KR102340412B1 (en) 2018-11-02 2019-11-01 Log-quantized mac for stochastic computing and accelerator comprising the same

Country Status (1)

Country Link
KR (1) KR102340412B1 (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2022203884A1 (en) * 2021-03-26 2022-09-29 Advanced Micro Devices, Inc. Data compressor for approximation of matrices for matrix multiply operations
WO2024087726A1 (en) * 2022-10-26 2024-05-02 Huawei Technologies Co., Ltd. Energetically efficient representation of signed integer non uniform weights

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR19980034878A (en) * 1996-11-09 1998-08-05 김광호 Vector quantization device and method with weight
KR20180077533A (en) * 2016-12-29 2018-07-09 한국과학기술원 Stochastic computing based SNG and neuromorphic circuit using the same

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR19980034878A (en) * 1996-11-09 1998-08-05 김광호 Vector quantization device and method with weight
KR20180077533A (en) * 2016-12-29 2018-07-09 한국과학기술원 Stochastic computing based SNG and neuromorphic circuit using the same

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
비특허문헌 1(Cornell University, 2016.03.03) *

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2022203884A1 (en) * 2021-03-26 2022-09-29 Advanced Micro Devices, Inc. Data compressor for approximation of matrices for matrix multiply operations
WO2024087726A1 (en) * 2022-10-26 2024-05-02 Huawei Technologies Co., Ltd. Energetically efficient representation of signed integer non uniform weights

Also Published As

Publication number Publication date
KR102340412B1 (en) 2021-12-17

Similar Documents

Publication Publication Date Title
Carmichael et al. Deep positron: A deep neural network using the posit number system
Drumond et al. Training dnns with hybrid block floating point
Johnson Rethinking floating point for deep learning
CN110222821B (en) Weight distribution-based convolutional neural network low bit width quantization method
Tambe et al. Algorithm-hardware co-design of adaptive floating-point encodings for resilient deep learning inference
US10872295B1 (en) Residual quantization of bit-shift weights in an artificial neural network
CN109214509B (en) High-speed real-time quantization structure and operation implementation method for deep neural network
EP3906507A1 (en) Dithered quantization of parameters during training with a machine learning tool
Zhang et al. Fast: Dnn training under variable precision block floating point with stochastic rounding
CN111832719A (en) Fixed point quantization convolution neural network accelerator calculation circuit
CN110852434B (en) CNN quantization method, forward calculation method and hardware device based on low-precision floating point number
KR20160037083A (en) Standalone floating-point conversion unit
KR102340412B1 (en) Log-quantized mac for stochastic computing and accelerator comprising the same
DiCecco et al. FPGA-based training of convolutional neural networks with a reduced precision floating-point library
KR20190044550A (en) Generating randomness in neural networks
EP4008057B1 (en) Lossless exponent and lossy mantissa weight compression for training deep neural networks
Sim et al. Log-quantized stochastic computing for memory and computation efficient DNNs
CN109325590B (en) Device for realizing neural network processor with variable calculation precision
KR20200134281A (en) Stochastic rounding logic
CN111091183A (en) Neural network acceleration system and method
Cai et al. Convolution without multiplication: A general speed up strategy for CNNs
CN111492369B (en) Residual quantization of shift weights in artificial neural networks
Drumond et al. End-to-end DNN training with block floating point arithmetic
KR102037043B1 (en) Fine-grained precision-adjustable Multiplier-Accumulator
Kalali et al. A power-efficient parameter quantization technique for CNN accelerators

Legal Events

Date Code Title Description
E701 Decision to grant or registration of patent right
GRNT Written decision to grant