KR102553941B1 - Method, multiplier-accumulator and apparatus for calculating deep learning network based on pop-count - Google Patents

Method, multiplier-accumulator and apparatus for calculating deep learning network based on pop-count Download PDF

Info

Publication number
KR102553941B1
KR102553941B1 KR1020200163708A KR20200163708A KR102553941B1 KR 102553941 B1 KR102553941 B1 KR 102553941B1 KR 1020200163708 A KR1020200163708 A KR 1020200163708A KR 20200163708 A KR20200163708 A KR 20200163708A KR 102553941 B1 KR102553941 B1 KR 102553941B1
Authority
KR
South Korea
Prior art keywords
multiplication
value
result values
values
result
Prior art date
Application number
KR1020200163708A
Other languages
Korean (ko)
Other versions
KR20220049432A (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 한국전자기술연구원
Priority to US17/254,254 priority Critical patent/US20220317973A1/en
Priority to PCT/KR2020/017253 priority patent/WO2022080579A1/en
Publication of KR20220049432A publication Critical patent/KR20220049432A/en
Application granted granted Critical
Publication of KR102553941B1 publication Critical patent/KR102553941B1/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
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F7/00Methods or arrangements for processing data by operating upon the order or content of the data handled
    • G06F7/38Methods or arrangements for performing computations using exclusively denominational number representation, e.g. using binary, ternary, decimal representation
    • G06F7/46Methods or arrangements for performing computations using exclusively denominational number representation, e.g. using binary, ternary, decimal representation using electromechanical counter-type accumulators
    • G06F7/462Multiplying; dividing
    • G06F7/463Multiplying; dividing by successive additions or subtractions
    • 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

Abstract

본 발명은 팝카운트 기반 딥러닝 신경망 연산 방법, 곱셈 누산기 및 장치에 관한 것이다. 본 발명의 일 실시예에 따른 연산 방법은 딥러닝 신경망(deep learning neural network)에 대한 연산 방법으로서, 가중치(W)들과 입력 값(A)들 간의 곱셈(제1 곱셈)들에 대해 각각, 제1 곱셈 결과 값들의 종류에 따른 원-핫 인코딩(one-hot encoding)의 코드들을 생성하는 단계; 상기 생성된 각 코드에 대해 팝카운트(pop-count)를 수행하는 단계; 서로 다른 상수 값인 상기 각 종류의 제1 곱셈 결과 값과 상기 팝카운트의 각 카운트 값 간의 상수 곱셈(제2 곱셈)에 대한 결과 값들을 누산하는 단계;를 포함한다.The present invention relates to a pop count-based deep learning neural network calculation method, multiplication accumulator, and apparatus. An operation method according to an embodiment of the present invention is an operation method for a deep learning neural network, and for multiplications (first multiplications) between weights W and input values A, respectively, generating one-hot encoding codes according to types of first multiplication result values; performing a pop-count on each of the generated codes; and accumulating result values for constant multiplication (second multiplication) between the first multiplication result value of each type, which is a different constant value, and each count value of the pop count.

Description

팝카운트 기반 딥러닝 신경망 연산 방법, 곱셈 누산기 및 장치{METHOD, MULTIPLIER-ACCUMULATOR AND APPARATUS FOR CALCULATING DEEP LEARNING NETWORK BASED ON POP-COUNT}Pop count-based deep learning neural network calculation method, multiplication accumulator and apparatus

본 발명은 팝카운트 기반 딥러닝 신경망 연산 방법, 곱셈 누산기 및 장치에 관한 것으로서, 더욱 상세하게는 심층신경망(deep neural network; DNN) 등과 같은 딥러닝 신경망(deep learning neural network)에 대한 연산을 팝카운트(pop-count)에 기반하여 처리하는 방법, 곱셈 누산기 및 장치에 관한 것이다.The present invention relates to a pop count-based deep learning neural network operation method, multiplication accumulator, and apparatus, and more particularly, to a pop count operation for a deep learning neural network such as a deep neural network (DNN). A method for processing based on (pop-count), a multiplication accumulator, and a device.

심층신경망(deep neural network; DNN) 등의 딥러닝 신경망(deep learning neural network)은 입력층(input layer)과 출력층(output layer) 사이에 여러 개의 은닉층(hidden layer)들로 이뤄진 인공신경망(artificial neural network; ANN)이다. 이때, 딥러닝 신경망은 일반적인 인공신경망과 마찬가지로 복잡한 비선형 관계(non-linear relationship)들을 모델링할 수 있다.A deep learning neural network such as a deep neural network (DNN) is an artificial neural network consisting of several hidden layers between an input layer and an output layer. network; ANN). At this time, the deep learning neural network can model complex non-linear relationships like a general artificial neural network.

이러한 딥러닝 신경망은 많은 파라미터 수와 연산량으로 인해 하드웨어 동작 시 많은 에너지와 시간이 소모되며, 이를 줄이기 위해 연산의 비트-정밀도를 낮추는 방법이 사용되고 있다. 특히, 딥러닝 신경망에 대한 연산은 세부적으로 수많은 곱셈 결과(multiplication result)들을 누적(accumulation)하는 곱셈-누산 연산의 반복이다. 이때, 비트-정밀도가 낮아질수록 곱셈 결과 값의 종류가 적어지면서, 동일한 값을 가지는 곱셈 결과들이 더 많이 누적되는 현상이 발생한다.Such a deep learning neural network consumes a lot of energy and time during hardware operation due to the large number of parameters and the amount of calculation, and a method of lowering the bit-precision of the calculation is used to reduce it. In particular, an operation for a deep learning neural network is a repetition of a multiplication-accumulation operation that accumulates numerous multiplication results in detail. At this time, as the bit-precision decreases, the number of multiplication result values decreases, and multiplication results having the same value accumulate more.

종래 기술의 경우, 이러한 동일한 결과 값을 가지는 곱셈들의 반복을 고려하지 않고 단순히 곱셈 연산을 반복 수행하므로, 하드웨어의 전력 효율 측면에서 매우 비효율적인 문제점이 있다.In the case of the prior art, since the multiplication operation is simply repeatedly performed without considering the repetition of multiplications having the same result value, there is a very inefficient problem in terms of hardware power efficiency.

KRKR 10-2020-012149710-2020-0121497 AA

상기한 바와 같은 종래 기술의 문제점을 해결하기 위하여, 본 발명은 비트-정밀도가 낮은 딥러닝 신경망에 대한 연산을 팝카운트(pop-count)에 기반하여 처리하는 기술을 제공하는데 그 목적이 있다.In order to solve the problems of the prior art as described above, an object of the present invention is to provide a technique for processing an operation for a deep learning neural network having low bit-precision based on a pop-count.

다만, 본 발명이 해결하고자 하는 과제는 이상에서 언급한 과제에 제한되지 않으며, 언급되지 않은 또 다른 과제들은 아래의 기재로부터 본 발명이 속하는 기술분야에서 통상의 지식을 가진 자에게 명확하게 이해될 수 있을 것이다.However, the problem to be solved by the present invention is not limited to the above-mentioned problems, and other problems not mentioned can be clearly understood by those skilled in the art from the description below. There will be.

상기와 같은 과제를 해결하기 위한 본 발명의 일 실시예에 따른 연산 방법은 딥러닝 신경망(deep learning neural network)에 대한 연산 방법으로서, 가중치(W)들과 입력 값(A)들 간의 곱셈(제1 곱셈)들에 대해 각각, 제1 곱셈 결과 값들의 종류에 따른 원-핫 인코딩(one-hot encoding)의 코드들을 생성하는 단계; 상기 생성된 각 코드에 대해 팝카운트(pop-count)를 수행하는 단계; 및 서로 다른 상수 값인 상기 각 종류의 제1 곱셈 결과 값과 상기 팝카운트의 각 카운트 값 간의 상수 곱셈(제2 곱셈)에 대한 결과 값들을 누산하는 단계;를 포함한다.An operation method according to an embodiment of the present invention for solving the above problems is an operation method for a deep learning neural network, and multiplication between weights (W) and input values (A) (first Generating one-hot encoding codes according to types of first multiplication result values for each of 1 multiplication); performing a pop-count on each of the generated codes; and accumulating result values for constant multiplication (second multiplication) between the first multiplication result value of each type, which is a different constant value, and each count value of the pop count.

상기 누산하는 단계는, 상기 제2 곱셈 결과 값들을 도출하는 제1 도출 단계; 및 상기 제2 곱셈 결과 값들에 대한 누산 결과 값을 도출하는 제2 도출 단계;를 포함할 수 있다.The accumulating step may include a first deriving step of deriving the second multiplication result values; and a second derivation step of deriving an accumulation result value for the second multiplication result values.

상기 제1 도출 단계는 상기 상수 값과 상기 카운트 값 간에 곱셈 연산을 수행하는 상수 곱셈기를 이용하거나, 상기 상수 값의 비트에 대한 시프트(shift)를 수행하는 시프터(shifter)를 이용하는 단계를 포함할 수 있다.The first deriving step may include using a constant multiplier for performing a multiplication operation between the constant value and the count value, or using a shifter for performing a bit shift of the constant value. there is.

상기 제1 도출 단계는 상기 제2 곱셈 결과 값들이 저장된 순람표(Lookup table)을 이용하는 단계를 포함할 수 있다.The first deriving step may include using a lookup table in which the second multiplication result values are stored.

상기 제2 도출 단계는 상기 제2 곱셈 결과 값들 간에 누산 연산을 수행하는 가산기 트리(adder tree)를 이용하는 단계를 포함할 수 있다.The second deriving may include using an adder tree that performs an accumulation operation between the second multiplication result values.

상기 누산하는 단계는 상기 제2 곱셈 결과 값들이 저장된 순람표(Lookup table)를 기반으로 분산 산술(distributed arithmetic)을 수행하는 단계를 포함할 수 있다.The accumulating may include performing distributed arithmetic based on a lookup table in which the second multiplication result values are stored.

상기 생성하는 단계는 가중치와 입력 값의 비트 종류에 따라, 상기 제1 곱셈 결과 값의 종류를 구분하여 상기 코드를 생성하는 단계를 포함할 수 있다.The generating may include generating the code by distinguishing the type of the first multiplication result value according to the weight and the bit type of the input value.

상기 생성하는 단계는, 상기 제1 곱셈에 대해 그 결과 값이 0(zero)인지 여부를 구분하는 제1 구분 단계; 및 그 결과 값이 0이 아닌 것(non-zero)으로 구분된 각 제1 곱셈에 대해 그 나머지의 결과 값 종류로 구분하는 제2 구분 단계; 및 상기 제2 구분 단계에서 구분된 결과를 기반으로, 상기 코드를 생성하는 단계;를 포함할 수 있다.The generating step may include: a first discrimination step of distinguishing whether a result value of the first multiplication is 0 (zero); and a second division step of classifying the remaining result values into types for each of the first multiplications in which the result value is non-zero. and generating the code based on the result of the classification in the second classification step.

상기 제2 구분 단계는, 상기 non-zero로 구분된 각 제1 곱셈에 대해, 가중치와 입력 값의 최상위비트(most significant bit)를 기준으로 2개 그룹으로 그 결과 값의 종류를 구분하는 제2-1 단계; 및 상기 2개 그룹에 대해 각 그룹에 속한 제1 곱셈에 대해 그 결과 값의 종류를 구분하는 제2-2 구분 단계;를 포함할 수 있다.In the second division step, for each first multiplication divided by the non-zero, a second division of the type of result value into two groups based on the weight and the most significant bit of the input value -Level 1; and a 2-2 division step of classifying the type of result value for the first multiplication belonging to each group with respect to the two groups.

본 발명의 일 실시예에 따른 연산 방법은, 상기 각 제1 곱셈 결과 값들의 종류에 대해, 그 반복 확률에 따라 다수의 데이터로 구분하는 단계; 및 제1 데이터에 속하는 상기 제1 곱셈에 대해, 상기 생성하는 단계, 상기 수행하는 단계 및 상기 누산하는 단계를 각각 적용하는 제1 연산 단계; 상기 제1 데이터 보다 반복 확률이 낮은 제2 데이터에 속하는 상기 제1 곱셈에 대해, 상기 제1 연산 단계와 다른 곱셈-누산의 연산을 수행하는 제2 연산 단계; 및 제1 및 제2 연산 단계의 결과 값들을 누산하는 제3 연산 단계;를 더 포함할 수 있다.An operation method according to an embodiment of the present invention includes: classifying each of the first multiplication result values into a plurality of data according to their repetition probability; and a first operation step of applying the generating step, the performing step, and the accumulating step to the first multiplication belonging to first data, respectively; a second calculation step of performing a multiplication-accumulation operation different from the first calculation step for the first multiplication belonging to second data having a lower repetition probability than the first data; and a third calculation step of accumulating result values of the first and second calculation steps.

본 발명의 일 실시예에 따른 곱셈-누산기는 딥러닝 신경망 연산에 적용되는 곱셈 누산기로서, 가중치(W)들과 입력 값(A)들 간의 곱셈(제1 곱셈)들에 대해 각각, 제1 곱셈 결과 값들의 종류에 따른 원-핫 인코딩(one-hot encoding)의 코드들을 생성하는 인코더; 상기 생성된 각 코드에 대해 팝카운트(pop-count)를 수행하는 팝카운터; 및 서로 다른 상수 값인 상기 각 종류의 제1 곱셈 결과 값과 상기 팝카운트의 각 카운트 값 간의 상수 곱셈(제2 곱셈) 결과 값들을 누산하는 곱셈-누산 연산부;를 포함한다.A multiplication-accumulator according to an embodiment of the present invention is a multiplication accumulator applied to a deep learning neural network operation, and for multiplications (first multiplications) between weights (W) and input values (A), a first multiplication, respectively, is performed. an encoder generating one-hot encoding codes according to types of result values; a pop-counter performing a pop-count on each of the generated codes; and a multiplication-accumulation operation unit accumulating constant multiplication (second multiplication) result values between the first multiplication result values of each type, which are different constant values, and each count value of the pop count.

상기 곱셈-누산 연산부는 상기 상수 값과 상기 카운트 값 간에 곱셈 연산을 수행하는 상수 곱셈기나, 상기 상수 값의 비트에 대한 시프트(shift)를 수행하는 시프터(shifter)를 기반으로 상기 제2 곱셈 결과 값을 도출할 수 있다.The multiplication-accumulation operation unit based on a constant multiplier performing a multiplication operation between the constant value and the count value or a shifter performing a bit shift of the constant value, the second multiplication result value can be derived.

상기 곱셈-누산 연산부는 상기 제2 곱셈 결과 값들이 저장된 순람표(Lookup table)를 기반으로 상기 제2 곱셈 결과 값들을 도출할 수 있다.The multiplication-accumulation operator may derive the second multiplication result values based on a lookup table in which the second multiplication result values are stored.

상기 곱셈-누산 연산부는 상기 제2 곱셈 결과 값들 간에 누산 연산을 수행하는 가산기 트리(adder tree)를 기반으로 상기 제2 곱셈 결과 값들을 누산할 수 있다.The multiplication-accumulation operation unit may accumulate the second multiplication result values based on an adder tree that performs an accumulation operation between the second multiplication result values.

상기 곱셈-누산 연산부는 상기 제2 곱셈 결과 값이 저장된 순람표(Lookup table)를 기반으로 분산 산술(distributed arithmetic)을 수행하여 상기 제2 곱셈 결과 값들을 누산할 수 있다.The multiplication-accumulation operation unit may accumulate the second multiplication result values by performing distributed arithmetic based on a lookup table in which the second multiplication result values are stored.

상기 인코더는 가중치와 입력 값의 비트 종류에 따라, 상기 제1 곱셈 결과 값의 종류를 구분하여 상기 코드를 생성할 수 있다.The encoder may generate the code by distinguishing the type of the first multiplication result value according to the weight and the bit type of the input value.

상기 인코더는 상기 각 제1 곱셈에 대해 그 결과 값이 0(zero)인지 여부를 제1 구분하고, 그 결과 값이 0이 아닌 것(non-zero)으로 구분된 각 제1 곱셈에 대해 그 결과 값의 종류를 제2 구분하며, 상기 제2 구분된 결과를 기반으로, 상기 코드를 생성할 수 있다.The encoder first determines whether the result value is 0 (zero) for each of the first multiplications, and the result value for each first multiplication that is classified as non-zero. The type of value is secondly classified, and the code can be generated based on a result of the second division.

상기 인코더는 상기 제2 구분 시, 상기 non-zero로 구분된 각 제1 곱셈에 대해 가중치와 입력 값의 최상위비트(most significant bit)를 기준으로 2개 그룹으로 그 결과 값의 종류를 구분한 후, 상기 2개 그룹에 대해 각 그룹에 속한 제1 곱셈에 대해 그 결과 값의 종류를 구분할 수 있다.In the second division, the encoder divides the type of result value into two groups based on the weight and the most significant bit of the input value for each first multiplication divided by the non-zero, and then , It is possible to distinguish the type of result value for the first multiplication belonging to each group for the above two groups.

본 발명의 일 실시예에 따른 곱셈-누산기는, 상기 인코더, 상기 팝카운터 및 상기 곱셈-누산 연산부를 각각 포함하며, 제1 데이터에 속하는 상기 제1 곱셈을 처리하는 제1 연산부; 상기 제1 데이터 보다 반복 확률이 낮은 제2 데이터에 속하는 상기 제1 곱셈에 대해, 상기 제1 연산부와 다른 곱셈-누산의 연산을 수행하는 제2 연산부; 및 제1 및 제2 연산부의 결과 값들을 누산하는 제3 연산부;를 더 포함할 수 있다.A multiplier-accumulator according to an embodiment of the present invention includes a first arithmetic unit that includes the encoder, the pop counter, and the multiply-accumulate arithmetic unit, and processes the first multiplication belonging to first data; a second operator performing a multiplication-accumulation operation different from that of the first operator on the first multiplication belonging to second data having a lower repetition probability than the first data; and a third arithmetic unit accumulating result values of the first and second arithmetic units.

본 발명의 일 실시예에 따른 전자 장치는 딥러닝 신경망(deep learning neural network) 연산을 수행하는 전자 장치로서, 상기 딥러닝 신경망의 가중치(W)들과, 상기 딥러닝 신경망의 입력층에 입력되는 입력 값(A)들을 저장한 메모리; 및 상기 메모리에 저장된 가중치들과 입력 값들 간의 곱셈(제1 곱셈)들에 대한 누산 결과 값을 계산하는 곱셈-누산기;를 포함한다.An electronic device according to an embodiment of the present invention is an electronic device that performs a deep learning neural network operation, wherein weights (W) of the deep learning neural network and input to an input layer of the deep learning neural network are a memory storing input values (A); and a multiplication-accumulator for calculating accumulated result values for multiplications (first multiplications) between input values and weights stored in the memory.

상기 곱셈-누산기는, 상기 제1 곱셈들에 대해 각각, 제1 곱셈 결과 값들의 종류에 따른 원-핫 인코딩(one-hot encoding)의 코드들을 생성할 수 있고, 상기 생성된 각 코드에 대해 팝카운트(pop-count)를 수행할 수 있으며, 서로 다른 상수 값인 상기 각 종류의 제1 곱셈 결과 값과 상기 팝카운트의 각 카운트 값 간의 상수 곱셈(제2 곱셈) 결과 값들을 누산할 수 있다.The multiplication-accumulator may generate one-hot encoding codes according to the type of first multiplication result values for each of the first multiplications, and pop each of the generated codes. A pop-count may be performed, and constant multiplication (second multiplication) result values between the first multiplication result value of each type, which is a different constant value, and each count value of the pop-count may be accumulated.

상기와 같이 구성되는 본 발명은 비트-정밀도가 낮은 심층신경망 등의 딥러닝 신경망에 대한 연산에서 많이 누적되는 동일한 결과 값을 가지는 곱셈들을 팝카운트 연산과 상수 곱셈으로 변환함으로써, 처리 속도를 향상시키면서, 그 하드웨어의 면적 및 소모 전력을 상당히 줄일 수 있는 이점이 있다.The present invention configured as described above converts multiplications having the same result values accumulated a lot in operations for deep learning neural networks such as deep neural networks with low bit-precision into pop count operations and constant multiplications, thereby improving processing speed, There is an advantage in that the area and power consumption of the hardware can be significantly reduced.

본 발명은 딥 러닝 신경망 연산을 처리하는 모바일, 에지 기기 및 서버 등의 다양한 하드웨어에 적용 가능한 이점이 있다.The present invention has the advantage of being applicable to various hardware such as mobile, edge devices and servers that process deep learning neural network calculations.

본 발명에서 얻을 수 있는 효과는 이상에서 언급한 효과들로 제한되지 않으며, 언급하지 않은 또 다른 효과들은 아래의 기재로부터 본 발명이 속하는 기술분야에서 통상의 지식을 가진 자에게 명확하게 이해될 수 있을 것이다.The effects obtainable in the present invention are not limited to the effects mentioned above, and other effects not mentioned can be clearly understood by those skilled in the art from the description below. will be.

도 1은 딥러닝 신경망의 구성에 대한 일 예를 나타낸다.
도 2는 딥러닝 신경망에서, 전단에 위치한 층(전단 층)의 다수 노드와 후단에 위치한 층(후단 층)의 어느 한 노드 사이의 연결 관계에 대한 일 예를 나타낸다.
도 3은 딥러닝 신경망에서, 입력층의 다수 노드와 제1 은닉층의 어느 한 노드 사이의 연결 관계에 대한 일 예를 나타낸다.
도 4는 입력 데이터의 비트-정밀도에 따른 TOPS(Tera Operations Per Second) 성능 비교의 일 예를 나타낸다.
도 5는 낮은 비트-정밀도(2-bit)에서 입력 데이터 확률 분포 및 곱셈 연산 결과의 확률 분포 개념도에 대한 일 예를 나타낸다.
도 6은 딥러닝 신경망 연산을 위한 일반적인 곱셈-누산의 하드웨어에 대한 일 예를 나타낸다.
도 7은 도 6의 곱셈-누산 하드웨어에서 발생하는 입력 데이터의 비트-플립(bit-flip)에 따른 에너지(전력) 소모 증가를 나타낸다.
도 8은 일반적인 곱셈-누산기에서 수행되는 곱셈-누산 연산의 개념도를 나타낸다.
도 9는 본 발명의 일 실시예에 따른 전자 장치(1)의 블록 구성도를 나타낸다.
도 10은 본 발명의 일 실시예에 따른 전자 장치(1)에서 신경망 처리부(10)의 블록 구성도를 나타낸다.
도 11은 제1 연산부(100)의 블록 구성도를 나타낸다.
도 12 및 도 13은 제1 연산부(100)의 동작에 대한 다양한 예를 나타낸다.
도 14는 효율적인 팝카운트를 위해, 단계적으로 원-핫 인코딩 코드를 생성 과정을 나타낸다.
도 15는 본 발명의 일 실시예에 따른 딥러닝 신경망의 연산 방법의 순서도를 나타낸다.
도 16은 본 발명의 다른 일 실시예에 따른 딥러닝 신경망의 연산 방법의 순서도를 나타낸다.
도 17은 4-bit × 4-bit 정밀도에서 제1 곱셈 결과 값들의 반복 확률 분포에 대한 시뮬레이션 결과의 일 예를 나타낸다.
1 shows an example of the configuration of a deep learning neural network.
2 shows an example of a connection relationship between multiple nodes of a layer located at the front end (front layer) and any one node of a layer located at the rear end (later layer) in a deep learning neural network.
3 shows an example of a connection relationship between multiple nodes of an input layer and any one node of a first hidden layer in a deep learning neural network.
4 shows an example of TOPS (Tera Operations Per Second) performance comparison according to bit-precision of input data.
5 shows an example of a conceptual diagram of probability distribution of input data probability distribution and multiplication operation result in low bit-precision (2-bit).
6 shows an example of a general multiplication-accumulation hardware for deep learning neural network operation.
FIG. 7 shows an increase in energy (power) consumption according to a bit-flip of input data generated by the multiplication-accumulation hardware of FIG. 6 .
8 shows a conceptual diagram of a multiplication-accumulation operation performed in a general multiplication-accumulator.
9 shows a block configuration diagram of an electronic device 1 according to an embodiment of the present invention.
10 shows a block diagram of a neural network processing unit 10 in an electronic device 1 according to an embodiment of the present invention.
11 shows a block configuration diagram of the first calculation unit 100 .
12 and 13 show various examples of the operation of the first calculation unit 100 .
14 shows a step-by-step process of generating one-hot encoding codes for efficient pop counting.
15 is a flowchart of a deep learning neural network calculation method according to an embodiment of the present invention.
16 is a flowchart of a deep learning neural network calculation method according to another embodiment of the present invention.
17 shows an example of a simulation result for a repetition probability distribution of first multiplication result values in 4-bit × 4-bit precision.

본 발명의 상기 목적과 수단 및 그에 따른 효과는 첨부된 도면과 관련한 다음의 상세한 설명을 통하여 보다 분명해질 것이며, 그에 따라 본 발명이 속하는 기술분야에서 통상의 지식을 가진 자가 본 발명의 기술적 사상을 용이하게 실시할 수 있을 것이다. 또한, 본 발명을 설명함에 있어서 본 발명과 관련된 공지 기술에 대한 구체적인 설명이 본 발명의 요지를 불필요하게 흐릴 수 있다고 판단되는 경우에는 그 상세한 설명을 생략하기로 한다.The above objects and means of the present invention and the effects thereof will become clearer through the following detailed description in conjunction with the accompanying drawings, and accordingly, those skilled in the art to which the present invention belongs can easily understand the technical idea of the present invention. will be able to carry out. In addition, in describing the present invention, if it is determined that a detailed description of a known technology related to the present invention may unnecessarily obscure the subject matter of the present invention, the detailed description will be omitted.

본 명세서에서 사용된 용어는 실시예들을 설명하기 위한 것이며, 본 발명을 제한하고자 하는 것은 아니다. 본 명세서에서, 단수형은 문구에서 특별히 언급하지 않는 한 경우에 따라 복수형도 포함한다. 본 명세서에서, "포함하다", “구비하다”, “마련하다” 또는 “가지다” 등의 용어는 언급된 구성요소 외의 하나 이상의 다른 구성요소의 존재 또는 추가를 배제하지 않는다.Terms used in this specification are for describing the embodiments and are not intended to limit the present invention. In this specification, singular forms also include plural forms in some cases unless otherwise specified in the text. In this specification, terms such as "comprise", "have", "provide" or "have" do not exclude the presence or addition of one or more other elements other than the mentioned elements.

본 명세서에서, “또는”, “적어도 하나” 등의 용어는 함께 나열된 단어들 중 하나를 나타내거나, 또는 둘 이상의 조합을 나타낼 수 있다. 예를 들어, “또는 B”“및 B 중 적어도 하나”는 A 또는 B 중 하나만을 포함할 수 있고, A와 B를 모두 포함할 수도 있다.In this specification, terms such as “or” and “at least one” may represent one of the words listed together, or a combination of two or more. For example, "or B" and "at least one of B" may include only one of A or B, or may include both A and B.

본 명세서에서, “예를 들어” 등에 따르는 설명은 인용된 특성, 변수, 또는 값과 같이 제시한 정보들이 정확하게 일치하지 않을 수 있고, 허용 오차, 측정 오차, 측정 정확도의 한계와 통상적으로 알려진 기타 요인을 비롯한 변형과 같은 효과로 본 발명의 다양한 실시 예에 따른 발명의 실시 형태를 한정하지 않아야 할 것이다.In this specification, descriptions following "for example" may not exactly match the information presented, such as cited characteristics, variables, or values, and tolerances, measurement errors, limits of measurement accuracy and other commonly known factors It should not be limited to the embodiments of the present invention according to various embodiments of the present invention with effects such as modifications including.

본 명세서에서, 어떤 구성요소가 다른 구성요소에 '연결되어’ 있다거나 '접속되어' 있다고 기재된 경우, 그 다른 구성요소에 직접적으로 연결되어 있거나 또는 접속되어 있을 수도 있지만, 중간에 다른 구성요소가 존재할 수도 있다고 이해되어야 할 것이다. 반면에, 어떤 구성요소가 다른 구성 요소에 '직접 연결되어' 있다거나 '직접 접속되어' 있다고 언급된 때에는, 중간에 다른 구성요소가 존재하지 않는 것으로 이해될 수 있어야 할 것이다.In this specification, when a component is described as being 'connected' or 'connected' to another component, it may be directly connected or connected to the other component, but there may be other components in the middle. It should be understood that it may be On the other hand, when a component is referred to as 'directly connected' or 'directly connected' to another component, it should be understood that no other component exists in the middle.

본 명세서에서, 어떤 구성요소가 다른 구성요소의 '상에' 있다거나 '접하여' 있다고 기재된 경우, 다른 구성요소에 상에 직접 맞닿아 있거나 또는 연결되어 있을 수 있지만, 중간에 또 다른 구성요소가 존재할 수 있다고 이해되어야 할 것이다. 반면, 어떤 구성요소가 다른 구성요소의 '바로 위에' 있다거나 '직접 접하여' 있다고 기재된 경우에는, 중간에 또 다른 구성요소가 존재하지 않은 것으로 이해될 수 있다. 구성요소 간의 관계를 설명하는 다른 표현들, 예를 들면, '~사이에'와 '직접 ~사이에' 등도 마찬가지로 해석될 수 있다.In the present specification, when an element is described as being 'on' or 'in contact with' another element, it may be in direct contact with or connected to the other element, but another element may be present in the middle. It should be understood that On the other hand, if an element is described as being 'directly on' or 'directly in contact with' another element, it may be understood that another element in the middle does not exist. Other expressions describing the relationship between components, such as 'between' and 'directly between', can be interpreted similarly.

본 명세서에서, '제1', '제2' 등의 용어는 다양한 구성요소를 설명하는데 사용될 수 있지만, 해당 구성요소는 위 용어에 의해 한정되어서는 안 된다. 또한, 위 용어는 각 구성요소의 순서를 한정하기 위한 것으로 해석되어서는 안되며, 하나의 구성요소와 다른 구성요소를 구별하는 목적으로 사용될 수 있다. 예를 들어, '제1구성요소'는 '제2구성요소'로 명명될 수 있고, 유사하게 '제2구성요소'도 '제1구성요소'로 명명될 수 있다.In this specification, terms such as 'first' and 'second' may be used to describe various elements, but the elements should not be limited by the above terms. In addition, the above terms should not be interpreted as limiting the order of each component, and may be used for the purpose of distinguishing one component from another. For example, a 'first element' may be named a 'second element', and similarly, a 'second element' may also be named a 'first element'.

다른 정의가 없다면, 본 명세서에서 사용되는 모든 용어는 본 발명이 속하는 기술분야에서 통상의 지식을 가진 자에게 공통적으로 이해될 수 있는 의미로 사용될 수 있을 것이다. 또한, 일반적으로 사용되는 사전에 정의되어 있는 용어들은 명백하게 특별히 정의되어 있지 않는 한 이상적으로 또는 과도하게 해석되지 않는다. Unless otherwise defined, all terms used in this specification may be used in a meaning commonly understood by those of ordinary skill in the art to which the present invention belongs. In addition, terms defined in commonly used dictionaries are not interpreted ideally or excessively unless explicitly specifically defined.

이하, 첨부된 도면을 참조하여 본 발명에 따른 바람직한 실시예를 상세히 설명하도록 한다.Hereinafter, preferred embodiments according to the present invention will be described in detail with reference to the accompanying drawings.

도 1은 딥러닝 신경망의 구성에 대한 일 예를 나타낸다.1 shows an example of the configuration of a deep learning neural network.

딥러닝 신경망(deep learning neural network)은, 도 1에 도시된 바와 같이, 입력층(input layer)과 출력층(output layer) 사이에 다수의 은닉층(hidden layer)(즉, n개의 은닉층)(단, n은 2이상의 자연수)을 포함하는 인공신경망(artificial neural network; ANN)이다. 이러한 딥러닝 신경망은 다수의 은닉층을 통해 입력층과 출력층 간의 다양한 비선형적 관계(non-linear relationship)를 학습하여 모델링할 수 있다.As shown in FIG. 1, a deep learning neural network has a plurality of hidden layers (ie, n hidden layers) between an input layer and an output layer (however, n is an artificial neural network (ANN) including a natural number of 2 or more. Such a deep learning neural network can be modeled by learning various non-linear relationships between an input layer and an output layer through a plurality of hidden layers.

이때, 입력층, 다수의 은닉층 및 출력층은 각각 다수의 노드(N)를 포함한다. 가령, 도 1에 도시된 바와 같이, 입력층은 Ni1, …Nik(단, k는 2이상의 자연수)의 노드들을, 제1 은닉층은 Nh11, …Nh1m(단, m는 2이상의 자연수)의 노드들을, 제n 은닉층은 Nhn1, …Nhns(단, n 및 s는 2이상의 자연수), 출력층은 No1, …Nok(단, p는 2이상의 자연수)의 노드들을 각각 포함할 수 있다.At this time, each of the input layer, the plurality of hidden layers, and the output layer includes a plurality of nodes N. For example, as shown in FIG. 1, the input layer N i1 , . . . Nodes of N ik (where k is a natural number greater than or equal to 2), the first hidden layer is N h11 , . . . Nodes of N h1m (where m is a natural number greater than or equal to 2), and the n-th hidden layer are N hn1 , . . . N hns (provided that n and s are natural numbers of 2 or greater), and the output layer is N o1 , . . . N ok (provided that p is a natural number of 2 or more) may each include nodes.

도 2는 딥러닝 신경망에서, 전단에 위치한 층(전단 층)의 다수 노드와 후단에 위치한 층(후단 층)의 어느 한 노드 사이의 연결 관계에 대한 일 예를 나타낸다. 또한, 도 3은 딥러닝 신경망에서, 입력층의 다수 노드와 제1 은닉층의 어느 한 노드 사이의 연결 관계에 대한 일 예를 나타낸다.2 shows an example of a connection relationship between multiple nodes of a layer located at the front end (front layer) and any one node of a layer located at the rear end (later layer) in a deep learning neural network. 3 shows an example of a connection relationship between multiple nodes of an input layer and any one node of a first hidden layer in a deep learning neural network.

딥러닝 신경망에서, 전단 층의 노드(전단 노드)들은 후단 층의 노드(후단 노드)들과 다양한 방식으로 연결된다. 이때, 각 노드는 가중치(W)를 가지며, 각 후단 노드의 노드 값은 그와 연결된 전단 노드의 노드 값 및 가중치에 의해 결정될 수 있다.In a deep learning neural network, the nodes of the previous layer (front nodes) are connected to the nodes of the back layer (post nodes) in various ways. At this time, each node has a weight W, and the node value of each subsequent node may be determined by the node value and weight of the previous node connected thereto.

즉, 도 2를 참조하면, 다수의 전단 노드(NF1, …NFr)(단, r은 2 이상의 자연수)는 적어도 하나의 후단 노드(NB)와 연결된다. 이때, 각 전단 노드인 NF1, …NFr에 대해, 각 노드 값(즉, 입력 값)(activation)이 AF1, …AFr이고, 각 가중치(weight)가 WF1, …WFr라면, 후단 노드(NB)의 노드 값은 h(WF1AF1 + …+ WFrAFr)이다. 이때, h는 활성화 함수(activation function)로서, 예를 들어 쌍곡 탄젠트 함수, 시그모이드 함수, ReLU 함수 등일 수 있으나, 이에 한정되는 것은 아니다.That is, referring to FIG. 2 , a plurality of front nodes N F1 , ...N Fr (where r is a natural number greater than or equal to 2) are connected to at least one rear node N B . At this time, each front node N F1 , . . . For N Fr , each node value (ie input value) (activation) is A F1 , … A Fr , and each weight is W F1 , . . . If W Fr , the node value of the subsequent node N B is h(W F1 A F1 + …+ W Fr A Fr ). In this case, h is an activation function, and may be, for example, a hyperbolic tangent function, a sigmoid function, or a ReLU function, but is not limited thereto.

가령, 도 3에 도시된 바와 같이, 입력층의 각 노드인 Ni1, …Nik에 입력 값(activation)이 A1, …Ak가 입력되고, 그 각 입력 노드의 가중치(weight)가 W1, …WK라면, 제1 은닉층의 Nh11의 노드 값은 h(W1A1 + …. + WkAk)이다.For example, as shown in FIG. 3, each node of the input layer N i1 , . . . The input value (activation) to N ik is A 1 , … A k is input, and the weight of each input node is W 1 , . . . If W K , the node value of N h11 of the first hidden layer is h(W 1 A 1 + …. + W k A k ).

이러한 딥러닝 신경망 연산은 수많은 연산을 통해 다양한 분야의 어플리케이션에서 높은 정확도를 보여주고 있다. 하지만, 딥러닝 신경망은 통상적으로 수백만개 내지 수십억개의 파라미터 수와 연산량을 갖기 때문에, 하드웨어 구현 시 많은 전력 및 에너지를 소모하고 긴 처리시간을 갖는다. 이에 따라, 효과적으로 파라미터 저장공간과 연산량을 줄이기 위해, 입력 데이터의 비트-정밀도를 감소시키는 방법, 즉 각 입력 값에 대한 할당 데이터의 비트 수를 줄이는 방법을 사용한다. 이때, 입력 데이터는 딥러닝 신경망에서 각 층에 입력되는 데이터로서, 특히 딥러닝 신경망의 각 후단 층에 입력되는 데이터일 수 있다. 즉, 하나의 후단 노드에 대한 입력 데이터는 그와 연결된 전단 노드의 노드 값인 입력 값(activation; A)과, 그와 연결된 전단 노드의 가중치(weight; W)를 포함한다.These deep learning neural network calculations show high accuracy in applications in various fields through numerous calculations. However, since a deep learning neural network typically has millions to billions of parameters and an amount of computation, it consumes a lot of power and energy and takes a long processing time when implemented in hardware. Accordingly, in order to effectively reduce the parameter storage space and the amount of calculation, a method of reducing bit-precision of input data, that is, a method of reducing the number of bits of allocated data for each input value is used. In this case, the input data may be data input to each layer in the deep learning neural network, and in particular, data input to each subsequent layer of the deep learning neural network. That is, input data for one subsequent node includes an input value (activation A), which is a node value of a previous node connected thereto, and a weight (W) of a previous node connected thereto.

만일, 입력 데이터의 비트-정밀도를 절반으로 줄인다면, 동일 연산에 소모하는 하드웨어의 전력 및 에너지를 약 1/4로 줄일 수 있다. 특히, 추론 연산의 경우, 모바일이나 에지 기기에서 동작하는 경우가 많은데, 학습 연산보다 낮은 비트-정밀도를 요구하기 때문에, 이러한 비트-정밀도를 낮춰서 사용하는 다양한 방식들이 보편화되고 있다.If the bit-precision of the input data is halved, the power and energy of hardware consumed for the same operation can be reduced by about 1/4. In particular, inference operations, which are often operated on mobile or edge devices, require lower bit-precision than learning operations, so various methods using lower bit-precisions are becoming common.

딥러닝 신경망 연산을 위해, 도 2 및 도 3에 도시된 바와 같이, 입력 값(A)들과 가중치(W)들 사이의 곱셈-누산(multiply-accumulate) 연산(즉, 입력 값들과 가중치들에 대한 곱셈 연산과, 그 곱셈 결과 값들을 누적하는 연산)이 수행되는데, 이때 전체 연산의 가장 큰 오버헤드는 곱셈 연산이다. 하지만, 비트-정밀도가 감소하면서, 동일한 결과 값을 가는 곱셈 연산들이 자주 반복되는 현상이 발생한다. 특히, 곱셈을 위한 입력 값들과 가중치 값들이 균등 분포(uniform distribution)가 아닌 정규 분포(normal distribution)(특히, 가중치의 경우) 및 반-정규 분포(half-normal distribution)(특히, 입력 값의 경우)를 갖기 때문에, 동일한 결과 값을 가지는 곱셈들의 반복 현상은 더욱 심화된다.For deep learning neural network calculation, as shown in FIGS. 2 and 3, a multiply-accumulate operation between input values (A) and weights (W) (ie, input values and weights) A multiplication operation and an operation of accumulating the multiplication result values) are performed. At this time, the largest overhead of the entire operation is the multiplication operation. However, as the bit-precision decreases, multiplication operations with the same result value are frequently repeated. In particular, input values for multiplication and weight values are not uniformly distributed, but normal distribution (especially for weights) and half-normal distribution (especially for input values) ), the phenomenon of repetition of multiplications having the same result value is further intensified.

높은 비트-정밀도에서는 곱셈 결과 값의 종류가 많아서 normal distribution/half-normal distribution의 영향이 있더라도 확률적으로 동일한 결과 값을 가지는 곱셈들이 많이 반복되지 않기 때문에 곱셈-누산 연산이 효율적이다. 하지만, 낮은 비트-정밀도에서는 동일한 결과 값을 가지는 곱셈들이 훨씬 자주 반복된다. 이에 따라 종래 기술과 같이 모든 곱셈에 대해 각각 곱셈 연산을 수행하는 경우, 동일한 결과 값을 가지는 곱셈들에 대한 반복적인 연산에 그 전력 및 에너지의 대부분을 소모하게 된다. 이처럼 낮은-비트 정밀도에서는 동일한 결과 값을 가지는 곱셈 연산의 반복을 대체하여, 하드웨어의 전력 효율을 증대할 수 있는 새로운 연산 방법이 필요하다.In high bit-precision, multiplication-accumulation operations are efficient because there are many types of multiplication result values, and multiplications with stochastically identical result values are not repeated many times even under the influence of normal distribution/half-normal distribution. However, at lower bit-precision, multiplications with the same result value are repeated much more often. Accordingly, in the case of performing a multiplication operation for each multiplication as in the prior art, most of the power and energy is consumed in repetitive operations for multiplications having the same result value. In this low-bit precision, a new operation method capable of increasing power efficiency of hardware by replacing repeated multiplication operations having the same result value is required.

도 4는 입력 데이터의 비트-정밀도에 따른 TOPS(Tera Operations Per Second) 성능 비교의 일 예를 나타낸다.4 shows an example of TOPS (Tera Operations Per Second) performance comparison according to bit-precision of input data.

딥러닝 신경망 연산의 비트-정밀도는 일반적으로 입력 데이터의 비트-정밀도로 표현될 수 있다. 도 4를 참조하면, 입력 데이터의 비트-정밀도 변화에 따른 GPU의 연산 처리 속도(TOPS) 성능을 비교할 수 있다. A100 GPU는 NVIDIA社의 최신 GPU 모델로 딥러닝 신경망 처리 전용 GPU이다. A100의 경우, 이전 버전인 V100과 달리 정수 8-bi (INT8), 정수 4-bit(INT4), 정수 1-bit(BINARY) 등과 같이, 초기에 사용되던 부동소수점 32-bit(FP32) 또는 16-bit(FP16) 보다 훨씬 낮은 비트-정밀도의 입력 데이터 형태를 지원한다. 정수 4-bit 연산의 경우, 부동소수점 32-bit 연산 대비 동일 GPU내에서 1248배의 연산 처리 속도 증가를 나타낸다.The bit-precision of deep learning neural network operations can generally be expressed as the bit-precision of input data. Referring to FIG. 4 , it is possible to compare TOPS performance of a GPU according to a change in bit-precision of input data. A100 GPU is NVIDIA's latest GPU model and is dedicated to deep learning neural network processing. In the case of the A100, unlike the previous version of the V100, the floating point 32-bit (FP32) or 16 Supports bit-precision input data types much lower than -bit (FP16). In the case of integer 4-bit operation, compared to floating point 32-bit operation, it shows a 1248 times increase in processing speed within the same GPU.

도 5는 낮은 비트-정밀도(2-bit)에서 입력 데이터 확률 분포 및 곱셈 연산 결과의 확률 분포 개념도에 대한 일 예를 나타낸다.5 shows an example of a conceptual diagram of probability distribution of input data probability distribution and multiplication operation result in low bit-precision (2-bit).

도 5를 참조하면, 2-bit의 낮은 비트-정밀도에서 입력 데이터의 확률 분포 및 곱셈 연산 결과의 확률 분포를 알 수 있다. 이 경우, 곱셈 결과 값의 종류는 0, 1, 2, 3, 4, 6 및 9의 총 7가지가 있으며, 입력 데이터 분포에 따라 그 곱셈 결과 값이 작은 종류일수록(즉, 9, 6, 4, 3, 2, 1 및 0의 순서로), 그 반복 확률이 더 커진다. 즉, 딥러닝 신경망의 각 층에서, 입력 데이터의 가중치(W)는 normal distribution을 가지며, 입력 값(A)은 half-normal distribution을 가진다. 이러한 분포에 의해, 0, 1, 2 및 3과 같이 그 곱셈 결과 값이 작은 종류에 속하는 곱셈들이 자주 반복된다.Referring to FIG. 5 , the probability distribution of the input data and the probability distribution of the result of the multiplication operation can be known at the low bit-precision of 2-bit. In this case, there are a total of seven types of multiplication result values: 0, 1, 2, 3, 4, 6, and 9, and according to the distribution of the input data, the smaller the multiplication result value (i.e., 9, 6, 4 , in the order of 3, 2, 1 and 0), the repetition probability becomes larger. That is, in each layer of the deep learning neural network, the weight (W) of the input data has a normal distribution, and the input value (A) has a half-normal distribution. Due to this distribution, multiplications belonging to a small class such as 0, 1, 2, and 3 are frequently repeated.

도 6은 딥러닝 신경망 연산을 위한 일반적인 곱셈-누산의 하드웨어에 대한 일 예를 나타내고, 도 7은 도 6의 곱셈-누산 하드웨어에서 발생하는 입력 데이터의 비트-플립(bit-flip)에 따른 에너지(전력) 소모 증가를 나타낸다. 또한, 도 8은 일반적인 곱셈-누산기에서 수행되는 곱셈-누산 연산의 개념도를 나타낸다.6 shows an example of general multiplication-accumulation hardware for deep learning neural network operation, and FIG. 7 shows energy according to bit-flip of input data generated by the multiplication-accumulation hardware of FIG. 6 ( power) indicates an increase in consumption. 8 shows a conceptual diagram of a multiplication-accumulation operation performed in a general multiplication-accumulator.

도 6 및 도 7을 참조하면, 일반적인 딥러닝 신경망의 하드웨어에서의 비트-플립에 따른 에너지(혹은 전력) 소모 증가를 알 수 있다. 즉, 일반적인 딥러닝 신경망의 하드웨어는 2차원 배열(2D array) 구조로 곱셈-누산(multiply-accumulation)의 연산을 수행하는데, 입력 데이터가 바뀌면 비트-플립으로 인해 그 결과 값이 같은 곱셈들에 대해서도 그 하드웨어 내부에서 스위칭 전력 소모가 발생한다. 도 7을 참조하면, 이러한 비트-플립의 횟수와 그 에너지 소모는 서로 비례 관계임을 알 수 있다.Referring to FIGS. 6 and 7 , an increase in energy (or power) consumption according to a bit-flip in hardware of a general deep learning neural network can be seen. That is, the hardware of a general deep learning neural network performs a multiply-accumulation operation in a 2D array structure. Switching power dissipation occurs inside the hardware. Referring to FIG. 7 , it can be seen that the number of bit-flips and the energy consumption are proportional to each other.

특히, 도 6과 같은 일반적인 곱셈-누산 하드웨어의 2D array 구조는 도 8의 구조를 다수 개 사용하는 구조를 가진다. 이때, 도 8의 구조에서, 가장 에너지 소모가 큰 부분은 곱셈기인데, 동일한 결과 값을 가지는 곱셈들에 대해 비트-플립으로 인한 스위칭 전력을 반복적으로 소모하는 것은 전체 하드웨어의 전력 효율 측면에서 비효율적이다.In particular, the 2D array structure of general multiplication-accumulation hardware as shown in FIG. 6 has a structure using a plurality of the structures of FIG. 8 . In this case, in the structure of FIG. 8, the multiplier consumes the most energy, and repeatedly consuming switching power due to bit-flip for multiplications having the same result value is inefficient in terms of power efficiency of the entire hardware.

이에, 본 발명은 딥러닝 신경망 연산을 팝카운트(pop-count)에 기반한 처리(즉, 제1 연산 방법)를 수행함으로써, 하드웨어의 전력 소모를 줄이고자 한다. 즉, 본 발명은 입력 데이터의 분포에 의해 어떤 곱셈 연산이 반복되는지를 예측하고, 이를 이용하여 반복 횟수를 세는 팝카운트 연산과 반복횟수×곱셈결과(미리 정해진 상수)의 상수곱셈 연산으로, 기존의 곱셈-누산 연산을 대체하고자 한다. 또한, 본 발명은 반복 횟수가 많은 경우에는 제1 연산 방법을 수행하고, 반복횟수가 적은 경우에는 종래의 일반적인 곱셈-누산 연산 방법(즉, 제2 연산 방법)을 수행하여, 상대적으로 높은 비트-정밀도에서도 반복 연산을 제거하도록 확장 가능하면서, 낮은 비트-정밀도에서의 효율은 더욱 향상시킬 수 있도록 한다.Accordingly, the present invention intends to reduce power consumption of hardware by performing a deep learning neural network operation based on a pop-count (ie, a first operation method). That is, the present invention predicts which multiplication operation is repeated by the distribution of input data and uses it to count the number of repetitions Pop count operation and constant multiplication operation of the number of repetitions × multiplication result (predetermined constant), It is intended to replace the multiply-accumulate operation. In addition, the present invention performs the first operation method when the number of iterations is large, and performs the conventional general multiplication-accumulation operation method (ie, the second operation method) when the number of repetitions is small, so that a relatively high bit- It is extensible to eliminate repetitive operations even in precision, while allowing efficiency at low bit-precision to be further improved.

도 9는 본 발명의 일 실시예에 따른 전자 장치(1)의 블록 구성도를 나타낸다.9 shows a block configuration diagram of an electronic device 1 according to an embodiment of the present invention.

본 발명의 일 실시예에 따른 전자 장치(1)는 딥러닝 신경망에 대한 연산을 수행하는 컴퓨팅(computing)이 가능한 장치이다.The electronic device 1 according to an embodiment of the present invention is a device capable of computing for performing calculations on a deep learning neural network.

예를 들어, 전자 장치는 데스크탑 PC(desktop personal computer), 랩탑 PC(laptop personal computer), 태블릿 PC(tablet personal computer), 넷북 컴퓨터(netbook computer), 워크스테이션(workstation), PDA(personal digital assistant), 스마트폰(smartphone), 스마트패드(smartpad), 또는 휴대폰(mobile phone), 등일 수 있으나, 이에 한정되는 것은 아니다.For example, the electronic device includes a desktop personal computer, a laptop personal computer, a tablet personal computer, a netbook computer, a workstation, and a personal digital assistant (PDA). , a smart phone (smartphone), a smart pad (smartpad), or a mobile phone (mobile phone), etc., but is not limited thereto.

이때, 딥러닝 신경망은 딥 러닝(deep learning) 기법에 따른 모델링을 위한 인공신경망으로서, 도 1 내지 도 3에 따라 상술한 입력층, 은닉층 및 출력층과, 각 층 내의 다수 노드를 각각 포함할 수 있다. 이러한 딥러닝 신경망은 다양한 딥 러닝 기법에 따라 학습 데이터에 의해 기 학습된 학습 모델일 수 있다.At this time, the deep learning neural network is an artificial neural network for modeling according to a deep learning technique, and may include the above-described input layer, hidden layer, and output layer according to FIGS. 1 to 3, and a plurality of nodes in each layer, respectively. . Such a deep learning neural network may be a learning model previously learned by learning data according to various deep learning techniques.

즉, 딥러닝 신경망은 다수의 층을 포함하여, 학습을 통해 입력과 출력 간의 관계에 대한 함수를 가질 수 있다. 즉, 딥러닝 신경망은 입력과 출력 간의 관계를 다수의 은닉층으로 표현한다. 가령, 딥러닝 신경망의 기 학습된 모델에 대해, 입력층에 입력 데이터가 입력되면, 해당 은닉층의 함수 작용에 따른 출력 데이터가 출력층에 출력될 수 있다. 이때, 다수의 은닉층은 각각 적어도 하나 이상의 필터를 포함할 수 있으며, 각 필터는 가중치(weight)의 매트릭스(matrix)를 가질 수 있다.That is, a deep learning neural network may include a plurality of layers and have a function for a relationship between an input and an output through learning. That is, the deep learning neural network expresses the relationship between input and output with multiple hidden layers. For example, for a pre-learned model of a deep learning neural network, when input data is input to an input layer, output data according to a function action of a corresponding hidden layer may be output to an output layer. In this case, each of the plurality of hidden layers may include at least one or more filters, and each filter may have a matrix of weights.

예를 들어, 딥 러닝 기법은 Deep Neural Network(DNN), Convolutional Neural Network(CNN), Recurrent Neural Network(RNN), Restricted Boltzmann Machine(RBM), Deep Belief Network(DBN), Deep Q-Networks 등을 포함할 수 있으나, 이에 한정되는 것은 아니다.For example, deep learning techniques include Deep Neural Network (DNN), Convolutional Neural Network (CNN), Recurrent Neural Network (RNN), Restricted Boltzmann Machine (RBM), Deep Belief Network (DBN), Deep Q-Networks, etc. It can be done, but is not limited thereto.

이러한 전자 장치(1)는, 도 9에 도시된 바와 같이, 신경망 처리부(10), 입력부(20), 통신부(30), 디스플레이(미도시), 메모리(40) 및 제어부(50)를 포함할 수 있다.As shown in FIG. 9 , the electronic device 1 may include a neural network processing unit 10, an input unit 20, a communication unit 30, a display (not shown), a memory 40, and a control unit 50. can

신경망 처리부(10)는 딥러닝 신경망에 대한 연산을 위해 곱셈-누산의 연산을 수행하는 구성으로서, 각종 회로 등에 의해 구현된 하드웨어일 수 있다. 다만, 신경망 처리부(10)의 구성 및 작용 등에 대한 상세한 설명은 후술하도록 한다.The neural network processing unit 10 is a component that performs a multiplication-accumulation operation for an operation on a deep learning neural network, and may be hardware implemented by various circuits. However, a detailed description of the configuration and operation of the neural network processing unit 10 will be described later.

입력부(20)는 다양한 사용자(감시자 등)의 입력에 대응하여, 입력데이터를 발생시키며, 다양한 입력수단을 포함할 수 있다. 예를 들어, 입력부(20)는 키보드(key board), 키패드(key pad), 돔 스위치(dome switch), 터치 패널(touch panel), 터치 키(touch key), 터치 패드(touch pad), 마우스(mouse), 메뉴 버튼(menu button) 등을 포함할 수 있으나, 이에 한정되는 것은 아니다. 가령, 입력부(20)는 딥러닝 신경망 연산을 위한 명령 등을 입력 받을 수 있다.The input unit 20 generates input data in response to inputs of various users (such as a supervisor), and may include various input means. For example, the input unit 20 may include a keyboard, a key pad, a dome switch, a touch panel, a touch key, a touch pad, and a mouse. (mouse), menu button (menu button), etc. may be included, but is not limited thereto. For example, the input unit 20 may receive a command or the like for deep learning neural network operation.

통신부(30)는 다른 장치와의 통신을 수행하는 구성이다. 예를 들어, 통신부(30)는 5G(5th generation communication), LTE-A(long term evolution-advanced), LTE(long term evolution), 블루투스, BLE(bluetooth low energe), NFC(near field communication), 와이파이(WiFi) 통신 등의 무선 통신을 수행하거나, 케이블 통신 등의 유선 통신을 수행할 수 있으나, 이에 한정되는 것은 아니다. 가령, 통신부(30)는 타 장치로부터 딥러닝 신경망에 대한 정보를 수신할 수 있으며, 딥러닝 신경망에 대한 연산 결과 등을 타 장치로 송신할 수 있다.The communication unit 30 is a component that communicates with other devices. For example, the communication unit 30 may perform 5th generation communication (5G), long term evolution-advanced (LTE-A), long term evolution (LTE), Bluetooth, bluetooth low energy (BLE), near field communication (NFC), Wireless communication such as WiFi communication or wired communication such as cable communication may be performed, but is not limited thereto. For example, the communication unit 30 may receive information on a deep learning neural network from another device and may transmit an operation result on the deep learning neural network to the other device.

메모리(40)는 전자 장치(1)의 동작에 필요한 각종 정보를 저장한다. 저장 정보로는 딥러닝 신경망에 대한 정보, 제1 및 제2 데이터에 대한 통계 값에 관한 정보, 후술할 딥러닝 신경망에 대한 연산 방법에 관련된 프로그램 정보 등이 포함될 수 있으나, 이에 한정되는 것은 아니다. 예를 들어, 메모리(40)는 그 유형에 따라 하드디스크 타입(hard disk type), 마그네틱 매체 타입(Sagnetic media type), CD-ROM(compact disc read only memory), 광기록 매체 타입(Optical Media type), 자기-광 매체 타입(Sagneto-optical media type), 멀티미디어 카드 마이크로 타입(Sultimedia card micro type), 플래시 저장부 타입(flash memory type), 롬 타입(read only memory type), 또는 램 타입(random access memory type) 등을 포함할 수 있으나, 이에 한정되는 것은 아니다. 또한, 메모리(40)는 그 용도/위치에 따라 캐시(cache), 버퍼, 주기억장치, 또는 보조기억장치이거나 별도로 마련된 저장 시스템일 수 있으나, 이에 한정되는 것은 아니다.The memory 40 stores various types of information necessary for the operation of the electronic device 1 . The stored information may include, but is not limited to, information on the deep learning neural network, information on statistical values of the first and second data, and program information related to an operation method for the deep learning neural network, which will be described later. For example, the memory 40 may be of a hard disk type, a magnetic media type, a compact disc read only memory (CD-ROM), or an optical media type according to its type. ), Sagneto-optical media type, Sultimedia card micro type, flash memory type, read only memory type, or RAM type (random access memory type), etc., but is not limited thereto. In addition, the memory 40 may be a cache, a buffer, a main memory, an auxiliary memory, or a separately provided storage system depending on its purpose/location, but is not limited thereto.

한편, 전자 장치(1)는 디스플레이(미도시)를 더 포함할 수도 있다. 이때, 디스플레이는 다양한 영상 데이터를 화면으로 표시하는 것으로서, 비발광형 패널이나 발광형 패널로 구성될 수 있다. 예를 들어, 디스플레이는 액정 디스플레이(LCD; liquid crystal display), 발광 다이오드(LED; light emitting diode) 디스플레이, 유기 발광 다이오드(OLED; organic LED) 디스플레이, 마이크로 전자기계 시스템(MEMS; micro electro mechanical systems) 디스플레이, 또는 전자 종이(electronic paper) 디스플레이 등을 포함할 수 있으나, 이에 한정되는 것은 아니다. 또한, 디스플레이는 입력부(20)와 결합되어 터치 스크린(touch screen) 등으로 구현될 수 있다. 가령, 디스플레이는 딥러닝 신경망에 대한 정보, 딥러닝 신경망 연산을 위한 설정 정보, 딥러닝 신경망에 대한 연산 결과 등 결과 등을 화면으로 표시할 수 있다.Meanwhile, the electronic device 1 may further include a display (not shown). At this time, the display displays various image data on a screen, and may be composed of a non-emissive panel or a light emitting panel. For example, displays include liquid crystal displays (LCDs), light emitting diodes (LEDs) displays, organic LEDs (OLEDs) displays, and micro electro mechanical systems (MEMS). A display or an electronic paper display may be included, but is not limited thereto. In addition, the display may be combined with the input unit 20 and implemented as a touch screen or the like. For example, the display may display results such as information on the deep learning neural network, setting information for calculating the deep learning neural network, and calculation results for the deep learning neural network on the screen.

제어부(50)는 전자 장치(1)의 다양한 제어 동작을 수행할 수 있다. 즉, 제어부(50)는 후술할 딥러닝 신경망 연산 방법의 수행을 제어할 수 있으며, 전자 장치(1)의 나머지 구성, 즉 신경망 처리부(10), 입력부(20), 통신부(30), 디스플레이(미도시), 메모리(40) 등의 동작을 제어할 수 있다. 예를 들어, 제어부(50)는 하드웨어인 프로세서(processor) 또는 해당 프로세서에서 수행되는 소프트웨어인 프로세스(process) 등을 포함할 수 있으나, 이에 한정되는 것은 아니다.The controller 50 may perform various control operations of the electronic device 1 . That is, the control unit 50 can control the execution of a deep learning neural network calculation method to be described later, and the remaining components of the electronic device 1, that is, the neural network processing unit 10, the input unit 20, the communication unit 30, the display ( Not shown), operation of the memory 40, etc. may be controlled. For example, the control unit 50 may include, but is not limited to, a processor that is hardware or a process that is software that is executed in the corresponding processor.

도 10은 본 발명의 일 실시예에 따른 전자 장치(1)에서 신경망 처리부(10)의 블록 구성도를 나타낸다.10 shows a block diagram of a neural network processing unit 10 in an electronic device 1 according to an embodiment of the present invention.

신경망 처리부(10)는 딥러닝 신경망에 대한 연산을 처리하며, 도 10에 도시된 바와 같이, 곱셈 누산기(11) 및 버퍼(12)를 포함할 수 있다. 이러한 곱셈 누산기(11)나, 곱셈 누산기(11) 및 버퍼(12)를 포함하는 구성은 다양한 회로로 구현된 하드웨어 구성일 수 있다. 다만, 곱셈 누산기(11), 즉 제1 연산부 내지 제3 연산부(100, 200, 300)는 프로세스 등의 하드웨어 구성이 소프트웨어 구성일 수도 있으며, 이 경우에 해당 소프트웨어에 대한 정보는 메모리(40)에 저장되어 제어부(50)의 제어에 따라 동작할 수 있다. 또한, 신경망 처리부(10) 또는 곱셈 누산기(11)는 제어부(50) 내에 별도로 마련된 하드웨어 구성일 수도 있다.The neural network processing unit 10 processes an operation for a deep learning neural network, and may include a multiplication accumulator 11 and a buffer 12 as shown in FIG. 10 . A configuration including the multiplication accumulator 11 or the multiplication accumulator 11 and the buffer 12 may be a hardware configuration implemented with various circuits. However, the hardware configuration of the multiplication accumulator 11, that is, the first to third operation units 100, 200, and 300 may be a software configuration, in which case information on the software is stored in the memory 40. It can be stored and operated according to the control of the control unit 50. In addition, the neural network processing unit 10 or the multiplication accumulator 11 may be a hardware component separately provided in the control unit 50.

곱셈 누산기(11)는 곱셈 누산에 대한 연산을 수행하는 구성으로서, 제1 연산부 내지 제3 연산부(100, 200, 300)를 포함할 수 있다.The multiplication accumulator 11 is a component that performs an operation on multiplication and accumulation, and may include first to third operation units 100 , 200 , and 300 .

도 11은 제1 연산부(100)의 블록 구성도를 나타내며, 도 12 및 도 13은 제1 연산부(100)의 동작에 대한 다양한 예를 나타낸다.FIG. 11 shows a block diagram of the first calculation unit 100, and FIGS. 12 and 13 show various examples of operations of the first calculation unit 100.

제1 연산부(100)는 제1 연산 방법, 즉 팝카운트(pop-count)에 기반한 처리를 수행하는 구성으로서, 도 11 내지 도 13에 도시된 바와 같이, 인코더(110), 팝카운터(120) 및 곱셈-누산 연산부(130)를 포함할 수 있다. 즉, 제1 연산부(100)는 반복적인 곱셈 연산을 간단한 팝카운트 연산과 상수 곱셈 연산으로 대체하는 구조를 가질 수 있다.The first operation unit 100 is a component that performs processing based on a first operation method, that is, a pop-count, and as shown in FIGS. 11 to 13, the encoder 110 and the pop-counter 120 and a multiplication-accumulation operation unit 130 . That is, the first operation unit 100 may have a structure in which a repetitive multiplication operation is replaced with a simple pop count operation and a constant multiplication operation.

인코더(110)는 입력 데이터들의 곱셈, 즉 가중치(W)들과 입력 값(A)들 간의 곱셈(제1 곱셈)들에 대해 각각, 제1 곱셈 결과 값들의 종류에 따른 원-핫 인코딩(one-hot encoding)의 코드들을 생성한다. 즉, 각 제1 곱셈에 대해, 로드(load)가 큰 곱셈기를 이용한 곱셈 연산을 수행하지 않고, 단지 그 가중치(W)의 비트 종류와 그 입력 값(A)의 비트 종류에 따라, 그 제1 곱셈의 종류(즉, 제1 곱셈 결과 값의 종류)에 매칭(matching)되는 원-핫 인코딩 코드를 생성하는 것이다.The encoder 110 performs one-hot encoding (one -hot encoding) generate codes. That is, for each first multiplication, a multiplication operation using a multiplier having a large load is not performed, but according to the bit type of the weight W and the bit type of the input value A, the first multiplication operation is not performed. To generate a one-hot encoding code that matches the type of multiplication (that is, the type of the first multiplication result value).

구체적으로, 가중치(W) 및 입력 값(A)의 비트 개수에 따라, 유한한 제1 곱셈 결과 값 종류의 개수도 결정되며, 그 유한한 종류의 각 제1 곱셈 결과 값은 서로 다른 상수 값을 가진다. 또한, 가중치(W) 및 입력 값(A)의 비트 종류에 따라, 제1 곱셈 결과 값의 종류가 매칭될 수 있으며, 매칭된 제1 곱셈 결과 값 종류에 따라 원-핫 인코딩 코드를 생성할 수 있다. Specifically, the number of finite types of first multiplication result values is also determined according to the weight (W) and the number of bits of the input value (A), and each of the finite types of first multiplication result values has a different constant value. have In addition, the type of the first multiplication result value may be matched according to the bit type of the weight W and the input value A, and a one-hot encoding code may be generated according to the matched type of the first multiplication result value. there is.

즉, 원-핫 인코딩 코드는 제1 곱셈 결과 값 종류의 개수만큼의 비트 개수를 가질 수 있다. 이때, 제1 곱셈이 해당하는 그 결과 값의 종류에 대한 비트 자리에 대해서만 1의 비트를 부여하고, 제1 곱셈이 해당하지 않는 나머지 결과 값 종류에 대한 비트 자리에 대해서는 0의 비트를 부여함으로써, 각 제1 곱셈을 원-핫 인코딩 코드로 표현할 수 있다.That is, the one-hot encoding code may have as many bits as the number of first multiplication result value types. At this time, by assigning a bit of 1 only to the bit position for the type of the result value to which the first multiplication corresponds, and assigning a bit of 0 to the bit position for the remaining type of result value to which the first multiplication does not correspond, Each first multiplication can be expressed as a one-hot encoding code.

예를 들어, 도 12 및 도 13에 도시된 바와 같이, 가중치(W)들 및 입력 값(A)들이 각각 2-bit를 가지는 경우, 그 결과 값은 0을 제외하고 1, 2, 3, 4, 6 및 9의 6개 종류를 가진다. 이때, 1, 2, 3, 4, 6 및 9의 제1 곱셈 결과 값은 서로 다른 상수 값을 가진다. 즉, 제1 곱셈 결과 값 종류인 1, 2, 3, 4, 6 및 9의 개수인 6만큼 6개 비트 자리를 마련하고, 2-bit인 가중치(W) 및 입력 값(A)의 종류에 따라, 그 제1 곱셈 결과 값의 종류를 구분하여, 마련된 각 비트 자리에 대해 1 또는 0의 비트를 부여한다.For example, as shown in FIGS. 12 and 13, when the weights (W) and the input values (A) each have 2-bits, the resulting values are 1, 2, 3, and 4 excluding 0. , 6 and 9 have six types. At this time, the result values of the first multiplication of 1, 2, 3, 4, 6, and 9 have different constant values. That is, 6 bit places are provided as many as 6, which is the number of 1, 2, 3, 4, 6, and 9, which are the types of the first multiplication result value, and 2-bit weight (W) and input value (A) type Accordingly, the type of the first multiplication result value is distinguished, and a bit of 1 or 0 is assigned to each prepared bit position.

즉, 가중치(W) 및 입력 값(A)의 곱셈인 제1 곱셈이 [01] × [01]인 경우, 1의 결과 값 종류의 비트 자리에만 1을 부여하여 [100000]의 코드를 생성하고, 제1 곱셈이 [01] × [10] 또는 [10] × [01]인 경우, 2의 결과 값 종류의 비트 자리에만 1을 부여하여 [010000]의 코드를 생성한다. 또한, 제1 곱셈이 [01] × [11] 또는 [11] × [01]인 경우, 3의 결과 값 종류의 비트 자리에만 1을 부여하여 [001000]의 코드를 생성하고, 제1 곱셈이 [10] × [10]인 경우, 4의 결과 값 종류의 비트 자리에만 1을 부여하여 [000100]의 코드를 생성한다. 또한, 제1 곱셈이 [10] × [11] 또는 [11] × [10]인 경우, 6의 결과 값 종류의 비트 자리에만 1을 부여하여 [000010]의 코드를 생성하고, 제1 곱셈이 [11] × [11]인 경우, 9의 결과 값 종류의 비트 자리에만 1을 부여하여 [000001]의 코드를 생성한다. 이와 같은 방식으로, 각 제1 곱셈에 대해, 그 가중치(W) 및 입력 값(A)의 종류에 따라, 그 결과 값의 종류를 구분하여, 원-핫 인코딩 코드를 생성할 수 있다.That is, when the first multiplication, which is the multiplication of the weight (W) and the input value (A) is [01] × [01], 1 is assigned only to the bit digit of the type of the result value of 1 to generate a code of [100000] , If the first multiplication is [01] × [10] or [10] × [01], a code of [010000] is generated by assigning 1 only to the bit position of the type of the result value of 2. In addition, when the first multiplication is [01] × [11] or [11] × [01], a code of [001000] is generated by assigning 1 only to the bit digit of the type of the result value of 3, and the first multiplication is In the case of [10] × [10], a code of [000100] is generated by assigning 1 only to the bit position of the type of the result value of 4. In addition, when the first multiplication is [10] × [11] or [11] × [10], a code of [000010] is generated by assigning 1 only to the bit position of the result value type of 6, and the first multiplication is In the case of [11] × [11], a code of [000001] is generated by assigning 1 only to the bit digit of the type of the result value of 9. In this way, for each first multiplication, a one-hot encoding code can be generated by classifying the type of result value according to the type of weight W and input value A.

물론, 제1 곱셈의 결과 값이 0인 경우에 대해서도 그 비트 자리를 부여하여 원-핫 인코딩 코드를 생성할 수 있다. 다만, 도 12 및 도 13에 도시된 바와 같이, 제1 곱셈의 결과 값이 0인 경우에 대해서는 원-핫 인코딩 코드와 별도로 그에 대해 표시할 수 있다. 이는 그 결과 값이 0인 제1 곱셈의 경우에 대해서는 곱셈 및 누산 등의 연산이 필요 없기 때문에, 해당 경우를 별도로 분리하여 표시하는 것이다.Of course, even when the result value of the first multiplication is 0, a one-hot encoding code may be generated by assigning the corresponding bit position. However, as shown in FIGS. 12 and 13, when the result value of the first multiplication is 0, it can be displayed separately from the one-hot encoding code. This is because operations such as multiplication and accumulation are not required for the first multiplication case in which the result value is 0, so the corresponding case is separately displayed.

가령, 도 12 및 도 13에 도시된 바와 같이, 가중치(W) 및 입력 값(A)의 각 값들에 대해, 각각 0(zero)인지 0이 아닌지(non-zero)인지를 index로 미리 표시(0인 경우에 0으로 표시)한 다음, 해당 index 중에 하나라도 0이라면 해당 제1 곱셈은 그 결과 값이 0인 것으로 Non-zero라 구분된 영역에 별도로 표시한다. 즉, Non-zero 영역이 0인 제1 곱셈은 그 결과 값이 0인 경우이다. 반면, Non-zero 영역이 1인 제1 곱셈은 그 결과 값이 0이 아닌 경우이며, 해당 제1 곱셈에 대해 그 가중치(W) 및 입력 값(A)의 비트 종류에 따라, 그 제1 곱셈 결과 값 종류를 구별하여, 원-핫 인코딩 코드를 생성한다.For example, as shown in FIGS. 12 and 13, for each value of the weight (W) and the input value (A), whether it is 0 (zero) or not (non-zero) is indicated in advance by an index ( If it is 0, it is displayed as 0), and then, if at least one of the corresponding indices is 0, the result of the first multiplication is 0, and is separately displayed in a non-zero area. That is, the first multiplication in which the non-zero area is 0 is a case where the result value is 0. On the other hand, the first multiplication in which the non-zero area is 1 is when the result value is not 0, and for the first multiplication, according to the weight (W) and the bit type of the input value (A), the first multiplication By distinguishing the result value type, one-hot encoding code is generated.

도 14는 효율적인 팝카운트를 위해, 단계적으로 원-핫 인코딩 코드를 생성 과정을 나타낸다.14 shows a step-by-step process of generating one-hot encoding codes for efficient pop counting.

한편, 제1 연산부(100)에서 가장 큰 비중을 차지하는 부분은 원-핫 인코딩 값을 찾아서 팝카운트를 하는 부분으로, 이 부분의 효율적인 구현이 매우 중요하다. 이에 따라, zero/non-zero를 먼저 구분하고 단계적으로 절반씩 구분해가며 원-핫 인코딩 값을 생성하면, 팝카운트 연산의 효율적인 구현이 가능하다.Meanwhile, the part that occupies the largest portion of the first calculation unit 100 is a part that finds a one-hot encoding value and performs a pop count, and efficient implementation of this part is very important. Accordingly, if one-hot encoding values are generated by dividing zero/non-zero first and then halving in stages, it is possible to efficiently implement the pop count operation.

가령, 도 14에 도시된 바와 같이, 인코더(110)는 Non-zero 영역에 대해 구분(즉, 각 제1 곱셈에 대해 그 결과 값이 0인지 여부를 구분)하는 제1 구분을 먼저 수행한 후, Non-zero 영역이 1인 각 제1 곱셈(즉, 그 결과 값이 non-zero인 것으로 구분된 각 제1 곱셈)에 대해서만 그 결과 값의 종류를 제2 구분을 수행할 수 있다.For example, as shown in FIG. 14, the encoder 110 first performs a first division to distinguish a non-zero region (that is, to determine whether the result value is 0 for each first multiplication), and then , the type of the result value may be secondly classified only for each first multiplication in which the non-zero region is 1 (ie, each first multiplication in which the result value is classified as non-zero).

또한, 제2 구분에 대해서도, 인코더(110)는 non-zero로 구분된 각 제1 곱셈에 대해, 가중치(W) 및 입력 값(A)의 최상위비트(most significant bit; MSB)를 기준으로 2개 그룹으로 그 결과 값의 종류를 구분하는 제2-1 구분을 수행한 후, 2개 그룹에 대해 각 그룹에 속한 제1 곱셈에 대해, 그 결과 값의 종류를 구분하는 제2-2 구분을 수행할 수 있다.In addition, for the second division, the encoder 110 calculates 2 based on the most significant bit (MSB) of the weight (W) and the input value (A) for each first multiplication divided by non-zero. After performing the 2-1 division to classify the type of the result value into two groups, for the first multiplication belonging to each group for the two groups, the 2-2 division to classify the type of the result value can be done

예를 들어, 가중치(W) 및 입력 값(A)이 곱셈이 [00] × [00], [01] × [00], [00] × [01] 등인 제1 곱셈의 경우, 가중치(W)의 비트가 모두 0이거나 입력 값(A)의 비트가 모두 0이므로(또는, 그 index 중에 어느 하나가 0이므로), 그 결과 값은 0으로 제1 구분할 수 있다.For example, in the case of the first multiplication of [00] × [00], [01] × [00], [00] × [01], etc., the weight (W) and the input value (A), the weight (W Since all bits of ) are 0 or all bits of the input value (A) are 0 (or because any one of the indexes is 0), the resulting value can be first identified as 0.

또한, 가중치(W) 및 입력 값(A)의 곱셈이 [01] × [01]인 제1 곱셈의 경우, 가중치(W) 및 입력 값(A)의 비트가 모두 0이 아니므로(또는, 그 index가 모두 1이므로), 그 결과 값이 0이 아닌 것으로 제1 구분할 수 있다. 이후, [01] 및 [01]의 각 MBS 중에 적어도 하나가 0이므로, 그 결과 값이 1, 2 및 3 중에 하나인 것으로 제2-1 구분할 수 있다. 이후, [01] 및 [01]의 나머지 비트 등의 종류에 따라, 그 결과 값이 1인 것으로 제2-2 구분할 수 있다.In addition, in the case of the first multiplication where the multiplication of the weight W and the input value A is [01] × [01], both the bits of the weight W and the input value A are not 0 (or, Since all of the indices are 1), it is possible to first distinguish that the resulting value is not 0. Then, since at least one of each MBS of [01] and [01] is 0, the result value is one of 1, 2, and 3, and 2-1 discrimination can be made. Thereafter, according to the type of [01] and the remaining bits of [01], the result value is 1 and can be classified as 2-2.

또한, 가중치(W) 및 입력 값(A)의 곱셈이 [11] × [10]인 제1 곱셈의 경우, 가중치(W) 및 입력 값(A)의 비트가 모두 0이 아니므로(또는, 그 index가 모두 1이므로), 그 결과 값이 0이 아닌 것으로 제1 구분할 수 있다. 이후, [11] 및 [10]의 각 MBS가 모두 1이므로, 그 결과 값이 4, 6 및 9 중에 하나인 것으로 제2-1 구분할 수 있다. 이후, [11] 및 [10]의 나머지 비트 등의 종류에 따라, 그 결과 값이 3인 것으로 제2-2 구분할 수 있다.In addition, in the case of the first multiplication where the multiplication of the weight (W) and the input value (A) is [11] × [10], both the bits of the weight (W) and the input value (A) are not 0 (or, Since all of the indices are 1), it is possible to first distinguish that the resulting value is not 0. Then, since each MBS of [11] and [10] is all 1, the result value is one of 4, 6, and 9, and 2-1 can be distinguished. Thereafter, according to the type of the remaining bits of [11] and [10], the result value is 3 and can be classified as 2-2.

즉, 가중치(W) 및 입력 값(A)의 각 비트 자리의 비트 종류에 따른 제1 및 제2 구분(제2-1 및 제2-2 구분)과 같은 단계적인 처리를 수행하는 경우, 인코더(110)는 보다 효율적으로 팝카운트가 가능한 원-핫 인코딩 코드를 생성할 수 있는 이점이 있다. 가령, 인코더(110)은 이러한 단계적인 처리가 하드웨어 구성 또는 소프트웨어 구성으로 구현될 수 있다. 특히, 이러한 단계적인 처리가 반영된 하드웨어 구성의 경우, 보다 빠르고 효율적인 원-핫 인코딩 코드의 생성이 가능한 이점이 있다.That is, when performing step-by-step processing such as first and second division (2-1 and 2-2 division) according to the bit type of each bit digit of the weight (W) and the input value (A), the encoder (110) has an advantage of generating a one-hot encoding code capable of more efficiently pop counting. For example, the encoder 110 may implement such step-by-step processing as a hardware configuration or a software configuration. In particular, in the case of a hardware configuration in which such step-by-step processing is reflected, there is an advantage in that faster and more efficient one-hot encoding codes can be generated.

다만, 본 발명은 이러한 단계적 수행에 한정되는 것은 아니며, 인코더(110)가 A 및 W의 각 비트 자리를 병렬적으로 매칭 처리하여, 그 결과 값 종류를 구분하여 각 제1 곱셈에 대한 원-핫 인코딩 코드를 생성하는 병렬 처리 구조를 가질 수도 있다.However, the present invention is not limited to such step-by-step execution, and the encoder 110 performs matching processing on each bit digit of A and W in parallel, classifies the resulting value type, and one-hot for each first multiplication. It may have a parallel processing structure that generates encoding codes.

팝카운터(120)는 인코더(110)에서 생성된 각 원-핫 인코딩 코드에 대해 팝카운트(pop-count)를 수행한다. 이때, 팝카운트는 대상 집합인 각 원-핫 인코딩 코드에 대해, 그 비트 자리 별로(즉, 제1 곱셈 결과 값의 종류 별로) 해당 자리에 부여된 비트들에서 0을 제외한 수(즉, 1)에 대해 팝카운트 처리하여, 각 자리에 대한 카운트 값(즉, 팝카운트 값)을 생성한다.The pop-counter 120 performs a pop-count on each one-hot encoding code generated by the encoder 110. At this time, the pop count is a number excluding 0 (ie, 1) from the bits assigned to the corresponding position for each one-hot encoding code that is the target set (ie, for each type of the first multiplication result value) for each bit position (ie, for each type of the first multiplication result value). By performing pop count processing on , a count value for each digit (i.e., a pop count value) is generated.

예를 들어, 제1 곱셈 결과 값의 종류가 1, 2, 3, 4, 6 및 9이고, 인코더(110)에서 다음의 표 1과 같은 16개 원-핫 인코딩 코드를 생성할 수 있다(이하, “제1 예시”라 지칭함).For example, if the types of the first multiplication result values are 1, 2, 3, 4, 6, and 9, the encoder 110 can generate 16 one-hot encoding codes as shown in Table 1 below (hereinafter , referred to as "the first example").

16개 원-핫 인코딩 코드16 one-hot encoding codes 각 제1 곱셈 결과 값 종류의 팝카운트 값Pop count value of each first multiplication result value type 제1 종류
(1)
first kind
(One)
제2 종류
(2)
2nd kind
(2)
제3 종류
(3)
3rd kind
(3)
제4 종류
(4)
4th kind
(4)
제5 종류
(6)
5th kind
(6)
제6 종류
(9)
6th kind
(9)
[100000], [010000], [100000], [010000],
[100000], [010000], [100000], [001000],
[000100], [000010], [000001], [000100],
[000010], [000100], [000001], [000100]
[100000], [010000], [100000], [010000],
[100000], [010000], [100000], [001000],
[000100], [000010], [000001], [000100],
[000010], [000100], [000001], [000100]
44 33 1One 44 22 22

이러한 제1 예시에서, 제1 내지 제6 종류에 따른 팝카운트 값은 각각 4, 3, 1, 4, 2 및 2이다. 즉, 이러한 팝카운트 값을 통해, 16개의 제1 곱셈에서, 제1 종류가 4번, 제2 종류가 3번, 제3 종류가 1번, 제4 종류가 4번, 제5 종류가 2번, 제6 종류가 2번 반복됨을 알 수 있다. 곱셈-누산 연산부(130)는 팝카운터(120)에서 도출된 팝카운트 값을 기반으로, 제1 곱셈 결과 값들을 누산한다. 즉, 곱셈-누산 연산부(130)는 서로 다른 상수 값인 각 종류의 제1 곱셈 결과 값과 각 카운트 값 간의 상수 곱셈(제2 곱셈)에 대한 결과 값들을 누산할 수 있다.In this first example, the pop count values according to the first to sixth types are 4, 3, 1, 4, 2, and 2, respectively. That is, through these pop count values, in the 16 first multiplications, the first kind is 4 times, the second kind is 3 times, the third kind is 1 time, the fourth kind is 4 times, and the fifth kind is 2 times. , it can be seen that the sixth kind is repeated twice. The multiplication-accumulation operator 130 accumulates first multiplication result values based on the pop count value derived from the pop counter 120 . That is, the multiplication-accumulation operation unit 130 may accumulate result values for constant multiplication (second multiplication) between the first multiplication result values of each type, which are different constant values, and each count value.

즉, 제1 예시에서, 곱셈-누산 연산부(130)는, 제1 종류의 값인 1과 그 팝카운트 값인 4 간의 제2 곱셈 결과 값(즉, 1×4=4)과, 제2 종류의 값인 2와 그 팝카운트 값인 2 간의 제2 곱셈 결과 값(즉, 2×3=6)과, 제3 종류의 값인 3과 그 팝카운트 값인 1 간의 제2 곱셈 결과 값(즉, 3×1=3)과, 제4 종류의 값인 4와 그 팝카운트 값인 4 간의 제2 곱셈 결과 값(즉, 4×4=16)과, 제5 종류의 값인 6과 그 팝카운트 값인 2 간의 제2 곱셈 결과 값(즉, 6×2=12)과, 제6 종류의 값인 9와 그 팝카운트 값인 2 간의 제2 곱셈 결과 값(즉, 9×2=18)을 각각 누산한다. 그 누산 결과 값은 4+6+3+16+12+18=59 이다.That is, in the first example, the multiplication-accumulation operation unit 130 calculates the second multiplication result value between 1, which is the first type of value, and 4, which is the pop count value (ie, 1×4=4), and the second type of value, The second multiplication result value between 2 and its pop count value 2 (i.e., 2 × 3 = 6) and the second multiplication result value between the third kind of value 3 and its pop count value 1 (i.e., 3 × 1 = 3 ), the second multiplication result between the fourth type of value, 4, and its pop count value, 4 (ie, 4×4 = 16), and the second multiplication result between the fifth type of value, 6, and its pop count value, 2. (ie, 6 × 2 = 12) and the second multiplication result value (ie, 9 × 2 = 18) between 9, which is the sixth type of value, and 2, which is the pop count value, are respectively accumulated. The accumulated result is 4+6+3+16+12+18=59.

이때, 곱셈-누산 연산부(130)는 제1 곱셈 결과 값(상수 값)과 카운트 값(변수 값) 간에 곱셈 연산(상수 값 × 변수 값)을 수행하는 상수 곱셈기(131)를 이용하여, 제2 곱셈 결과 값을 도출할 수 있다. 또한, 곱셈-누산 연산부(130)는 제1 곱셈 결과 값(상수 값)의 비트에 대한 시프트(shift)를 수행하는 시프터(shifter)(132)를 이용하여, 제2 곱셈 결과 값을 도출할 수 있다. 다만, 시프터(132)는 단순히 그 상수 값의 비트를 왼쪽으로 시프트함으로써 제2 곱셈 결과 값을 도출하거나, 그 상수 값의 비트를 왼쪽으로 시프트하면서 그 끝자리 비트에 1을 부여함으로써 제2 곱셈 결과 값을 도출할 수 있다. 이러한 시프트 수행 시 끝자리 비트에 대해 1을 부여하는 작용은 상수 값 및 변수 값의 비트 종류에 따라 선택될 수 있다.At this time, the multiplication-accumulation operation unit 130 uses a constant multiplier 131 that performs a multiplication operation (constant value × variable value) between the first multiplication result value (constant value) and the count value (variable value), Multiplication results can be derived. In addition, the multiplication-accumulation operation unit 130 may derive a second multiplication result value by using a shifter 132 that shifts bits of the first multiplication result value (constant value). there is. However, the shifter 132 derives the second multiplication result value by simply shifting the bit of the constant value to the left, or shifts the bit of the constant value to the left and assigns 1 to the last bit of the constant value to derive the second multiplication result value. can be derived. When performing such a shift, an action of giving 1 to the last bit may be selected according to the bit type of the constant value and variable value.

도 12에서, 곱셈-누산 연산부(130)는 제3 종류(제1 곱셈 결과 값이 3), 제5 종류(제1 곱셈 결과 값이 6) 및 제6 종류(제1 곱셈 결과 값이 9)에 대해 상수 곱셈기(131)를 이용하였고, 나머지 제1 종류(제1 곱셈 결과 값이 1), 제2 종류(제1 곱셈 결과 값이 2) 및 제4 종류(제1 곱셈 결과 값이 4)에 대해 시프터(132)를 이용함으로써, 각 제2 곱셈 결과 값을 도출하였으나, 본 발명이 이에 한정되는 것은 아니다.In FIG. 12, the multiplication-accumulation unit 130 has a third type (the first multiplication result value is 3), a fifth type (the first multiplication result value is 6), and a sixth type (the first multiplication result value is 9). The constant multiplier 131 was used for , and the rest of the first type (the first multiplication result value is 1), the second type (the first multiplication result value is 2), and the fourth kind (the first multiplication result value is 4) By using the shifter 132 for , each second multiplication result value was derived, but the present invention is not limited thereto.

예를 들어, 제1 종류의 상수 값(제1 곱셈 결과 값)은 1, 즉 [01]이고, 그 카운트 값이 3인 경우, 그 제2 곱셈 결과 값은 1×3=3이다. 이를 위해, 제1 종류의 비트인 [01]을 왼쪽으로 한번 시프트하면서 그 끝자리에 1을 부여함으로써, [11]인 3의 제2 곱셈 결과 값을 도출할 수 있다.For example, when the first type of constant value (first multiplication result value) is 1, that is, [01], and the count value is 3, the second multiplication result value is 1×3=3. To this end, by shifting [01], which is the first type of bit, to the left once and assigning 1 to the last digit, the resultant value of the second multiplication of [11], which is 3, can be derived.

예를 들어, 제2 종류의 상수 값은 2, 즉 [10]이고, 그 카운트 값이 2인 경우, 그 제2 곱셈 결과 값은 2×2=4이다. 이를 위해, 제2 종류의 비트인 [10]을 왼쪽으로 한번 시프트함으로써, [100]인 4의 제2 곱셈 결과 값을 도출할 수 있다.For example, if the constant value of the second type is 2, that is, [10], and the count value is 2, the second multiplication result value is 2×2=4. To this end, by shifting [10], which is the second type of bit, to the left once, a value resulting from the second multiplication of 4, which is [100], can be derived.

또한, 곱셈-누산 연산부(130)는 입력들에 대한 누산 작용을 수행하는 가산기 트리(adder tree)(133)를 이용하여, 상수 곱셈기(131) 또는 시프터(132)에 의해 도출된 제2 곱셈 결과 값들을 누산할 수 있다.In addition, the multiplication-accumulation operation unit 130 uses an adder tree 133 that performs an accumulation operation on inputs, and the second multiplication result derived by the constant multiplier 131 or shifter 132 Values can be accumulated.

한편, 도 13에서, 곱셈-누산 연산부(130)는 제2 곱셈 결과 값들이 저장된 순람표(Lookup table; LUT)(134)를 이용하여, 제2 곱셈 결과 값들을 도출할 수도 있다. 즉, 순람표에는 제1 곱셈 결과 값(상수 값)과 카운트 값(변수 값)의 제2 곱셈 결과 값들이 저장되어 있다. 이러한 순람표(134)에 카운트 값(변수 값)만을 입력하거나, 제1 곱셈 결과 값(상수 값) 및 카운트 값(변수 값)을 입력하면, 곱셈 연산 없이도 그와 매칭되는 제2 곱셈 결과 값을 획득할 수 있다. 다만, 이 경우에도, 가산기 트리(133)를 이용하여, 순람표(134)를 통해 획득한 제2 곱셈 결과 값들을 누산할 수 있다. 다만, 본 발명이 이에 한정되는 것은 아니며, 곱셈-누산 연산부(130)는 제2 곱셈 결과 값이 저장된 순람표(134)를 기반으로, 분산 산술(distributed arithmetic)을 수행함으로써 제2 곱셈 결과 값들을 누산할 수도 있다.Meanwhile, in FIG. 13 , the multiplication-accumulation operation unit 130 may derive second multiplication result values using a lookup table (LUT) 134 in which the second multiplication result values are stored. That is, the first multiplication result value (constant value) and the second multiplication result value of the count value (variable value) are stored in the lookup table. If only the count value (variable value) is entered in this lookup table 134, or if the first multiplication result value (constant value) and count value (variable value) are entered, the second multiplication result value that matches it without a multiplication operation can be obtained However, even in this case, the second multiplication result values obtained through the lookup table 134 may be accumulated using the adder tree 133 . However, the present invention is not limited thereto, and the multiplication-accumulation operation unit 130 calculates the second multiplication result values by performing distributed arithmetic based on the lookup table 134 in which the second multiplication result values are stored. It may leak.

즉, 제1 연산부(100)는 가중치(W)와 입력 값(A)의 조합을 보고 0이 아닌 곱셈 결과(가령, 1,2,3,4,6,9)와 매칭하는 회로를 통해, 현재 가중치와 입력 값에서 어떤 곱셈 결과들이 있는지 매칭(matching)하여, 원-핫 인코딩(one-hot encoding)을 생성한다. 이후, 제1 연산부(100)는 원-핫 인코딩 값들에 대해 팝카운트를 수행한다. 이후, 제1 연산부(100)는 팝카운트를 통해 얻은 각 제1 곱셈의 반복 횟수와 이미 알고 있는 그 제1 곱셈 결과 값을 곱하는 반복 횟수 × 제1 곱셈 결과 값(미리 정해진 상수 값)의 상수 곱셈 연산을 하고, 이를 누적함으로써 도 8에 도시된 곱셈-누산의 연산과 동일한 결과를 얻을 수 있다.That is, the first operation unit 100 looks at the combination of the weight W and the input value A, and through a circuit that matches a non-zero multiplication result (eg, 1,2,3,4,6,9), One-hot encoding is generated by matching what multiplication results are in the current weight and input value. Then, the first operation unit 100 performs a pop count on the one-hot encoding values. Thereafter, the first operation unit 100 multiplies the number of repetitions of each first multiplication obtained through the pop count by the known first multiplication result value × constant multiplication of the first multiplication result value (predetermined constant value). By performing the calculation and accumulating it, the same result as the multiplication-accumulation operation shown in FIG. 8 can be obtained.

특히, 상수 곱셈 연산은 곱셈의 한쪽 피연산자(operand)가 상수 값이기 때문에, 하드웨어 구현 시 일반적인 곱셈 연산과 비교하여, 매우 작은 면적과 전력을 소모하는 이점이 있다. 또한, 원-핫 인코딩을 찾는 매칭 연산과 팝카운트 연산 역시 기존 연산에 비해 하드웨어 구현이 효율적인 연산들이다. 따라서, 도 12 및 도 13에 도시된 바와 같은 하드웨어 구성을 구현하면, 도 8에 도시된 종래의 곱셈-누산 연산에 기반한 하드웨어보다 전반적으로 그 전력 효율이 뛰어난 이점을 가질 수 있다.In particular, the constant multiplication operation has an advantage of consuming a very small area and power compared to a general multiplication operation when implemented in hardware because one operand of the multiplication is a constant value. In addition, matching operation and pop count operation for finding one-hot encoding are also operations that are more efficient in hardware implementation than conventional operations. Therefore, implementing the hardware configuration as shown in FIGS. 12 and 13 may have an advantage in overall power efficiency superior to hardware based on the conventional multiply-accumulate operation shown in FIG. 8 .

도 17은 4-bit × 4-bit 정밀도에서 제1 곱셈 결과 값들의 반복 확률 분포에 대한 시뮬레이션 결과의 일 예를 나타낸다.17 shows an example of a simulation result for a repetition probability distribution of first multiplication result values in 4-bit × 4-bit precision.

한편, 제1 연산 방법에 따라 팝카운트 기반 연산으로 모든 연산을 수행할 경우, 상대적으로 높은 비트-정밀도에서는 그 개수가 상당히 많은 제1 곱셈 결과 값 종류를 모두 커버해야 하므로, 팝카운트 오버헤드가 급격히 증가한다. 또한, 낮은 비트-정밀도 내에서도, 도 17에 도시된 바와 같이, 상대적으로 반복 확률이 높은 제1 곱셈 결과 값 종류와, 상대적으로 반복 확률이 낮은 곱셈 결과 값 종류가 극명하게 나눠지므로, 이를 충분히 활용하고 높은 비트-정밀도에서도 반복되는 제1 곱셈을 제거하는 효과를 적용할 수 있는 확장성 있는 하드웨어 구조 등의 구성이 필요하다.On the other hand, when all operations are performed by pop count-based operation according to the first operation method, pop count overhead is rapidly increasing because all types of first multiplication result values, the number of which is quite large, must be covered in a relatively high bit-precision. It increases. In addition, even within low bit-precision, as shown in FIG. 17, the first multiplication result value type with a relatively high repetition probability and the multiplication result value type with a relatively low repetition probability are clearly divided, making full use of this A configuration such as a scalable hardware structure capable of applying the effect of removing the repeated first multiplication even at high bit-precision is required.

이에 따라, 제1 곱셈들에 대해, 그 결과 값 종류의 반복 확률에 따라 다수의 데이터로 구분할 수 있다. 즉, 반복 확률이 상대적으로 높아 자주 반복되는 데이터(제1 데이터)에 속하는 제1 곱셈들에 대해서는 제1 연산부(100)에서 처리한다. 반면, 반복 확률이 상대적으로 낮아 자주 반복되지 않는 데이터(제2 데이터)에 속하는 제1 곱셈들에 대해서는 제2 연산부(200)에서 처리한다. 다만, 이러한 제1 및 제2 데이터에 대해서는 사전에 통계적 처리에 의해 그 통계 값이 메모리(40)에 기 저장되어 있는 것이 바람직하다.Accordingly, for the first multiplications, a plurality of data may be divided according to the repetition probability of the resulting value type. That is, the first multiplications belonging to frequently repeated data (first data) having a relatively high repetition probability are processed by the first operation unit 100 . On the other hand, the second operation unit 200 processes first multiplications belonging to data (second data) that is not frequently repeated due to a relatively low repetition probability. However, it is preferable that statistical values of the first and second data are pre-stored in the memory 40 through statistical processing in advance.

다음으로, 제2 연산부(200)는 제1 연산부(100)와 다른 곱셈-누산의 연산을 수행하는 구성이다. 가령, 제2 연산부(200)는 제2 연산 방법을 수행하는 구성일 수 있다. 이 경우, 제2 연산부(200)는, 종래 기술과 같이, 제1 곱셈에 대해, 해당 각 가중치(W)와 해당 각 입력 값(A) 간의 곱셈 연산과, 그 곱셈 연산의 결과 값에 대한 누산 연산을 각각 수행할 수 있다. 예를 들어, 이러한 각각의 연산을 위해, 제2 연산부(200)는 도 6 또는 도 7의 구조를 가질 수 있으나, 이에 한정되는 것은 아니다.Next, the second arithmetic unit 200 is a component that performs a multiplication-accumulation operation different from that of the first arithmetic unit 100 . For example, the second calculation unit 200 may be a component that performs a second calculation method. In this case, as in the prior art, the second operation unit 200 performs a multiplication operation between each corresponding weight W and each corresponding input value A for the first multiplication, and accumulates the resultant value of the multiplication operation. Each operation can be performed. For example, for each of these operations, the second operation unit 200 may have the structure of FIG. 6 or 7, but is not limited thereto.

예를 들어, 입력 데이터에서, W가 W1, W2, W3 및 W4이고, A가 A1, A2, A3 및 A4인 경우, 제2 연산부(200)는 W1×A1, W2×A2, W3×A3 및 W4×A4의 각각에 대한 제1 곱셈의 연산과, 이들 그 제1 곱셈 결과 값들에 대한 누적 연산(즉, W1×A1 + W2×A2 + W3×A3 + W4×A4)을 각각 수행하도록 구성될 수 있다.For example, in the input data, when W is W 1 , W 2 , W 3 , and W 4 , and A is A 1 , A 2 , A 3 , and A 4 , the second operation unit 200 calculates W 1 ×A 1 , W 2 ×A 2 , W 3 ×A 3 and W 4 ×A 4 , and an accumulation operation on the first multiplication result values (ie, W 1 ×A 1 + W 2 ×A 2 + W 3 ×A 3 + W 4 ×A 4 ).

제3 연산부(300)는 제1 및 제2 연산부(100, 200)의 결과 값들을 누산한다. 즉, 제3 연산부(300)는 제1 연산부(100)에서 처리된 제1 데이터에 속한 제1 곱셈들의 누산 결과 값(즉, 제1 데이터의 제1 곱셈 결과 값들에 대한 누산 결과 값)과, 제2 연산부(200)에서 처리된 제2 데이터에 속한 제1 곱셈들의 누산 결과 값(즉, 제2 데이터의 제1 곱셈 결과 값들에 대한 누산 결과 값)을 누산한다.The third arithmetic unit 300 accumulates result values of the first and second arithmetic units 100 and 200 . That is, the third operation unit 300 calculates the accumulated result values of the first multiplications belonging to the first data processed by the first operation unit 100 (ie, the accumulated result values of the first multiplication result values of the first data), Accumulated result values of the first multiplications belonging to the second data processed by the second operation unit 200 (ie, accumulated result values of the first multiplication result values of the second data) are accumulated.

상술한 바와 같이, 본 발명은 전체 입력 데이터를 반복 확률이 높은 제1 데이터와, 반복 확률이 낮은 제2 데이터로 구분함으로써, 구분된 각 데이터의 종류에 따라 각 제1 곱셈에 대해 다양한 곱셈-누산을 수행할 수 있다. 특히, 제1 데이터는 팝카운트-상수 곱셈을 기반으로 제1 연산부(100)에서 수행하여 그 반복 연산을 줄이는 효과를 가질 수 있다. 또한, 제2 데이터와 같이 반복 확률 대비 원-핫 인코딩 생성 오버헤드가 큰 부분은 일반적인 곱셈-누산 기반으로 제2 연산부(200)에서 처리한다.As described above, the present invention divides the entire input data into first data having a high repetition probability and second data having a low repetition probability, so that various multiplication-accumulations are performed for each first multiplication according to the type of each divided data. can be performed. In particular, the first data may be performed in the first operation unit 100 based on pop count-constant multiplication, thereby reducing the number of repetitive operations. In addition, a portion having a large one-hot encoding generation overhead compared to repetition probability, such as the second data, is processed by the second operation unit 200 on a general multiplication-accumulation basis.

이러한 구조를 적용하면, 전체 데이터 중 대부분의 반복 확률(도 17에서 80%)이 일부 제1 곱셈 결과 값 종류에 몰려 있는 데이터가 팝카운트-상수 곱셈 기반의 제1 연산부(100)에서 처리되므로, 그 처리 속도를 향상시키면서 그 소모 전력을 상당히 줄일 수 있다. 또한, 제2 연산부(200)는 기존의 곱셈-누산 기반 하드웨어보다 훨씬 적은 곱셈-누산기(도 17에서 20%)만 있어도 빠른 연산 처리 속도를 유지할 수 있다. 다만, 제1 연산부(100)와 재2 연산부(200) 간의 처리 속도를 동기화하는 제어가 필요할 수 있다.When this structure is applied, most of the repetition probability (80% in FIG. 17) of the entire data is processed in the first operation unit 100 based on pop count-constant multiplication, Its power consumption can be significantly reduced while improving its processing speed. In addition, the second arithmetic unit 200 can maintain a fast processing speed even with a much smaller multiplier-accumulator (20% in FIG. 17) than conventional multiply-accumulate-based hardware. However, control for synchronizing processing speeds between the first calculation unit 100 and the second calculation unit 200 may be required.

버퍼(12)는 곱셈 누산기(11)의 동작, 즉 제1 연산부 내지 제3 연산부(100, 200, 300)의 동작에 필요한 다양한 데이터를 임시 저장하는 메모리로서, 제1 연산부 내지 제3 연산부(100, 200, 300)에 대한 글로벌 버퍼(global buffer)의 기능을 제공할 수 있다. 가령, 버퍼(12)는 제어부(50)와 메모리(40)의 사이에 고속으로 동작하여, 제1 연산부 내지 제3 연산부(100, 200, 300)와 메모리(40) 간의 데이터 전달을 연계할 수 있다. 즉, 버퍼(12)는 제1 연산부(100)로 제1 데이터를 전달할 수 있고, 제2 연산부(200)로 제2 데이터를 전달할 수 있다. 또한, 버퍼(120)는 제3 연산부(300)에서 누산된 결과 값인 제3 데이터를 제3 연산부(300)로부터 전달받을 수 있다.The buffer 12 is a memory for temporarily storing various data necessary for the operation of the multiplication accumulator 11, that is, the operation of the first to third operation units 100, 200, and 300, and is a memory for the first to third operation units 100 , 200, 300) may provide a function of a global buffer. For example, the buffer 12 operates at high speed between the control unit 50 and the memory 40, and data transmission between the first to third operation units 100, 200, and 300 and the memory 40 can be linked. there is. That is, the buffer 12 may transfer first data to the first operation unit 100 and transfer second data to the second operation unit 200 . Also, the buffer 120 may receive third data, which is a result value accumulated by the third operation unit 300 , from the third operation unit 300 .

한편, 신경망 처리부(10)는 프로세서 등의 별도의 자체 제어부(미도시)를 포함할 수 있다. 이러한 제어부는 전자 장치(1)의 제어부(50)의 명령에 따라, 상술한 곱셈 누산기(11) 및 버퍼(12)의 동작을 제어할 수 있으나, 이에 한정되는 것은 아니다.Meanwhile, the neural network processor 10 may include a separate self-controller (not shown) such as a processor. The control unit may control the operations of the multiplication accumulator 11 and the buffer 12 according to a command of the control unit 50 of the electronic device 1, but is not limited thereto.

이하, 본 발명의 다양한 실시예에 따른 딥러닝 신경망의 연산 방법에 대해 설명하도록 한다.Hereinafter, a method for calculating a deep learning neural network according to various embodiments of the present invention will be described.

도 15는 본 발명의 일 실시예에 따른 딥러닝 신경망의 연산 방법의 순서도를 나타낸다.15 is a flowchart of a deep learning neural network calculation method according to an embodiment of the present invention.

본 발명의 일 실시예에 따른 딥러닝 신경망의 연산 방법은, 도 15에 도시된 바와 같이, S101 내지 S103을 포함한다. 이러한 S101 내지 S103는 제어부(50)에 의해 제어될 수 있으며, 상술한 바와 같이 신경망 처리부(10)의 제1 연산부(100)의 동작이 수행되는 단계들일 수 있다.A deep learning neural network calculation method according to an embodiment of the present invention, as shown in FIG. 15, includes S101 to S103. These S101 to S103 may be controlled by the control unit 50, and as described above, may be steps in which the operation of the first calculation unit 100 of the neural network processing unit 10 is performed.

S101은 가중치(W)들과 입력 값(A)들 간의 곱셈(제1 곱셈)들에 대해 각각, 제1 곱셈 결과 값들의 종류에 따른 원-핫 인코딩(one-hot encoding)의 코드들을 생성하는 단계이다. S101 generates one-hot encoding codes according to the types of first multiplication result values for multiplications (first multiplications) between weights W and input values A, respectively. It is a step.

가령, S101에서, 가중치와 입력 값의 비트 종류에 따라, 제1 곱셈 결과 값의 종류를 구분하여 원-핫 인코딩 코드를 생성할 수 있다.For example, in S101, the one-hot encoding code may be generated by distinguishing the type of the first multiplication result value according to the bit type of the weight and the input value.

구체적으로, S101은 제1 곱셈에 대해 그 결과 값이 0(zero)인지 여부를 구분하는 제1 구분 단계와, 그 결과 값이 0이 아닌 것(non-zero)으로 구분된 각 제1 곱셈에 대해 그 나머지의 결과 값 종류로 구분하는 제2 구분 단계와, 제2 구분 단계에서 구분된 결과를 기반으로 원-핫 인코딩 코드를 생성하는 단계를 각각 포함할 수 있다.Specifically, S101 is a first discrimination step for distinguishing whether the resultant value is 0 (zero) for the first multiplication, and for each first multiplication that the resultant value is non-zero (non-zero). and a step of generating one-hot encoding codes based on the results classified in the second classification step.

또한, 제2 구분 단계는, non-zero로 구분된 각 제1 곱셈에 대해, 가중치와 입력 값의 최상위비트(most significant bit)를 기준으로 2개 그룹으로 그 결과 값의 종류를 구분하는 제2-1 단계와, 2개 그룹에 대해 각 그룹에 속한 제1 곱셈에 대해 그 결과 값의 종류를 구분하는 제2-2 구분 단계를 각각 포함할 수 있다.In addition, in the second division step, for each first multiplication divided by non-zero, a second division of the type of the result value into two groups based on the weight and the most significant bit of the input value A -1 step and a 2-2 division step of distinguishing the type of the resulting value for the first multiplication belonging to each group for the two groups may be included, respectively.

즉, S101은 상술한 제1 연산부(100)의 인코더(110)의 동작이 수행되는 단계일 수 있다.That is, S101 may be a step in which the above-described operation of the encoder 110 of the first operation unit 100 is performed.

이후, S102는 S101에서 생성된 각 원-핫 인코딩 코드에 대해 팝카운트(pop-count)를 수행하는 단계이다. 즉, S102는 상술한 제1 연산부(100)의 팝카운터(120)의 동작이 수행되는 단계일 수 있다.Thereafter, S102 is a step of performing a pop-count for each one-hot encoding code generated in S101. That is, S102 may be a step in which the above-described operation of the pop counter 120 of the first calculation unit 100 is performed.

이후, S103은 서로 다른 상수 값인 상기 각 종류의 제1 곱셈 결과 값과 상기 팝카운트의 각 카운트 값 간의 상수 곱셈(제2 곱셈)에 대한 결과 값들을 누산하는 단계이다.Thereafter, S103 is a step of accumulating result values for constant multiplication (second multiplication) between the first multiplication result value of each type, which is a different constant value, and each count value of the pop count.

구체적으로, S103은 제2 곱셈 결과 값들을 도출하는 제1 도출 단계와, 상기 제2 곱셈 결과 값들에 대한 누산 결과 값을 도출하는 제2 도출 단계를 포함할 수 있다.Specifically, S103 may include a first derivation step of deriving second multiplication result values, and a second derivation step of deriving accumulated result values for the second multiplication result values.

가령, 제1 도출 단계는 상수 값과 카운트 값 간에 곱셈 연산을 수행하는 상수 곱셈기를 이용하거나, 상수 값의 비트에 대한 시프트(shift)를 수행하는 시프터(shifter)를 이용하는 단계를 포함할 수 있다. 또한, 제1 도출 단계는 제2 곱셈 결과 값들이 저장된 순람표(Lookup table)을 이용하는 단계를 포함할 수 있다.For example, the first deriving step may include using a constant multiplier performing a multiplication operation between a constant value and a count value, or using a shifter performing a bit shift of the constant value. Also, the first deriving step may include using a lookup table in which second multiplication result values are stored.

또한, 제2 도출 단계는 제2 곱셈 결과 값들 간에 누산 연산을 수행하는 가산기 트리(adder tree)를 이용하는 단계를 포함할 수 있다.Also, the second deriving step may include using an adder tree that performs an accumulation operation between the second multiplication result values.

한편, S103은 제2 곱셈 결과 값들이 저장된 순람표(Lookup table)를 기반으로 분산 산술(distributed arithmetic)을 수행하는 단계를 포함할 수 있다.Meanwhile, S103 may include performing distributed arithmetic based on a lookup table in which second multiplication result values are stored.

즉, S103은 상술한 제1 연산부(100)의 곱셈-누산 연산부(130)의 동작이 수행되는 단계일 수 있다.That is, S103 may be a step in which the operation of the multiplication-accumulation unit 130 of the first operation unit 100 is performed.

도 16은 본 발명의 다른 일 실시예에 따른 딥러닝 신경망의 연산 방법의 순서도를 나타낸다.16 is a flowchart of a deep learning neural network calculation method according to another embodiment of the present invention.

본 발명의 다른 일 실시예에 따른 딥러닝 신경망의 연산 방법은, 도 16에 도시된 바와 같이, S201 내지 S203을 포함한다. 이러한 S201 내지 S203는 제어부(50)에 의해 제어될 수 있으며, 상술한 바와 같이 신경망 처리부(10)의 제1 연산부 내지 제3 연산부(100, 200, 300)에서 수행될 수 있다.A deep learning neural network calculation method according to another embodiment of the present invention, as shown in FIG. 16, includes S201 to S203. These steps S201 to S203 may be controlled by the control unit 50 and may be performed by the first to third operation units 100 , 200 , and 300 of the neural network processing unit 10 as described above.

S201은 각 제1 곱셈 결과 값들의 종류에 대해, 그 반복 확률에 따라 다수의 데이터로 구분하는 단계이다. 이때, 메모리(40)에 기 저장되어 버퍼(12)로 전달된 통계 데이터를 기반으로 다수의 데이터를 구분할 수 있다. 가령, 상대적으로 반복 확률이 높은 제1 데이터와, 상대적으로 반복 확률이 낮은 제2 데이터로 구분할 수 있다.S201 is a step of classifying each type of first multiplication result value into a plurality of data according to the repetition probability. In this case, a plurality of pieces of data may be distinguished based on statistical data previously stored in the memory 40 and transmitted to the buffer 12 . For example, it may be divided into first data having a relatively high repetition probability and second data having a relatively low repetition probability.

이후, S202는 구분된 데이터에 따라, 제1 연산 방법 또는 제2 연산 방법이 수행되는 단계이다.Thereafter, S202 is a step in which a first calculation method or a second calculation method is performed according to the classified data.

S202는 제1 데이터에 속하는 상기 제1 곱셈에 대해, S101 내지 S103에 따른 제1 연산 방법을 적용하는 제1 연산 단계를 포함할 수 있다. 즉, 이러한 제1 연산 단계는 상술한 제1 연산부(100)의 동작이 수행되는 단계일 수 있다.S202 may include a first calculation step of applying the first calculation method according to S101 to S103 to the first multiplication belonging to first data. That is, this first calculation step may be a step in which the above-described operation of the first calculation unit 100 is performed.

또한, S202는 제2 데이터에 속하는 상기 제1 곱셈에 대해, 제1 연산 단계와 다른 곱셈-누산의 연산을 수행하는 제2 연산 단계를 포함할 수 있다. 가령, 해당 각 가중치와 해당 각 입력 값 간의 곱셈 연산과, 그 곱셈 연산의 결과 값에 대한 누산 연산을 각각 수행하는 제2 연산 방법을 적용할 수 있다. 즉, 이러한 제2 연산 단계는 상술한 제2 연산부(200)의 동작이 수행되는 단계일 수 있다.Further, S202 may include a second calculation step of performing a multiplication-accumulation operation different from the first calculation step for the first multiplication belonging to the second data. For example, a second calculation method may be applied, which performs a multiplication operation between each corresponding weight and each corresponding input value, and an accumulation operation for a result value of the multiplication operation. That is, this second calculation step may be a step in which the above-described operation of the second calculation unit 200 is performed.

이후, S203은 제1 및 제2 연산 단계의 결과 값들을 누산하는 단계이다. 즉, S203은 상술한 제3 연산부(300)의 동작이 수행되는 단계일 수 있다.Thereafter, S203 is a step of accumulating result values of the first and second calculation steps. That is, S203 may be a step in which the above-described operation of the third operation unit 300 is performed.

상술한 바와 같이 구성되는 본 발명은 비트-정밀도가 낮은 심층신경망 등의 딥러닝 신경망에 대한 연산에서 많이 누적되는 동일한 결과 값을 가지는 곱셈들을 팝카운트 연산과 상수 곱셈으로 변환함으로써, 처리 속도를 향상시키면서, 그 하드웨어의 면적 및 소모 전력을 상당히 줄일 수 있는 이점이 있다. 또한, 본 발명은 딥 러닝 신경망 연산을 처리하는 모바일, 에지 기기 및 서버 등의 다양한 하드웨어에 적용 가능한 이점이 있다.The present invention configured as described above improves processing speed by converting multiplications having the same result value accumulated a lot in operations for deep learning neural networks such as deep neural networks with low bit-precision into pop count operations and constant multiplications. , there is an advantage of significantly reducing the area and power consumption of the hardware. In addition, the present invention has the advantage of being applicable to various hardware such as mobile, edge devices and servers that process deep learning neural network calculations.

본 발명의 상세한 설명에서는 구체적인 실시 예에 관하여 설명하였으나 본 발명의 범위에서 벗어나지 않는 한도 내에서 여러 가지 변형이 가능함은 물론이다. 그러므로 본 발명의 범위는 설명된 실시 예에 국한되지 않으며, 후술되는 청구범위 및 이 청구범위와 균등한 것들에 의해 정해져야 한다.In the detailed description of the present invention, specific embodiments have been described, but various modifications are possible without departing from the scope of the present invention. Therefore, the scope of the present invention is not limited to the described embodiments, and should be defined by the following claims and equivalents thereof.

1: 전자 장치 10: 신경망 처리부
11: 곱셈 누산기 12: 버퍼
20: 입력부 30: 통신부
40: 메모리 50: 제어부
100: 제1 연산부 110: 인코더
120: 팝카운터 130: 곱셈-누산 연산부
131: 상수 곱셈기 132: 시프터
133: 가산기 트리 134: 순람표
200: 제2 연산부 300: 제3 연산부
1: electronic device 10: neural network processing unit
11: multiplication accumulator 12: buffer
20: input unit 30: communication unit
40: memory 50: control unit
100: first operation unit 110: encoder
120: pop counter 130: multiplication-accumulation operation unit
131: constant multiplier 132: shifter
133 Adder tree 134 Lookup table
200: second arithmetic unit 300: third arithmetic unit

Claims (20)

딥러닝 신경망(deep learning neural network)에 대한 연산 방법으로서,
가중치(W)들과 입력 값(A)들 간의 곱셈인 제1 곱셈에 대해, 각 제1 곱셈 결과 값 종류의 반복 확률에 따라 다수의 데이터로 구분하는 단계; 및
제1 데이터에 속하는 제1 곱셈에 대해, 팝카운트에 기반한 상수 곱셈의 곱셈-누산의 연산을 수행하는 제1 연산 단계;
상기 제1 데이터 보다 반복 확률이 낮은 제2 데이터에 속하는 제1 곱셈에 대해, 각 가중치와 각 입력 값 간의 곱셈 연산과, 그 곱셈 연산의 결과 값에 대한 누산 연산을 각각 수행함으로써, 상기 제1 연산 단계와 다른 곱셈-누산의 연산을 수행하는 제2 연산 단계; 및
제1 및 제2 연산 단계의 결과 값들을 누산하는 제3 연산 단계;를 포함하고,
상기 제1 연산 단계는,
상기 제1 데이터에 속하는 제1 곱셈들에 대해 각각, 제1 곱셈 결과 값들의 종류에 따른 원-핫 인코딩(one-hot encoding)의 코드들을 생성하는 단계;
상기 생성된 각 코드에 대해 팝카운트(pop-count)를 수행하는 단계; 및
서로 다른 상수 값인 상기 각 종류의 제1 곱셈 결과 값과 상기 팝카운트의 각 카운트 값 간의 상수 곱셈인 제2 곱셈에 대한 결과 값들을 누산하는 단계;를 포함하며,
상기 누산하는 단계는,
제2 곱셈 결과 값들을 도출하는 제1 도출 단계; 및
제2 곱셈 결과 값들에 대한 누산 결과 값을 도출하는 제2 도출 단계;
를 포함하는 연산 방법.
As an operation method for a deep learning neural network,
Dividing into a plurality of data according to the repetition probability of each first multiplication result value type for the first multiplication, which is the multiplication between the weights (W) and the input values (A); and
a first operation step of performing a multiplication-accumulation operation of constant multiplication based on the pop count on the first multiplication belonging to the first data;
For the first multiplication belonging to the second data having a lower repetition probability than the first data, a multiplication operation between each weight and each input value and an accumulation operation on the resultant value of the multiplication operation are performed, respectively, so that the first operation is performed. a second operation step of performing a multiplication-accumulation operation different from the step; and
A third calculation step of accumulating result values of the first and second calculation steps;
In the first calculation step,
generating one-hot encoding codes according to types of first multiplication result values, respectively, for first multiplications belonging to the first data;
performing a pop-count on each of the generated codes; and
Accumulating result values for second multiplication, which is constant multiplication between the first multiplication result values of each kind, which are different constant values, and each count value of the pop count;
In the step of accumulating,
a first derivation step of deriving second multiplication result values; and
a second derivation step of deriving an accumulation result value for the second multiplication result values;
Calculation method including.
삭제delete 제1항에 있어서,
상기 제1 도출 단계는 상기 상수 값과 상기 카운트 값 간에 곱셈 연산을 수행하는 상수 곱셈기를 이용하거나, 상기 상수 값의 비트에 대한 시프트(shift)를 수행하는 시프터(shifter)를 이용하는 단계를 포함하는 연산 방법.
According to claim 1,
The first deriving step includes using a constant multiplier for performing a multiplication operation between the constant value and the count value, or using a shifter for performing a shift of bits of the constant value Operation comprising: method.
제1항에 있어서,
상기 제1 도출 단계는 상기 제2 곱셈 결과 값들이 저장된 순람표(Lookup table)을 이용하는 단계를 포함하는 연산 방법.
According to claim 1,
The first derivation step includes using a lookup table in which the second multiplication result values are stored.
제3항 또는 제4항에 있어서,
상기 제2 도출 단계는 상기 제2 곱셈 결과 값들 간에 누산 연산을 수행하는 가산기 트리(adder tree)를 이용하는 단계를 포함하는 연산 방법.
According to claim 3 or 4,
The second derivation step includes using an adder tree that performs an accumulation operation between the second multiplication result values.
제1항에 있어서,
상기 누산하는 단계는 상기 제2 곱셈 결과 값들이 저장된 순람표(Lookup table)를 기반으로 분산 산술(distributed arithmetic)을 수행하는 단계를 포함하는 연산 방법.
According to claim 1,
The accumulating step includes performing distributed arithmetic based on a lookup table in which the second multiplication result values are stored.
제1항에 있어서,
상기 생성하는 단계는 가중치와 입력 값의 비트 종류에 따라, 상기 제1 곱셈 결과 값의 종류를 구분하여 상기 코드를 생성하는 단계를 포함하는 연산 방법.
According to claim 1,
The generating step includes generating the code by distinguishing a type of the first multiplication result value according to a weight and a bit type of an input value.
제7항에 있어서,
상기 생성하는 단계는,
상기 제1 곱셈에 대해 그 결과 값이 0(zero)인지 여부를 구분하는 제1 구분 단계; 및
그 결과 값이 0이 아닌 것(non-zero)으로 구분된 각 제1 곱셈에 대해 그 나머지의 결과 값 종류로 구분하는 제2 구분 단계; 및
상기 제2 구분 단계에서 구분된 결과를 기반으로, 상기 코드를 생성하는 단계;
를 포함하는 연산 방법.
According to claim 7,
The generating step is
a first discrimination step of discriminating whether a resultant value of the first multiplication is 0 (zero); and
A second division step of classifying the remaining result values into types for each first multiplication in which the result value is non-zero; and
generating the code based on a result of the classification in the second classification step;
Calculation method including.
제8항에 있어서,
상기 제2 구분 단계는,
상기 non-zero로 구분된 각 제1 곱셈에 대해, 가중치와 입력 값의 최상위비트(most significant bit)를 기준으로 2개 그룹으로 그 결과 값의 종류를 구분하는 제2-1 단계; 및
상기 2개 그룹에 대해 각 그룹에 속한 제1 곱셈에 대해 그 결과 값의 종류를 구분하는 제2-2 구분 단계;
를 포함하는 연산 방법.
According to claim 8,
The second division step,
A 2-1 step of classifying the types of result values into two groups based on the weight and the most significant bit of the input value for each of the first multiplications classified as non-zero; and
a 2-2 division step of classifying the type of the resultant value for the first multiplication belonging to each group with respect to the two groups;
Calculation method including.
삭제delete 딥러닝 신경망 연산 시에 가중치(W)들과 입력 값(A)들 간의 곱셈인 제1 곱셈을 처리하기 위해 적용되는 곱셈 누산기로서,
각 제1 곱셈 결과 값 종류의 반복 확률에 따라 구분된 다수의 데이터 중 제1 데이터에 속하는 제1 곱셈에 대해, 팝카운트에 기반한 상수 곱셈의 곱셈-누산의 연산을 수행하는 제1 연산부;
상기 제1 데이터 보다 반복 확률이 낮은 제2 데이터에 속하는 제1 곱셈에 대해, 각 가중치와 각 입력 값 간의 곱셈 연산과, 그 곱셈 연산의 결과 값에 대한 누산 연산을 각각 수행함으로써, 상기 제1 연산부와 다른 곱셈-누산의 연산을 수행하는 제2 연산부; 및
제1 및 제2 연산부의 결과 값들을 누산하는 제3 연산부;를 포함하고,
상기 제1 연산부는,
상기 제1 데이터에 속하는 제1 곱셈들에 대해 각각, 제1 곱셈 결과 값들의 종류에 따른 원-핫 인코딩(one-hot encoding)의 코드들을 생성하는 인코더;
상기 생성된 각 코드에 대해 팝카운트(pop-count)를 수행하는 팝카운터; 및
서로 다른 상수 값인 상기 각 종류의 제1 곱셈 결과 값과 상기 팝카운트의 각 카운트 값 간의 상수 곱셈인 제2 곱셈에 대한 결과 값들을 누산하는 곱셈-누산 연산부;를 포함하며,
상기 곱셈-누산 연산부는 제2 곱셈 결과 값들을 도출한 후, 제2 곱셈 결과 값들에 대한 누산 결과 값을 도출하는 곱셈 누산기.
As a multiplication accumulator applied to process first multiplication, which is multiplication between weights (W) and input values (A) during deep learning neural network operation,
A first operation unit for performing a multiplication-accumulation operation of constant multiplication based on a pop count for first multiplication belonging to first data among a plurality of pieces of data classified according to a repetition probability of each first multiplication result value type;
With respect to the first multiplication belonging to the second data having a lower repetition probability than the first data, the first operation unit performs a multiplication operation between each weight and each input value and an accumulation operation on the resultant value of the multiplication operation, respectively. a second arithmetic unit performing multiplication-accumulation operations different from ?; and
A third calculation unit accumulating result values of the first and second calculation units;
The first operation unit,
an encoder generating one-hot encoding codes according to types of first multiplication result values, respectively, for first multiplications belonging to the first data;
a pop-counter performing a pop-count on each of the generated codes; and
A multiplication-accumulation operation unit for accumulating result values for second multiplication, which is constant multiplication between the first multiplication result values of each type, which are different constant values, and each count value of the pop count;
The multiplication-accumulator for deriving second multiplication result values and then deriving accumulated result values for the second multiplication result values.
제11항에 있어서,
상기 곱셈-누산 연산부는 상기 상수 값과 상기 카운트 값 간에 곱셈 연산을 수행하는 상수 곱셈기나, 상기 상수 값의 비트에 대한 시프트(shift)를 수행하는 시프터(shifter)를 기반으로 상기 제2 곱셈 결과 값을 도출하는 곱셈 누산기.
According to claim 11,
The multiplication-accumulation operation unit based on a constant multiplier performing a multiplication operation between the constant value and the count value or a shifter performing a bit shift of the constant value, the second multiplication result value multiplication accumulator that derives .
제11항에 있어서,
상기 곱셈-누산 연산부는 상기 제2 곱셈 결과 값들이 저장된 순람표(Lookup table)를 기반으로 상기 제2 곱셈 결과 값들을 도출하는 곱셈 누산기.
According to claim 11,
The multiplication-accumulator for deriving the second multiplication result values based on a lookup table in which the second multiplication result values are stored.
제12항 또는 제13항에 있어서,
상기 곱셈-누산 연산부는 상기 제2 곱셈 결과 값들 간에 누산 연산을 수행하는 가산기 트리(adder tree)를 기반으로 상기 제2 곱셈 결과 값들을 누산하는 곱셈 누산기.
According to claim 12 or 13,
Wherein the multiplication-accumulation operation unit accumulates the second multiplication result values based on an adder tree that performs an accumulation operation between the second multiplication result values.
제11항에 있어서,
상기 곱셈-누산 연산부는 상기 제2 곱셈 결과 값이 저장된 순람표(Lookup table)를 기반으로 분산 산술(distributed arithmetic)을 수행하여 상기 제2 곱셈 결과 값들을 누산하는 곱셈 누산기.
According to claim 11,
The multiplication-accumulator performs distributed arithmetic based on a lookup table in which the second multiplication result values are stored and accumulates the second multiplication result values.
제11항에 있어서,
상기 인코더는 가중치와 입력 값의 비트 종류에 따라, 상기 제1 곱셈 결과 값의 종류를 구분하여 상기 코드를 생성하는 곱셈 누산기.
According to claim 11,
The encoder generates the code by distinguishing the type of the first multiplication result value according to the bit type of the weight and the input value.
제11항에 있어서,
상기 인코더는 상기 각 제1 곱셈에 대해 그 결과 값이 0(zero)인지 여부를 제1 구분하고, 그 결과 값이 0이 아닌 것(non-zero)으로 구분된 각 제1 곱셈에 대해 그 결과 값의 종류를 제2 구분하며, 상기 제2 구분된 결과를 기반으로, 상기 코드를 생성하는 곱셈 누산기.
According to claim 11,
The encoder first determines whether the result value is 0 (zero) for each of the first multiplications, and the result value for each first multiplication that is classified as non-zero. A multiplication accumulator that secondly distinguishes a type of value and generates the code based on a result of the second classification.
제17항에 있어서,
상기 인코더는 상기 제2 구분 시, 상기 non-zero로 구분된 각 제1 곱셈에 대해 가중치와 입력 값의 최상위비트(most significant bit)를 기준으로 2개 그룹으로 그 결과 값의 종류를 구분한 후, 상기 2개 그룹에 대해 각 그룹에 속한 제1 곱셈에 대해 그 결과 값의 종류를 구분하는 곱셈 누산기.
According to claim 17,
In the second division, the encoder divides the type of result value into two groups based on the weight and the most significant bit of the input value for each first multiplication divided by the non-zero, and then , A multiplication accumulator for distinguishing the type of result value for the first multiplication belonging to each group for the two groups.
삭제delete 딥러닝 신경망(deep learning neural network) 연산을 수행하는 전자 장치로서,
상기 딥러닝 신경망의 가중치(W)들과, 상기 딥러닝 신경망의 입력층에 입력되는 입력 값(A)들을 저장한 메모리; 및
상기 메모리에 저장된 가중치들과 입력 값들 간의 곱셈인 제1 곱셈들에 대한 누산 결과 값을 계산하는 곱셈-누산기;를 포함하며,
상기 곱셈-누산기는,
각 제1 곱셈 결과 값 종류의 반복 확률에 따라 구분된 다수의 데이터 중 제1 데이터에 속하는 제1 곱셈에 대해, 팝카운트에 기반한 상수 곱셈의 곱셈-누산의 연산을 수행하는 제1 연산부;
상기 제1 데이터 보다 반복 확률이 낮은 제2 데이터에 속하는 제1 곱셈에 대해, 각 가중치와 각 입력 값 간의 곱셈 연산과, 그 곱셈 연산의 결과 값에 대한 누산 연산을 각각 수행함으로써, 상기 제1 연산부와 다른 곱셈-누산의 연산을 수행하는 제2 연산부; 및
제1 및 제2 연산부의 결과 값들을 누산하는 제3 연산부;를 포함하고,
상기 제1 연산부는,
상기 제1 데이터에 속하는 제1 곱셈들에 대해 각각, 제1 곱셈 결과 값들의 종류에 따른 원-핫 인코딩(one-hot encoding)의 코드들을 생성하는 인코더;
상기 생성된 각 코드에 대해 팝카운트(pop-count)를 수행하는 팝카운터; 및
서로 다른 상수 값인 상기 각 종류의 제1 곱셈 결과 값과 상기 팝카운트의 각 카운트 값 간의 상수 곱셈인 제2 곱셈에 대한 결과 값들을 누산하는 곱셈-누산 연산부;를 포함하며,
상기 곱셈-누산 연산부는 제2 곱셈 결과 값들을 도출한 후, 제2 곱셈 결과 값들에 대한 누산 결과 값을 도출하는 전자 장치.
An electronic device that performs a deep learning neural network operation,
a memory storing weights (W) of the deep learning neural network and input values (A) input to an input layer of the deep learning neural network; and
A multiplication-accumulator for calculating accumulated result values for first multiplications, which are multiplications between weights stored in the memory and input values;
The multiplier-accumulator is
A first operation unit for performing a multiplication-accumulation operation of constant multiplication based on a pop count for first multiplication belonging to first data among a plurality of pieces of data classified according to a repetition probability of each first multiplication result value type;
With respect to the first multiplication belonging to the second data having a lower repetition probability than the first data, the first operation unit performs a multiplication operation between each weight and each input value and an accumulation operation on the resultant value of the multiplication operation, respectively. a second arithmetic unit performing multiplication-accumulation operations different from ?; and
A third calculation unit accumulating result values of the first and second calculation units;
The first operation unit,
an encoder generating one-hot encoding codes according to types of first multiplication result values, respectively, for first multiplications belonging to the first data;
a pop-counter performing a pop-count on each of the generated codes; and
A multiplication-accumulation operation unit for accumulating result values for second multiplication, which is constant multiplication between the first multiplication result values of each type, which are different constant values, and each count value of the pop count;
The multiplication-accumulation operation unit derives second multiplication result values and then derives accumulated result values for the second multiplication result values.
KR1020200163708A 2020-10-14 2020-11-30 Method, multiplier-accumulator and apparatus for calculating deep learning network based on pop-count KR102553941B1 (en)

Priority Applications (2)

Application Number Priority Date Filing Date Title
US17/254,254 US20220317973A1 (en) 2020-10-14 2020-11-30 Pop count-based deep learning neural network computation method, multiply accumulator and device
PCT/KR2020/017253 WO2022080579A1 (en) 2020-10-14 2020-11-30 Pop-count-based deep learning neural network calculation method, multiplication accumulator, and device

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
KR20200132847 2020-10-14
KR1020200132847 2020-10-14

Publications (2)

Publication Number Publication Date
KR20220049432A KR20220049432A (en) 2022-04-21
KR102553941B1 true KR102553941B1 (en) 2023-07-10

Family

ID=81437572

Family Applications (1)

Application Number Title Priority Date Filing Date
KR1020200163708A KR102553941B1 (en) 2020-10-14 2020-11-30 Method, multiplier-accumulator and apparatus for calculating deep learning network based on pop-count

Country Status (1)

Country Link
KR (1) KR102553941B1 (en)

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20170351781A1 (en) * 2016-06-06 2017-12-07 Salesforce.Com, Inc. Relevant information retrieval in record management systems
WO2019213745A1 (en) * 2018-05-08 2019-11-14 The Governing Council Of The University Of Toronto Neural network processing element

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR20200121497A (en) 2019-04-16 2020-10-26 한국전자통신연구원 Method and apparatus for neural network computing for deep neural network

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20170351781A1 (en) * 2016-06-06 2017-12-07 Salesforce.Com, Inc. Relevant information retrieval in record management systems
WO2019213745A1 (en) * 2018-05-08 2019-11-14 The Governing Council Of The University Of Toronto Neural network processing element

Also Published As

Publication number Publication date
KR20220049432A (en) 2022-04-21

Similar Documents

Publication Publication Date Title
Wang et al. A high-speed and low-complexity architecture for softmax function in deep learning
KR102476343B1 (en) Apparatus and method for supporting neural network calculation of fixed-point numbers with relatively few digits
US20180150744A1 (en) Neural network data entry system
CN107340993B (en) Arithmetic device and method
US20190332925A1 (en) Neural hardware accelerator for parallel and distributed tensor computations
US20180075342A1 (en) Information processing apparatus, ising unit, and information processing apparatus control method
CN112074806A (en) Block floating point computations using reduced bit width vectors
US20200117981A1 (en) Data representation for dynamic precision in neural network cores
KR102655950B1 (en) High speed processing method of neural network and apparatus using thereof
US20220092408A1 (en) Neural network weight distribution using a tree direct-memory access (dma) bus
US20190347072A1 (en) Block floating point computations using shared exponents
Abed et al. High‐performance low‐power approximate Wallace tree multiplier
US11270196B2 (en) Multi-mode low-precision inner-product computation circuits for massively parallel neural inference engine
KR102553941B1 (en) Method, multiplier-accumulator and apparatus for calculating deep learning network based on pop-count
US20190278566A1 (en) System and method for long addition and long multiplication in associative memory
US20210294608A1 (en) Processing in memory methods for convolutional operations
CN112085154A (en) Asymmetric quantization for compression and inference acceleration of neural networks
Parhami Truncated ternary multipliers
US20220317973A1 (en) Pop count-based deep learning neural network computation method, multiply accumulator and device
CN112384935A (en) Hierarchical parallelism in a distributed neural network core network
EP3971787A1 (en) Spatial tiling of compute arrays with shared control
JP2020042399A (en) Product sum operation device, product sum operation method and system
JP2023505237A (en) Flexible Precision Neural Inference Processing Unit
US20200065676A1 (en) Neural network method, system, and computer program product with inference-time bitwidth flexibility
KR20210086233A (en) Method and apparatus for processing matrix data through relaxed pruning

Legal Events

Date Code Title Description
E902 Notification of reason for refusal
E701 Decision to grant or registration of patent right
GRNT Written decision to grant