KR20220114435A - Method and apparatus for accelerating convolutional neural networks - Google Patents

Method and apparatus for accelerating convolutional neural networks Download PDF

Info

Publication number
KR20220114435A
KR20220114435A KR1020210017924A KR20210017924A KR20220114435A KR 20220114435 A KR20220114435 A KR 20220114435A KR 1020210017924 A KR1020210017924 A KR 1020210017924A KR 20210017924 A KR20210017924 A KR 20210017924A KR 20220114435 A KR20220114435 A KR 20220114435A
Authority
KR
South Korea
Prior art keywords
input
sparse
convolutional neural
neural network
tensor
Prior art date
Application number
KR1020210017924A
Other languages
Korean (ko)
Other versions
KR102644702B1 (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 KR1020210017924A priority Critical patent/KR102644702B1/en
Publication of KR20220114435A publication Critical patent/KR20220114435A/en
Application granted granted Critical
Publication of KR102644702B1 publication Critical patent/KR102644702B1/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/08Learning methods
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/04Architecture, e.g. interconnection topology
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/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

Landscapes

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

Abstract

The present specification relates to a method and device for accelerating a convolutional neural network. The method for accelerating the convolutional neural network according to one embodiment of the present specification comprises: a step of converting the 3D tensor input into a compressed format based on a rarity of an input activation value included in the 3D tensor input and a rarity of a weight included in a weight filter; a step of performing an operation based on the converted compression format; and a step of calculating a 3D tensor output from a result of the operation. Therefore, the present invention is capable of improving an inference speed of the convolutional neural network.

Description

컨볼루션 신경망 가속 방법 및 장치 {METHOD AND APPARATUS FOR ACCELERATING CONVOLUTIONAL NEURAL NETWORKS}Convolutional Neural Network Acceleration Method and Apparatus {METHOD AND APPARATUS FOR ACCELERATING CONVOLUTIONAL NEURAL NETWORKS}

본 명세서는 컨볼루션 신경망 가속 방법 및 장치에 관한 것이다.The present specification relates to a method and apparatus for accelerating a convolutional neural network.

컨볼루션 신경망(Convolutional Neural Network;CNN)은 가중치를 갖는 필터를 이용하여 이미지로부터 이미지에 포함된 특정 객체를 인식하는 영상 처리 기법으로 최근 컨볼루션 신경망의 깊이가 깊어짐에 따라 신경망의 연산량과 매개변수의 수가 크게 증가하고 있다. 따라서, 이러한 연산량과 매개변수의 수 증가에 따른 메모리 사용량을 줄이기 위하여 신경망을 압축하는 PRUNING 기법이 활발히 연구되고 있다. Convolutional Neural Network (CNN) is an image processing technique that recognizes a specific object included in an image from an image using a weighted filter. number is increasing significantly. Therefore, the PRUNING technique for compressing the neural network is being actively studied in order to reduce the memory usage due to the increase in the number of calculations and parameters.

가중치가 희소한 경우 대부분의 컨볼루션 연산 결과는 0값이 많으며, 이는 불필요한 연산에 해당된다. 종래에는 이러한 의미 없는 연산을 피하기 위해 가중치의 희소성을 고려하는 방법이 사용된다.When the weights are sparse, most of the results of the convolution operation have many zero values, which is an unnecessary operation. Conventionally, in order to avoid such meaningless operation, a method that considers the sparsity of the weight is used.

이러한 가중치의 희소성에 기초한 신경망 가속 방법은 2차원 입력 행렬 간의 빠른 행렬 곱 연산을 위해 3차원 입력 텐서를 2차원 입력 행렬로 차원을 한 단계 낮춘다. The neural network acceleration method based on the sparsity of these weights lowers the dimension of a 3D input tensor to a 2D input matrix by one level for fast matrix multiplication between 2D input matrices.

그러나 3차원 입력 텐서를 2차원 입력 행렬로 차원을 낮추는 경우, latency와 메모리 오버헤드(Lowering 오버헤드)의 문제점이 발생한다. 즉, 2차원 입력 행렬을 만드는 과정에서 시간 지연이 발생하며, 추가적인 저장 공간 확보가 필요함에 따라 메모리 오버헤드가 발생한다.However, when the dimension of a 3D input tensor is reduced to a 2D input matrix, problems of latency and memory overhead (lowering overhead) occur. That is, a time delay occurs in the process of creating a two-dimensional input matrix, and memory overhead occurs as additional storage space is required.

따라서, 이러한 문제점을 해결함과 동시에 임베디드 시스템에서 컨볼루션 신경망의 추론 속도를 향상 시킬 수 있는 기술의 필요성이 대두되고 있다.Therefore, there is a need for a technology that can improve the reasoning speed of convolutional neural networks in embedded systems while solving these problems.

본 명세서의 목적은 가중치의 희소성뿐만 아니라 입력 활성값의 희소성을 이용하여 의미 없는 연산 수행을 최소화하고, 컨볼루션 신경망의 추론 속도를 향상시킬 수 있는 컨볼루션 신경망 가속 방법 및 장치를 제공하는 것이다.An object of the present specification is to provide a method and apparatus for accelerating a convolutional neural network, which can minimize the performance of meaningless calculations and improve the inference speed of the convolutional neural network by using the sparsity of the input activation values as well as the sparsity of the weights.

또한 본 명세서의 목적은 3차원 입력 텐서를 2차원 입력 행렬로 변환하지 않고 압축 포맷으로 변환하여 메모리 낭비 및 오버헤드의 발생을 방지하는 컨볼루션 신경망 가속 방법 및 장치를 제공하는 것이다.It is also an object of the present specification to provide a method and apparatus for accelerating a convolutional neural network that converts a 3D input tensor into a compressed format without converting it into a 2D input matrix, thereby preventing memory waste and overhead.

본 명세서의 목적들은 이상에서 언급한 목적으로 제한되지 않으며, 언급되지 않은 본 명세서의 다른 목적 및 장점들은 하기의 설명에 의해서 이해될 수 있고, 본 명세서의 실시예에 의해 보다 분명하게 이해될 것이다. 또한, 본 명세서의 목적 및 장점들은 특허 청구 범위에 나타낸 수단 및 그 조합에 의해 실현될 수 있음을 쉽게 알 수 있을 것이다.The objects of the present specification are not limited to the above-mentioned objects, and other objects and advantages of the present specification that are not mentioned may be understood by the following description, and will be more clearly understood by the examples of the present specification. It will also be readily apparent that the objects and advantages of the present specification may be realized by the means and combinations thereof indicated in the claims.

본 명세서의 일 실시예에 따른 컨볼루션 신경망 가속 방법은 3차원 텐서 입력에 포함된 입력 활성값의 희소성 및 가중치 필터에 포함된 가중치의 희소성에 기초하여 상기 3차원 텐서 입력을 압축 포맷으로 변환하는 단계, 변환된 압축 포맷에 기초하여 연산을 수행하는 단계 및 연산의 결과로부터 3차원 텐서 출력을 산출하는 단계를 포함한다.The method for accelerating a convolutional neural network according to an embodiment of the present specification includes converting the 3D tensor input into a compressed format based on the sparsity of the input active values included in the 3D tensor input and the sparsity of the weights included in the weight filter. , performing an operation based on the converted compression format, and calculating a three-dimensional tensor output from the result of the operation.

또한, 본 명세서의 일 실시예에서 압축 포맷은 CSR (Compressed Sparse Row) 및 CSOA (Compressed Sparse Overlapped Activations) 중 어느 하나이다.In addition, in an embodiment of the present specification, the compression format is any one of Compressed Sparse Row (CSR) and Compressed Sparse Overlapped Activations (CSOA).

또한, 본 명세서의 일 실시예에서 3차원 텐서 입력을 압축 포맷으로 변환하는 단계는 입력 활성값이 0인 입력 활성값의 개수가 미리 설정된 입력 활성 기준값 미만이면 밀집으로 판단하고, 입력 활성값이 0인 입력 활성값의 개수가 미리 설정된 입력 활성 기준값 이상이면 희소로 판단하여 입력 활성값의 희소성을 결정하고, 가중치가 0인 가중치의 개수가 미리 설정된 가중치 기준값 미만이면 밀집으로 판단하고, 가중치가 0인 가중치의 개수가 미리 설정된 가중치 기준값 이상이면 희소로 판단하여 가중치의 희소성을 결정한다.In addition, in the embodiment of the present specification, the step of converting the 3D tensor input into a compressed format is determined to be dense if the number of input active values with an input active value of 0 is less than a preset input active reference value, and the input active value is 0 If the number of input active values is greater than or equal to the preset input active reference value, it is determined as sparse and the input active value is sparse. If the number of weights is greater than or equal to a preset weight reference value, the weight is determined to be sparse, and the sparseness of the weights is determined.

또한, 본 명세서의 일 실시예에 따른 컨볼루션 신경망 가속 방법은 입력 활성값의 희소성이 희소로 판단되고, 상기 가중치의 희소성이 밀집으로 판단되면 im2CSR (image to Compressed Sparse Row)변환 방법을 통해 상기 3차원 텐서 입력을 상기 CSR로 변환한다.In addition, in the convolutional neural network acceleration method according to an embodiment of the present specification, when the sparseness of the input activation value is determined to be sparse and the sparseness of the weights is determined to be dense, the above 3 Transform the dimensional tensor input into the CSR.

또한, 본 명세서의 일 실시예에 따른 컨볼루션 신경망 가속 방법은 입력 활성값의 희소성 및 가중치의 희소성이 모두 희소로 판단되면 im2CSOA (image to Compressed Sparse Overlapped Activations) 변환 방법을 통해 상기 3차원 텐서 입력을 상기 CSOA로 변환한다.In addition, in the convolutional neural network acceleration method according to an embodiment of the present specification, when both the sparsity of the input activation value and the sparsity of the weight are determined to be sparse, the 3D tensor input is converted to the im2CSOA (image to Compressed Sparse Overlapped Activations) method. converted to the CSOA.

또한, 본 명세서의 일 실시예에서 변환된 압축 포맷에 기초하여 연산을 수행하는 단계는 압축 포맷이 CSR인 경우 CSR과 가중치 필터의 SpMDM (Sparse Matrix Dense Matrix multiplication) 연산을 수행한다.In addition, in the embodiment of the present specification, the step of performing an operation based on the converted compression format performs a sparse matrix density matrix multiplication (SpMDM) operation of the CSR and the weight filter when the compression format is CSR.

또한, 본 명세서의 일 실시예에서 변환된 압축 포맷에 기초하여 연산을 수행하는 단계는 압축 포맷이 CSOA인 경우 CSOA와 가중치 필터로부터 변환된 CSC (Compressed Sparse Column)의 SpMSpM (Sparse Matrix Sparse Matrix multiplication) 연산을 수행한다.In addition, in an embodiment of the present specification, the step of performing an operation based on the converted compression format is a Sparse Matrix Sparse Matrix multiplication (SpMSpM) of a Compressed Sparse Column (CSC) converted from a CSOA and a weight filter when the compression format is CSOA. perform calculations

또한, 본 명세서의 일 실시예에서 SpMSpM 연산은 CSC와 상기 CSOA의 외적 연산이다.In addition, in an embodiment of the present specification, the SpMSpM operation is a cross product operation of the CSC and the CSOA.

본 명세서의 일 실시예에 따른 컨볼루션 신경망 가속 장치는 3차원 텐서 입력에 포함된 입력 활성값의 희소성 및 가중치 필터에 포함된 가중치의 희소성에 기초하여 3차원 텐서 입력을 압축 포맷으로 변환하는 변환부, 변환된 압축 포맷에 기초하여 연산을 수행하는 연산부 및 연산의 결과로부터 3차원 텐서 출력을 산출하는 출력부를 포함한다.The apparatus for accelerating a convolutional neural network according to an embodiment of the present specification is a conversion unit that converts a 3D tensor input into a compressed format based on the sparsity of the input active values included in the 3D tensor input and the sparsity of the weights included in the weight filter , an operation unit that performs an operation based on the converted compression format, and an output unit that calculates a 3D tensor output from the result of the operation.

또한, 본 명세서의 일 실시예에서 압축 포맷은 CSR (Compressed Sparse Row) 및 CSOA (Compressed Sparse Overlapped Activations) 중 어느 하나이다.In addition, in an embodiment of the present specification, the compression format is any one of Compressed Sparse Row (CSR) and Compressed Sparse Overlapped Activations (CSOA).

또한, 본 명세서의 일 실시예에서 변환부는 입력 활성값이 0인 입력 활성값의 개수가 미리 설정된 입력 활성 기준값 미만이면 밀집으로 판단하고, 입력 활성값이 0인 입력 활성값의 개수가 미리 설정된 입력 활성 기준값 이상이면 희소로 판단하여 입력 활성값의 희소성을 결정하고, 가중치가 0인 가중치의 개수가 미리 설정된 가중치 기준값 미만이면 밀집으로 판단하고, 가중치가 0인 가중치의 개수가 미리 설정된 가중치 기준값 이상이면 희소로 판단하여 가중치의 희소성을 결정한다.In addition, in an embodiment of the present specification, the conversion unit determines that the number of input active values of which the input active value is 0 is less than a preset input active reference value is dense, and the number of input active values of which the input active value is 0 is preset. If it is greater than or equal to the active reference value, it is determined as sparse and the input active value is sparse. If the number of weights with zero weight is less than the preset weight reference value, it is determined as dense. The sparseness of the weights is determined by judging them as sparse.

또한, 본 명세서의 일 실시예에서 변환부는 입력 활성값의 희소성이 희소로 판단되고, 가중치의 희소성이 밀집으로 판단되면 im2CSR (image to Compressed Sparse Row) 변환 방법을 통해 3차원 텐서 입력을 상기 CSR로 변환한다.In addition, in an embodiment of the present specification, when it is determined that the sparseness of the input active value is sparse and the sparseness of the weights is determined to be dense, the transformation unit converts the 3D tensor input into the CSR through the im2CSR (image to Compressed Sparse Row) transformation method. convert

또한, 본 명세서의 일 실시예에서 변환부는 입력 활성값의 희소성 및 가중치의 희소성이 모두 희소로 판단되면 im2CSOA (image to Compressed Sparse Overlapped Activations) 변환 방법을 통해 3차원 텐서 입력을 상기 CSOA로 변환한다.In addition, in an embodiment of the present specification, when both the sparseness of the input activation value and the sparseness of the weight are determined to be sparse, the transform unit converts the 3D tensor input into the CSOA through an image to Compressed Sparse Overlapped Activations (im2CSOA) transformation method.

또한, 본 명세서의 일 실시예에서 연산부는 압축 포맷이 CSR인 경우 CSR과 가중치 필터의 SpMDM (Sparse Matrix Dense Matrix multiplication) 연산을 수행한다.In addition, in an embodiment of the present specification, when the compression format is CSR, the operation unit performs Sparse Matrix Dense Matrix multiplication (SpMDM) operation of the CSR and the weight filter.

또한, 본 명세서의 일 실시예에서 연산부는 압축 포맷이 CSOA인 경우 CSOA와 가중치 필터로부터 변환된 CSC (Compressed Sparse Column)의 SpMSpM (Sparse Matrix Sparse Matrix multiplication) 연산을 수행한다.In addition, in an embodiment of the present specification, when the compression format is CSOA, the operation unit performs a sparse matrix sparse matrix multiplication (SpMSpM) operation of a compressed sparse column (CSC) converted from the CSOA and the weight filter.

또한, 본 명세서의 일 실시예에서 SpMSpM 연산은 CSC와 CSOA의 외적 연산이다.In addition, in an embodiment of the present specification, the SpMSpM operation is a cross product operation of CSC and CSOA.

본 명세서의 일 실시예에 따른 컨볼루션 신경망 가속 방법 및 장치는 가중치의 희소성뿐만 아니라 입력 활성값의 희소성을 이용하여 의미 없는 연산 수행을 최소화하고, 컨볼루션 신경망의 추론 속도를 향상시킬 수 있다.The method and apparatus for accelerating a convolutional neural network according to an embodiment of the present specification can use sparsity of weights as well as sparsity of input active values to minimize meaningless operation and improve inference speed of a convolutional neural network.

또한 본 명세서의 일 실시예에 따른 컨볼루션 신경망 가속 방법 및 장치는 3차원 입력 텐서를 2차원 입력 행렬로 변환하지 않고 압축 포맷으로 변환하여 메모리 낭비 및 오버헤드의 발생을 방지할 수 있다.In addition, the method and apparatus for accelerating a convolutional neural network according to an embodiment of the present specification may convert a 3D input tensor into a compressed format without converting it into a 2D input matrix, thereby preventing memory waste and overhead.

도 1은 컨볼루션 신경망에서 입력 이미지의 객체를 인식하는 단계를 나타낸 도면이다.
도 2는 본 명세서의 일 실시예에 따른 컨볼루션 신경망 가속 장치의 구성도이다.
도 3은 본 명세서의 일 실시예에서 3차원 텐서 입력을 압축 포맷 중 하나인 CSC로 변환하는 방법을 나타낸 도면이다.
도 4는 종래의 3차원 텐서 입력에서 압축 포맷으로 변환하는 과정을 나타낸 도면이다.
도 5는 본 명세서의 일 실시예에서 3차원 텐서 입력에서 압축 포맷으로 변환하는 과정을 나타낸 도면이다.
도 6은 im2CSR 변환 방법을 이용하여 3차원 텐서 입력을 CSR로 변환하고, 3차원 텐서 출력을 산출하는 과정을 나타낸 도면이다.
도 7은 im2CSR 변환 방법에 대한 알고리즘 의사코드를 나타낸 도면이다.
도 8은 im2CSOA 변환 방법을 이용하여 3차원 텐서 입력을 CSOA로 변환하고, 3차원 텐서 출력을 산출하는 과정을 나타낸 도면이다.
도 9은 im2CSOA 변환 방법에 대한 알고리즘 의사코드를 나타낸 도면이다.
도 10은 본 명세서의 일 실시예에 따른 컨볼루션 신경망 가속 방법의 순서도이다.
1 is a diagram illustrating a step of recognizing an object of an input image in a convolutional neural network.
2 is a block diagram of an apparatus for accelerating a convolutional neural network according to an embodiment of the present specification.
3 is a diagram illustrating a method of converting a 3D tensor input into CSC, which is one of the compression formats, according to an embodiment of the present specification.
4 is a diagram illustrating a process of converting a conventional 3D tensor input into a compressed format.
5 is a diagram illustrating a process of converting a 3D tensor input into a compressed format according to an embodiment of the present specification.
6 is a diagram illustrating a process of converting a 3D tensor input to a CSR and calculating a 3D tensor output using the im2CSR transformation method.
7 is a diagram illustrating an algorithm pseudocode for an im2CSR conversion method.
8 is a diagram illustrating a process of converting a 3D tensor input to a CSOA using the im2CSOA transformation method and calculating a 3D tensor output.
9 is a diagram illustrating an algorithm pseudocode for an im2CSOA conversion method.
10 is a flowchart of a method for accelerating a convolutional neural network according to an embodiment of the present specification.

전술한 목적, 특징 및 장점은 첨부된 도면을 참조하여 상세하게 후술되며, 이에 따라 본 명세서가 속하는 기술분야에서 통상의 지식을 가진 자가 본 명세서의 기술적 사상을 용이하게 실시할 수 있을 것이다. 본 명세서를 설명함에 있어서 본 명세서와 관련된 공지 기술에 대한 구체적인 설명이 본 명세서의 요지를 불필요하게 흐릴 수 있다고 판단되는 경우에는 상세한 설명을 생략한다. 이하, 첨부된 도면을 참조하여 본 명세서에 따른 바람직한 실시예를 상세히 설명하기로 한다. 도면에서 동일한 참조부호는 동일 또는 유사한 구성요소를 가리키는 것으로 사용된다.The above-described objects, features, and advantages will be described below in detail with reference to the accompanying drawings, and accordingly, those of ordinary skill in the art to which this specification belongs will be able to easily implement the technical idea of the present specification. In the description of the present specification, if it is determined that a detailed description of a known technology related to the present specification may unnecessarily obscure the subject matter of the present specification, the detailed description will be omitted. Hereinafter, preferred embodiments according to the present specification will be described in detail with reference to the accompanying drawings. In the drawings, the same reference numerals are used to indicate the same or similar components.

도 1은 컨볼루션 신경망에서 입력 이미지의 객체를 인식하는 단계를 나타낸 도면이다.1 is a diagram illustrating a step of recognizing an object of an input image in a convolutional neural network.

컨볼루션 신경망(Convolutional Neural Networks, CNN)은 여러 단계의 계층을 거쳐 이미지에 포함된 객체를 인식하게 된다. 구체적으로 도 1에 도시된 바와 같이, 입력 이미지(10)가 컨볼루션 신경망에 입력되면 컨볼루션 계층(Convolution Layer)(20), 풀링 계층(Pooling Layer)(30) 및 완전 연결 계층(Fully Connected Later)(40)을 거쳐 인식된 객체의 결과값(50)이 출력될 수 있다.Convolutional Neural Networks (CNN) recognize objects included in images through multiple layers. Specifically, as shown in FIG. 1, when the input image 10 is input to the convolutional neural network, a convolution layer 20, a pooling layer 30, and a fully connected layer ) 40 , a result value 50 of the recognized object may be output.

컨볼루션 계층(20)은 컨볼루션 신경망을 이루는 핵심 요소로써 입력 이미지(10)의 일정 영역의 값들에 대해 가중치를 적용하는 가중치 필터와의 컨볼루션 연산을 통해 객체의 특징을 추출한다. 컨볼루션 계층(20)에서 추출된 특징은 풀링 계층(30)에서의 입력값이 된다.The convolutional layer 20 is a key element constituting the convolutional neural network, and extracts object features through a convolution operation with a weight filter that applies weights to values of a certain region of the input image 10 . A feature extracted from the convolutional layer 20 becomes an input value from the pooling layer 30 .

풀링 계층(30)은 컨볼루션 레이어에서 입력된 일정 크기의 블록을 통합하여 하나의 대푯값으로 대체하는 연산을 수행한다. 풀링 계층(30)는 이와 같은 풀링을 통해 입력 데이터의 사이즈를 줄이고, 과적합(overfitting)을 방지할 수 있다.The pooling layer 30 performs an operation of integrating blocks of a certain size input from the convolution layer and replacing them with one representative value. The pooling layer 30 may reduce the size of input data and prevent overfitting through such pooling.

완전 연결 계층(40)은 한 계층의 모든 뉴런이 그 다음 계층의 모든 뉴런과 연결된 상태를 말한다. 즉, 1차원 배열의 형태로 평탄화 된 행렬을 통해 이미지를 분류하는데 사용되는 계층이다. 완전 연결 계층(40)에서는 여러 계층으로부터 학습된 특징을 통해 이미지를 분류하게 된다.The fully connected layer 40 refers to a state in which all neurons in one layer are connected to all neurons in the next layer. That is, it is a layer used to classify images through a flattened matrix in the form of a one-dimensional array. In the fully connected layer 40, images are classified through features learned from several layers.

이와 같이 입력된 이미지인 고양이 사진은 컨볼루션 신경망을 통해 cat으로 인식되며 분류된다. 이하에서는 본 발명인 컨볼루션 신경망의 여러 계층 중 컨볼루션 계층(20)에서의 신경망 가속을 위한 장치 및 방법에 대해 설명한다.The cat picture, which is the input image in this way, is recognized and classified as a cat through a convolutional neural network. Hereinafter, an apparatus and method for neural network acceleration in the convolutional layer 20 among several layers of the convolutional neural network according to the present invention will be described.

도 2는 본 명세서의 일 실시예에 따른 컨볼루션 신경망 가속 장치의 구성도이다.2 is a block diagram of an apparatus for accelerating a convolutional neural network according to an embodiment of the present specification.

도면을 참조하면 컨볼루션 신경망 가속 장치(22)는 변환부(100), 연산부(200) 및 출력부(300)를 포함한다.Referring to the drawings, the convolutional neural network acceleration device 22 includes a transform unit 100 , an operation unit 200 , and an output unit 300 .

변환부(100)는 3차원 텐서 입력을 행렬 형태의 압축 포맷으로 변경한다. 입력 이미지(10)는 높이, 너비, 채널로 구성된 3차원 텐서로 표현될 수 있고, 높이는 입력 이미지(10)의 세로 방향 픽셀 수, 너비는 입력 이미지(10)의 가로 방향 픽셀 수, 채널은 색 성분을 의미한다. 흑백 이미지는 채널 수가 1이며, 컬러 이미지는 적색(Red), 녹색(Green), 청색(Blue)으로 채널 수가 3이다. 또한, 각 픽셀은 0부터 255 사이의 값인 입력 활성값을 갖는다. 만약, 높이가 28, 너비가 28인 컬러 이미지가 있다면 이 이미지의 텐서는 (28 × 28 × 3)의 크기를 가지는 3차원 텐서로 표현될 수 있다.The transform unit 100 converts the 3D tensor input into a matrix-type compression format. The input image 10 may be expressed as a three-dimensional tensor consisting of a height, a width, and a channel, the height is the number of pixels in the vertical direction of the input image 10 , the width is the number of pixels in the horizontal direction of the input image 10 , and the channel is the color means ingredients. A black-and-white image has 1 channel, and a color image has 3 channels for red, green, and blue. Also, each pixel has an input active value that is a value between 0 and 255. If there is a color image having a height of 28 and a width of 28, the tensor of this image can be expressed as a three-dimensional tensor having a size of (28 × 28 × 3).

변환부(100)는 이러한 3차원 텐서 입력을 행렬 형태의 압축 포맷으로 변경한다. 압축 포맷은 CSR (Compressed Sparse Row) 및 CSOA (Compressed Sparse Overlapped Activations) 중 어느 하나일 수 있으며, 구체적인 압축 포맷 방법은 후술하여 상세히 설명하도록 한다.The transform unit 100 converts the 3D tensor input into a matrix-type compression format. The compression format may be any one of Compressed Sparse Row (CSR) and Compressed Sparse Overlapped Activations (CSOA), and a detailed compression format method will be described later in detail.

보다 상세하게, 변환부(100)는 3차원 텐서 입력에 포함된 입력 활성값의 희소성 및 가중치 필터에 포함된 가중치의 희소성에 기초하여 3차원 텐서 입력을 압축 포맷으로 변경한다. In more detail, the transform unit 100 converts the 3D tensor input into a compressed format based on the sparsity of the input active values included in the 3D tensor input and the sparsity of the weights included in the weight filter.

3차원 텐서 입력에 포함된 입력 활성값이 0이면 이미지 인식에 의미 없는 값이며, 0인 입력 활성값에 의해 연산 수행 시간이 지연될 수 있다. 따라서, 3차원 텐서 입력에 포함된 입력 활성값의 다수가 0인 경우 변환부(100)는 0을 제거하기 위해 3차원 텐서 입력을 압축 포맷으로 변경한다.If the input active value included in the 3D tensor input is 0, it is a meaningless value for image recognition, and the operation execution time may be delayed by the input active value of 0. Accordingly, when the majority of input active values included in the 3D tensor input are 0, the transform unit 100 changes the 3D tensor input to a compressed format in order to remove 0.

이때, 입력 활성값이 0인 입력 활성값의 개수를 기준으로 입력 활성값의 희소성이 결정된다. 즉, 변환부(100)는 입력 활성값의 희소성 결정의 기준이 되는 입력 활성 기준값 및 입력 활성 기준값을 미리 설정할 수있다. 상세하게, 변환부(100)는 입력 활성값이 0인 입력 활성값의 개수가 미리 설정된 입력 활성 기준값 미만이면 밀집으로 판단하고, 입력 활성값이 0인 입력 활성값의 개수가 미리 설정된 입력 활성 기준값 이상이면 희소로 판단하여 입력 활성값의 희소성을 결정한다. In this case, the sparseness of the input active value is determined based on the number of input active values in which the input active value is 0. That is, the converter 100 may preset an input activity reference value and an input activity reference value that are criteria for determining the sparseness of the input activity value. In detail, the conversion unit 100 determines that if the number of input active values having an input active value of 0 is less than a preset input active reference value, it is determined to be dense, and the number of input active values having an input active value of 0 is a preset input active reference value. If it is greater than or equal to, it is determined as sparse, and the sparseness of the input active value is determined.

마찬가지로 가중치 필터에 포함된 가중치가 0인 가중치의 개수를 기준으로 가중치의 희소성이 결정된다. 즉, 변환부(100)는 가중치의 희소성 결정의 기준이 되는 가중치 기준값 및 가중치 기준값을 미리 설정할 수 있다. 상세하게, 변환부(100)는 가중치가 0인 가중치의 개수가 미리 설정된 가중치 기준값 미만이면 밀집으로 판단하고, 상기 가중치가 0인 가중치의 개수가 미리 설정된 가중치 기준값 이상이면 희소로 판단하여 가중치의 희소성을 결정한다. Similarly, the sparsity of the weight is determined based on the number of weights with zero weight included in the weight filter. That is, the conversion unit 100 may preset a weight reference value and a weight reference value, which are criteria for determining the scarcity of the weight. In detail, if the number of weights with zero weights is less than a preset weight reference value, the conversion unit 100 determines that the weights are dense, and if the number of weights with zero weights is greater than or equal to a preset weight reference value, determines them as sparse. to decide

예를 들어, 9개의 가중치가 포함되는 가중치 필터에서 가중치 기준값이 3이고 가중치 기준값이 6인 경우 변환부(100)는 가중치가 0인 가중치의 개수가 2이면 가중치의 희소성을 밀집으로 판단하고, 가중치가 0인 가중치의 개수가 8이면 가중치의 희소성을 희소로 판단하여 가중치의 희소성을 결정한다.For example, in a weight filter including 9 weights, when the weight reference value is 3 and the weight reference value is 6, the transformation unit 100 determines the sparseness of the weights as dense if the number of weights with 0 weights is 2, If the number of weights with 0 is 8, the sparsity of the weights is determined by determining the sparsity of the weights.

다시 말해, 본 명세서에 따른 컨볼루션 신경망 가속 장치(22)는 입력 활성값의 희소성 및 가중치의 희소성을 모두 고려하여 압축 포맷으로 변환하고 컨볼루션 연산을 수행함으로써 컨볼루션 신경망의 추론 속도를 향상시킬 수 있다.In other words, the convolutional neural network acceleration device 22 according to the present specification can improve the inference speed of the convolutional neural network by converting it into a compressed format in consideration of both the sparsity of the input active value and the sparsity of the weight and performing the convolution operation. have.

구체적으로, 본 명세서에서 변환부(100)는 입력 활성값이 희소한 경우를 전제로 가중치가 희소한 경우 및 밀집한 경우로 나누어 3차원 텐서 입력을 서로 다른 변환 방법을 통해 서로 다른 압축 포맷으로 변환한다. Specifically, in the present specification, the transform unit 100 converts the 3D tensor input into different compression formats through different transformation methods by dividing the weights into sparse and dense cases on the premise that the input active value is sparse. .

즉, 입력 활성값의 희소성이 희소로 판단되고, 가중치의 희소성이 밀집으로 판단되면 im2CSR (image to Compressed Sparse Row)가속 방법을 통해 상기 3차원 텐서 입력을 CSR로 변경하고, 입력 활성값의 희소성 및 가중치의 희소성이 모두 희소로 판단되면 im2CSOA (image to Compressed Sparse Overlapped Activations) 가속 방법을 통해 3차원 텐서 입력을 CSOA로 변환한다. 구체적인 압축 포맷의 변환 방법에 대해서는 후술하여 설명한다. That is, when the sparseness of the input activation value is determined to be sparse and the sparseness of the weights is determined to be dense, the 3D tensor input is changed to CSR through the im2CSR (image to compressed sparse row) acceleration method, and the sparsity and When all weights are judged to be sparse, the 3D tensor input is converted to CSOA through the im2CSOA (image to Compressed Sparse Overlapped Activations) acceleration method. A specific compression format conversion method will be described later.

입력 활성값이 희소하지 않은 경우, 종래의 신경망 압축 방법인 Lowering method 또는 Direct Sparse Convolution 과 같이 가중치의 희소성만이 고려되는 방법이 사용되는 바, 본 명세서에서는 입력 활성값이 희소하지 않은 경우를 전제하지 않는다.When the input activation value is not sparse, a method in which only the sparsity of the weight is considered is used, such as the conventional lowering method or Direct Sparse Convolution, which is a conventional neural network compression method. does not

연산부(200)는 변환된 압축 포맷에 기초하여 연산을 수행한다. 구체적으로, 압축 포맷이 CSR인 경우 연산부(200)는 CSR과 가중치 필터의 SpMDM (Sparse Matrix Dense Matrix multiplication) 연산을 수행하고, 압축 포맷이 CSOA인 경우 CSOA와 가중치 필터로부터 변환된 CSC (Compressed Sparse Column)의 SpMSpM (Sparse Matrix Sparse Matrix multiplication) 연산을 수행한다.The operation unit 200 performs an operation based on the converted compression format. Specifically, when the compression format is CSR, the operation unit 200 performs Sparse Matrix Dense Matrix multiplication (SpMDM) operation of the CSR and the weight filter, and when the compression format is the CSOA, the Compressed Sparse Column (CSC) converted from the CSOA and the weight filter. ) of SpMSpM (Sparse Matrix Sparse Matrix multiplication) operation.

출력부(300)는 연산의 결과로부터 3차원 텐서 출력을 산출한다. 컨벌루션 계층(20)에서 산출된 3차원 텐서 출력은 풀링 계층(30)의 입력으로 활용된다.The output unit 300 calculates a 3D tensor output from the result of the operation. The 3D tensor output calculated from the convolutional layer 20 is used as an input of the pooling layer 30 .

도 3은 본 명세서의 일 실시예에서 3차원 텐서 입력을 압축 포맷 중 하나인 CSC로 변환하는 방법을 나타낸 도면이다.3 is a diagram illustrating a method of converting a 3D tensor input into CSC, which is one of the compression formats, according to an embodiment of the present specification.

3차원 텐서 입력(110)에 포함된 입력 활성값은 복수이며, 서로 같거나 다른 값을 갖는다. 여기서 변환부(100)는 3차원 텐서 입력(110)을 입력 활성값 중 0인 값을 제거하고 3개의 행렬 형태인 압축 포맷으로 변환할 수 있다. 압축 포맷은 0이 아닌 입력 활성값의 정보만을 가지고 있기 때문에 이후 연산 수행시 정확성 손실이 최소화 될 수 있다.A plurality of input active values included in the 3D tensor input 110 have the same or different values. Here, the transform unit 100 may convert the 3D tensor input 110 into a compressed format in the form of three matrices by removing a value of 0 among input active values. Since the compression format only has information of non-zero input active values, loss of accuracy can be minimized when performing subsequent calculations.

도면을 참조하면 변환부(100)는 3차원 텐서 입력(110)를 압축 포맷(130) 중 하나인 CSR(Compressed Sparse Row)로 변환한다. CSR에는 3차원 텐서 입력(110)의 입력 활성값이 가로의 순서대로 재정렬된다. 구체적으로, 첫번째 행렬인 PTR(132)에는 0이 아닌 입력 활성값의 개수인 행 압축 정보가 저장된다. 두번째 행렬인 COL(134)에는 열 인덱스 값이 저장되고, 세번째 행렬인 VAL(136)에는 입력 활성값 데이터가 저장된다. Referring to the drawing, the converter 100 converts the 3D tensor input 110 into a Compressed Sparse Row (CSR) which is one of the compression formats 130 . In the CSR, the input active values of the 3D tensor input 110 are rearranged in a horizontal order. Specifically, the first matrix PTR 132 stores row compression information, which is the number of non-zero input active values. A column index value is stored in a second matrix, COL 134 , and input activation value data is stored in a third matrix, VAL 136 .

예컨대, 3차원 텐서 입력(110)에서 첫번째 행의 입력 활성값은 2,1, 두번째 행의 입력 활성값은 2,7, 세번째 행의 입력 활성값은 7,9,9, 마지막 행의 입력 활성값은 1,2의 값을 각각 갖는다. For example, in the 3D tensor input 110 , the input active values of the first row are 2,1, the input active values of the second row are 2,7, the input active values of the third row are 7,9,9, and the input active values of the last row Each value has a value of 1,2.

PTR(132)에는 0을 시작으로 각 행의 입력 활성값 개수가 누적되어 표시되므로 0,2,4,7,9의 값이 저장된다. COL(134)에는 열 인덱스로 3차원 텐서 입력(110)의 좌측부터 0,1,2,3의 열 인덱스를 가지므로 0.1,1,2,0,2,3,1,3의 값이 저장된다. VAL(136)에는 입력 활성값 데이터인 2,1,2,7,7,9,9,1,2의 값이 저장된다. 이와 같이 변환된 압축 포맷은 0이 아닌 입력 활성값이 3차원 텐서 입력(110)에서 어느 위치에 어느 값이 들어가는지에 대한 정보를 포함한다.Since the number of input active values in each row is accumulated and displayed in the PTR 132, starting with 0, values of 0, 2, 4, 7, and 9 are stored. Since the COL 134 has a column index of 0,1,2,3 from the left of the 3D tensor input 110 as a column index, values of 0.1,1,2,0,2,3,1,3 are stored. do. The VAL 136 stores values of 2,1,2,7,7,9,9,1,2, which are input active value data. The compressed format converted in this way includes information on which value is included in which position in the 3D tensor input 110 of the non-zero input active value.

도 3에서는 CSR의 변환 방법을 설명하였으나, CSC(Compressed Sparse Column)는 입력 활성값을 세로의 순서대로 재정렬하고, CSOA(Compressed Sparse Overlapped Activations)는 가중치가 부여된 입력 활성값을 가로의 순서대로 재정렬한 압축 포맷으로서 CSC 및 CSOA 또한 CSR의 변환 방법과 유사하게 변환될 수 있다.Although the conversion method of CSR has been described in FIG. 3 , Compressed Sparse Column (CSC) rearranges input activation values in a vertical order, and Compressed Sparse Overlapped Activations (CSOA) rearranges weighted input activation values in a horizontal order. As one compression format, CSC and CSOA can also be converted similarly to the conversion method of CSR.

도 4는 종래의 3차원 텐서 입력에서 압축 포맷으로 변환하는 과정을 나타낸 도면이고, 도 5는 본 명세서의 일 실시예에서 3차원 텐서 입력에서 압축 포맷으로 변환하는 과정을 나타낸 도면이다. 이하, 도 4 및 도 5를 참조하여 설명하도록 한다.4 is a diagram illustrating a process of converting a conventional 3D tensor input into a compressed format, and FIG. 5 is a diagram illustrating a process of converting a 3D tensor input into a compressed format according to an embodiment of the present specification. Hereinafter, it will be described with reference to FIGS. 4 and 5 .

도 4를 참조하면, 종래에는 3차원 텐서 입력(110)을 2차원 행렬(120)로 먼저 변환한 뒤 변환된 2차원 행렬(120)을 다시 CSR 등의 압축 포맷(130)으로 변환하였다. 이는, 가중치 필터와의 행렬 곱 연산에서 3차원보다 같은 차원인 2차원 행렬 간의 연산이 더 빠르기 때문이다.Referring to FIG. 4 , conventionally, a 3D tensor input 110 is first converted into a 2D matrix 120 , and then the 2D matrix 120 is converted back into a compression format 130 such as CSR. This is because, in the matrix multiplication operation with the weight filter, the operation between the two-dimensional matrix of the same dimension is faster than the three-dimensional operation.

그러나, 3차원 텐서 입력(110)을 2차원 행렬(120)로 변환하는 경우 변환하는 과정에서 시간 지연이 발생하며, 추가적으로 메모리 오버헤드의 문제가 발생할 수 있다.However, when the 3D tensor input 110 is converted into the 2D matrix 120, a time delay occurs in the conversion process, and a problem of additional memory overhead may occur.

본 명세서의 일 실시예에 따른 컨볼루션 신경망 가속 장치(22)는 도 5에 도시된 바와 같이 3차원 텐서 입력(110)을 2차원 행렬(120)을 거치지 않고 바로 압축 포맷(130)으로 변환한다.The convolutional neural network acceleration apparatus 22 according to an embodiment of the present specification converts the 3D tensor input 110 directly into the compression format 130 without going through the 2D matrix 120 as shown in FIG. 5 . .

따라서, 3차원 텐서 입력(110)을 2차원 행렬(120)로 변환하는 과정에서 발생하는 시간 지연 및 메모리 오버헤드의 문제는 발생하지 않는다. 또한, 이에 따라 컨볼루션 계층(20)의 연산 속도가 향상되며 전체적인 컨볼루션 신경망의 추론 속도가 가속될 수 있다.Accordingly, problems of time delay and memory overhead that occur in the process of transforming the 3D tensor input 110 into the 2D matrix 120 do not occur. In addition, according to this, the operation speed of the convolutional layer 20 may be improved, and the inference speed of the overall convolutional neural network may be accelerated.

한편, 압축 포맷(130)은 CSR 및 CSOA 중 어느 하나일 수 있고, 3차원 텐서 입력(110)은 3차원 텐서 입력에 포함된 입력 활성값의 희소성 및 가중치 필터에 포함된 가중치의 희소성에 기초하여 압축 포맷으로 변환될 수 있다. 또한, 상술한 압축 포맷(130)은 im2SCR 또는 im2CSOA 변환 방법을 통해 3차원 텐서 입력(110)으로부터 변환될 수 있다. Meanwhile, the compression format 130 may be any one of CSR and CSOA, and the 3D tensor input 110 is based on the sparsity of the input active values included in the 3D tensor input and the sparsity of the weights included in the weight filter. It can be converted to a compressed format. In addition, the above-described compression format 130 may be converted from the 3D tensor input 110 through an im2SCR or im2CSOA transformation method.

도 6은 im2CSR 변환 방법을 이용하여 3차원 텐서 입력을 CSR로 변환하고, 3차원 텐서 출력을 산출하는 과정을 나타낸 도면이고, 도 7은 im2CSR 변환 방법에 대한 알고리즘 의사코드를 나타낸 도면이다.6 is a diagram illustrating a process of converting a 3D tensor input to a CSR using the im2CSR transformation method and calculating a 3D tensor output, and FIG. 7 is a diagram illustrating an algorithm pseudocode for the im2CSR transformation method.

이하, 도6 및 도 7을 참조하여 설명하도록 한다.Hereinafter, it will be described with reference to FIGS. 6 and 7 .

3차원 텐서 입력(110)은 3차원 텐서 입력에 포함된 입력 활성값의 희소성 및 가중치 필터에 포함된 가중치의 희소성에 기초하여 압축 포맷으로 변환될 수 있다. 구체적으로, 변환부(100)는 입력 활성값의 희소성이 희소로 판단되고, 가중치의 희소성이 밀집으로 판단되면 im2CSR (image to Compressed Sparse Row)변환 방법을 통해 3차원 텐서 입력을 CSR로 변환하고, 입력 활성값의 희소성 및 가중치의 희소성이 모두 희소로 판단되면 im2CSOA(image to Compressed Sparse Overlapped Activations) 변환 방법을 통해 3차원 텐서 입력을 CSOA로 변환한다. 입력 활성값의 희소성 및 가중치의 희소성을 결정하는 방법에 대해서는 상술한 바와 같다.The 3D tensor input 110 may be converted into a compressed format based on the sparsity of the input active values included in the 3D tensor input and the sparsity of the weights included in the weight filter. Specifically, when the sparseness of the input active value is determined to be sparse and the sparseness of the weights is determined to be dense, the transformation unit 100 converts the 3D tensor input into a CSR through an image to Compressed Sparse Row (im2CSR) transformation method, When both the sparsity of the input activation values and the sparsity of the weights are determined to be sparse, the 3D tensor input is converted into CSOA through the image to Compressed Sparse Overlapped Activations (im2CSOA) transformation method. The method of determining the sparsity of the input active value and the sparsity of the weight has been described above.

도 6에 도시된 바와 같이, 3차원 텐서 입력(110)에 포함된 입력 활성값(112)이 희소로 판단되고 가중치 필터에 포함된 가중치의 희소성이 밀집으로 판단된 경우 im2CSR 변환 방법을 통해 3차원 텐서 입력(110)이 CSR(130)로 변환된다. As shown in FIG. 6 , when it is determined that the input activation values 112 included in the 3D tensor input 110 are sparse and the sparseness of the weights included in the weight filter is determined to be dense, the im2CSR transformation method is used to 3D The tensor input 110 is converted to a CSR 130 .

이후, 연산부(200)는 변환된 CSR을 2차원 행렬인 가중치 필터(210)와 연산하면 출력부(300)는 연산의 결과로부터 3차원 텐서 출력(310)을 산출한다. 이때 사용되는 연산 방법은 내적 기반의 행렬 곱을 수행하는 SpMDM일 수 있다.Thereafter, the calculation unit 200 calculates the transformed CSR with the weight filter 210 which is a 2D matrix, and the output unit 300 calculates a 3D tensor output 310 from the result of the operation. In this case, the calculation method used may be SpMDM which performs matrix multiplication based on dot product.

한편, im2CSR 변환 방법은 도 7에 도시된 알고리즘 의사코드에 의해 수행된다. 알고리즘의 실제 구현은 32비트 부동 소수점의 4-way ARM advanced Single Instruction Multiple Data (SIMD) 유닛과 스레드 수준 병렬 처리를 위하여 OpenMP가 사용되었다. Meanwhile, the im2CSR transformation method is performed by the algorithm pseudocode shown in FIG. 7 . The actual implementation of the algorithm used a 32-bit floating-point 4-way ARM advanced Single Instruction Multiple Data (SIMD) unit and OpenMP for thread-level parallel processing.

도 7에서 2행 내지 11행은 3차원 텐서 입력을 CSR로 변환하는 알고리즘이다. 여기서 BNNZ는 CSR 압축 포맷인 B에서 0이 아닌 값의 수 (number of nonzero, NNZ)를 나타낸다. Rows 2 to 11 in FIG. 7 are algorithms for converting a 3D tensor input into a CSR. Here, B NNZ represents the number of nonzero values (NNZ) in B, which is the CSR compression format.

또한 12행 내지 17행은 변환된 CSR과 가중치 필터의 SpMDM 연산을 수행하는 알고리즘이다. 내적 기반 SpMDM을 실행하려면 현재 행의 NNZ 정보를 사용할 수 있어야한다. 이 정보를 얻으려면 현재 NNZ 값의 누적 값을 다음 NNZ 값의 누적 값에서 빼야 한다. 14행에 표현된 내적 기반 SpMDM은 이 NNZ만큼 반복된다.Also, lines 12 to 17 are algorithms for performing SpMDM operation of the transformed CSR and weight filter. To run the dot product-based SpMDM, the NNZ information of the current row must be available. To obtain this information, the cumulative value of the current NNZ value must be subtracted from the cumulative value of the next NNZ value. The dot product-based SpMDM represented in line 14 is repeated by this NNZ.

도 8은 im2CSOA 변환 방법을 이용하여 3차원 텐서 입력을 CSOA로 변환하고, 3차원 텐서 출력을 산출하는 과정을 나타낸 도면이고, 도 9는 im2CSOA 변환 방법에 대한 알고리즘 의사코드를 나타낸 도면이다. 이하, 도8 및 도 9를 참조하여 설명하도록 한다.8 is a diagram illustrating a process of converting a 3D tensor input to a CSOA using the im2CSOA transformation method and calculating a 3D tensor output, and FIG. 9 is a diagram illustrating an algorithm pseudocode for the im2CSOA transformation method. Hereinafter, it will be described with reference to FIGS. 8 and 9 .

도 8에 도시된 바와 같이, 3차원 텐서 입력(110)에 포함된 입력 활성값(112)이 희소로 판단되고 가중치 필터(220)에 포함된 가중치의 희소성 또한 희소로 판단된 경우 im2CSOA(image to Compressed Sparse Overlapped Activations) 변환 방법을 통해 3차원 텐서 입력(110)이 CSOA(130)로 변환된다. As shown in FIG. 8 , when the input active value 112 included in the 3D tensor input 110 is determined to be sparse and the weight included in the weight filter 220 is also determined to be sparse, im2CSOA(image to The 3D tensor input 110 is converted into the CSOA 130 through the Compressed Sparse Overlapped Activations conversion method.

이때, 가중치 필터(220)에 포함된 가중치의 희소성이 희소한 경우에는 가중치의 희소성이 밀집한 경우와는 달리 가중치가 0인 가중치의 개수가 다수이므로 연산의 효율화를 위해 가중치 필터(220) 또한 압축 포맷으로 변환되어야 한다. 변환부(100)는 가중치 필터(220)를 가중치 필터의 가중치를 열의 순서대로 재정렬한 CRC(150) 압축 포맷으로 변환한다. At this time, in the case where the sparseness of the weights included in the weight filter 220 is sparse, unlike the case where the sparseness of the weights is dense, the number of weights with zero weights is large. Therefore, in order to improve the operation efficiency, the weight filter 220 also compresses the format. should be converted to The transform unit 100 converts the weight filter 220 into a CRC 150 compression format in which the weights of the weight filter are rearranged in the order of columns.

이후, 연산부(200)가 변환된 CSC(150)와 변환된 CSOA를 연산하면 출력부(300)는 연산의 결과로부터 3차원 텐서 출력(320)을 산출한다. 이때 사용되는 연산 방법은 외적 기반의 행렬 곱을 수행하는 SpMSpM일 수 있다.Thereafter, when the calculating unit 200 calculates the converted CSC 150 and the converted CSOA, the output unit 300 calculates a 3D tensor output 320 from the result of the operation. In this case, the calculation method used may be SpMSpM which performs matrix multiplication based on the cross product.

즉, 연산부(200)는 im2CSR 변환 방법에서 CSR과 가중치 필터를 통해 내적 기반의 행렬 곱을 수행하는 것과는 달리 im2CSOA 변환 방법에서 CSOA와 CSC를 통해 외적 기반의 행렬 곱을 수행한다.That is, the operation unit 200 performs an outer product-based matrix multiplication through CSOA and CSC in the im2CSOA transformation method, unlike in the im2CSR transformation method where the dot product-based matrix multiplication is performed through CSR and a weight filter.

CSOA와 CSC를 통해 내적 기반의 행렬 곱이 수행되는 경우 곱셈 수행시마다 인덱스가 맞는지 여부를 판단하여야 하므로 인덱스 매칭 과정이 문제되었으나, CSC의 열과 SCOA의 행에 대한 외적 기반의 행렬 곱이 수행됨으로써 인덱스 매칭 문제가 제거될 수 있다. 또한, 0이 아닌 값의 재사용을 최대로 하면서 연산 속도가 향상될 수 있다. When the dot product-based matrix multiplication is performed through CSOA and CSC, the index matching process is a problem because it is necessary to determine whether the index is correct each time the multiplication is performed. can be removed. In addition, the operation speed may be improved while maximizing the reuse of non-zero values.

한편, im2CSOA 변환 방법은 도 9에 도시된 알고리즘 의사코드에 의해 수행된다.Meanwhile, the im2CSOA conversion method is performed by the algorithm pseudocode shown in FIG. 9 .

im2CSR와 마찬가지로 알고리즘의 실제 구현은 32비트 부동 소수점 4-way ARM SIMD와 OpenMP가 사용되었다. Like im2CSR, the actual implementation of the algorithm used 32-bit floating point 4-way ARM SIMD and OpenMP.

도 9에서 2행 내지 11행은 가중치 필터(220)를 CSC(150)로 변환하는 알고리즘이다. 또한, 12행 내지 21행은 3차원 텐서 입력(110)을 CSOA(140)로 변환하는 알고리즘이다. 마지막으로 22행 내지 28행은 CSC(150)와 CSOA(140)의 SpMSpM 연산을 수행하는 알고리즘이다.Rows 2 to 11 in FIG. 9 are algorithms for converting the weight filter 220 into the CSC 150 . In addition, lines 12 to 21 are algorithms for converting the 3D tensor input 110 into the CSOA 140 . Finally, lines 22 to 28 are algorithms for performing the SpMSpM operation of the CSC 150 and the CSOA 140 .

도 10은 본 명세서의 일 실시예에 따른 컨볼루션 신경망 가속 방법의 순서도이다. 10 is a flowchart of a method for accelerating a convolutional neural network according to an embodiment of the present specification.

도면을 참조할 때, 변환부(100)가 3차원 텐서 입력을 압축 포맷으로 변환하면(S100), 연산부(200)는 변환된 압출 포맷에 기초하여 연산을 수행한다(S200).Referring to the drawings, when the converting unit 100 converts the 3D tensor input into a compressed format (S100), the calculating unit 200 performs an operation based on the converted extrusion format (S200).

구체적으로 변환부(100)는 3차원 텐서 입력에 포함된 입력 활성값의 희소성 및 가중치 필터에 포함된 가중치의 희소성에 기초하여 3차원 텐서 입력을 압축 포맷으로 변환한다.Specifically, the transform unit 100 converts the 3D tensor input into a compressed format based on the sparsity of the input active values included in the 3D tensor input and the sparsity of the weights included in the weight filter.

다시 말해, 변환부(100)는 입력 활성값의 희소성이 희소로 판단되고, 가중치의 희소성이 밀집으로 판단되면 im2CSR (image to Compressed Sparse Row)변환 방법을 통해 3차원 텐서 입력을 상기 CSR로 변환하고, 입력 활성값의 희소성 및 가중치의 희소성이 모두 희소로 판단되면 im2CSOA (image to Compressed Sparse Overlapped Activations) 변환 방법을 통해 3차원 텐서 입력을 CSOA로 변환한다.In other words, when the sparseness of the input active value is determined to be sparse and the sparseness of the weights is determined to be dense, the transform unit 100 converts the 3D tensor input into the CSR through the im2CSR (image to Compressed Sparse Row) transformation method, , when the sparsity of the input activation values and the sparsity of the weights are all determined to be sparse, the 3D tensor input is converted into CSOA through the im2CSOA (image to Compressed Sparse Overlapped Activations) transformation method.

이후, 출력부(300)는 연산의 결과로부터 3차원 텐서 출력을 산출한다(S300). 산출된 3차원 텐서 출력은 풀링 계층(30)의 입력으로 활용될 수 있다.Thereafter, the output unit 300 calculates a three-dimensional tensor output from the result of the operation (S300). The calculated 3D tensor output may be utilized as an input of the pooling layer 30 .

본 명세서의 일 실시예에 따른 컨볼루션 신경망 가속 방법은 가중치의 희소성뿐만 아니라 입력 활성값의 희소성을 이용하여 의미 없는 연산 수행을 최소화하고, 컨볼루션 신경망의 추론 속도를 향상시킬 수 있다.The method for accelerating a convolutional neural network according to an embodiment of the present specification may use sparsity of an input active value as well as sparsity of weights to minimize meaningless operation and improve inference speed of a convolutional neural network.

또한 본 명세서의 일 실시예에 따른 컨볼루션 신경망 가속 방법은 3차원 입력 텐서를 2차원 입력 행렬로 변환하지 않고 압축 포맷으로 변환하여 메모리 낭비 및 오버헤드의 발생을 방지할 수 있다.In addition, the convolutional neural network acceleration method according to an embodiment of the present specification converts a 3D input tensor into a compressed format without converting it into a 2D input matrix, thereby preventing memory waste and overhead.

이상과 같이 본 발명에 대해서 예시한 도면을 참조로 하여 설명하였으나, 본 명세서에 개시된 실시 예와 도면에 의해 본 발명이 한정되는 것은 아니며, 본 발명의 기술사상의 범위 내에서 통상의 기술자에 의해 다양한 변형이 이루어질 수 있음은 자명하다. 아울러 앞서 본 발명의 실시 예를 설명하면서 본 발명의 구성에 따른 작용 효과를 명시적으로 기재하여 설명하지 않았을지라도, 해당 구성에 의해 예측 가능한 효과 또한 인정되어야 함은 당연하다.As described above, the present invention has been described with reference to the illustrated drawings, but the present invention is not limited by the embodiments and drawings disclosed in the present specification. It is obvious that variations can be made. In addition, although the effect of the configuration of the present invention has not been explicitly described and described while describing the embodiment of the present invention, it is natural that the effect predictable by the configuration should also be recognized.

Claims (16)

컨볼루션 신경망을 압축하여 연산 속도를 향상시키는 컨볼루션 신경망 가속 방법에 있어서,
3차원 텐서 입력에 포함된 입력 활성값의 희소성 및 가중치 필터에 포함된 가중치의 희소성에 기초하여 상기 3차원 텐서 입력을 압축 포맷으로 변환하는 단계;
상기 변환된 압축 포맷에 기초하여 연산을 수행하는 단계; 및
상기 연산의 결과로부터 3차원 텐서 출력을 산출하는 단계를 포함하는
컨볼루션 신경망 가속 방법.
In the convolutional neural network acceleration method for improving computation speed by compressing the convolutional neural network,
converting the 3D tensor input into a compressed format based on the sparsity of the input active values included in the 3D tensor input and the sparsity of the weights included in the weight filter;
performing an operation based on the converted compression format; and
Comprising the step of calculating a three-dimensional tensor output from the result of the operation
Convolutional neural network acceleration method.
제1항에 있어서,
상기 압축 포맷은
CSR (Compressed Sparse Row) 및 CSOA (Compressed Sparse Overlapped Activations) 중 어느 하나인
컨볼루션 신경망 가속 방법.
According to claim 1,
The compression format is
Compressed Sparse Row (CSR) or Compressed Sparse Overlapped Activations (CSOA)
Convolutional neural network acceleration method.
제2항에 있어서,
상기 3차원 텐서 입력을 압축 포맷으로 변환하는 단계는
상기 입력 활성값이 0인 입력 활성값의 개수가 미리 설정된 입력 활성 기준값 미만이면 밀집으로 판단하고, 상기 입력 활성값이 0인 입력 활성값의 개수가 상기 입력 활성 기준값 이상이면 희소로 판단하여 입력 활성값의 희소성을 결정하고,
상기 가중치가 0인 가중치의 개수가 미리 설정된 가중치 기준값 미만이면 밀집으로 판단하고, 상기 가중치가 0인 가중치의 개수가 상기 가중치 기준값 이상이면 희소로 판단하여 가중치의 희소성을 결정하는
컨볼루션 신경망 가속 방법.
3. The method of claim 2,
The step of converting the 3D tensor input into a compressed format includes:
If the number of input active values of which the input active value is 0 is less than a preset input activation reference value, it is determined as dense, and if the number of input active values of which the input active value is 0 is equal to or greater than the input active reference value, it is determined as sparse, and input activation determine the sparsity of a value,
If the number of weights with zero weight is less than a preset weight reference value, it is determined as dense, and when the number of weights with zero weight is greater than or equal to the weight reference value, it is determined as sparse to determine the sparseness of the weights.
Convolutional neural network acceleration method.
제3항에 있어서,
상기 입력 활성값의 희소성이 희소로 판단되고, 상기 가중치의 희소성이 밀집으로 판단되면 im2CSR (image to Compressed Sparse Row)변환 방법을 통해 상기 3차원 텐서 입력을 상기 CSR로 변환하는
컨볼루션 신경망 가속 방법.
4. The method of claim 3,
When the sparseness of the input activation value is determined to be sparse and the sparseness of the weights is determined to be dense, converting the 3D tensor input into the CSR through an image to Compressed Sparse Row (im2CSR) transformation method
Convolutional neural network acceleration method.
제3항에 있어서,
상기 입력 활성값의 희소성 및 상기 가중치의 희소성이 모두 희소로 판단되면 im2CSOA (image to Compressed Sparse Overlapped Activations) 변환 방법을 통해 상기 3차원 텐서 입력을 상기 CSOA로 변환하는
컨볼루션 신경망 가속 방법.
4. The method of claim 3,
When the sparsity of the input activation value and the sparsity of the weight are both determined to be sparse, the 3D tensor input is converted into the CSOA through an image to Compressed Sparse Overlapped Activations (im2CSOA) transformation method.
Convolutional neural network acceleration method.
제2항에 있어서,
상기 변환된 압축 포맷에 기초하여 연산을 수행하는 단계는
상기 압축 포맷이 CSR인 경우 상기 CSR과 상기 가중치 필터의 SpMDM (Sparse Matrix Dense Matrix multiplication) 연산을 수행하는
컨볼루션 신경망 가속 방법.
3. The method of claim 2,
The step of performing an operation based on the converted compression format
When the compression format is CSR, performing Sparse Matrix Dense Matrix multiplication (SpMDM) operation of the CSR and the weight filter
Convolutional neural network acceleration method.
제2항에 있어서,
상기 변환된 압축 포맷에 기초하여 연산을 수행하는 단계는
상기 압축 포맷이 CSOA인 경우 상기 CSOA와 상기 가중치 필터로부터 변환된 CSC (Compressed Sparse Column)의 SpMSpM (Sparse Matrix Sparse Matrix multiplication) 연산을 수행하는
컨볼루션 신경망 가속 방법.
3. The method of claim 2,
The step of performing an operation based on the converted compression format
When the compression format is CSOA, performing a Sparse Matrix Sparse Matrix multiplication (SpMSpM) operation of the CSOA and the CSC (Compressed Sparse Column) converted from the weight filter.
Convolutional neural network acceleration method.
제7항에 있어서,
상기 SpMSpM 연산은
상기 CSC와 상기 CSOA의 외적 연산인
컨볼루션 신경망 가속 방법.
8. The method of claim 7,
The SpMSpM operation is
The cross product operation of the CSC and the CSOA
Convolutional neural network acceleration method.
컨볼루션 신경망을 압축하여 연산 속도를 향상시키는 컨볼루션 신경망 가속 장치에 있어서,
3차원 텐서 입력에 포함된 입력 활성값의 희소성 및 가중치 필터에 포함된 가중치의 희소성에 기초하여 상기 3차원 텐서 입력을 압축 포맷으로 변환하는 변환부;
상기 변환된 압축 포맷에 기초하여 연산을 수행하는 연산부; 및
상기 연산의 결과로부터 3차원 텐서 출력을 산출하는 출력부를 포함하는
컨볼루션 신경망 가속 장치.
In the convolutional neural network accelerator for improving computation speed by compressing the convolutional neural network,
a conversion unit converting the 3D tensor input into a compressed format based on the sparsity of the input active values included in the 3D tensor input and the sparsity of the weights included in the weight filter;
an operation unit for performing an operation based on the converted compression format; and
and an output unit for calculating a three-dimensional tensor output from the result of the operation
Convolutional Neural Network Accelerator.
제9항에 있어서,
상기 압축 포맷은
CSR (Compressed Sparse Row) 및 CSOA (Compressed Sparse Overlapped Activations) 중 어느 하나인
컨볼루션 신경망 가속 장치.
10. The method of claim 9,
The compression format is
Compressed Sparse Row (CSR) or Compressed Sparse Overlapped Activations (CSOA)
Convolutional Neural Network Accelerator.
제10항에 있어서,
상기 변환부는
상기 입력 활성값이 0인 입력 활성값의 개수가 미리 설정된 입력 활성 기준값 미만이면 밀집으로 판단하고, 상기 입력 활성값이 0인 입력 활성값의 개수가 상기 입력 활성 기준값 이상이면 희소로 판단하여 상기 입력 활성값의 희소성을 결정하고,
상기 가중치가 0인 가중치의 개수가 미리 설정된 가중치 기준값 미만이면 밀집으로 판단하고, 상기 가중치가 0인 가중치의 개수가 상기 가중치 기준값 이상이면 희소로 판단하여 상기 가중치의 희소성을 결정하는
컨볼루션 신경망 가속 장치.
11. The method of claim 10,
the conversion unit
If the number of input active values of which the input active value is 0 is less than a preset input activation reference value, it is determined as dense, and if the number of input active values with the input active value of 0 is equal to or greater than the input active reference value, it is determined as sparse, and the input determine the sparsity of the active values,
If the number of weights with zero weights is less than a preset weight reference value, it is determined as dense, and when the number of weights with zero weights is greater than or equal to the weight reference value, it is determined as sparse, and the sparseness of the weights is determined.
Convolutional Neural Network Accelerator.
제11항에 있어서,
상기 변환부는
상기 입력 활성값의 희소성이 희소로 판단되고, 상기 가중치의 희소성이 밀집으로 판단되면 im2CSR (image to Compressed Sparse Row) 변환 방법을 통해 상기 3차원 텐서 입력을 상기 CSR로 변환하는
컨볼루션 신경망 가속 장치.
12. The method of claim 11,
the conversion unit
When it is determined that the sparseness of the input activation value is sparse and the sparseness of the weights is determined to be dense, converting the 3D tensor input into the CSR through an image to Compressed Sparse Row (im2CSR) transformation method
Convolutional Neural Network Accelerator.
제11항에 있어서,
상기 변환부는
상기 입력 활성값의 희소성 및 상기 가중치의 희소성이 모두 희소로 판단되면 im2CSOA (image to Compressed Sparse Overlapped Activations) 변환 방법을 통해 상기 3차원 텐서 입력을 상기 CSOA로 변환하는
컨볼루션 신경망 가속 장치.
12. The method of claim 11,
the conversion unit
When the sparsity of the input activation value and the sparsity of the weight are both determined to be sparse, the 3D tensor input is converted into the CSOA through an image to Compressed Sparse Overlapped Activations (im2CSOA) transformation method.
Convolutional Neural Network Accelerator.
제10항에 있어서,
상기 연산부는
상기 압축 포맷이 CSR인 경우 상기 CSR과 상기 가중치 필터의 SpMDM (Sparse Matrix Dense Matrix multiplication) 연산을 수행하는
컨볼루션 신경망 가속 장치.
11. The method of claim 10,
the calculation unit
When the compression format is CSR, performing Sparse Matrix Dense Matrix multiplication (SpMDM) operation of the CSR and the weight filter
Convolutional Neural Network Accelerator.
제10항에 있어서,
상기 연산부는
상기 압축 포맷이 CSOA인 경우 상기 CSOA와 상기 가중치 필터로부터 변환된 CSC (Compressed Sparse Column)의 SpMSpM (Sparse Matrix Sparse Matrix multiplication) 연산을 수행하는
컨볼루션 신경망 가속 장치.
11. The method of claim 10,
the calculation unit
When the compression format is CSOA, performing a Sparse Matrix Sparse Matrix multiplication (SpMSpM) operation of the CSOA and the CSC (Compressed Sparse Column) converted from the weight filter.
Convolutional Neural Network Accelerator.
제15항에 있어서,
상기 SpMSpM 연산은
상기 CSC와 상기 CSOA의 외적 연산인
컨볼루션 신경망 가속 장치.
16. The method of claim 15,
The SpMSpM operation is
The cross product operation of the CSC and the CSOA
Convolutional Neural Network Accelerator.
KR1020210017924A 2021-02-08 2021-02-08 Method and apparatus for accelerating convolutional neural networks KR102644702B1 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
KR1020210017924A KR102644702B1 (en) 2021-02-08 2021-02-08 Method and apparatus for accelerating convolutional neural networks

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
KR1020210017924A KR102644702B1 (en) 2021-02-08 2021-02-08 Method and apparatus for accelerating convolutional neural networks

Publications (2)

Publication Number Publication Date
KR20220114435A true KR20220114435A (en) 2022-08-17
KR102644702B1 KR102644702B1 (en) 2024-03-06

Family

ID=83110692

Family Applications (1)

Application Number Title Priority Date Filing Date
KR1020210017924A KR102644702B1 (en) 2021-02-08 2021-02-08 Method and apparatus for accelerating convolutional neural networks

Country Status (1)

Country Link
KR (1) KR102644702B1 (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
GB2623140A (en) * 2023-03-02 2024-04-10 Imagination Tech Ltd Methods and systems for performing a sparse submanifold convolution using an NNA

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR20180052069A (en) * 2016-11-07 2018-05-17 한국전자통신연구원 Convolution neural network system and method for compressing synapse data of convolution neural network
KR20200067916A (en) * 2016-06-14 2020-06-12 더 가버닝 카운슬 오브 더 유니버시티 오브 토론토 Accelerator for deep neural networks
KR20210006919A (en) * 2018-05-08 2021-01-19 더 가버닝 카운슬 오브 더 유니버시티 오브 토론토 Neural network processing elements

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR20200067916A (en) * 2016-06-14 2020-06-12 더 가버닝 카운슬 오브 더 유니버시티 오브 토론토 Accelerator for deep neural networks
KR20180052069A (en) * 2016-11-07 2018-05-17 한국전자통신연구원 Convolution neural network system and method for compressing synapse data of convolution neural network
KR20210006919A (en) * 2018-05-08 2021-01-19 더 가버닝 카운슬 오브 더 유니버시티 오브 토론토 Neural network processing elements

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
GB2623140A (en) * 2023-03-02 2024-04-10 Imagination Tech Ltd Methods and systems for performing a sparse submanifold convolution using an NNA

Also Published As

Publication number Publication date
KR102644702B1 (en) 2024-03-06

Similar Documents

Publication Publication Date Title
KR102335955B1 (en) Convolution neural network system and operation method thereof
CN110163370A (en) Compression method, chip, electronic equipment and the medium of deep neural network
CN110443883B (en) Plane three-dimensional reconstruction method for single color picture based on droplock
Diana Andrushia et al. Saliency-based image compression using Walsh–Hadamard transform (WHT)
US20210203992A1 (en) Data preprocessing and data augmentation in frequency domain
TW202228081A (en) Method and apparatus for reconstruct image from bitstreams and encoding image into bitstreams, and computer program product
CN111931927B (en) Method and device for reducing occupation of computing resources in NPU
CN116612288B (en) Multi-scale lightweight real-time semantic segmentation method and system
CN110334800A (en) A kind of lightweight 3D convolutional network system for video identification
CN111882053B (en) Neural network model compression method based on splicing convolution
KR20220114435A (en) Method and apparatus for accelerating convolutional neural networks
CN111881920A (en) Network adaptation method of large-resolution image and neural network training device
CN109447239B (en) Embedded convolutional neural network acceleration method based on ARM
CN113361493B (en) Facial expression recognition method robust to different image resolutions
CN114761968B (en) Method, system and storage medium for frequency domain static channel filtering
Wang et al. Design light-weight 3D convolutional networks for video recognition temporal residual, fully separable block, and fast algorithm
CN111626298A (en) Real-time image semantic segmentation device and segmentation method
CN114612309B (en) Full-on-chip dynamic reconfigurable super-resolution device
KR102599753B1 (en) YUV Image Processing Method and System Using A Neural Network Composed Of Dual-Path Blocks
CN110647898A (en) Image processing method, image processing device, electronic equipment and computer storage medium
KR102336381B1 (en) Compression of aurora spectral data
CN113743602B (en) Method for improving post-processing speed of model
CN115620198A (en) Action recognition method, system, equipment and storage medium based on attention mechanism
KR20220114890A (en) Method for computing neural network using ruduction-repetition block and apparatus using the same
CN115908144A (en) Image processing method, device, equipment and medium based on random wavelet attention

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