KR102107077B1 - Line-based memory management method for performing convolution operation in convolutional neural network inference and its inference device - Google Patents

Line-based memory management method for performing convolution operation in convolutional neural network inference and its inference device Download PDF

Info

Publication number
KR102107077B1
KR102107077B1 KR1020180143805A KR20180143805A KR102107077B1 KR 102107077 B1 KR102107077 B1 KR 102107077B1 KR 1020180143805 A KR1020180143805 A KR 1020180143805A KR 20180143805 A KR20180143805 A KR 20180143805A KR 102107077 B1 KR102107077 B1 KR 102107077B1
Authority
KR
South Korea
Prior art keywords
line
line buffer
feature map
convolution
convolution operation
Prior art date
Application number
KR1020180143805A
Other languages
Korean (ko)
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 KR1020180143805A priority Critical patent/KR102107077B1/en
Application granted granted Critical
Publication of KR102107077B1 publication Critical patent/KR102107077B1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T1/00General purpose image data processing
    • G06T1/60Memory management
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0602Interfaces specially adapted for storage systems specifically adapted to achieve a particular effect
    • G06F3/0626Reducing size or complexity of storage systems
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/04Architecture, e.g. interconnection topology
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/08Learning methods
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N5/00Computing arrangements using knowledge-based models
    • G06N5/04Inference or reasoning models

Abstract

The present invention relates to a line unit memory management method for performing a convolution operation in a convolutional neural network inference device including at least one convolutional layer, and an inference device using the same. The line unit memory management method of the present invention comprises the steps of: storing, in a second line buffer, a result of performing a convolution operation of a line unit by accessing at least one line buffer including a first line buffer; and reusing the first line buffer when the first line buffer is no longer used in the convolution operation. According to the present invention, a line buffer for storing input/output feature maps of each convolutional layer in a memory by a horizontal or vertical line unit is used, and the line buffer which is no longer used is allowed to store another line or to be reused for other purposes even though not all convolution operations from the input feature map are completed, such that all input/output feature maps are not required to be stored in the memory. Therefore, an effect of reducing the amount of memory required for the convolution operation compared to that of an existing invention which stores all input/output feature maps.

Description

컨볼루션 신경망 추론에서 컨볼루션 연산을 수행하기 위한 라인 단위 메모리 관리 방법 및 그 추론 장치{LINE-BASED MEMORY MANAGEMENT METHOD FOR PERFORMING CONVOLUTION OPERATION IN CONVOLUTIONAL NEURAL NETWORK INFERENCE AND ITS INFERENCE DEVICE}LINE-BASED MEMORY MANAGEMENT METHOD FOR PERFORMING CONVOLUTION OPERATION IN CONVOLUTIONAL NEURAL NETWORK INFERENCE AND ITS INFERENCE DEVICE}

본 발명은 컨볼루션 신경망(convolutional neural network)을 사용하는 추론(inference)에서 컨볼루션 연산(convolution operation)을 수행하기 위한 메모리 관리 방법 및 그 방법을 사용하는 추론 장치에 관한 것으로, 보다 상세하게는, 컨볼루션 연산을 수행하기 위해 사용되는 메모리를 효율적으로 할당 및 재사용하여 컨볼루션 연산에 요구되는 메모리의 양을 감소시키는 방법 및 그 방법을 사용하는 추론 장치에 관한 것이다.The present invention relates to a memory management method for performing a convolution operation in an inference using a convolutional neural network and a reasoning apparatus using the method, and more specifically, It relates to a method for reducing the amount of memory required for a convolution operation by efficiently allocating and reusing the memory used to perform the convolution operation, and a reasoning apparatus using the method.

프로세서의 발달로 딥러닝(deep learning)을 수행하는 신경망(neural network)을 사용하는 시도가 많아지면서 분류(classification), 회귀(regression), 업스케일링(upscaling) 등의 추론(inference)에 컨볼루션 신경망(convolutional neural network)이 많이 적용되고 있다. 특히, 디스플레이 장치의 해상도가 지속적으로 높아져 기존 Full HD 영상의 4배 및 16배 해상도인 4K 및 8K TV 시장이 확대되고 있는 상황 속에서, 기존의 저해상도로 만들어진 컨텐츠를 고해상도의 장치에서 선명도를 유지하면서도 왜곡이 발생하지 않게 시청할 수 있도록 이미지를 확대하는 초해상도 기술에 컨볼루션 신경망을 사용하는 추론 장치는 매우 좋은 적용 예라고 할 수 있다.Convolutional neural networks for inferences such as classification, regression, and upscaling due to the increasing number of attempts to use neural networks that perform deep learning due to the development of processors. (convolutional neural network) is widely applied. In particular, while the resolution of display devices is constantly increasing, 4K and 8K TV markets, which are 4 times and 16 times the resolution of existing Full HD video, are expanding, while maintaining the clarity of existing low-resolution content on high-resolution devices. A reasoning device using a convolutional neural network for super-resolution technology that enlarges an image so that it can be viewed without distortion is a very good application example.

컨볼루션 신경망은 다층의 컨볼루션 층(convolutional layer)으로 구성된 신경망으로서, 상위 계층으로 갈수록 점진적으로 대상 영역이 확장되는 형태의 특징맵(feature map)을 생성하며, 이 과정에서 receptive field의 연결구조를 통하여 특징점의 위치이동에 강인한 특징맵을 학습해 나간다. 그런데, 일반적으로 컨볼루션 층이 많아질수록 추론의 성능이 좋아지는 것으로 보고되고 있는데, 컨볼루션 층이 많아지면 각 컨볼루션 층마다 입력 및 출력으로 사용되는 특징맵(feature map)의 수도 증가하므로 이를 저장하기 위한 메모리의 양도 함께 증가하는 문제가 발생한다.The convolutional neural network is a neural network composed of multiple layers of convolutional layers, which creates a feature map in a form in which the target region gradually expands toward the upper layer. In this process, the connection structure of the receptive field is created. Through this, students learn feature maps that are robust to the movement of feature points. However, in general, it has been reported that as the number of convolutional layers increases, the performance of inference improves. As the number of convolutional layers increases, the number of feature maps used as inputs and outputs increases for each convolutional layer, thereby saving it. The amount of memory for doing so also increases.

도 1은 학습된 필터(또는 커널)를 사용하여 컨볼루션 연산을 수행하는 예를 도시하고 있다(“vImage Programming Guide,”Apple Inc., Cupertino, CA, USA, 2016). 도 1을 참조하면, 컨볼루션 신경망을 구성하는 각 컨볼루션 층은 입력 특징맵(1)으로부터 컨볼루션 연산을 수행하여 출력 특징맵(3)을 생성한다. 입력 특징맵(1)은 추론할 입력 데이터이거나 전단계 컨볼루션 층의 출력 특징맵이고, 출력 특징맵(3)은 추론된 출력 데이터로 사용되거나 다음 단계 컨볼루션 층의 입력 특징맵으로 사용된다. 컨볼루션 연산은 학습된 가중치(weight)로 구성되는 필터(또는 커널)를 통과하는 것으로서, 입력 픽셀값과 가중치의 곱셈 및 덧셈으로 구성되는 가중합 연산(weighted sum)을 한다. 컨볼루션 연산을 진행하는 방식으로는 일정한 타일크기의 픽셀을 한번에 연산하고 다음 타일을 연산하는 방법, 또는 '라인 단위'(가로 또는 세로 방향)로 연산을 수행하고, 한 라인의 연산이 완료되면 다음 라인의 연산하는 방법 등 다양하게 있을 수 있다. 1 illustrates an example of performing a convolution operation using a learned filter (or kernel) (“vImage Programming Guide,” Apple Inc., Cupertino, CA, USA, 2016). Referring to FIG. 1, each convolutional layer constituting the convolutional neural network performs a convolution operation from the input feature map 1 to generate an output feature map 3. The input feature map 1 is the input data to be inferred or the output feature map of the previous convolutional layer, and the output feature map 3 is used as the inferred output data or is used as the input feature map of the next convolutional layer. The convolution operation passes through a filter (or kernel) composed of learned weights, and performs a weighted sum composed of multiplication and addition of input pixel values and weights. As a method of performing the convolution operation, pixels of a certain tile size are calculated at a time, and the next tile is calculated, or 'line unit' (horizontal or vertical direction) is performed. There can be various ways to calculate the line.

도 2는 2차원(a)과 3차원(b)의 컨볼루션 연산을 도시하고 있다(Vivienne Sze, et al., “Efficient Processing of Deep Neural Networks: A Tutorial and Survey”, Proceedings of the IEEE, Vol. 105, No. 12, December 2017). 도 2(a)는 H*W(세로*가로)의 2차원 입력 특징맵(1)으로부터 R*S의 필터로 컨볼루션 연산(가중합 연산)을 수행하여 E*F의 2차원 출력 특징맵(3)을 생성하는 것을 도시하고 있다. 도 2(b)는 도 2(a)의 2차원 컨볼루션 연산을 3차원으로 확장한 것이다. 도 2(b)를 참조하면, 입력 특징맵(1)의 크기가 H*W이고, 채널의 개수가 C이고, 특징맵 한 점의 데이터 크기가 D byte라면 입력 특징맵(1)의 크기는 H*W*C*D byte가 되고, 출력 특징맵(3)의 크기는 E*F*M*D byte가 된다. 따라서, 컨볼루션 연산을 위해서는 각 컨볼루션 층마다 중간 특징맵(입력 특징맵(1) 및/또는 출력 특징맵(3))을 모두 저장해야하므로, 컨볼루션 연산에 요구되는 메모리는 중간 특징맵의 크기, 채널의 개수, 컨볼루션 층의 개수 등에 따라 상당한 크기가 요구된다. 일례로, 4K 해상도의 이미지의 경우 H=2160, W=3840 이고, 컨볼루션 네트워크의 채널의 개수 C=12, 특징맵 한 점의 데이터 크기 D=1.5 byte, 컨볼루션 층의 개수가 40개라면, 특징맵을 저장하기 위해 필요한 메모리는 5.7GB가 필요하며, 초당 60 프레임 속도의 동영상을 실시간으로 8K의 초해상도 추론을 수행한다고 할 때 필요한 메모리 대역폭은 333.7 GB/sec으로 현실적인 구현이 거의 불가능한 수준이 되므로, 특징맵 저장에 요구되는 메모리의 크기 및 대역폭이 신경망 구현의 큰 문제점으로 작용하고 있다.2 shows convolution operations in two dimensions (a) and three dimensions (b) (Vivienne Sze, et al., “Efficient Processing of Deep Neural Networks: A Tutorial and Survey”, Proceedings of the IEEE, Vol .105, No. 12, December 2017). FIG. 2 (a) shows a convolution operation (weighted operation) of the H * W (vertical * horizontal) 2D input feature map (1) with a filter of R * S to perform a 2D output feature map of E * F (3) is shown. 2 (b) is an extension of the 2D convolution operation of FIG. 2A to 3D. Referring to FIG. 2 (b), if the size of the input feature map 1 is H * W, the number of channels is C, and the data size of one point of the feature map is D bytes, the size of the input feature map 1 is H * W * C * D bytes, and the size of the output feature map 3 is E * F * M * D bytes. Therefore, in order to calculate the convolution, since the intermediate feature map (input feature map 1 and / or output feature map 3) must be stored for each convolutional layer, the memory required for the convolution operation is an intermediate feature map. Significant size is required depending on the size, number of channels, and number of convolutional layers. For example, in the case of an image of 4K resolution, if H = 2160, W = 3840, the number of channels in the convolutional network C = 12, the data size of one point of the feature map D = 1.5 bytes, and the number of convolutional layers is 40 , The memory required to store the feature map requires 5.7 GB, and the memory bandwidth required for real-time 8K super-resolution inference of video at 60 frames per second is 333.7 GB / sec. Because of this, the size and bandwidth of the memory required to store the feature map is working as a big problem in the neural network implementation.

메모리는 프로세서가 빠르게 액세스할 수 있는 온칩(on-chip) 형태로 많이 구현되는데, 온칩 형태의 메모리는 용량에 한계가 있다. 특징맵을 저장하기 위해 외부 또는 오프칩(off-chip) 저장부(예를 들면, DDR 등)를 사용할 수도 있지만, 전력 소모나 처리 지연(latency)에 문제가 있다. 대한민국 공개특허 10-2018-0062911호에는 유연하고 효율적인 3차원 컨볼루션을 수행하기 위한 신경망 유닛이 공지되어 있고, 등록특허 10-1788829호에는 컨볼루션 연산을 위한 HW 가속기가 개시되어 있지만, 여전히 큰 크기의 특징맵을 메모리에 온전히 저장하고 있어야하기 때문에 상술한 메모리 크기 문제의 효율적인 해결이 필요하다.The memory is often implemented in an on-chip form that can be quickly accessed by the processor, but the on-chip type memory has a limited capacity. External or off-chip storage (for example, DDR) may be used to store the feature map, but there is a problem in power consumption or processing latency. Korean Patent Publication No. 10-2018-0062911 discloses a neural network unit for performing flexible and efficient three-dimensional convolution, and Patent Registration No. 10-1788829 discloses an HW accelerator for convolution operation, but still has a large size It is necessary to efficiently store the memory size problem described above, because the feature maps of must be completely stored in the memory.

KR 10-2018-0062911 A.KR 10-2018-0062911 A. KR 10-1788829 B1.KR 10-1788829 B1.

“vImage Programming Guide,”Apple Inc., Cupertino, CA, USA, 2016. “VImage Programming Guide,” Apple Inc., Cupertino, CA, USA, 2016. Vivienne Sze, et al., “Efficient Processing of Deep Neural Networks: A Tutorial and Survey”, Proceedings of the IEEE, Vol. 105, No. 12, December 2017. Vivienne Sze, et al., “Efficient Processing of Deep Neural Networks: A Tutorial and Survey”, Proceedings of the IEEE, Vol. 105, No. 12, December 2017. Andrew Lavin, et al., “Fast Algorithms for Convolutional Neural Networks”, The IEEE Conference on Computer Vision and Pattern Recognition (CVPR), 2016, pp. 4013-4021. Andrew Lavin, et al., “Fast Algorithms for Convolutional Neural Networks”, The IEEE Conference on Computer Vision and Pattern Recognition (CVPR), 2016, pp. 4013-4021. Tianqi Chen, et al., “MXNet: A flexible and efficient machine learning library for heterogeneous distributed systems,”In Neural Information Processing Systems, Workshop on Machine Learning Systems (LearningSys'15), 2015. Tianqi Chen, et al., “MXNet: A flexible and efficient machine learning library for heterogeneous distributed systems,” In Neural Information Processing Systems, Workshop on Machine Learning Systems (LearningSys'15), 2015.

본 발명은 상기와 같은 종래 기술의 문제점을 해결하기 위해 창안된 것으로, 컨볼루션 연산을 수행하기 위해 사용되는 메모리의 양을 감소시키기 위해 각 컨볼루션 층의 입출력 특징맵을 라인 단위로 메모리에 저장하고 재사용하도록 함으로써 컨볼루션 연산에 요구되는 메모리의 양을 감소시키는 방법 및 그 방법을 사용하는 추론 장치를 제공하는 것을 목적으로 한다.The present invention was created to solve the problems of the prior art as described above. In order to reduce the amount of memory used to perform the convolution operation, input / output feature maps of each convolution layer are stored in the memory in line units. It is an object of the present invention to provide a method for reducing the amount of memory required for a convolution operation and a reasoning apparatus using the method.

또한, 컨볼루션 층의 개수와 특징맵의 라인 개수에 따라 요구되는 메모리의 양을 더욱 최소화시킬 수 있는 방법 및 그 방법을 사용하는 추론 장치를 제공하는 것을 또 다른 목적으로 한다.Another object is to provide a method for further minimizing the amount of memory required according to the number of convolution layers and the number of lines in a feature map, and a reasoning apparatus using the method.

상기 기술적 과제를 달성하기 위한, 본 발명의 일 실시예에 따르면, 적어도 하나의 컨볼루션 층을 포함하는 컨볼루션 신경망 추론 장치에서 컨볼루션 연산을 수행하기 위한 라인 단위 메모리 관리 방법으로서, 제1라인버퍼를 포함하는 적어도 하나의 라인버퍼를 액세스하여 라인 단위의 컨볼루션 연산을 수행한 결과를 제2라인버퍼에 저장하는 단계; 및 상기 제1라인버퍼가 더 이상 컨볼루션 연산에 사용되지 않게 되면 상기 제1라인버퍼를 재사용하는 단계;를 포함하고, 상기 각 컨볼루션 층은 입력 특징맵으로부터 컨볼루션 연산을 수행하여 출력 특징맵을 생성하고, 상기 제1라인버퍼는 상기 입력 특징맵의 적어도 한 라인을 저장하고 있고, 상기 제2라인버퍼는 상기 출력 특징맵의 적어도 한 라인을 저장하고, 상기 제1라인버퍼 및 제2라인버퍼는 각각 소정의 메모리 영역인, 방법이 제공된다.In order to achieve the above technical problem, according to an embodiment of the present invention, as a line-by-line memory management method for performing a convolution operation in a convolutional neural network inference device including at least one convolutional layer, the first line buffer Accessing at least one line buffer including and storing a result of performing a line-wise convolution operation in a second line buffer; And reusing the first line buffer when the first line buffer is no longer used for the convolution operation, wherein each convolution layer performs a convolution operation from the input feature map to output the feature map. And the first line buffer stores at least one line of the input feature map, and the second line buffer stores at least one line of the output feature map, and the first line buffer and the second line. A method is provided in which the buffers are each a predetermined memory area.

상기 입력 특징맵은 추론할 입력 데이터 또는 전단계 컨볼루션 층의 출력 특징맵이고, 라인 단위로 적어도 하나의 라인버퍼에 저장되는 것일 수 있다.The input feature map may be input data to be inferred or an output feature map of a previous step convolution layer, and may be stored in at least one line buffer in line units.

상기 생성된 출력 특징맵은 추론된 출력 데이터로 사용되거나 다음 단계 컨볼루션 층의 입력 특징맵으로 사용되고, 라인 단위로 적어도 하나의 라인버퍼에 저장되는 것일 수 있다.The generated output feature map may be used as inferred output data or used as an input feature map of a next-level convolution layer, and may be stored in at least one line buffer in units of lines.

상기 제1라인버퍼 및 제2라인버퍼는 컨볼루션 층의 특성에 따라 가변적인 크기를 가질 수 있다.The first line buffer and the second line buffer may have a variable size according to the characteristics of the convolution layer.

상기 컨볼루션 층이 소정의 활성 함수, 배치정규화 함수 또는 1x1 컨볼루션 연산을 더 포함하는 경우에는, 상기 컨볼루션 연산 결과를 상기 제2라인버퍼에 저장할 때 상기 활성 함수, 배치정규화 함수 또는 1x1 컨볼루션 연산을 온더플라이로 수행하여 저장할 수 있다.When the convolution layer further includes a predetermined active function, batch normalization function, or 1x1 convolution operation, when the result of the convolution operation is stored in the second line buffer, the active function, batch normalization function, or 1x1 convolution Calculations can be performed on-the-fly and stored.

상기 라인은 가로 또는 세로 방향 라인일 수 있다.The line may be a horizontal or vertical line.

상기 컨볼루션 연산을, 입력 특징맵의 라인 단위로 수행하되 순차적 순회 방식으로 수행하거나, 적어도 하나의 특징맵의 라인 단위로 수행하되 대각선 순회 방식으로 수행할 수 있다.The convolution operation may be performed in line units of an input feature map, but in a sequential traversal method, or in line units of at least one feature map, but in a diagonal traversal method.

상기 순차적 순회 방식 또는 대각선 순회 방식은 상기 컨볼루션 층의 개수와 상기 라인 개수에 기초하여 선택될 수 있다.The sequential traversal scheme or the diagonal traversal scheme may be selected based on the number of convolution layers and the number of lines.

상기 방법은, 상기 제2라인버퍼로부터 다음 단계 컨볼루션 층의 컨볼루션 연산이 가능한 경우에는 상기 입력 특징맵의 컨볼루션 연산보다 상기 다음 단계 컨볼루션 층의 컨볼루션 연산을 먼저 수행하여 제3라인버퍼에 저장하는 단계를 더 포함하고, 상기 제3라인버퍼는 소정의 메모리 영역일 수 있다.In the above method, when the convolution operation of the next-level convolution layer is possible from the second line buffer, the convolution operation of the next-level convolution layer is performed first before the convolution operation of the input feature map. Further comprising the step of storing in, the third line buffer may be a predetermined memory area.

상기 제1라인버퍼를 재사용하는 단계는 상기 입력 특징맵으로부터의 모든 컨볼루션 연산이 완료되기 전이라 하더라도 상기 제1라인버퍼가 더 이상 사용되지 않게 되면 상기 제1라인버퍼를 다른 라인을 저장하거나 다른 용도로 사용할 수 있다.The step of reusing the first line buffer stores the first line buffer or another line when the first line buffer is no longer used, even before all convolution operations from the input feature map are completed. Can be used for purposes.

위노그라드 알고리즘을 사용하는 경우에는 타일의 크기에 따라 상기 입력 특징맵을 복수개의 라인 단위로 적어도 하나의 라인버퍼에 저장할 수 있다.When the Winograd algorithm is used, the input feature map may be stored in at least one line buffer in units of a plurality of lines according to the size of a tile.

상기 컨볼루션 층을 적어도 하나의 그룹으로 구분하여 그룹 단위로 컨볼루션 연산을 수행할 수 있다.The convolution layer may be divided into at least one group to perform convolution operations in group units.

상기 방법은, 상기 그룹 단위의 연산 수행이 라인 단위로 완료되면 라인 단위로 외부 저장부에 저장하는 단계; 및 상기 저장한 결과를 다음 그룹의 컨볼루션 연산을 위한 입력으로 사용하는 단계를 더 포함할 수 있다.The method includes the step of storing in the external storage unit on a line-by-line basis when the group-wise operation is completed in line units; And using the stored result as an input for the next group of convolution operations.

또한, 바람직한 일 실시예에 따르면, 전술한 각 방법에 따른 방법을 실행시키기 위한, 컴퓨터-판독가능한 기록매체에 저장된 컴퓨터 프로그램이 제공된다.In addition, according to one preferred embodiment, a computer program stored in a computer-readable recording medium for executing the method according to each method described above is provided.

또한, 다른 바람직한 일 실시예에 따르면, 전술한 각 방법을 실행시키기 위한 프로그램이 기록된, 컴퓨터-판독가능한 기록매체가 제공된다.In addition, according to another preferred embodiment, there is provided a computer-readable recording medium in which a program for executing each method described above is recorded.

상기 기술적 과제를 달성하기 위한, 본 발명의 다른 일 실시예에 따르면, 입력 특징맵으로부터 컨볼루션 연산을 수행하여 출력 특징맵을 생성하는 컨볼루션 층을 적어도 하나 포함하는 컨볼루션 신경망 추론 장치로서, 상기 적어도 하나의 입력 특징맵과 적어도 하나의 출력 특징맵을 가로 또는 세로의 라인 단위로 저장하되 적어도 하나의 라인을 저장할 수 있는 영역이 할당된 적어도 하나의 라인버퍼를 포함하는 메모리; 제1라인버퍼 및 제2라인버퍼에 각각 상기 메모리의 소정의 영역을 할당하고, 상기 제1라인버퍼는 상기 입력 특징맵의 적어도 한 라인을 저장하고, 상기 제2라인버퍼는 상기 출력 특징맵의 적어도 한 라인을 저장하고, 상기 제1라인버퍼가 더 이상 컨볼루션 연산에 사용되지 않게 되면 상기 제1라인버퍼를 재사용하도록 메모리를 관리하는 메모리 관리부; 및 상기 제1라인버퍼를 포함하는 적어도 하나의 라인버퍼를 액세스하여 라인 단위의 컨볼루션 연산을 수행하고 그 결과를 상기 제2라인버퍼에 저장하는 연산부;를 포함하는 장치가 제공된다.According to another embodiment of the present invention for achieving the above technical problem, as a convolutional neural network inference device including at least one convolutional layer for generating an output feature map by performing a convolution operation from an input feature map, wherein A memory including at least one line buffer in which at least one input feature map and at least one output feature map are stored in units of horizontal or vertical lines, but an area capable of storing at least one line is allocated; Each of the first line buffer and the second line buffer is assigned a predetermined area of the memory, the first line buffer stores at least one line of the input feature map, and the second line buffer of the output feature map A memory management unit that stores at least one line and manages a memory to reuse the first line buffer when the first line buffer is no longer used for convolution; And an operation unit that accesses at least one line buffer including the first line buffer to perform a convolution operation on a line-by-line basis and stores the result in the second line buffer.

상기 입력 특징맵은 추론할 입력 데이터 또는 전단계 컨볼루션 층의 출력 특징맵이고, 라인 단위로 적어도 하나의 라인버퍼에 저장될 수 있다.The input feature map is input data to be inferred or an output feature map of the previous convolutional layer, and may be stored in at least one line buffer in line units.

상기 생성된 출력 특징맵은 추론된 출력 데이터로 사용되거나 다음 단계 컨볼루션 층의 입력 특징맵으로 사용되고, 라인 단위로 적어도 하나의 라인버퍼에 저장될 수 있다.The generated output feature map may be used as inferred output data or used as an input feature map of the next step convolution layer, and may be stored in at least one line buffer in line units.

상기 연산부는, 상기 컨볼루션 층이 소정의 활성 함수, 배치정규화 함수 또는 1x1 컨볼루션 연산을 더 포함하는 경우에는 상기 컨볼루션 연산 결과를, 상기 제2라인버퍼에 저장할 때 상기 활성 함수, 배치정규화 함수 또는 1x1 컨볼루션 연산을 온더플라이로 수행하여 저장할 수 있다.When the convolution layer further includes a predetermined active function, a batch normalization function, or a 1x1 convolution operation, the operation unit stores the result of the convolution operation in the second line buffer, the active function, and a batch normalization function. Alternatively, the 1x1 convolution operation can be performed and stored on the fly.

상기 메모리 관리부는 상기 컨볼루션 층의 특성에 따라 상기 제1라인버퍼 및 제2라인버퍼에 가변적인 크기로 상기 메모리의 영역을 할당할 수 있다.The memory manager may allocate an area of the memory in a variable size to the first line buffer and the second line buffer according to the characteristics of the convolution layer.

상기 메모리 관리부는, 상기 컨볼루션 연산이 입력 특징맵의 라인 단위로 수행되되 순차적 순회 방식으로 수행되거나 적어도 하나의 특징맵의 라인 단위로 수행되되 대각선 순회 방식으로 수행되도록 상기 메모리의 소정의 영역을 적어도 하나의 라인버퍼로 할당할 수 있다.The memory management unit may perform at least a predetermined area of the memory such that the convolution operation is performed in line units of the input feature map, but is performed in a sequential traversal manner or in line units of at least one feature map, but in a diagonal traversal scheme. Can be assigned as one line buffer.

상기 메모리 관리부는, 상기 순차적 순회 방식 또는 대각선 순회 방식을 상기 컨볼루션 층의 개수와 상기 라인 개수에 기초하여 선택할 수 있다.The memory management unit may select the sequential traversal method or the diagonal traversal method based on the number of convolution layers and the number of lines.

상기 메모리 관리부는, 상기 제2라인버퍼로부터 다음 단계 컨볼루션 층의 컨볼루션 연산이 가능한 경우에는 상기 입력 특징맵의 컨볼루션 연산보다 상기 다음 단계 컨볼루션 층의 컨볼루션 연산을 먼저 수행하여 제3라인버퍼에 저장하도록 상기 제3라인버퍼에 상기 메모리의 소정의 영역을 할당할 수 있다.When the convolution operation of the next-level convolution layer is possible from the second line buffer, the memory management unit first performs convolution operation of the next-level convolution layer before the convolution operation of the input feature map. A predetermined area of the memory may be allocated to the third line buffer to be stored in a buffer.

상기 메모리 관리부는, 상기 입력 특징맵으로부터의 모든 컨볼루션 연산이 완료되기 전이라 하더라도 상기 제1라인버퍼가 더 이상 사용되지 않게 되면 상기 제1라인버퍼를 다른 라인을 저장하거나 다른 용도로 사용할 수 있다.The memory management unit may store the first line buffer for another line or use it for another purpose, even if the first line buffer is no longer used even before all convolution operations from the input feature map are completed. .

상기 메모리 관리부는, 위노그라드 알고리즘을 사용하는 경우에는 타일의 크기에 따라 상기 입력 특징맵을 복수개의 라인 단위로 적어도 하나의 라인버퍼에 저장하도록 상기 메모리의 영역을 할당할 수 있다.When using the Winograd algorithm, the memory manager may allocate an area of the memory to store the input feature map in at least one line buffer in a plurality of line units according to the size of a tile.

상기 메모리 관리부는, 상기 컨볼루션 층을 적어도 하나의 그룹으로 구분하여 그룹 단위로 컨볼루션 연산을 수행할 수 있도록 라인버퍼를 관리할 수 있다.The memory management unit may divide the convolution layer into at least one group and manage a line buffer to perform convolution operation in group units.

상기 메모리 관리부는, 상기 그룹 단위의 연산 수행이 라인 단위로 완료되면 라인 단위로 외부 저장부에 저장하고, 상기 저장한 결과를 다음 그룹의 컨볼루션 연산을 위한 입력으로 사용할 수 있다.When the group unit operation is completed in line units, the memory manager may store the line unit in an external storage unit and use the stored result as an input for the next group of convolution operations.

이상과 같이, 본 발명에 따르면, 각 컨볼루션 층의 입출력 특징맵을 가로 또는 세로 라인 단위로 메모리에 저장하는 라인버퍼를 사용하고, 입력 특징맵으로부터의 모든 컨볼루션 연산이 완료되기 전이라 하더라도 더 이상 사용되지 않게 된 라인버퍼는 다른 라인을 저장하거나 다른 용도로 재사용하도록 하여 입출력 특징맵을 모두 메모리에 저장하고 있을 필요가 없도록 함으로써, 종래의 기술이 입출력 특징맵을 모두 저장하는 것에 비하여 컨볼루션 연산에 요구되는 메모리의 양을 감소시키는 효과가 있다.As described above, according to the present invention, a line buffer for storing input / output feature maps of each convolutional layer in memory in horizontal or vertical line units is used, even before all convolution operations from the input feature map are completed. The line buffer, which is no longer used, saves other lines or reuses them for other purposes, so that it is not necessary to store all of the input / output feature maps in memory, so that the prior art saves all input / output feature maps. It has the effect of reducing the amount of memory required for.

또한, 컨볼루션 층의 개수와 특징맵의 라인 개수에 따라 컨볼루션 연산 순서에 순차적 순회 방식 또는 대각선 순회 방식을 적용하는 방법을 선택하여 사용할 수 있도록 제공함으로써, 컨볼루션 연산에 요구되는 메모리의 양을 더욱 감소시키는 효과가 있다.In addition, by providing a method of selecting and applying a sequential traversal method or a diagonal traversal method to the convolution operation order according to the number of convolution layers and the number of lines in the feature map, the amount of memory required for the convolution operation is provided. It has a further reducing effect.

도 1은 입력 특징맵으로부터 출력 특징맵을 생성하는 컨볼루션 연산을 나타내는 도면이다.
도 2는 2차원(a) 및 3차원(b) 컨볼루션 연산을 나타내는 도면이다.
도 3 및 도 4는 본 발명의 일 실시예에 따른 컨볼루션 층, 특징맵, 메모리 및 라인버퍼의 구성을 나타내는 블록도이다.
도 5는 종래의 특징맵 단위의 메모리 관리 방법을 나타내는 블록도이다.
도 6 및 7은 각각 본 발명의 다른 일 실시예에 따른 순차적 순회 방식으로 컨볼루션 연산을 수행하도록 하는 메모리 관리 방법을 설명하기 위한 블록도 및 순서도이다.
도 8은 본 발명의 일 실시예에 따른 순차적 순회 방식과 대각선 순회 방식으로 컨볼루션 연산을 수행하는 순서를 나타내는 도면이다.
도 9 및 10은 각각 본 발명의 또 다른 일 실시예에 따른 대각선 순회 방식으로 컨볼루션 연산을 수행하도록 하는 메모리 관리 방법을 설명하기 위한 블록도 및 순서도이다.
도 11은 본 발명의 또 다른 바람직한 일 실시예에 따라, 필터 윈도우의 크기가 5인 경우 대각선 순회 방식으로 컨볼루션 연산을 수행하는 순서를 나타내는 도면이다.
도 12 및 13은 각각 본 발명의 또 다른 바람직한 일 실시예에 따라, 온칩 메모리의 제한이 있는 경우 대각선 순회 방식으로 컨볼루션 연산을 수행하도록 하는 메모리 관리 방법을 설명하기 위한 블록도 및 순서도이다.
도 14는 위노그라드(Winograd) 알고리즘을 본 발명의 또 다른 바람직한 일 실시예로 적용한 도면이다.
도 15는 본 발명의 일 실시예에 따른 추론 장치를 나타내는 블록도이다.
1 is a diagram illustrating a convolution operation for generating an output feature map from an input feature map.
2 is a view showing two-dimensional (a) and three-dimensional (b) convolution operations.
3 and 4 are block diagrams showing the configuration of a convolution layer, a feature map, a memory, and a line buffer according to an embodiment of the present invention.
5 is a block diagram showing a conventional memory management method in a feature map unit.
6 and 7 are block diagrams and flowcharts for explaining a memory management method for performing convolution operations in a sequential traversal method according to another embodiment of the present invention.
8 is a view showing a sequence of performing a convolution operation in a sequential traversal method and a diagonal traversal method according to an embodiment of the present invention.
9 and 10 are block diagrams and flowcharts illustrating a memory management method for performing convolution operations in a diagonal traversal method according to another embodiment of the present invention, respectively.
11 is a diagram illustrating a sequence of performing convolution operations in a diagonal traversal method when the size of a filter window is 5 according to another preferred embodiment of the present invention.
12 and 13 are block diagrams and flowcharts for explaining a memory management method for performing convolution operations in a diagonal traversal method when there is a limitation of on-chip memory, according to another preferred embodiment of the present invention, respectively.
14 is a diagram of applying the Winograd algorithm to another preferred embodiment of the present invention.
15 is a block diagram showing an inference device according to an embodiment of the present invention.

이하, 첨부한 도면을 참조하여 본 발명이 속하는 기술 분야에서 통상의 지식을 가진 자가 용이하게 실시할 수 있도록 본 발명의 실시예를 상세히 설명한다. 하기의 설명에서는 본 발명의 실시예에 따른 동작을 이해하는데 필요한 부분만이 도시되고 설명되며 그 이외 부분의 도시와 설명은 본 발명의 요지를 흐리지 않도록 생략하였다. 그러나 본 발명은 여러 가지 상이한 형태로 구현될 수 있으며 여기에서 설명하는 실시예에 한정되지 않는다.Hereinafter, embodiments of the present invention will be described in detail with reference to the accompanying drawings so that those skilled in the art to which the present invention pertains can easily practice. In the following description, only the parts necessary for understanding the operation according to the embodiment of the present invention are shown and described, and the illustration and description of other parts are omitted so as not to obscure the subject matter of the present invention. However, the present invention can be implemented in many different forms and is not limited to the embodiments described herein.

또한, 이하에서 설명되는 본 명세서 및 청구범위에 사용된 용어나 단어는 통상적이거나 사전적인 의미로 한정해서 해석되어서는 아니 되며, 본 발명을 가장 적절하게 표현할 수 있도록 본 발명의 기술적 사상에 부합하는 의미와 개념으로 해석되어야 한다.In addition, the terms or words used in the specification and claims described below should not be interpreted as being limited to the ordinary or lexical meanings, and the meanings consistent with the technical spirit of the present invention so as to best represent the present invention. And should be interpreted as a concept.

명세서 전체에서, 어떤 부분이 어떤 구성요소를 "포함"한다고 할 때, 이는 특별히 반대되는 기재가 없는 한 다른 구성요소를 제외하는 것이 아니라 다른 구성요소를 더 포함할 수 있는 것을 의미한다.Throughout the specification, when a part “includes” a certain component, it means that the component may further include other components, not to exclude other components, unless otherwise stated.

설명의 간략함을 위해, 본 명세서에서는 예시를 들어 순서도 또는 플로우 차트의 형태로 하나 이상의 방법이 일련의 단계로서 도시되고 기술되어 있지만, 본 발명이 단계들의 순서에 의해 제한되지 않는데 그 이유는 본 발명에 따라 본 명세서에 도시되고 기술되어 있는 것과 다른 순서로 또는 다른 단계들과 동시에 행해질 수 있기 때문이라는 것을 잘 알 것이다. 또한, 예시된 모든 단계들이 본 발명에 따라 방법을 구현해야만 하는 것은 아닐 수 있다.For the sake of simplicity, one or more methods are shown and described as a series of steps, for example in the form of a flowchart or flow chart, although the invention is not limited by the order of the steps because the present invention It will be appreciated that this can be done in a different order than the one shown and described herein or concurrently with other steps. Also, not all steps illustrated may have to implement the method in accordance with the present invention.

본 발명의 다양한 실시예들을 설명함에 있어, 대응되는 구성요소에 대해서는 동일한 명칭 및 동일한 참조부호를 부여하여 설명하도록 한다. 본 발명의 실시예를 설명하기 위하여 참조하는 도면에서 구성요소의 크기나 선의 두께 등은 이해의 편의상 과장되게 표현되어 있을 수 있다.In describing various embodiments of the present invention, corresponding components will be described with the same name and the same reference numerals. In the drawings referred to describe an embodiment of the present invention, the size of a component or the thickness of a line may be exaggerated for convenience of understanding.

명세서 전체에서, 설명 및 도시의 편의를 위하여 약자를 <표 1>과 같이 사용하기로 한다. 그리고, Hn, Wn, Cn, Dn, Kn 은 n의 값에 따라, 즉, 각 컨볼루션 층마다 일반적으로 상이한 값을 가질 수 있지만, 본 발명의 실시예에 따른 동작의 설명 및 도시를 간략하게 하기 위하여, 각 컨볼루션 층마다 상이한 값을 가지지 않고 동일한 값을 가지는 것으로 설명 및 도시를 하기로 한다. 예를 들어, H1과 H2는 각각 첫번째와 두번째 컨볼루션 층의 높이로서 서로 다른 값을 가질 수 있으나, 본 명세서의 다양한 실시예에서는 동일한 값을 가지는 것으로 가정하여 설명 및 도시하기로 한다. 이를 위하여 단순화한 약자를 <표 1>에 기재하고 있다. 또한, 각 실시예에서 설명하는 각 약자의 값도 설명의 편의를 위하여 <표 1>에 기재한 예시 값으로 설명하기로 한다.Throughout the specification, abbreviations will be used as shown in Table 1 for convenience of description and illustration. And, H n , W n , C n , D n , K n may have different values in general according to the value of n, that is, for each convolution layer, the description of the operation according to the embodiment of the present invention and To simplify the illustration, description and illustration will be given as having the same value instead of different values for each convolution layer. For example, H 1 and H 2 may have different values as the heights of the first and second convolution layers, respectively, but in various embodiments of the present specification, it will be described and illustrated on the assumption that they have the same values. To this end, abbreviated abbreviations are listed in <Table 1>. In addition, the value of each abbreviation described in each embodiment will be described as an example value shown in <Table 1> for convenience of explanation.

약자Abbreviation 설명Explanation 단순화한 약자Abbreviation 예시 값Example value NN 컨볼루션 층의 개수Number of convolutional layers 77 nn 컨볼루션 인덱스Convolution index 0, 1,…0, 1,… Hn H n n번째 컨볼루션 층의 출력 특징맵의 세로 크기Vertical size of the output feature map of the nth convolution layer HH 21602160 hh 높이 인덱스Height index 1, 2,…1, 2,… Wn W n n번째 컨볼루션 층의 출력 특징맵 가로 크기Horizontal size of output feature map of nth convolution layer WW 38403840 Cn C n n번째 컨볼루션 층의 출력 특징맵 채널 개수Number of output feature map channels in nth convolution layer CC 1616 Dn D n n번째 컨볼루션 층의 출력 특징맵 데이터 크기Output feature map data size of nth convolution layer DD 12bit=1.5byte12bit = 1.5byte Kn K n n번째 컨볼루션 층의 출력 특징맵 필터 크기Output feature map filter size for nth convolution layer KK 33

상술한 바와 같이, 본 발명에 따른 설명 및 도시를 위하여 특별히 반대되는 기재가 없는 한 <표 1>에 기재된 단순화한 약자와 예시 값을 사용하지만, 이는 설명 및 도시의 편의를 위한 것일 뿐, 단순화한 약자와 예시 값으로 한정해서 해석되어서는 아니 되며, 본 발명의 기술적 사상에 부합하는 의미와 개념으로 해석되어야 한다.As described above, for the description and illustration according to the present invention, the simplified abbreviations and example values described in <Table 1> are used, unless otherwise stated, but this is for convenience of description and illustration only. It should not be interpreted as being limited to abbreviations and example values, but should be interpreted as meanings and concepts consistent with the technical spirit of the present invention.

도 3 및 도 4는 본 발명의 일 실시예에 따른 컨볼루션 층, 특징맵, 메모리 및 라인버퍼의 구성을 나타내는 블록도이다.3 and 4 are block diagrams showing the configuration of a convolution layer, a feature map, a memory, and a line buffer according to an embodiment of the present invention.

도 3을 참조하면, 컨볼루션 신경망 추론은 입력 데이터(input data), 컨볼루션 층(conv. layer #1, #2,…, #7), 출력 데이터(output data)를 포함할 수 있다.Referring to FIG. 3, the convolutional neural network inference may include input data, convolutional layers (conv. Layers # 1, # 2, ..., # 7), and output data.

입력 데이터는 추론에 사용할 데이터이며, 가로 크기 W, 세로 크기 H의 예가 도시되어 있다. 본 도면에서는 설명 및 도시의 편의를 위하여 입력 데이터, 컨볼루션 층, 출력 데이터의 크기가 모두 동일한 크기로 도시되어 있으나, 이에 한정되는 것은 아니며, 입력 데이터, 각 컨볼루션 층 및 출력 데이터는 각각 서로 다른 가로와 세로 크기를 가질 수 있다. 또한, 도면에는 컨볼루션 층이 7개로 도시되어 있으나, 이에 한정되는 것은 아니며, 컨볼루션 신경망의 특성에 따라 수십 ~ 수백개의 층 또는 그 이상 단계의 층이 사용될 수 있다.The input data is data to be used for inference, and examples of the horizontal size W and the vertical size H are shown. In this drawing, for convenience of description and illustration, the sizes of the input data, the convolution layer, and the output data are all shown in the same size, but are not limited thereto, and the input data, each convolution layer, and the output data are different from each other. It can have both horizontal and vertical dimensions. In addition, although seven convolutional layers are shown in the drawings, the present invention is not limited thereto, and dozens to hundreds of layers or more may be used depending on the characteristics of the convolutional neural network.

각 컨볼루션 층은 컨볼루션 연산(Conv1, Conv2,…)과 ReLU(rectified linear unit)를 포함할 수 있다. 컨볼루션 연산은 도 1 및 2에서 설명하였듯이 덧셈과 곱셈의 다양한 조합으로 다양한 가중합 연산이 사용될 수 있다. ReLU는 입력이 0보다 작으면 0을 출력하고, 0보다 크면 입력을 그대로 출력하는 비선형 활성 함수(activation function)의 일종이다. 과거 신경망에서 많이 사용되던 활성 함수인 시그모이드(sigmoid) 함수보다 나은 성능을 보여 최근 신경망에서 많이 사용되고 있다. ReLU는 활성 함수의 일 예로서 도시된 것으로서, 이에 한정되는 것은 아니며, ReLU 대신 PReLU 등 다른 다양한 활성 함수를 사용할 수 있다.Each convolution layer may include a convolution operation (Conv1, Conv2,…) and a Rerected Linear Unit (ReLU). As described in FIGS. 1 and 2, various weighted sum operations may be used in various combinations of addition and multiplication. ReLU is a kind of nonlinear activation function that outputs 0 when the input is less than 0 and outputs the input as it is if it is greater than 0. It shows a better performance than the sigmoid function, which is an active function that has been used in neural networks in the past. ReLU is illustrated as an example of an active function, and is not limited thereto, and various other active functions such as PReLU may be used instead of ReLU.

또한, 컨볼루션 층에는 ReLU 같은 활성 함수 외에도 배치정규화(batch normalization) 함수 또는 1x1 컨볼루션 등이 대신 또는 더 포함될 수도 있다. 배치정규화 함수는 컨볼루션 층의 출력 값들이 한쪽으로 치우쳐지면 활성 함수가 제대로 동작하지 않아서, gradient diminishing/exploding 문제를 야기할 수 있고, 학습 수렴속도도 저하되므로, 이를 방지하기 위해 입력의 평균을 0으로, 분산을 1로 정규화 시켜주는 방법이다. 활성 함수의 입력이 한쪽으로 치우치게 되면, 제 역할을 못 할 수 있기 때문에 컨볼루션 신경망에서 자주 사용되는 기법이다. 1x1 컨볼루션은 특징맵의 채널(channel)을 늘리거나 줄이는데 주로 사용될 수 있다.In addition, the convolution layer may include, instead of an active function such as ReLU, a batch normalization function or 1x1 convolution instead or more. Batch normalization function, when the output values of the convolution layer are biased to one side, the active function does not work properly, which can cause gradient diminishing / exploding problems, and the learning convergence speed is also lowered. It is a method to normalize the variance to 1. It is a technique that is often used in convolutional neural networks because the input of the active function may not play a role if it is skewed to one side. 1x1 convolution can be mainly used to increase or decrease the channel of the feature map.

상술한 활성 함수, 배치정규화 함수, 1x1 컨볼루션의 연산은, 메모리를 액세스할 필요 없이 컨볼루션 연산 결과를 메모리에 저장할 때 온더플라이(on-the-fly)로 계산하여 저장할 수 있다.The above-described active function, batch normalization function, and 1x1 convolution operation can be calculated and stored on-the-fly when the convolution operation result is stored in the memory without access to the memory.

각 컨볼루션 층은 이 외에도 풀링(pooling) 등 다양한 함수들을 더 포함하여 구성될 수 있지만, 본 발명의 실시예에 따른 동작을 이해하는데 필요한 부분만을 도시하기 위해 생략하였다.Each convolution layer may further include various functions such as pooling, but is omitted to show only parts necessary for understanding the operation according to an embodiment of the present invention.

또한, 컨볼루션 층은 7번(#7) 층과 같이 컨볼루션 연산(Conv7)만 포함할 수도 있다.Also, the convolution layer may include only a convolution operation (Conv7), such as layer 7 (# 7).

출력 데이터는 최종 출력된 추론 데이터일 수 있으며, 본 도면에서는 7번(#7) 컨볼루션 층의 출력 특징맵을 사용하는 것으로 도시되어 있다.The output data may be the final output inference data, and is illustrated in this figure as using the output feature map of the convolution layer 7 (# 7).

입력 데이터는 1번(#1) 컨볼루션 층의 입력으로 사용되어 컨볼루션 연산을 수행하는데, 이 때 입력 데이터는 0번(n=0) 메모리에 저장을 하게 된다.The input data is used as the input of the convolution layer 1 (# 1) to perform the convolution operation. At this time, the input data is stored in memory 0 (n = 0).

1번 컨볼루션 층은, 입력 특징맵으로서 0번 메모리를 액세스하여 컨볼루션 연산(Conv1) 및 ReLU 연산을 수행하여 출력 특징맵을 생성하고, 이를 1번(n=1) 메모리에 저장을 한다. 즉, 1번 컨볼루션 층은 0번 메모리에 저장되어 있는 입력 특징맵으로부터 컨볼루션 연산 및 ReLU를 수행하여 1번 메모리에 출력 특징맵을 저장한다. 1번 메모리에 저장된 출력 특징맵은 2번 컨볼루션 층의 입력 특징맵으로 사용되고, 2번 컨볼루션 층의 연산 결과(출력 특징맵)는 2번(n=2) 메모리에 저장된다.The convolution layer 1 accesses memory 0 as an input feature map, performs a convolution operation (Conv1) and a ReLU operation, generates an output feature map, and stores it in memory 1 (n = 1). That is, the convolution layer 1 performs convolution operation and ReLU from the input feature map stored in the memory 0 to store the output feature map in the memory 1. The output feature map stored in memory # 1 is used as the input feature map of the convolution layer # 2, and the operation result (output feature map) of the convolution layer # 2 is stored in memory # 2 (n = 2).

마찬가지 방법으로 2번 메모리에 저장된 출력 특징맵은 3번 컨볼루션 층의 입력 특징맵으로 사용되고, 3번 컨볼루션 층의 연산 결과(출력 특징맵)는 3번(n=3) 메모리에 저장된다.In the same way, the output feature map stored in the memory 2 is used as the input feature map of the convolutional layer 3, and the operation result (output feature map) of the convolutional layer 3 is stored in the memory 3 (n = 3).

마지막 컨볼루션 층인 7번 컨볼루션 층의 연산 결과(출력 특징맵)는 7번 메모리에 저장되고, 이 값은 최종 추론 값이 된다.The calculation result (output feature map) of the last convolutional layer 7 convolutional layer is stored in the 7th memory, and this value becomes the final inference value.

도 4를 참조하면, 상술한 메모리의 본 발명에 따른 메모리 할당 및 라인버퍼의 구성이 도시되어 있다.Referring to FIG. 4, a memory allocation and line buffer configuration according to the present invention of the above-described memory are illustrated.

본 발명은 컨볼루션 연산이 '라인 단위'로 연산이 수행될 수 있다는 것에 착안하여, 입력 및 출력 특징맵을 라인 단위로 저장한다.The present invention contemplates that the convolution operation can be performed in 'line units', and stores input and output feature maps in line units.

도 4(a)를 참조하면, H*W 크기의 입력 또는 출력 특징맵(20)이 H개의 가로 라인이 각 라인별로 H개의 라인버퍼(21, 22, 23, 24,…)에 저장되는 개념이 도시되어 있다.Referring to FIG. 4 (a), an H * W size input or output feature map 20 stores H horizontal lines in H line buffers 21, 22, 23, 24, ... for each line. This is shown.

도시된 라인버퍼(21, 22, 23, 24)는 논리적인(logical) 메모리로서 메모리의 특정 영역(주소)이 각각 할당된 것이다. 즉, 연속된 라인버퍼(21, 22, 23, 24)가 반드시 연속적인 물리적(physical) 주소를 가질 필요는 없는 것이다.The illustrated line buffers 21, 22, 23, and 24 are logical memories, each of which is assigned a specific area (address) of the memory. That is, the continuous line buffers 21, 22, 23, and 24 do not have to have consecutive physical addresses.

각 라인버퍼(21, 22, 23, 24)는 특징맵(20)의 적어도 한 라인을 저장할 수 있도록 그 크기가 할당되는 것이 바람직하며, 두개 또는 그 이상의 라인이 저장될 수도 있다.Each of the line buffers 21, 22, 23, and 24 is preferably assigned a size to store at least one line of the feature map 20, and two or more lines may be stored.

도 4(a) 도시된 예에 의하면, 특징맵을 구성하는 H개의 라인을 저장하기 위해 H개의 라인버퍼가 도시되어 있다.According to the example shown in FIG. 4 (a), H line buffers are illustrated to store H lines constituting the feature map.

도 4(b)를 참조하면, 도 3에서 설명한 0번(n=0)부터 7번(n=7)까지의 특징맵을 저장하기 위한 라인버퍼들이 도시되어 있다. 즉, 0번 특징맵(입력 데이터 또는 1번 컨볼루션 층의 입력 특징맵) 저장을 위한 H개의 라인버퍼, 1번 특징맵(1번 컨볼루션 층의 출력 특징맵 또는 2번 컨볼루션 층의 입력 특징맵)을 저장하기 위한 H개의 라인버퍼가 도시되어 있는 것이다.Referring to FIG. 4 (b), line buffers for storing feature maps 0 to 7 (n = 7) described in FIG. 3 are illustrated. That is, H line buffers for storing the feature map 0 (input data or the input feature map of the convolution layer 1), the feature map 1 (the output feature map of the convolution layer 1 or the input of the convolution layer 2) Feature maps) are shown with H line buffers.

그런데, 후술하겠지만, 본 발명에 따른 효율적인 메모리 관리 방법에 따르면, 각 특징맵의 저장을 위해 라인버퍼를 할당하지만, 0번부터 7번까지 8장의 모든 특징맵을 동시에 저장하고 있을 필요가 없고, 한걸음 더 나아가서, 한 특징맵 내에서도 1번부터 H번까지의 모든 라인을 동시에 저장하고 있을 필요가 없다.However, as will be described later, according to the efficient memory management method according to the present invention, a line buffer is allocated for storage of each feature map, but it is not necessary to store all eight feature maps from 0 to 7 at the same time. Furthermore, there is no need to store all lines 1 through H simultaneously within a feature map.

따라서, 메모리 할당이 되어 실제로 특정 라인을 저장하거나 사용되고 있는 라인버퍼(23, 24)는 해시(빗금) 또는 체크 무늬로 도시하고, 아무런 해시나 체크 무늬가 없는 라인버퍼(21, 22)는 사용이 완료되어 더 이상 필요하지 않거나, 아직 사용이 되지 않아 실제로는 메모리가 할당되지 않는 메모리로서 설명 편의상 도시된 것이다. 이하 실시예에 도시된 도면에서도 해시 또는 체크 무늬가 있는 라인버퍼는 실제로 현재 사용되는 라인버퍼이고, 아무런 무늬가 없는 라인버퍼는 설명 편의상 도시된 것일 뿐 현재 현재 시점에서는 사용되지 않는 것으로 이해하면 된다.Therefore, the line buffers 23 and 24 that are allocated or actually used for storing or using a specific line are shown in a hash (hatched) or checkered pattern, and the line buffers 21 and 22 without any hash or checkered pattern can be used. It is completed and is no longer needed, or is not used yet, and is actually shown as a memory to which memory is not allocated. In the drawings shown in the following examples, it is understood that the line buffer with hash or checkered is actually the currently used line buffer, and the line buffer without any pattern is shown for convenience of description only and is not used at the present time.

또한, 사용중인 라인버퍼(23, 24)라고 하더라도, 사용이 완료되어 더 이상 해당 라인을 저장할 필요가 없다고 판단되면 라인버퍼(23, 24)를 다른 라인을 저장하도록 메모리 재할당을 하거나 아예 다른 용도로 사용할 수 있다.In addition, even if the line buffers 23 and 24 are in use, when it is determined that the use is no longer necessary to store the line, the line buffers 23 and 24 may be reallocated memory to store other lines, or other uses at all. Can be used as

또한, 라인버퍼가 한 채널의 한 라인을 저장하는 것으로 도시되어 있지만, 이에 한정되는 것은 아니며, 한 라인버퍼가 한 채널의 여러 라인을 저장할 수도 있고, 여러 채널의 한 라인, 여러 채널의 여러 라인을 저장할 수도 있다.In addition, although the line buffer is illustrated to store one line of one channel, the present invention is not limited thereto, and one line buffer may store multiple lines of one channel, one line of multiple channels, and multiple lines of multiple channels. You can also save.

도 5는 종래의 특징맵 단위의 메모리 관리 방법을 나타내는 블록도이다.5 is a block diagram showing a conventional memory management method in a feature map unit.

Tianqi Chen, et al., “MXNet: A flexible and efficient machine learning library for heterogeneous distributed systems,”in LearningSys'15, 2015.는 모든 컨볼루션 층의 모든 특징맵을 저장하지 않고, 현재 컨볼루션 연산에 사용되는 특징맵만 메모리에 저장을 하고, 더 이상 다음 컨볼루션 층의 컨볼루션 연산에 사용되지 않는 특징맵은 재사용을 하는 '특징맵 단위의 메모리 관리' 개념을 개시하였다.Tianqi Chen, et al., “MXNet: A flexible and efficient machine learning library for heterogeneous distributed systems,” in LearningSys'15, 2015. does not store all feature maps of all convolutional layers, and is currently used for computation of convolution The concept of 'memory management in units of feature maps' is disclosed, in which only feature maps are stored in memory, and feature maps that are no longer used in the convolution operation of the next convolution layer are reused.

도 5(a)를 참조하면, 3번 특징맵(3번 컨볼루션 층의 출력 특징맵인 동시에 4번 컨볼루션 층의 입력 특징맵)이 H개의 라인버퍼에 저장되어 있고, 3번 특징맵으로부터 컨볼루션 연산(Conv4)을 수행하여 그 결과인 4번 특징맵을 H개의 라인버퍼에 저장하는 것을 도시하고 있다.Referring to FIG. 5 (a), the feature map 3 (the output feature map of the convolutional layer 3 and the input feature map of the convolutional layer 4) is stored in H line buffers, and from the feature map 3, It shows that the convolution operation (Conv4) is performed and the resultant feature map 4 is stored in H line buffers.

본 '특징맵 단위의 메모리 관리'에 따르면, 0번부터 7번까지 8개의 특징맵을 동시에 저장하지 않고, 컨볼루션 연산 순서상 반드시 필요한 특징맵만 저장을 하면 된다.According to the 'memory management in units of feature maps', 8 feature maps from 0 to 7 are not stored at the same time, and only feature maps necessary for convolution operation need to be stored.

즉, 4번 컨볼루션 층의 연산을 수행 중이라면, 입력 특징맵인 3번 특징맵과 출력 특징맵인 4번 특징맵만 메모리 액세스가 되면 되므로, 더 이상 2번 특징맵은 필요가 없으므로 5번 특징맵 저장을 위한 라인버퍼로 메모리 재할당을 하던가 기타 다른 용도로 메모리를 재사용하면 된다.In other words, if the operation of the convolution layer 4 is being performed, only the feature map No. 3 which is the input feature map and the feature map No. 4, which is the output feature map, need to be accessed by memory. You can reallocate memory as a line buffer for storing feature maps or reuse memory for other purposes.

마찬가지로, 도 5(b)를 참조하면, 4번 특징맵(4번 컨볼루션 층의 출력 특징맵인 동시에 5번 컨볼루션 층의 입력 특징맵)이 H개의 라인버퍼에 저장되어 있고, 4번 특징맵으로부터 컨볼루션 연산(Conv5)을 수행하여 그 결과인 5번 특징맵을 H개의 라인버퍼에 저장하는 것을 도시하고 있다. 이 때 3번 특징맵은 메모리 재할당 또는 재사용하면 된다.Similarly, referring to FIG. 5 (b), feature # 4 (the output feature map of the convolutional layer # 4 and input feature map of the convolutional layer # 5) is stored in H line buffers, and feature # 4 It is shown that the convolution operation (Conv5) is performed from the map and the resultant feature map 5 is stored in H line buffers. At this time, the feature map 3 can be reassigned or reused.

따라서, 종래의 '특징맵 단위의 메모리 관리'에서는 적어도 2장의 특징맵을 저장할 수 있는 메모리, 즉, 2H 개의 라인버퍼를 확보해야 한다. Therefore, in the conventional 'memory management in units of feature maps', a memory capable of storing at least two feature maps, that is, 2H line buffers must be secured.

도 6 및 7은 각각 본 발명의 다른 일 실시예에 따른 순차적 순회 방식으로 컨볼루션 연산을 수행하도록 하는 메모리 관리 방법을 설명하기 위한 블록도 및 순서도(S100)이다.6 and 7 are block diagrams and flowcharts (S100) for explaining a memory management method for performing convolution operations in a sequential traversal method according to another embodiment of the present invention.

본 발명은 도 5에서 설명한 종래의 '특징맵 단위'의 메모리 관리에서 한걸음 더 나아가서, 컨볼루션 연산이 특징맵의 '라인 단위'로 수행될 수 있다는 특징에 착안하여, 도 5의 메모리 관리를 더욱 효율적으로 하여 컨볼루션 연산에 요구되는 메모리의 크기를 훨씬 더 줄이는 '라인 단위의 메모리 관리”에 관한 것이다.The present invention goes one step further from the conventional 'feature map unit' memory management described in FIG. 5, and focuses on the feature that the convolution operation can be performed in 'line unit' of the feature map, further improving the memory management of FIG. It is about 'memory on a line-by-line' basis, which reduces the amount of memory required for convolution by making it much more efficient.

본 발명에 따른 '라인 단위의 메모리 관리'를 효율적으로 수행하기 위해서는 '라인 단위의 컨볼루션 연산'을 수행하며, '라인 단위의 컨볼루션 연산'을 수행하는 순서를 2가지로 할 수 있는데, 잠시 도 8을 참조하면, 본 발명의 일 실시예에 따른 순차적 순회 방식과 대각선 순회 방식으로 컨볼루션 연산을 수행하는 순서를 나타내는 도면이 도시되어 있다.In order to efficiently perform 'line-level memory management' according to the present invention, 'line-level convolution operation' is performed, and 'line-level convolution operation' can be performed in two steps. Referring to FIG. 8, a diagram illustrating a sequence of performing convolution operations in a sequential traversal method and a diagonal traversal method according to an embodiment of the present invention is illustrated.

도 8(a)를 참조하면, '순차적 순회 방식'으로서, 각 컨볼루션 층의 컨볼루션 연산을 한 특징맵 내에서 라인 순서대로(1, 2, 3, 4) 수행하는 것을 도시하고 있다. 한 특징맵의 마지막 라인(4번 라인)의 연산이 마무리되면 그 다음 단계 컨볼루션 층의 특징맵의 연산을 역시 라인 순서대로(5, 6, 7, 8) 수행하는 것이다.Referring to FIG. 8 (a), as a 'sequential traversal method', it is shown that convolution operation of each convolution layer is performed in line order (1, 2, 3, 4) in one feature map. When the operation of the last line (line 4) of one feature map is completed, the operation of the feature map of the next step convolution layer is also performed in line order (5, 6, 7, 8).

도 8(b)를 참조하면, '대각선 순회 방식'으로서, 한 특징맵의 한 라인의 연산이 수행된 후, '만약 다음 단계 컨볼루션 층의 컨볼루션 연산이 가능한 경우에는' 다음 라인의 연산보다 다음 단계 컨볼루션 층의 연산을 더 먼저 수행하는 방식이다. 예를 들어, 2번 라인의 생성이 완료되면, 제로 패딩 및 1,2번 라인으로부터 1번 특징맵의 3번 라인의 연산이 가능하게 된다. 이 때 (2번 라인과 동일한 특쟁맵 내의) 다음 라인인 4번 라인의 생성보다 먼저 (다음 단계 컨볼루션 층인) 다음 특징맵의 3번 라인을 먼저 생성하는 것이다. 예를 더 들어보면, 1, 2, 4번 라인으로부터 컨볼루션 연산으로 5번 라인을 생성한 후에 8번을 생성하지 않고 (다음 단계 컨볼루션 층인) 6번을 먼저 생성하는 것이다.Referring to FIG. 8 (b), after the operation of one line of a feature map is performed as the 'diagonal traversal method', 'if the convolution operation of the next-level convolution layer is possible' than the operation of the next line The next step is to perform the operation of the convolution layer first. For example, when generation of line 2 is completed, zero padding and operation of line 3 of feature map 1 from line 1 and 2 are enabled. In this case, the third line of the next feature map (which is a next-level convolutional layer) is generated before the next line (in the same special map as the second line) of the next line. For example, after generating the 5th line from the 1st, 2nd and 4th lines by the convolution operation, the 8th generation (which is the next step convolution layer) is not generated.

즉, 순차적 순회 방식은 해당 컨볼루션 층의 연산을 모두 마무리한 후 다음 컨볼루션 층의 연산을 수행하는 데 비하여, 대각선 순회 방식은 해당 컨볼루션 층의 연산이 마무리되기 전에 다음 단계 또는 그 다음 단계의 컨볼루션 연산을 먼저 수행하는 방식이다.In other words, the sequential traversal method performs the operation of the next convolutional layer after completing all the operations of the convolutional layer, whereas the diagonal traversal method performs the next or next step before the operation of the convolutional layer is completed. This is the way to perform the convolution operation first.

도 6의 실시예 및 도 7의 순서도는 상술한 '순차적 순회 방식'을 사용한 실시예이다.The embodiment of FIG. 6 and the flowchart of FIG. 7 are embodiments using the above-described 'sequential traversal method'.

도 6(a)를 참조하면, 4번 컨볼루션 층의 연산을 수행하여 4번 특징맵을 생성하는 과정 중에, 4번 특징맵의 (H+6)번째 라인을 생성하기 위해서는, 4번 출력 특징맵의 필터 크기가 3이라면, 3번 특징맵의 5, 6, 7번 라인이 필요하다. 따라서, 5, 6, 7번 라인버퍼를 액세스하여 컨볼루션 연산을 수행하여 그 결과를 (H+6)번 라인버퍼에 저장하는 것을 도시하고 있다.Referring to FIG. 6 (a), during the process of generating the feature map No. 4 by performing the operation of the convolution layer No. 4, in order to generate the (H + 6) -th line of the feature map No. 4, output feature No. 4 If the filter size of the map is 3, lines 5, 6, and 7 of the feature map 3 are needed. Accordingly, it is shown that the line buffers 5, 6, and 7 are accessed to perform convolution operations and the result is stored in line buffer (H + 6).

이어서 도 6(b)를 참조하면, 4번 특징맵의 (H+7)번째 라인을 생성하기 위해서는, 3번 특징맵의 6, 7, 8번 라인이 필요하다. 따라서, 6, 7, 8번 라인버퍼를 액세스하여 컨볼루션 연산을 수행하여 그 결과를 (H+7)번 라인버퍼에 저장하는 것을 도시하고 있다.Subsequently, referring to FIG. 6 (b), lines 6, 7, and 8 of the feature map 3 are required to generate the (H + 7) -th line of the feature map 4. Accordingly, it is shown that the line buffers 6, 7, and 8 are accessed to perform a convolution operation and the result is stored in the line buffer (H + 7).

이러한 과정을 순서도로 설명을 하면 S100과 같다.If this process is explained in a flow chart, it is the same as S100.

S110 단계에서, 5번 내지 7번 라인버퍼를 액세스하여 컨볼루션 연산을 수행한 결과를 (H+6)번 라인버퍼에 저장한다.In step S110, the results of performing the convolution operation by accessing the line buffers 5 to 7 are stored in the line buffer (H + 6).

그러면, 5번 라인은 더 이상 컨볼루션 연산에 필요하지 않으므로, 5번 라인버퍼를 (H+7)번 라인버퍼로 할당할 수 있다(S120). 물론, 5번 라인버퍼는 재사용이 가능하므로 다른 용도로 사용할 수도 있고, (H+7)번 라인버퍼는 다른 메모리 영역으로 미리 할당 받을 수도 있다.Then, line 5 is no longer required for the convolution operation, so line 5 buffer can be assigned as line buffer (H + 7) (S120). Of course, the line buffer number 5 is reusable, so it can be used for other purposes, and the line buffer number (H + 7) can be pre-allocated to another memory area.

그리고, 순차적 순회 방식의 연산 순서에 따라, S130 단계에서, 6번 내지 8번 라인버퍼를 액세스하여 컨볼루션 연산을 수행한 결과를 (H+7)번 라인버퍼에 저장할 수 있다.Then, according to the operation sequence of the sequential traversal method, in step S130, the result of performing the convolution operation by accessing the line buffers 6 to 8 may be stored in the line buffer (H + 7).

그러면, 6번 라인은 더 이상 컨볼루션 연산에 필요하지 않으므로, 6번 라인버퍼를 (H+8)번 라인버퍼로 할당할 수 있다(S140). 물론, 6번 라인버퍼는 재사용이 가능하므로 다른 용도로 사용할 수도 있고, (H+8)번 라인버퍼는 다른 메모리 영역으로 미리 할당 받을 수도 있다.Then, line 6 is no longer required for the convolution operation, so line 6 buffer can be allocated as line buffer (H + 8) (S140). Of course, the line buffer number 6 is reusable, so it can be used for other purposes, and the line buffer number (H + 8) can be pre-allocated to another memory area.

이상과 같이 순차적 순회 방식으로 라인 단위 컨볼루션 연산을 수행하면, 도 6에의 빗금 및 체크 무늬의 라인버퍼로부터 알 수 있듯이, 컨볼루션 연산에 5번부터 (H+6)번 라인버퍼까지 (또는 6번부터 (H+7)번 라인버퍼까지) 최소 (H+2)개의 라인버퍼만 할당되어 있으면 된다.If the line-wise convolution operation is performed in the sequential traversal method as described above, as can be seen from the hatched and checkered line buffers in FIG. 6, from the 5th to the (H + 6) th line buffers in the convolution operation (or 6 From (H + 7) to line buffer), only (H + 2) line buffers need to be allocated.

따라서, 도 5의 방법에서 필요한 메모리의 크기가 2H개의 라인버퍼인데 비하여, 도 6의 순차적 순회 방식은 최소 (H+2)개의 라인버퍼만 있으면 되므로, H 값이 커질수록 거의 절반 정도의 메모리만 있으면 되는 것이다.Therefore, the size of the memory required in the method of FIG. 5 is 2H line buffers, whereas the sequential traversal method of FIG. 6 only needs at least (H + 2) line buffers, so as the H value increases, only about half of the memory You just need it.

도 9 및 10은 각각 본 발명의 또 다른 일 실시예에 따른 대각선 순회 방식으로 컨볼루션 연산을 수행하도록 하는 메모리 관리 방법을 설명하기 위한 블록도 및 순서도(S200)이다.9 and 10 are block diagrams and flowcharts (S200) for explaining a memory management method for performing convolution operations in a diagonal traversal method according to another embodiment of the present invention.

도 9(a)를 참조하면, 6번 컨볼루션 층의 연산을 수행하여 51번 라인을 생성하는 과정으로서, 6번 특징맵의 51번 라인을 생성하기 위해서는, 6번 출력 특징맵의 필터 크기가 3이라면, 5번 특징맵의 34, 42, 50번 라인이 필요하다. 따라서, 34, 42, 50번 라인버퍼를 액세스하여 컨볼루션 연산을 수행하여 그 결과를 51번 라인버퍼에 저장하는 것을 도시하고 있다.Referring to FIG. 9 (a), as a process of generating the 51st line by performing the operation of the 6th convolution layer, in order to generate the 51st line of the 6th feature map, the filter size of the 6th output feature map is If it is 3, lines 34, 42, and 50 of feature map 5 are required. Accordingly, it is illustrated that the line buffers 34, 42, and 50 are accessed to perform a convolution operation and the result is stored in the line buffer 51.

이어서 도 6(b)를 참조하면, 대각선 순회 방식에 의해 7번 특징맵의 52번 라인을 생성하기 위해서는, 7번 출력 특징맵의 필터 크기가 3이라면, 6번 특징맵의 35, 43, 51번 라인이 필요하다. 따라서, 35, 43, 51번 라인버퍼를 액세스하여 컨볼루션 연산을 수행하여 그 결과를 52번 라인버퍼에 저장하는 것을 도시하고 있다.Subsequently, referring to FIG. 6 (b), in order to generate line 52 of the feature map No. 7 by the diagonal traversal method, if the filter size of the output feature map No. 7 is 3, 35, 43, 51 of the feature map No. 6 Need line number one. Accordingly, it is illustrated that the line buffers 35, 43, and 51 are accessed to perform convolution operations and the results are stored in the line buffer 52.

이러한 과정을 순서도로 설명을 하면 S200과 같다.If this process is described in a flow chart, it is the same as S200.

S210 단계에서, 34, 42, 50번 라인버퍼를 액세스하여 컨볼루션 연산을 수행한 결과를 51번 라인버퍼에 저장한다.In step S210, the results of performing the convolution operation by accessing the line buffers 34, 42, and 50 are stored in the line buffer 51.

그러면, 34번 라인은 더 이상 컨볼루션 연산에 필요하지 않으므로, 34번 라인버퍼를 52번 라인버퍼로 할당할 수 있다(S220). 물론, 34번 라인버퍼는 재사용이 가능하므로 다른 용도로 사용할 수도 있고, 52번 라인버퍼는 다른 메모리 영역으로 미리 할당 받을 수도 있다.Then, line 34 is no longer required for the convolution operation, so line 34 buffer can be allocated as line 52 buffer (S220). Of course, line 34 buffer can be reused, so it can be used for other purposes, and line 52 buffer can be pre-allocated to another memory area.

그리고, 대각선 순회 방식의 연산 순서에 따라, S230 단계에서, 다음 단계 컨볼루션 층의 라인버퍼인 35, 43, 51번 라인버퍼를 액세스하여 컨볼루션 연산을 수행한 결과를 52번 라인버퍼에 저장할 수 있다.In addition, in step S230, the line buffers 35, 43, and 51 of the next step convolution layer are accessed and the result of the convolution operation can be stored in the line buffer 52 according to the operation sequence of the diagonal traversal method. have.

그러면, 35번 라인은 더 이상 컨볼루션 연산에 필요하지 않으므로, 35번 라인버퍼를 53번 라인버퍼로 할당할 수 있다(S240). 물론, 35번 라인버퍼는 재사용이 가능하므로 다른 용도로 사용할 수도 있고, 53번 라인버퍼는 다른 메모리 영역으로 미리 할당 받을 수도 있다.Then, line 35 is no longer required for the convolution operation, so line 35 buffer can be allocated as line 53 buffer (S240). Of course, line 35 buffer can be reused, so it can be used for other purposes, and line 53 buffer can be pre-allocated to another memory area.

이상과 같이 대각적 순회 방식으로 라인 단위 컨볼루션 연산을 수행하면, 도 9에의 빗금 및 체크 무늬의 라인버퍼로부터 알 수 있듯이, 컨볼루션 연산에 최소 2(N+1)개의 라인버퍼만 할당되어 있으면 된다.If the line-wise convolution operation is performed in the diagonal traversal method as described above, as can be seen from the hatched and checkered line buffers in FIG. 9, if at least 2 (N + 1) line buffers are allocated to the convolution operation do.

따라서, 도 6의 순차적 순회 방식에서 필요한 메모리의 크기가 (H+2)개의 라인버퍼가 필요한데 비하여, 도 9의 대각선 순회 방식은 최소 2(N+1)개의 라인버퍼만 있으면 된다.Therefore, the size of the memory required in the sequential traversal scheme of FIG. 6 requires (H + 2) line buffers, whereas the diagonal traversal scheme of FIG. 9 only needs at least 2 (N + 1) line buffers.

참고로, 도 9(a)에서 44번 라인을 저장하고 있지 않는데, 그 이유는 7번 특징맵이 추론된 출력 이미지라는 가정을 한 것이다. 출력 이미지의 경우는 메모리에 굳이 그 값을 계속 유지하지 않고, 외부 또는 다른 블록으로 그 값을 전송하는 것이 바람직하기 때문이다.For reference, in FIG. 9 (a), line 44 is not stored. The reason is that the feature map # 7 is an inferred output image. This is because, in the case of an output image, it is desirable to transmit the value to an external or other block without necessarily maintaining the value in memory.

본 발명에 따른 두가지의 컨볼루션 연산 순회 방식은 컨볼루션 층의 개수(N)와 특징맵의 라인 개수(H)에 기초하여 선택할 수 있다. 예를 들어, (H+2) < 2(N+1) 이면 순차적 순회 방식을 사용하는 것이 바람직하고, 그렇지 않으면 대각선 순회 방식을 사용하는 것이 바람직하다. 일례로서, 4K 해상도의 이미지의 경우 H=2160, W=3840 이고, 컨볼루션 네트워크의 채널의 개수 C=12, 특징맵 한 점의 데이터 크기 D=1.5 byte, 컨볼루션 층의 개수 N=40 이라면, 순차적 순회 방식의 경우 142.5 MB, 대각선 순회 방식의 경우 5.4 MB가 필요하여, 대각선 순회 방식을 사용하는 것이 훨씬 적은 메모리를 사용할 수 있는 것이다.The two convolution operation traversal schemes according to the present invention can be selected based on the number (N) of convolutional layers and the number of lines (H) of feature maps. For example, if (H + 2) <2 (N + 1), it is preferable to use a sequential traversal scheme, otherwise it is preferable to use a diagonal traversal scheme. As an example, if the image of 4K resolution is H = 2160, W = 3840, the number of channels of the convolutional network C = 12, the data size of one point of the feature map D = 1.5 bytes, the number of convolutional layer N = 40 , 142.5 MB for the sequential traversal method and 5.4 MB for the diagonal traversal method, so using the diagonal traversal method can use much less memory.

그런데, 위의 가정은, <표 1>에서 설명하였듯이, 컨볼루션 신경망의 여러가지 특성들을 단순화한 것으로서, 실제로는 여러가지 특성들을 고려하여 선택하는 것이 바람직하다. 예를 들어, 각 컨볼루션 층 간의 중간 특징맵들은 그 크기가 모두 동일한 것은 아닐 수 있으므로, 상술한 (H+2) < 2N 에서 각 특징맵들의 H가 컨볼루션 층마다 다를 수 있다는 점을 고려하여 선택해야 하는 것이다.However, the above assumption, as described in <Table 1>, simplifies various characteristics of the convolutional neural network, and in practice it is preferable to select in consideration of various characteristics. For example, considering that the intermediate feature maps between the respective convolution layers may not all have the same size, considering that (H + 2) <2N, H of each feature map may be different for each convolution layer. You have to choose.

따라서, 본 실시예들에서는 설명 및 도시의 편의를 위하여 순차적 및 대각선 순회 방식을 간략하게 설명 및 도시하였지만, 이에 한정해서 해석되어서는 아니 되며, 본 발명의 기술적 사상에 부합하는 의미와 개념으로 해석되어야 한다.Therefore, in the present exemplary embodiments, the sequential and diagonal traversal methods are briefly described and illustrated for convenience of description and illustration, but should not be interpreted as being limited thereto, but should be interpreted as meanings and concepts consistent with the technical spirit of the present invention. do.

한편, 전술한 순차적 순회 방식은, 라인단위로 연산을 하되, '반드시' 그 다음 라인을 연산할 필요는 없을 수 있다. 또한, 2개의 라인을 동시에 연산할 수도 있다. 본 발명에 따른 순차적 순회 방식은 라인 단위로 연산을 하는 기술적 사상에 기반한 것이므로, 전술한 실시예는 메모리 요구량을 최소로 하는 경우의 설명이며, 메모리의 여유가 있을 경우에는 전술한 최소 라인버퍼외에 추가로 라인버퍼를 더 할당할 수도 있으므로, 전술한 실시예로 한정되는 것은 아니다.On the other hand, in the sequential traversal method described above, the operation is performed on a line basis, but it may not be necessary to 'compute' the next line. Also, two lines can be operated simultaneously. Since the sequential traversal method according to the present invention is based on the technical idea of calculating in units of lines, the above-described embodiment is a description of a case in which the memory demand is minimized, and when there is room for memory, in addition to the above-described minimum line buffer. Since the line buffer may be further allocated, it is not limited to the above-described embodiment.

또한, 전술한 대각선 순회 방식도, '만약 다음 단계 컨볼루션 층의 컨볼루션 연산이 가능한 경우에는' 다음 라인의 연산보다 '반드시' 다음 단계 컨볼루션 층의 연산을 더 먼저 수행해야 하는 것은 아니다. 즉, 다음 라인을 계속 더 수행한 후에 다음 단계 컨볼루션 층의 연산을 할 수도 있는 것이다. 본 발명에 따른 대각선 순회 방식은, '라인 단위로 연산을 하되 반드시 한 컨볼루션 층의 연산을 모두 수행한 후에 다음 단계 컨볼루션 층의 연산을 수행할 필요는 없다'는 기술 사상에 기반한 것이다. 따라서, 이에 한정해서 해석되어서는 아니 되며, 본 발명의 기술적 사상에 부합하는 의미와 개념으로 해석되어야 한다.Also, in the diagonal traversal method described above, it is not necessary to perform the operation of the next-level convolution layer 'never' before the operation of the next line 'if the convolution operation of the next-level convolution layer is possible'. In other words, the operation of the next step convolution layer may be performed after continuing the next line. The diagonal traversal method according to the present invention is based on the technical idea that 'the operation is performed in units of lines, but it is not necessary to perform the operation of the next step convolution layer after all operations of one convolution layer are performed'. Therefore, it should not be interpreted as being limited to this, and should be interpreted as meanings and concepts consistent with the technical spirit of the present invention.

또한, 전술한 순차적 순회 방식 및 대각선 순회 방식 모두 라인을 가로 방향으로 가정하여 도시하고 설명하였지만, 이에 한정되는 것은 아니며, 세로 방향으로도 가능하다.In addition, although the above-described sequential traversing method and diagonal traversing method have been illustrated and described assuming the line in the horizontal direction, the present invention is not limited thereto, and is also possible in the vertical direction.

도 11은 본 발명의 또 다른 바람직한 일 실시예에 따라, 필터 윈도우의 크기가 5인 경우 대각선 순회 방식으로 컨볼루션 연산을 수행하는 순서를 나타내는 도면이다.11 is a diagram illustrating a sequence of performing convolution operations in a diagonal traversal method when the size of a filter window is 5 according to another preferred embodiment of the present invention.

전술한 실시예들은 필터(커널) 윈도우를 일반적으로 많이 사용하는 3x3을 사용한 예시이다. 즉, 필터의 높이가 3인 예시이다.The above-described embodiments are examples using 3x3, which generally uses a filter (kernel) window. That is, it is an example in which the height of the filter is 3.

도 11을 참조하면, 전술한 실시예들과 달리 필터의 높이가 5인 경우(예를 들어 5x5), 대각선 순회 방식으로 컨볼루션 연산을 수행하는 순서를 나타내고 있다. 예로서, 71번 라인(6번 컨볼루션 층의 출력 특징맵)의 컨볼루션 연산을 수행하기 위해서는 5번 특징맵의 42, 48, 55, 62, 70번 라인버퍼 값, 즉, 5개의 값이 필요하다. 71번 라인의 컨볼루션 연산이 완료되면, 42번 라인버퍼는 다른 용도로 재사용하거나 72번 라인버퍼로 할당할 수 있다. 다음으로는 72번 라인(7번 컨볼루션 층의 출력 특징맵)의 컨볼루션 연산을 수행하기 위해서 6번 특징맵의 제로패딩, 49, 56, 63, 71번 라인버퍼의 값을 액세스하면 된다.Referring to FIG. 11, when the height of the filter is 5 (for example, 5x5) unlike the above-described embodiments, a sequence of performing convolution operations in a diagonal traversal method is illustrated. For example, in order to perform the convolution operation of the 71st line (the output feature map of the 6th convolution layer), the 42, 48, 55, 62, 70 line buffer values of the 5 feature maps, that is, the 5 values need. When the convolution operation of the 71st line is completed, the 42nd line buffer can be reused for another purpose or allocated as the 72nd line buffer. Next, in order to perform the convolution operation of the 72nd line (output feature map of the 7th convolution layer), the value of the zero padding of the 6th feature map, the 49, 56, 63, and 71 line buffer values may be accessed.

이상과 같이 다양한 필터 크기(또는 높이)에 대하여도 대각선 순회 방식을 적용할 수 있으며, 요구되는 메모리의 크기를 계해보면, 필터 높이가 K이고, 입력층을 포함한 컨볼루션 층의 개수가 N일 때, (K-1)(N+1)이 된다. 도 9의 실시예는 K가 3이므로, 요구되는 메모리 크기는 (3-1)(N+1) = 2(N+1) 이 되는 것이다.Diagonal traversal can be applied to various filter sizes (or heights) as described above. When calculating the required memory size, when the filter height is K and the number of convolution layers including the input layer is N , (K-1) (N + 1). In the embodiment of FIG. 9, since K is 3, the required memory size is (3-1) (N + 1) = 2 (N + 1).

또한, 전술한 모든 실시예들은 스트라이드(stride)를 1로 가정하여 도시하고 설명하였지만, 스트라이드가 1보다 큰 경우에도 적용이 가능하다.In addition, although all the above-described embodiments are illustrated and described on the assumption that the stride is 1, it is applicable even when the stride is greater than 1.

도 12 및 13은 각각 본 발명의 또 다른 바람직한 일 실시예에 따라, 온칩 메모리의 제한이 있는 경우 대각선 순회 방식으로 컨볼루션 연산을 수행하도록 하는 메모리 관리 방법을 설명하기 위한 블록도 및 순서도(S300)이다.12 and 13, respectively, according to another preferred embodiment of the present invention, when there is a limitation of on-chip memory, a block diagram and a flow chart for explaining a memory management method for performing convolution operation in a diagonal traversal method (S300). to be.

도 12를 참조하면, 메모리의 제약으로 인하여 컨볼루션 층을 2개의 그룹으로 나누어 대각선 순회 방식을 적용한 예로서, 4번 컨볼루션 층까지를 하나의 그룹으로 구분하고, 나머지 컨볼루션 층을 다른 그룹으로 구분한 예시이다.Referring to FIG. 12, as an example of applying the diagonal traversal method by dividing the convolution layer into two groups due to memory limitation, the convolution layer No. 4 is divided into one group, and the remaining convolution layers are divided into different groups. This is a separated example.

도 12(a)는 첫번째 그룹의 연산을 도시하는 것으로서, 10개의 라인버퍼만 사용하며, 35번 라인을 생성하는 것을 나타내고 있다.FIG. 12 (a) shows the operation of the first group, which shows that only 10 line buffers are used and line 35 is generated.

4번 특징맵의 라인이 생성되면, 생성된 라인을 DDR 등의 외부 저장부에 저장할 수 있다.When the line of the feature map 4 is generated, the generated line can be stored in an external storage such as DDR.

4번 특징맵의 모든 라인의 생성 및 외부 저장이 완료되면, 도 12(b)에서와 같이, 저장되어 있던 4번 특징맵의 라인을 읽어들이면서 5번 특징맵의 각 라인을 생성할 수 있다.When the generation and external storage of all lines of the feature map No. 4 are completed, as shown in FIG. 12 (b), each line of the feature map No. 5 may be generated while reading the lines of the stored feature map No. 4. .

이러한 과정을 순서도로 설명을 하면 S300과 같다.If this process is explained in a flow chart, it is the same as S300.

S310 단계에서, 24, 29, 34번 라인버퍼를 액세스하여 컨볼루션 연산을 수행한 결과를 35번 라인버퍼에 저장한다.In step S310, the results of performing the convolution operation by accessing the line buffers 24, 29, and 34 are stored in the line buffer 35.

그러면, 24번 라인은 더 이상 컨볼루션 연산에 필요하지 않으므로, 24번 라인버퍼를 36번 라인버퍼로 할당하거나 재사용할 수 있다(S320).Then, line 24 is no longer required for the convolution operation, so line 24 buffer can be allocated or reused as line 36 buffer (S320).

그리고, 35번 라인버퍼에 저장된 값을 외부 저장부로 전송하고, 35번 라인버퍼를 37번 라인버퍼로 할당하거나 재사용할 수 있다(S330).Then, the value stored in the line 35 buffer can be transferred to an external storage, and the line 35 buffer can be assigned to the line buffer 37 or reused (S330).

첫번재 그룹의 컨볼루션 연산이 완료된 후, 외부 저장부에서 특징맵을 라인단위로 읽어들여 두번째 그룹의 컨볼루션 연산을 수행할 수 있다 (S340).After the convolution operation of the first group is completed, the feature map can be read in line units from the external storage unit to perform the convolution operation of the second group (S340).

이상과 같이, 사용할 수 있는 메모리에 제약이 있는 경우에는, 컨볼루션 층을 복수개의 그룹으로 구분하여 각 그룹 단위로 대각선 순회 방식으로 라인 단위 컨볼루션 연산을 수행하고, 그룹 단위 결과를 외부 저장부에 저장하고, 다음 그룹의 연산을 위해 저장되어 있던 특징맵을 읽어와서 연산을 수행할 수 있다.As described above, when the available memory is limited, the convolution layer is divided into a plurality of groups, and line-by-line convolution operation is performed in a diagonal traversal method for each group, and the group unit results are stored in the external storage. Save and read the feature map stored for the next group of operations to perform the operation.

도 14는 위노그라드(Winograd) 알고리즘을 본 발명의 또 다른 바람직한 일 실시예로 적용한 도면이다.14 is a diagram of applying the Winograd algorithm to another preferred embodiment of the present invention.

위노드라드 알고리즘은, 종래의 컨볼루션 연산에 사용되는 가중합 연산의 곱셈 수가 많다는 문제를 해결하기 위해, 행렬변환을 통해 컨볼루션 연산에 필요한 곱셈결과를 인접 특징맵과 공유함으로써 필요한 곱셈기의 갯수를 줄이는 알고리즘이다.In order to solve the problem that the number of multiplications of the weighted sum operation used in the conventional convolution operation is large, the Winodard algorithm shares the multiplication result necessary for the convolution operation with a neighboring feature map through matrix transformation, thereby increasing the number of multipliers required. It is a reduction algorithm.

위노그라드 알고리즘에 의하면, 타일(tile)의 크기에 따라 특징맵의 상하 두개 또는 그 이상의 라인을 한번에 액세스하여 연산하게 된다.According to the Winograd algorithm, two or more lines of the top and bottom of the feature map are accessed and calculated at one time according to the size of a tile.

따라서, 위노그라드 알고리즘을 본 발명에 따른 대각선 순회 방식에 적용한 것이 도 14에 도시되어 있다.Accordingly, it is illustrated in FIG. 14 that the Winograd algorithm is applied to the diagonal traversal method according to the present invention.

도 14를 참조하면, 각 특징맵의 상하 두개의 라인이 같은 번호의 라인버퍼에 저장되어 도시되어 있다. 예를 들어, 1번 특징맵의 첫번째와 두번째 라인이 1번 라인버퍼에 같이 저장되어 있는 것이다. 마찬가지로, 1번 특징맵의 세번?와 네번째 라인이 2번 라인버퍼에 함께 저장되어 있다. 이렇게 하여 라인버퍼 단위로 전술한 대각선 순회 방식의 컨볼루션 연산을 수행하면 위노그라드 연산을 적용할 수 있게 수행되는 것이다.Referring to FIG. 14, two upper and lower lines of each feature map are stored and stored in the line buffer of the same number. For example, the first and second lines of the feature map # 1 are stored together in the line buffer # 1. Likewise, the third and fourth lines of the feature map # 1 are stored together in the line # 2 buffer. In this way, if the above-described diagonal traversal convolution operation is performed in a line buffer unit, it is performed to apply the Winograd operation.

위노그라드 연산은 종래의 컨볼루션 연산을 곱셈수를 줄이는 일종의 연산기이므로, 본 발명에 따른 라인 단위 메모리 관리에 의한 라인 단위 연산을 수행하는 기술 사상을 그대로 적용할 수 있고, 다만 컨볼루션 연산을 수행하는 연산기만 달라지는 것이다.Since the Winograd operation is a kind of operator that reduces the number of multiplications by the conventional convolution operation, the technical idea of performing the line unit operation by the line unit memory management according to the present invention can be applied as it is, but the convolution operation is performed. Only the calculator is different.

또한, 이외에도, 특징맵을 블록 단위로 나누어 컨볼루션 연산을 수행하는 알고리즘들도 소개가 되고 있지만 종래의 컨볼루션 연산을 근사치로 수행하는 손실 있는(lossy) 알고리즘인데 반하여, 본 발명은 종래의 컨볼루션 연산을 손실 없이(lossless) 수행하면서도 메모리를 효율적으로 재사용할 수 있다.In addition, algorithms for performing convolution operations by dividing the feature map into block units are also introduced, while the conventional invention is a lossy algorithm for performing convolution operations as an approximation. Memory can be efficiently reused while performing operations without loss.

도 15는 본 발명의 일 실시예에 따른 추론 장치(10)를 나타내는 블록도이다.15 is a block diagram showing an inference device 10 according to an embodiment of the present invention.

도 15를 참조하면, 본 발명에 따른 추론 장치(10)는 메모리(11), 메모리 관리부(13) 및 연산부(15)를 포함할 수 있다.Referring to FIG. 15, the inference device 10 according to the present invention may include a memory 11, a memory management unit 13 and a calculation unit 15.

장치(10)는 입력 특징맵으로부터 컨볼루션 연산을 수행하여 출력 특징맵을 생성하는 적어도 하나의 컨볼루션 층을 포함하는 컨볼루션 신경망 추론 장치일 수 있다.The device 10 may be a convolutional neural network inference device including at least one convolutional layer that performs an convolution operation from an input feature map to generate an output feature map.

메모리(11)는 적어도 하나의 입력 특징맵과 적어도 하나의 출력 특징맵을 가로 또는 세로의 라인 단위로 저장할 수 있고, 적어도 하나의 라인을 저장할 수 있는 메모리 영역이 할당된 적어도 하나의 라인버퍼를 포함할 수 있다.The memory 11 may store at least one input feature map and at least one output feature map in horizontal or vertical line units, and include at least one line buffer allocated with a memory area capable of storing at least one line. can do.

메모리(11)는 하나의 메모리일 수도 있고, 여러 개의 메모리가 통합해서 관리되는 메모리일 수도 있다.The memory 11 may be a single memory or a memory in which multiple memories are integrated and managed.

메모리 관리부(13)는 각 라인버퍼에 메모리(11)의 소정의 영역을 할당할 수 있다. 상세한 라인버퍼의 관리에 대하여는 상세히 전술하였으므로 생략하기로 한다.The memory management unit 13 may allocate a predetermined area of the memory 11 to each line buffer. The detailed management of the line buffer will be omitted since it has been described in detail above.

또한, 장치(10)는 외부 저장부(40)를 더 포함하여 구성될 수도 있는데, 컨볼루션 층을 적어도 하나의 그룹으로 구분하여 그룹 단위로 컨볼루션 연산을 라인 단위로 수행하여 외부 저장부(40)에 그 결과를 저장하고, 저장한 결과를 다음 그룹의 컨볼루션 연산을 위한 입력으로 사용할 수 있다.In addition, the device 10 may further include an external storage unit 40. The convolutional layer is divided into at least one group, and convolution operations are performed in groups on a line-by-line basis to perform external storage. ), And the saved result can be used as input for convolution operation of the next group.

외부 저장부(40)는 온칩의 다른 메모리일 수도 있고, DDR 등의 오프칩 메모리일 수도 있고, HDD 등 소정의 저장장치일 수도 있으나 이에 한정되는 것은 아니다.The external storage unit 40 may be on-chip other memory, off-chip memory such as DDR, or may be a predetermined storage device such as an HDD, but is not limited thereto.

이상과 같이, 본 실시예들에 의하면, 각 컨볼루션 층의 입출력 특징맵을 가로 또는 세로 라인 단위로 메모리에 저장하는 라인버퍼를 사용하고, 입력 특징맵으로부터의 모든 컨볼루션 연산이 완료되기 전이라 하더라도 더 이상 사용되지 않게 된 라인버퍼는 다른 라인을 저장하거나 다른 용도로 재사용하도록 하여 입출력 특징맵을 모두 메모리에 저장하고 있을 필요가 없도록 함으로써, 종래의 기술이 입출력 특징맵을 모두 저장하는 것에 비하여 컨볼루션 연산에 요구되는 메모리의 양을 감소시킬 수 있다.As described above, according to the present exemplary embodiments, a line buffer for storing input / output feature maps of each convolutional layer in memory in horizontal or vertical line units is used, and before all convolution operations from the input feature map are completed. Even if the line buffer is no longer used, it is not necessary to store all of the input / output feature maps in memory by storing other lines or reusing them for other purposes, so that the conventional technology convolutes compared to storing all input / output feature maps. It is possible to reduce the amount of memory required for the computation of a solution.

또한, 컨볼루션 층의 개수와 특징맵의 라인 개수에 따라 컨볼루션 연산 순서에 순차적 순회 방식 또는 대각선 순회 방식을 적용하는 방법을 선택하여 사용할 수 있도록 제공함으로써, 컨볼루션 연산에 요구되는 메모리의 양을 더욱 감소시킬 수 있다.In addition, by providing a method of selecting and applying a sequential traversal method or a diagonal traversal method to the convolution operation order according to the number of convolution layers and the number of lines in the feature map, the amount of memory required for the convolution operation is provided. It can be further reduced.

또한, 이상에서 설명된 컨볼루션 연산을 수행하기 위한 라인 단위 메모리 관리 방법의 실시예는 다양한 컴퓨터 구성요소들을 통하여 수행될 수 있는 컴퓨터 프로그램 명령어의 형태로 구현될 수 있다. 또한, 상기 구현된 컴퓨터 프로그램은 컴퓨터 판독 가능한 기록 매체에 기록될 수도 있다. 언급된 기록 매체는 ROM, 자기 디스크 혹은 콤팩트 디스크, 광 디스크 등 일 수 있으나, 이에 반드시 한정되지는 않는다.Further, an embodiment of a line-level memory management method for performing the convolution operation described above may be implemented in the form of computer program instructions that can be performed through various computer components. Further, the implemented computer program may be recorded on a computer-readable recording medium. The recording medium mentioned may be a ROM, magnetic disk or compact disk, optical disk, etc., but is not limited thereto.

이상에서와 같이, 본 발명은 도면에 도시된 실시예를 참고로 설명되었으나 이는 예시적인 것에 불과하며, 본 기술 분야의 통상의 지식을 가진 자라면 이로부터 다양한 변형 및 균등한 다른 실시예가 가능하다는 점을 이해할 것이다. 따라서, 본 발명의 진정한 기술적 보호 범위는 첨부된 특허청구범위의 기술적 사상에 의하여 정해져야 할 것이다.As described above, the present invention has been described with reference to the embodiment shown in the drawings, but this is merely exemplary, and various modifications and equivalent other embodiments are possible therefrom by those of ordinary skill in the art. Will understand Therefore, the true technical protection scope of the present invention should be determined by the technical spirit of the appended claims.

1: 입력 특징맵
3: 출력 특징맵
10: 추론 장치
11: 메모리
13: 메모리 관리부
15: 연산부
20: 특징맵
21, 22, 23, 24: 라인버퍼 또는 특징맵의 라인
40: 외부 저장부
1: Input feature map
3: Output feature map
10: reasoning device
11: Memory
13: Memory management
15: operation section
20: Feature map
21, 22, 23, 24: Line buffer or line of feature map
40: external storage

Claims (27)

적어도 하나의 컨볼루션 층(convolutional layer)을 포함하는 컨볼루션 신경망(convolutional neural network) 추론(inference) 장치에서 컨볼루션 연산(convolution operation)을 수행하기 위한 라인 단위 메모리 관리 방법으로서,
제1라인버퍼를 포함하는 적어도 하나의 라인버퍼를 액세스하여 라인 단위의 컨볼루션 연산을 수행한 결과를 제2라인버퍼에 저장하는 단계; 및
상기 제1라인버퍼가 더 이상 컨볼루션 연산에 사용되지 않게 되면 상기 제1라인버퍼를 재사용하는 단계;
를 포함하고,
상기 각 컨볼루션 층은 입력 특징맵(feature map)으로부터 컨볼루션 연산을 수행하여 출력 특징맵을 생성하고,
상기 제1라인버퍼는 상기 입력 특징맵의 적어도 한 라인을 저장하고 있고,
상기 제2라인버퍼는 상기 출력 특징맵의 적어도 한 라인을 저장하고,
상기 제1라인버퍼 및 제2라인버퍼는 각각 소정의 메모리 영역영역이고,
상기 컨볼루션 연산을, 입력 특징맵의 라인 단위로 수행하되 순차적 순회 방식으로 수행하거나, 적어도 하나의 특징맵의 라인 단위로 수행하되 대각선 순회 방식으로 수행하고,
상기 순차적 순회 방식 또는 대각선 순회 방식 중에서 최소로 필요한 라인버퍼의 크기가 작은 쪽의 방식을 선택하되, 상기 최소로 필요한 라인버퍼의 크기는 상기 컨볼루션 층의 개수와 상기 라인 개수에 기초하여 계산되는 것인, 방법.
A line-by-line memory management method for performing a convolution operation in a convolutional neural network inference device including at least one convolutional layer,
Accessing at least one line buffer including the first line buffer and storing a result of performing a line-wise convolution operation in a second line buffer; And
Reusing the first line buffer when the first line buffer is no longer used in the convolution operation;
Including,
Each convolution layer performs a convolution operation from an input feature map to generate an output feature map,
The first line buffer stores at least one line of the input feature map,
The second line buffer stores at least one line of the output feature map,
Each of the first line buffer and the second line buffer is a predetermined memory area area,
The convolution operation is performed in line units of the input feature map, but in a sequential traversal method, or in line units of at least one feature map, but in a diagonal traversal method,
The method of the least required line buffer size among the sequential traversal method or the diagonal traversal method is selected, but the minimum required line buffer size is calculated based on the number of convolutional layers and the number of lines. Phosphorus, how.
제1항에 있어서,
상기 입력 특징맵은 추론할 입력 데이터 또는 전단계 컨볼루션 층의 출력 특징맵이고, 라인 단위로 적어도 하나의 라인버퍼에 저장되는 것을 특징으로 하는, 방법.
According to claim 1,
The input feature map is an input feature to be inferred or an output feature map of the previous convolutional layer, characterized in that it is stored in at least one line buffer in line units.
제1항에 있어서,
상기 생성된 출력 특징맵은 추론된 출력 데이터로 사용되거나 다음 단계 컨볼루션 층의 입력 특징맵으로 사용되고, 라인 단위로 적어도 하나의 라인버퍼에 저장되는 것을 특징으로 하는, 방법.
According to claim 1,
The generated output feature map is used as inferred output data or is used as an input feature map of the next step convolution layer, characterized in that it is stored in at least one line buffer in line units.
제1항에 있어서,
상기 제1라인버퍼 및 제2라인버퍼는 컨볼루션 층의 특성에 따라 가변적인 크기를 가지는 것을 특징으로 하는, 방법.
According to claim 1,
The method of claim 1, wherein the first line buffer and the second line buffer have a variable size according to the characteristics of the convolution layer.
제1항에 있어서,
상기 컨볼루션 층이 소정의 활성 함수(activation function), 배치정규화 함수(batch normalization function) 또는 1x1 컨볼루션 연산을 더 포함하는 경우에는, 상기 컨볼루션 연산 결과를 상기 제2라인버퍼에 저장할 때 상기 활성 함수, 배치정규화 함수 또는 1x1 컨볼루션 연산을 온더플라이(on-the-fly)로 수행하여 저장하는 것을 특징으로 하는, 방법.
According to claim 1,
When the convolution layer further includes a predetermined activation function, a batch normalization function, or a 1x1 convolution operation, when the convolution operation result is stored in the second line buffer, the activity is activated. A method, characterized in that a function, a batch normalization function, or a 1x1 convolution operation is performed on-the-fly and stored.
제1항에 있어서,
상기 라인은 가로 또는 세로 방향 라인인 것을 특징으로 하는, 방법.
According to claim 1,
The method, characterized in that the line is a horizontal or vertical line.
삭제delete 삭제delete 제1항에 있어서,
상기 제2라인버퍼로부터 다음 단계 컨볼루션 층의 컨볼루션 연산이 가능한 경우에는 상기 입력 특징맵의 컨볼루션 연산보다 상기 다음 단계 컨볼루션 층의 컨볼루션 연산을 먼저 수행하여 제3라인버퍼에 저장하는 단계를 더 포함하고,
상기 제3라인버퍼는 소정의 메모리 영역인 것을 특징으로 하는, 방법.
According to claim 1,
When the convolution operation of the next-level convolution layer is possible from the second line buffer, performing the convolution operation of the next-level convolution layer before the convolution operation of the input feature map and storing it in the third line buffer. Further comprising,
The third line buffer is characterized in that the predetermined memory area.
제1항에 있어서,
상기 제1라인버퍼를 재사용하는 단계는 상기 입력 특징맵으로부터의 모든 컨볼루션 연산이 완료되기 전이라 하더라도 상기 제1라인버퍼가 더 이상 사용되지 않게 되면 상기 제1라인버퍼를 다른 라인을 저장하거나 다른 용도로 사용하는 것을 특징으로 하는, 방법.
According to claim 1,
The step of reusing the first line buffer stores the first line buffer or another line when the first line buffer is no longer used, even before all convolution operations from the input feature map are completed. A method characterized by being used for a purpose.
제1항에 있어서,
위노그라드 알고리즘(Winograd's Algorithm)을 사용하는 경우에는 타일(tile)의 크기에 따라 상기 입력 특징맵을 복수개의 라인 단위로 적어도 하나의 라인버퍼에 저장하는 것을 특징으로 하는, 방법.
According to claim 1,
When using the Winograd's Algorithm, the method characterized in that the input feature map is stored in at least one line buffer in units of a plurality of lines according to the size of a tile.
제1항에 있어서,
상기 컨볼루션 층을 적어도 하나의 그룹으로 구분하여 그룹 단위로 컨볼루션 연산을 수행하는 것을 특징으로 하는, 방법.
According to claim 1,
A method comprising dividing the convolution layer into at least one group and performing a convolution operation on a group basis.
제12항에 있어서,
상기 그룹 단위의 연산 수행이 라인 단위로 완료되면 라인 단위로 외부 저장부에 저장하는 단계; 및
상기 저장한 결과를 다음 그룹의 컨볼루션 연산을 위한 입력으로 사용하는 단계를 더 포함하는 것을 특징으로 하는, 방법.
The method of claim 12,
Storing the group unit in an external storage unit on a line-by-line basis when the group-wise operation is completed; And
And using the stored result as an input for the next group of convolution operations.
청구항 제1항 내지 청구항 제6항 및 청구항 제9항 내지 청구항 제13항 중의 어느 한 항에 따른 방법을 실행시키기 위한, 컴퓨터-판독가능한 기록매체에 저장된 프로그램.
A program stored on a computer-readable recording medium for executing the method according to any one of claims 1 to 6 and 9 to 13.
청구항 제1항 내지 청구항 제6항 및 청구항 제9항 내지 청구항 제13항 중의 어느 한 항에 따른 방법을 실행시키기 위한 프로그램이 기록된, 컴퓨터-판독가능한 기록매체.
A computer-readable recording medium in which a program for executing a method according to any one of claims 1 to 6 and 9 to 13 is recorded.
입력 특징맵으로부터 컨볼루션 연산을 수행하여 출력 특징맵을 생성하는 컨볼루션 층을 적어도 하나 포함하는 컨볼루션 신경망 추론 장치로서,
상기 적어도 하나의 입력 특징맵과 적어도 하나의 출력 특징맵을 가로 또는 세로의 라인 단위로 저장하되 적어도 하나의 라인을 저장할 수 있는 영역이 할당된 적어도 하나의 라인버퍼를 포함하는 메모리;
제1라인버퍼 및 제2라인버퍼에 각각 상기 메모리의 소정의 영역을 할당하고, 상기 제1라인버퍼는 상기 입력 특징맵의 적어도 한 라인을 저장하고, 상기 제2라인버퍼는 상기 출력 특징맵의 적어도 한 라인을 저장하고, 상기 제1라인버퍼가 더 이상 컨볼루션 연산에 사용되지 않게 되면 상기 제1라인버퍼를 재사용하도록 메모리를 관리하는 메모리 관리부; 및
상기 제1라인버퍼를 포함하는 적어도 하나의 라인버퍼를 액세스하여 라인 단위의 컨볼루션 연산을 수행하고 그 결과를 상기 제2라인버퍼에 저장하는 연산부;
를 포함하고,
상기 메모리 관리부는, 상기 컨볼루션 연산이 입력 특징맵의 라인 단위로 수행되되 순차적 순회 방식으로 수행되거나 적어도 하나의 특징맵의 라인 단위로 수행되되 대각선 순회 방식으로 수행되도록 상기 메모리의 소정의 영역을 적어도 하나의 라인버퍼로 할당하고,
상기 순차적 순회 방식 또는 대각선 순회 방식 중에서 최소로 필요한 라인버퍼의 크기가 작은 쪽의 방식을 선택하되, 상기 최소로 필요한 라인버퍼의 크기는 상기 컨볼루션 층의 개수와 상기 라인 개수에 기초하여 계산되는 것을 특징으로 하는, 장치.
A convolutional neural network inference device including at least one convolutional layer that performs a convolution operation from an input feature map to generate an output feature map,
A memory including at least one line buffer in which the at least one input feature map and at least one output feature map are stored in units of horizontal or vertical lines, but an area capable of storing at least one line is allocated;
Each of the first line buffer and the second line buffer is assigned a predetermined area of the memory, the first line buffer stores at least one line of the input feature map, and the second line buffer of the output feature map A memory management unit that stores at least one line and manages a memory to reuse the first line buffer when the first line buffer is no longer used for convolution; And
An operation unit accessing at least one line buffer including the first line buffer to perform convolution operation on a line-by-line basis and to store the result in the second line buffer;
Including,
The memory management unit may perform at least a predetermined area of the memory such that the convolution operation is performed in line units of the input feature map, but is performed in a sequential traversal manner or in line units of at least one feature map, but in a diagonal traversal scheme. Assigned to one line buffer,
Select the one of the least necessary line buffer size among the sequential traversing method or diagonal traversing method, but the size of the minimum required line buffer is calculated based on the number of convolutional layers and the number of lines. Features, device.
제16항에 있어서,
상기 입력 특징맵은 추론할 입력 데이터 또는 전단계 컨볼루션 층의 출력 특징맵이고, 라인 단위로 적어도 하나의 라인버퍼에 저장되는 것을 특징으로 하는, 장치.
The method of claim 16,
The input feature map is input data to be inferred or an output feature map of the previous-level convolution layer, characterized in that it is stored in at least one line buffer in line units.
제16항에 있어서,
상기 생성된 출력 특징맵은 추론된 출력 데이터로 사용되거나 다음 단계 컨볼루션 층의 입력 특징맵으로 사용되고, 라인 단위로 적어도 하나의 라인버퍼에 저장되는 것을 특징으로 하는, 장치.
The method of claim 16,
The generated output feature map is used as inferred output data or is used as an input feature map of the next step convolution layer, characterized in that stored in at least one line buffer in line units.
제16항에 있어서,
상기 연산부는, 상기 컨볼루션 층이 소정의 활성 함수, 배치정규화 함수 또는 1x1 컨볼루션 연산을 더 포함하는 경우에는 상기 컨볼루션 연산 결과를, 상기 제2라인버퍼에 저장할 때 상기 활성 함수, 배치정규화 함수 또는 1x1 컨볼루션 연산을 온더플라이로 수행하여 저장하는 것을 특징으로 하는, 장치.
The method of claim 16,
When the convolution layer further includes a predetermined active function, a batch normalization function, or a 1x1 convolution operation, the operation unit stores the result of the convolution operation in the second line buffer, the active function, and a batch normalization function. Or 1x1 convolution operation performed on-the-fly and stored.
제16항에 있어서,
상기 메모리 관리부는 상기 컨볼루션 층의 특성에 따라 상기 제1라인버퍼 및 제2라인버퍼에 가변적인 크기로 상기 메모리의 영역을 할당하는 것을 특징으로 하는, 장치.
The method of claim 16,
The memory management unit allocates an area of the memory in a variable size to the first line buffer and the second line buffer according to the characteristics of the convolution layer.
삭제delete 삭제delete 제16항에 있어서,
상기 메모리 관리부는, 상기 제2라인버퍼로부터 다음 단계 컨볼루션 층의 컨볼루션 연산이 가능한 경우에는 상기 입력 특징맵의 컨볼루션 연산보다 상기 다음 단계 컨볼루션 층의 컨볼루션 연산을 먼저 수행하여 제3라인버퍼에 저장하도록 상기 제3라인버퍼에 상기 메모리의 소정의 영역을 할당하는 것을 특징으로 하는, 장치.
The method of claim 16,
When the convolution operation of the next-level convolution layer is possible from the second line buffer, the memory management unit first performs convolution operation of the next-level convolution layer before the convolution operation of the input feature map. And a predetermined area of the memory is allocated to the third line buffer to be stored in a buffer.
제16항에 있어서,
상기 메모리 관리부는, 상기 입력 특징맵으로부터의 모든 컨볼루션 연산이 완료되기 전이라 하더라도 상기 제1라인버퍼가 더 이상 사용되지 않게 되면 상기 제1라인버퍼를 다른 라인을 저장하거나 다른 용도로 사용하는 것을 특징으로 하는, 장치.
The method of claim 16,
The memory management unit may store the first line buffer for another line or use it for another purpose even if the first line buffer is no longer used even before all convolution operations from the input feature map are completed. Features, device.
제16항에 있어서,
상기 메모리 관리부는, 위노그라드 알고리즘을 사용하는 경우에는 타일의 크기에 따라 상기 입력 특징맵을 복수개의 라인 단위로 적어도 하나의 라인버퍼에 저장하도록 상기 메모리의 영역을 할당하는 것을 특징으로 하는, 장치.
The method of claim 16,
The memory management unit allocates an area of the memory to store the input feature map in at least one line buffer in units of a plurality of lines according to the size of a tile when using the Winograd algorithm.
제16항에 있어서,
상기 메모리 관리부는, 상기 컨볼루션 층을 적어도 하나의 그룹으로 구분하여 그룹 단위로 컨볼루션 연산을 수행할 수 있도록 라인버퍼를 관리하는 것을 특징으로 하는, 장치.
The method of claim 16,
And the memory management unit divides the convolution layer into at least one group and manages a line buffer to perform convolution operations in group units.
제26항에 있어서,
상기 메모리 관리부는, 상기 그룹 단위의 연산 수행이 라인 단위로 완료되면 라인 단위로 외부 저장부에 저장하고, 상기 저장한 결과를 다음 그룹의 컨볼루션 연산을 위한 입력으로 사용하는 것을 특징으로 하는, 장치.

The method of claim 26,
The memory management unit, characterized in that when the group-wise operation is completed in line units, stores in the external storage unit in line units, and uses the stored result as an input for the next group of convolution operations .

KR1020180143805A 2018-11-20 2018-11-20 Line-based memory management method for performing convolution operation in convolutional neural network inference and its inference device KR102107077B1 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
KR1020180143805A KR102107077B1 (en) 2018-11-20 2018-11-20 Line-based memory management method for performing convolution operation in convolutional neural network inference and its inference device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
KR1020180143805A KR102107077B1 (en) 2018-11-20 2018-11-20 Line-based memory management method for performing convolution operation in convolutional neural network inference and its inference device

Publications (1)

Publication Number Publication Date
KR102107077B1 true KR102107077B1 (en) 2020-05-06

Family

ID=70737467

Family Applications (1)

Application Number Title Priority Date Filing Date
KR1020180143805A KR102107077B1 (en) 2018-11-20 2018-11-20 Line-based memory management method for performing convolution operation in convolutional neural network inference and its inference device

Country Status (1)

Country Link
KR (1) KR102107077B1 (en)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111753974A (en) * 2020-06-22 2020-10-09 深圳鲲云信息科技有限公司 Neural network accelerator
CN111898081A (en) * 2020-07-09 2020-11-06 上海兆芯集成电路有限公司 Convolution operation method and convolution operation device
CN112862074A (en) * 2021-02-07 2021-05-28 Oppo广东移动通信有限公司 Model operation method and device, electronic equipment and storage medium
US11409675B2 (en) 2020-12-22 2022-08-09 Samsung Electronics Co., Ltd. Data transmission method for convolution operation, fetcher, and convolution operation apparatus

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR20110048794A (en) * 2009-11-03 2011-05-12 삼성전자주식회사 Image processor and electric device including the same
KR101788829B1 (en) 2015-08-24 2017-10-20 (주)뉴로컴즈 Convolutional neural network computing apparatus
KR20180062911A (en) 2016-12-01 2018-06-11 비아 얼라이언스 세미컨덕터 씨오., 엘티디. Neural Network Unit That Performs Efficient 3-Dimensional Convolutions
US20180189229A1 (en) * 2017-01-04 2018-07-05 Stmicroelectronics S.R.L. Deep convolutional network heterogeneous architecture
WO2018194849A1 (en) * 2017-04-17 2018-10-25 Microsoft Technology Licensing, Llc Minimizing memory reads and increasing performance by leveraging aligned blob data in a processing unit of a neural network environment

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR20110048794A (en) * 2009-11-03 2011-05-12 삼성전자주식회사 Image processor and electric device including the same
KR101788829B1 (en) 2015-08-24 2017-10-20 (주)뉴로컴즈 Convolutional neural network computing apparatus
KR20180062911A (en) 2016-12-01 2018-06-11 비아 얼라이언스 세미컨덕터 씨오., 엘티디. Neural Network Unit That Performs Efficient 3-Dimensional Convolutions
US20180189229A1 (en) * 2017-01-04 2018-07-05 Stmicroelectronics S.R.L. Deep convolutional network heterogeneous architecture
WO2018194849A1 (en) * 2017-04-17 2018-10-25 Microsoft Technology Licensing, Llc Minimizing memory reads and increasing performance by leveraging aligned blob data in a processing unit of a neural network environment

Non-Patent Citations (5)

* Cited by examiner, † Cited by third party
Title
"vImage Programming Guide,"Apple Inc., Cupertino, CA, USA, 2016.
Andrew Lavin, et al., "Fast Algorithms for Convolutional Neural Networks", The IEEE Conference on Computer Vision and Pattern Recognition (CVPR), 2016, pp. 4013-4021.
JINCHENG YU 등, ‘Instruction Driven Cross-layer CNN Accelerator For Fast Detection on FPGA’, ACM Tran. on Reconfig. Tech. and Sys., Vol. 9, No. 4, 2017.12. 1부.* *
Tianqi Chen, et al., "MXNet: A flexible and efficient machine learning library for heterogeneous distributed systems,"In Neural Information Processing Systems, Workshop on Machine Learning Systems (LearningSys'15), 2015.
Vivienne Sze, et al., "Efficient Processing of Deep Neural Networks: A Tutorial and Survey", Proceedings of the IEEE, Vol. 105, No. 12, December 2017.

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111753974A (en) * 2020-06-22 2020-10-09 深圳鲲云信息科技有限公司 Neural network accelerator
CN111898081A (en) * 2020-07-09 2020-11-06 上海兆芯集成电路有限公司 Convolution operation method and convolution operation device
CN111898081B (en) * 2020-07-09 2024-02-27 上海兆芯集成电路股份有限公司 Convolution operation method and convolution operation device
US11409675B2 (en) 2020-12-22 2022-08-09 Samsung Electronics Co., Ltd. Data transmission method for convolution operation, fetcher, and convolution operation apparatus
US11797461B2 (en) 2020-12-22 2023-10-24 Samsung Electronics Co., Ltd. Data transmission method for convolution operation, fetcher, and convolution operation apparatus
CN112862074A (en) * 2021-02-07 2021-05-28 Oppo广东移动通信有限公司 Model operation method and device, electronic equipment and storage medium

Similar Documents

Publication Publication Date Title
KR102107077B1 (en) Line-based memory management method for performing convolution operation in convolutional neural network inference and its inference device
US20190220742A1 (en) Neural network engine with tile-based execution
US20180137414A1 (en) Convolution operation device and convolution operation method
KR20200067632A (en) Method and apparatus for allocating memory space for driving a neural network
WO2021012215A1 (en) Neural network segmentation method, prediction method and related device
US7554874B2 (en) Method and apparatus for mapping memory
US20060204046A1 (en) Method and apparatus for motion estimation in video signal decoding
US11467968B2 (en) Memory-adaptive processing method for convolutional neural network
WO2019084788A1 (en) Computation apparatus, circuit and relevant method for neural network
KR20180052069A (en) Convolution neural network system and method for compressing synapse data of convolution neural network
CN116010299A (en) Data processing method, device, equipment and readable storage medium
US20220012587A1 (en) Convolution operation method and convolution operation device
CN114282661A (en) Method for operating neural network model, readable medium and electronic device
CN111898081B (en) Convolution operation method and convolution operation device
US20210103793A1 (en) Block-based inference method for memory-efficient convolutional neural network implementation and system thereof
US8937624B2 (en) Method and apparatus for translating memory access address
JP2020191012A (en) Image processing apparatus, imaging apparatus, and image processing method
Wang et al. An implementation method of the box filter on FPGA
JP2018055570A (en) Arithmetic processing apparatus, arithmetic processing method, and program
KR102516833B1 (en) Memory apparatus and method for processing data the same
KR20210143440A (en) Method for optimizing hardware structure of convolutional neural networks
JP5113174B2 (en) Method and apparatus for simultaneously generating multi-site FM screen dots
CN111199268B (en) Implementation method and device of full connection layer, electronic equipment and computer readable storage medium
US20050169541A1 (en) Image signal processing apparatus and image signal processing method
JP3011344B2 (en) Image processing device

Legal Events

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