WO2020177250A1 - 一种数据读取系统和方法 - Google Patents

一种数据读取系统和方法 Download PDF

Info

Publication number
WO2020177250A1
WO2020177250A1 PCT/CN2019/093539 CN2019093539W WO2020177250A1 WO 2020177250 A1 WO2020177250 A1 WO 2020177250A1 CN 2019093539 W CN2019093539 W CN 2019093539W WO 2020177250 A1 WO2020177250 A1 WO 2020177250A1
Authority
WO
WIPO (PCT)
Prior art keywords
data
image
unit
image block
convolution
Prior art date
Application number
PCT/CN2019/093539
Other languages
English (en)
French (fr)
Inventor
刘明润
Original Assignee
上海熠知电子科技有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 上海熠知电子科技有限公司 filed Critical 上海熠知电子科技有限公司
Publication of WO2020177250A1 publication Critical patent/WO2020177250A1/zh

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F15/00Digital computers in general; Data processing equipment in general
    • G06F15/76Architectures of general purpose stored program computers
    • G06F15/78Architectures of general purpose stored program computers comprising a single central processing unit
    • G06F15/7807System on chip, i.e. computer system on a single chip; System in package, i.e. computer system on one or more chips in a single package
    • G06F15/781On-chip cache; Off-chip memory
    • 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
    • G06N3/045Combinations of networks
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T1/00General purpose image data processing
    • G06T1/60Memory management

Definitions

  • the invention relates to the field of computers, and in particular to a data reading system and method for image processing convolutional neural networks with low cache occupation.
  • CNN Convolutional Neural Network
  • Convolutional neural networks generally consist of multiple alternating convolutional layers, pooling layers and finally fully connected layers.
  • Convolutional neural networks can pass the network loss to all layers of the network through the back propagation method.
  • the parameter update learning process is realized by stochastic gradient descent algorithm.
  • the biggest difference between a convolutional neural network and a traditional neural network is that its convolutional layer uses a weight-sharing locally connected network instead of a traditional weight-independent fully connected network. This makes the volume The number of connections of the product neural network is far less than that of the traditional neural network.
  • the two-dimensional data structure of the convolutional layer makes the convolutional neural network very suitable for processing image data information.
  • the addition of the pooling layer makes the convolutional neural network have a certain degree of robustness to the geometric changes (translation, scaling, rotation, etc.) of the input data.
  • Convolutional neural networks surpass most traditional machine vision algorithms in performance due to their powerful data feature extraction capabilities and nonlinear learning capabilities. At present, convolutional neural networks have become the mainstream method in research and application fields such as image classification and target recognition.
  • the commonly used convolutional neural network has a huge amount of calculation, and generally adopts multiple multiply-accumulators (MAU) to run concurrently to reduce the calculation time of the network.
  • MAU multiply-accumulators
  • the convolution kernel of the convolutional neural network for image processing uses two-dimensional or even three-dimensional data structures, and directly reads these data pairs with discontinuous addresses from the system memory (for example, DDR)
  • system memory for example, DDR
  • the present invention proposes a data reading method, which greatly reduces the access to the system memory on the premise of meeting the MAU calculation requirements.
  • a data reading system including:
  • a configuration unit where the configuration unit receives parameter information calculated by convolution
  • a data reading unit wherein the data reading unit divides the image subjected to the convolution calculation so that the divided image block generates M times the data required for the convolution calculation each time, and the data reading unit divides the image by row Read in the segmented image block;
  • a data caching unit accesses the data read in by the data reading unit
  • Data expansion and output unit the data expansion and output unit reads out a line of image data stored in the data buffer unit, and then expands the line of data required for M convolution calculations to generate a total of M*K data, and The output terminal performs output.
  • the configuration unit determines the number of data segmentation for each row and the length of the last remaining data according to the parameter information calculated by the convolution, the bus bit width of the system and the characteristics of the memory.
  • the width of the segmented image block is between M and M+K-1.
  • the data reading unit reads the data of the next row to cover the data buffer The data of the first row of the unit number.
  • the data expansion and output unit reads the expanded data to the subsequent MAU at a speed of K times the bandwidth.
  • a data reading method including:
  • step F until the last line of the image is completed
  • the width of the segmented image block is between M and M+K-1.
  • the data reading method further includes: G) determining whether there are unprocessed image blocks, and if there are no unprocessed image blocks, the data reading operation ends;
  • Step D) If there is an unprocessed image block, take the unprocessed image block as the current image block, return to the first channel of the current image block, read in the first K rows of data of the current image block, store it in the data buffer unit, and repeat Step Step D) to Step G).
  • the number of consecutive convolution calculations M each time is determined according to parameters such as the convolution kernel size, image size, system bus bit width, and memory.
  • the disclosed system and method of the present invention can make full use of the low delay characteristic of the system for continuous address burst read operations. Improve the utilization of system bandwidth.
  • the disclosed system and method of the present invention adopt a method of segmenting an image, so that the size of the buffer space is a fixed value MxK, which reduces the size requirement of the system on the on-chip buffer.
  • Fig. 1 shows a schematic diagram of the relationship between the parameters of the convolutional network input data according to the present invention.
  • Fig. 2 shows a schematic block diagram of a data reading system 200 according to an embodiment of the present invention.
  • Fig. 3 shows a flowchart of a data reading method according to an embodiment of the present invention.
  • Fig. 4 shows a schematic diagram of the relationship between the parameters of the convolutional network input data according to an example of the present invention.
  • Fig. 5 shows a schematic structural diagram of a data expansion and output unit according to an embodiment of the present invention.
  • Fig. 6 shows a schematic diagram of the state of caching in step 304 according to an embodiment of the present invention.
  • FIG. 7 shows a schematic diagram of the state of the cache in step 305 according to an embodiment of the present invention.
  • Convolution calculation can be regarded as a process of weighted summation. Each pixel in the image area is multiplied by each element of the filter (ie, weight matrix). The sum of all products is used as the new value of the center pixel of the area. .
  • the filter is the weight used in convolution, expressed by a matrix, the matrix is the same size as the corresponding image area, and its rows and columns are odd numbers, which is a weight matrix.
  • Figure 1 shows a schematic diagram of various parameters of the convolutional network input data according to the present invention. Completing all calculations requires WxH convolution calculations (W convolutions per line, H lines in total). Here, in order to maintain the output image size unchanged, it is necessary to fill a circle with data with a width of 1 and a value of 0 around the input image. The amount of data required for each convolution is KxKxC.
  • the address of the input image data is generally continuously incremented along the row direction.
  • Each convolution calculation will undergo a large range of jumps in the data address when changing lines or changing channels. This is very unfriendly to commonly used system memory accesses (for example, DDR), and will cause longer read delays. Cause the overall performance of the system to decrease.
  • Fig. 2 shows a schematic block diagram of a data reading system 200 according to an embodiment of the present invention.
  • the data reading system of the image processing convolutional neural network with low cache occupancy includes a configuration unit 210, a data reading unit 220, a data caching unit 230, and a data expansion and output unit 240.
  • the configuration unit 210 receives the image and convolution kernel parameter information transmitted from the upper module. These parameter information may include the address of the image in the system storage space, the size of the image, the size of the convolution kernel, and so on.
  • the configuration unit determines the number of data segmentation for each row and the length of the last remaining data according to these parameters and the characteristics of the system, so that each segmented image block can generate data required for M convolution calculations.
  • the data reading unit 220 slices the image with a larger width, so that each sliced image block can generate data required for M convolution calculations.
  • the width of each segmented image block is between M and M+K-1, which is determined by the position of the segmented image block. Then, read in the segmented image by line. M can be changed according to the bus bit width of the system and the characteristics of the memory. The purpose is to make the data length of the continuous address read in each time can make full use of the burst read capability of the system memory and offset the read delay overhead caused by switching addresses .
  • the data read in by the data reading unit 220 will be temporarily stored in the data buffer unit 230 and used by the data expansion and output unit 240. Since longitudinally adjacent convolution kernels will have part of the data repeated, the data cache unit can reduce the occupation of this part of the data on the system bus.
  • the data expansion and output unit 240 expands the horizontal data into data required by the convolution kernel, and outputs it to the MAU for convolution calculation. Since the horizontally adjacent convolution kernels also have partial data repetition, the repetitiveness of the data can be used to increase the internal bandwidth, thereby increasing the throughput rate of the data to the MAU.
  • FIG. 3 shows a flowchart of a data reading method according to an embodiment of the present invention.
  • step 301 convolution calculation parameters are received.
  • the system processor CPU
  • the convolution calculation parameter information may include the address of the image in the system storage space, the size of the image, the size of the convolution kernel, and the step size.
  • the configuration unit determines the number of times of data segmentation for each row and the length of the last remaining data, so that each segmented image block can generate data required for M convolution calculations.
  • the width of each segmented image block is between M and M+K-1, which is determined by the position of the segmented image block.
  • M can be changed according to the bus bit width of the system and the characteristics of the memory.
  • the purpose is to make the data length of the continuous address read in each time can make full use of the burst read capability of the system memory and offset the read delay overhead caused by switching addresses .
  • the data reading unit performs image segmentation according to the determined segmented image block width, reads the first K rows of data of the segmented image block, and stores it in the data buffer unit. By segmenting the image and changing the order of data reading, it is no longer a simple read from the left to the right for a wider image.
  • the size of the data cache space is a fixed value MxK, which reduces the system's requirements for the size of the on-chip cache.
  • step 303 the data expansion and output unit reads the first row of image data stored in the buffer, and then expands the first row of data of all the first channels in the previous M convolution calculations to generate a total of M*K data .
  • the expanded data is sent to the subsequent MAU at a speed of K times the read bandwidth.
  • the expansion method is shown in Figure 5.
  • Fig. 5 shows a schematic structural diagram of a data expansion and output unit according to an embodiment of the present invention. These data can be sent to the subsequent MAU at 3 times the speed of the read-in bandwidth.
  • the structure diagram of the data expansion module is shown in Figure 5.
  • four data output interfaces are shown in FIG. 5, and those skilled in the art should realize that the number of data interfaces is not limited to four.
  • the number of data interfaces can generally be determined by the internal bandwidth. For example, when the system bandwidth is 128 bits and each data is 8 bits, the output interface is 16 groups, and each group is 3 data 24 bits wide.
  • step 304 step 303 is repeated to read and expand the data from the second row to the Kth row. So far, all KxK data of the first channel in the previous M convolution calculations have been generated.
  • step 305 the data reading unit reads in the data of the next row and overwrites the data of the first row in the buffer. For example, in this example, the data reading unit reads the data of the fourth row and overwrites the data of the first row of the first channel, as shown in FIG. 7.
  • step 306 the data expansion and output unit reads the updated K lines of data stored in the buffer and expands.
  • the expansion and output method is similar to steps 303 to 304.
  • the data expansion and output unit reads the second, third, and fourth rows of data stored in the buffer and expands them as the first channel data required for the first 128 convolution calculations of the second row.
  • step 306 step 306 is repeated until the last line of the image is completed.
  • step 308 for the remaining channels of the image, steps 302 to 307 are repeated to generate data on all channels required for convolution calculation.
  • step 309 it is determined whether there are still unprocessed image blocks. If there is no unprocessed image block, the data reading operation ends.
  • step 310 go back to the first line of the first channel and read the first K lines of data of the current image block into the data buffer unit.
  • An image block has several pixels overlapping. For example, in this example, because the 128th point is used in the 129th convolution calculation of the first row of the first channel, the data of the 128th point and the 129th point need to be read in repeatedly.
  • step 311 the data expansion and output unit reads the K lines of data stored in the buffer and expands it.
  • the expansion and output method is similar to steps 303 to 304.
  • the 128th to 224th points of each row of the first 3 rows are read from the data buffer unit and expanded to produce the first row required for the 129th to 224th convolution calculations. Channel data.
  • steps 305-307 are repeated for the remaining data rows of the current image block of the first channel. For example, in this example, repeat steps 305-307 for the 128th-224th points on the 4-224th row of channel 1, and obtain the data of channel 1 required for the 129th-224th convolution calculation in each row. Obtain the channel 1 data required for the 129th to 224th convolution calculations in each row.
  • steps 309-311 are repeated for the data of the remaining channels to obtain all the data required for the 129th to 224th convolution calculations in each row, and then return to step 309.
  • the above embodiment takes a 3*3 convolution kernel as an example.
  • the convolution kernel can also have other sizes, and those skilled in the art can use the convolution kernel size, image size, and system Parameters such as bus bit width and memory determine the number of consecutive convolution calculations and the image segmentation size.
  • the disclosed system and method of the present invention can make full use of the low delay characteristic of the system for continuous address burst read operations. Improve the utilization of system bandwidth.
  • the disclosed system and method of the present invention adopt a method of segmenting an image, so that the size of the buffer space is a fixed value MxK, which reduces the size requirement of the system on the on-chip buffer.

Landscapes

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

Abstract

本发明公开了一种数据读取系统,包括:配置单元,所述配置单元接收卷积计算的参数信息;数据读取单元,所述数据读取单元对进行卷积计算的图像进行切分,使得切分后的图像块每次产生M次卷积计算所需的数据,所述数据读取单元按行读入切分后图像块;数据缓存单元,所述数据缓存单元存取所述所述数据读取单元读入的数据;以及数据扩展及输出单元,所述数据扩展及输出单元读出数据缓存单元中存放的一行图像数据,然后扩展M次卷积计算所需的该行的数据,共产生M*K个数据,并在输出端进行输出。

Description

一种数据读取系统和方法 技术领域
本发明涉及计算机领域,尤其涉及一种低缓存占用的图像处理卷积神经网络的数据读取系统和方法。
背景技术
卷积神经网络(Convolutional Neural Network,CNN)是一种前馈神经网络,与传统的BP神经网络相比,具有识别效率高、旋转缩放不变性好等优点,已在数字图像处理及人脸识别等各个领域得到了广泛的应用。
传统卷积神经网络一般由多个交替的卷积层、池化层以及最后的全连接层组成。卷积神经网络可通过反向传播方法将网络损失传递到网络的所有层。参数更新学习过程通过随机梯度下降算法来实现。卷积神经网络与传统神经网络最大的区别在于,其卷积层采用了一种权值共享局部连接网络,而不是传统的权值独立全连接网络,这使得在层数相同的情况下,卷积神经网络的连接数目要远少于传统神经网络。卷积层的二维数据结构使得卷积神经网络非常适合于处理图像数据信息。此外,池化层的加入使得卷积神经网络对输入数据的几何变化(平移、缩放、旋转等)具有一定程度的稳健性。卷积神经网络由于其强大的数据特征提取能力和非线性学习能力,在性能上超越了大多数传统的机器视觉算法。目前在图像分类、目标识别等研究和应用领域,卷积神经网络已经成为主流方法。
目前常用的卷积神经网络由于计算量特别巨大,一般均采用多个乘累加器(MAU)并发运行的方式来降低网络的计算时间。而要为这些MAU同时提供计算所需的数据,对系统的总线带宽也提出了很大的挑战。
另一方面,用于图像处理的卷积神经网络的卷积核用到的均为二维甚至三维的数据结构,直接从系统的内存(例如,DDR)中读取这些地址不连续的数据对系统内存的利用率也会产生极大的影响。
发明内容
针对现有技术中存在的上述问题,本发明提出一种数据读取方法,在满足MAU计算需求的前提下,将对系统内存的访问大大降低。
根据本发明的一个方面,提供一种数据读取系统,包括:
配置单元,所述配置单元接收卷积计算的参数信息;
数据读取单元,所述数据读取单元对进行卷积计算的图像进行切分,使得切分后的图像块每次产生M次卷积计算所需的数据,所述数据读取单元按行读入切分后图像块;
数据缓存单元,所述数据缓存单元存取所述所述数据读取单元读入的数据;以及
数据扩展及输出单元,所述数据扩展及输出单元读出数据缓存单元中存放的一行图像数据,然后扩展M次卷积计算所需的该行的数据,共产生M*K个数据,并在输出端进行输出。
在本发明的一个实施例中,所述配置单元根据卷积计算的参数信息和系统的总线位宽及内存的特性确定每行数据切分的次数及最后一次剩余数据的长度。
在本发明的一个实施例中,切分后的图像块的宽度在M到M+K-1之间。
在本发明的一个实施例中,当所述数据扩展及输出单元对数据缓存单元中存储的K行数据完成扩展输出后,所述数据读取单元读入下一行的数据,覆盖所述数据缓存单元编号最靠前的一行的数据。
在本发明的一个实施例中,所述数据扩展及输出单元将扩展后的数据以K倍读入带宽的速度被送至后级的MAU。
根据本发明的另一个方面,提供一种数据读取方法,包括:
A)接收卷积计算参数,所述卷积计算参数包括图像尺寸、通道数、卷积核尺寸KxK、和/或步长;
B)确定图像的每行数据切分的次数及最后一次剩余数据的长度,使得切分后的图像块每次产生M次卷积计算所需的数据;
C)根据所确定的切分后的图像块宽度进行图像切分,对于图像块的第一通道,读入切分后的图像块的前K行数据,将其存入数据缓存单元中;
D)读出数据缓存单元中存放的第一行图像数据,然后扩展前M次卷积计算内的所有第一个通道的第一行的数据,共产生M*K个数据;
E)将数据缓存单元中存放的第二行至第K行的图像数据读出并扩展;
F)读入图像块下一行的数据,覆盖数据缓存单元中编号最靠前的一行的数据,对数据缓存单元中存储的更新的K行的数据执行步骤D)和步骤E);
重复步骤F),直至完成图像的最后一行;
对于图像块的其余通道,重复步骤B)至步骤F);
在本发明的另一个实施例中,切分后的图像块的宽度在M到M+K-1之间。
在本发明的另一个实施例中,相邻图像块的数据之间有若干像素的重叠。
在本发明的另一个实施例中,该数据读取方法还包括:G)判断是否还存在未处理的图像块,如果不存在未处理的图像块,则数据读取操作结束;
如果存在未处理的图像块,则将未处理的图像块作为当前图像块,返回当前图像块的第一通道,读入当前图像块的前K行数据,将其存入数据缓存单元中,重复步骤步骤D)至步骤G)。
在本发明的另一个实施例中,根据卷积核尺寸、图像尺寸、系统的总线位宽及内存等参数确定每次连续产生的卷积计算的次数M。
通过本发明公开的系统和方法,可以充分利用卷积神经网络中相邻卷积核中重复的数据,极大降低对系统内存的访问量,从而降低了卷积神经网络对系统带宽的要求。
本发明的公开的系统和方法可以充分利用系统对连续地址突发读操作的低延时特性。提高了系统带宽的利用率。
本发明的公开的系统和方法采用了切分图像的方法,使得缓存空间的大小为固定值MxK,降低了系统对片上缓存的尺寸要求。
附图说明
为了进一步阐明本发明的各实施例的以上和其它优点和特征,将参考附图来呈现本发明的各实施例的更具体的描述。可以理解,这些附图只描绘本发明的典型实施例,因此将不被认为是对其范围的限制。在附图中,为了清楚明了, 相同或相应的部件将用相同或类似的标记表示。
图1示出了根据本发明的卷积网络输入数据各参数的关系示意图。
图2示出根据本发明的一个实施例的数据读取系统200的示意框图。
图3示出根据本发明的一个实施例的数据读取方法的流程图。
图4示出了根据本发明的一个示例的卷积网络输入数据各参数的关系示意图。
图5示出根据本发明的一个实施例的数据扩展及输出单元的结构示意图。
图6示出根据本发明的一个实施例的步骤304中缓存的状态示意图。
图7示出根据本发明的一个实施例的步骤305中缓存的状态示意图。
具体实施方式
在以下的描述中,参考各实施例对本发明进行描述。然而,本领域的技术人员将认识到可在没有一个或多个特定细节的情况下或者与其它替换和/或附加方法、材料或组件一起实施各实施例。在其它情形中,未示出或未详细描述公知的结构、材料或操作以免使本发明的各实施例的诸方面晦涩。类似地,为了解释的目的,阐述了特定数量、材料和配置,以便提供对本发明的实施例的全面理解。然而,本发明可在没有特定细节的情况下实施。此外,应理解附图中示出的各实施例是说明性表示且不一定按比例绘制。
在本说明书中,对“一个实施例”或“该实施例”的引用意味着结合该实施例描述的特定特征、结构或特性被包括在本发明的至少一个实施例中。在本说明书各处中出现的短语“在一个实施例中”并不一定全部指代同一实施例。
需要说明的是,本发明的实施例以特定顺序对步骤进行描述,然而这只是为了方便区分各步骤,而并不是限定各步骤的先后顺序,在本发明的不同实施例中,可根据具体的流程的调节来调整各步骤的先后顺序。
卷积计算可看作是加权求和的过程,将图像区域中的每个像素分别与滤波器(即,权矩阵)的每个元素对应相乘,所有乘积之和作为区域中心像素的新值。
滤波器是卷积时使用到的权,用一个矩阵表示,该矩阵与对应的图像区域大小相同,其行、列都是奇数,是一个权矩阵。
假设输入数据的参数为:图像宽度W(像素数),图像高度H(像素数),图像通道数C,卷积核尺寸为KxK,步长为S=1。图1示出了根据本发明的卷积网络输入数据各参数的示意图。完成所有计算需要WxH次卷积计算(每行W次卷积,共H行),这里,为了维持输出图像尺寸不变,需要在输入图像周围一圈填充宽度为1且值为0的数据。而每次卷积需要的数据量为KxKxC。因此所有卷积计算需要的总数据量(不包含权重数据)为WxHxKxKxC=K 2xHxWxC。可见,由于相邻卷积核间的数据会重复使用,使得总数据量远远超过了实际的输入图像数据(HxWxC)。
另一方面,输入图像数据的地址是一般是沿行方向连续递增的。每个卷积计算在换行或者换通道时数据的地址会发生较大范围的跳变,这对常用的系统内存访问(例如,DDR)是非常不友好的,会产生较长的读延时从而导致系统的整体性能下降。
图2示出根据本发明的一个实施例的数据读取系统200的示意框图。如图2所示,低缓存占用的图像处理卷积神经网络的数据读取系统包括配置单元210、数据读取单元220、数据缓存单元230、数据扩展及输出单元240。
配置单元210接收上层模块传来的图像及卷积核参数信息。这些参数信息可包括图像在系统存储空间中的地址,图像的尺寸,卷积核的尺寸等。配置单元根据这些参数和系统的特性确定每行数据切分的次数及最后一次剩余数据的长度,使得每个切分后的图像块可以产生M次卷积计算所需的数据。
数据读取单元220对于宽度较大的图像进行切分,使得每个切分后的图像块可以产生M次卷积计算所需的数据。每个切分后的图像块的宽度在M到M+K-1之间,由切分后的图像块的位置而决定。然后,按行读入切分后图像。M可以根据系统的总线位宽及内存的特性而改变,目的是使得每次读入的连续地址的数据长度可以充分利用系统内存的突发读取能力,抵消切换地址带来的读延时开销。
数据读取单元220读入的数据将先暂存在数据缓存单元230中,并供数据扩展及输出单元240使用。由于纵向相邻的卷积核会有部分数据重复,数据缓存单元可以降低这部分数据对系统总线的占用。
数据扩展及输出单元240将横向的数据扩展成卷积核所需要的数据,并 输出给MAU供卷积计算使用。由于横向相邻的卷积核也有部分数据重复,这里可以利用数据的重复性增大内部带宽,从而提高数据到MAU上的吞吐率。
下面结合具体图像示例及图3详细描述根据本发明的数据读取系统的操作过程。图3示出根据本发明的一个实施例的数据读取方法的流程图。
假设输入图像为224x224,通道数为16,卷积核尺寸为3x3,步长为1。每次连续产生M=128次卷积计算所需的数据,各个参数关系如图4所示。
首先,在步骤301,接收卷积计算参数。可由系统处理器(CPU)将卷积计算参数写入配置单元。这些卷积计算参数信息可包括图像在系统存储空间中的地址、图像的尺寸、卷积核的尺寸、步长等。配置单元确定每行数据切分的次数及最后一次剩余数据的长度,使得每个切分后的图像块可以产生M次卷积计算所需的数据。每个切分后的图像块的宽度在M到M+K-1之间,由切分后的图像块的位置而决定。M可以根据系统的总线位宽及内存的特性而改变,目的是使得每次读入的连续地址的数据长度可以充分利用系统内存的突发读取能力,抵消切换地址带来的读延时开销。
例如,在本示例中,为了产生128次卷积计算所需的数据,第一次切分出的图像宽度为M+1=129。剩余宽度不足128,则一直读到行尾。
在步骤302,由数据读取单元根据所确定的切分后的图像块宽度进行图像切分,并读入切分后的图像块的前K行数据,将其存入数据缓存单元中。通过对图像进行切分,改变数据读入顺序,对于较宽的图像不再是简单的从左边一直读到右边。数据缓存空间的大小为固定值MxK,降低了系统对片上缓存的尺寸要求。
例如,在本示例中,数据读取单元首先读入前K=3行数据每行读入M+1=129个,并存入数据缓存单元中。
在步骤303,数据扩展及输出单元读出缓存中存放的第一行图像数据,然后扩展前M次卷积计算内的所有第一个通道的第一行的数据,共产生M*K个数据。扩展后的数据以K倍读入带宽的速度被送至后级的MAU。
例如,在本示例中,数据扩展及输出单元读出缓存中存放的第一行的129个数据,然后扩展前M=128次卷积计算内的所有第一个通道的第一行的数据,共产生M*K=128*3个数据。扩展的方法如图5所示。图5示出根据本发明的 一个实施例的数据扩展及输出单元的结构示意图。这些数据可以以3倍读入带宽的速度被送至后级的MAU。数据扩展模块的结构示意图如图5所示。为了便于图示,在图5中示出4个数据输出接口,本领域的技术人员应该意识到数据接口的数量不限于4个。数据接口的数量一般可由内部带宽决定。例如,当系统带宽是128位且每个数据为8位时,输出接口就是16组,每组宽度为3个数据24位。
在步骤304,重复步骤303,将第二行至第K行的数据读出并扩展。至此,前M次卷积计算内的第一通道的所有KxK个数据均已生成。
例如,在本示例中,将第二行和第三行的数据读出并扩展,至此,前M=128次卷积计算内的第一通道的所有3x3个数据均已生成。此时缓存的状态如图6所示。
在步骤305,数据读取单元读入下一行的数据,覆盖缓存中编号最靠前的一行的数据。例如,在本示例中,数据读取单元读入第四行的数据,将第一通道第一行的数据覆盖,如图7所示。
在步骤306,数据扩展及输出单元读出缓存中存放的更新的K行的数据并扩展。其扩展和输出方法类似于步骤303至304。
例如,在本示例中,数据扩展及输出单元读出缓存中存放的第二、三、四行的数据并扩展,作为第二行的前128次卷积计算所需的第一通道的数据。
在步骤307,重复步骤306,直至完成图像的最后一行。产生的图像所有行的前M次卷积计算所需的第一通道的数据。
在步骤308,对于图像的其余通道,重复步骤302至步骤307,产生卷积计算所需的所有通道上的数据。
在步骤309,判断是否还存在未处理的图像块。如果不存在未处理的图像块,则数据读取操作结束。
如果存在,则将未处理的图像块作为当前图像块,在步骤310,回到第一个通道第一行,向数据缓存单元读入当前图像块的前K行数据,其中当前图像块与前一图像块有若干像素的重叠。例如,在本示例中,因为第一通道第一行的第129次卷积计算需要用到第128个点,所以,需要重复读入第128个点和第129个点的数据。
在步骤311,数据扩展及输出单元读出缓存中存放的K行的数据并扩展。其扩展和输出方法类似于步骤303至304。例如,在本示例中,从数据缓存单元中读出前3行每行第128到第224个点的数据并扩展,产生第一行的第129到第224次卷积计算所需的第一通道的数据。
在步骤312,对第一通道当前图像块的其余数据行,重复步骤305-307。例如,在本示例中,对通道1的第4-224行的第128-224个点,重复步骤305-307,得出每行第129~224次卷积计算所需的通道1的数据,得出每行第129~224次卷积计算所需的通道1的数据。
在步骤313,对其余通道的数据,重复步骤309-311,得出每行第129~224次卷积计算所需的所有数据,然后返回步骤309。
上述实施例以3*3的卷积核为例,本领域的技术人员应该意识到,卷积核还可以使其它尺寸,并且本领域的技术人员可以根据卷积核尺寸、图像尺寸、系统的总线位宽及内存等参数确定每次连续产生的卷积计算的次数、图像切分尺寸。
通过本发明公开的系统和方法,可以充分利用卷积神经网络中相邻卷积核中重复的数据,极大降低对系统内存的访问量,从而降低了卷积神经网络对系统带宽的要求。
本发明的公开的系统和方法可以充分利用系统对连续地址突发读操作的低延时特性。提高了系统带宽的利用率。
本发明的公开的系统和方法采用了切分图像的方法,使得缓存空间的大小为固定值MxK,降低了系统对片上缓存的尺寸要求。
尽管上文描述了本发明的各实施例,但是,应该理解,它们只是作为示例来呈现的,而不作为限制。对于相关领域的技术人员显而易见的是,可以对其做出各种组合、变型和改变而不背离本发明的精神和范围。因此,此处所公开的本发明的宽度和范围不应被上述所公开的示例性实施例所限制,而应当仅根据所附权利要求书及其等同替换来定义。

Claims (10)

  1. 一种数据读取系统,包括:
    配置单元,所述配置单元接收卷积计算的参数信息;
    数据读取单元,所述数据读取单元对进行卷积计算的图像进行切分,使得切分后的图像块每次产生M次卷积计算所需的数据,所述数据读取单元按行读入切分后图像块;
    数据缓存单元,所述数据缓存单元存取所述所述数据读取单元读入的数据;以及
    数据扩展及输出单元,所述数据扩展及输出单元读出数据缓存单元中存放的一行图像数据,然后扩展M次卷积计算所需的该行的数据,共产生M*K个数据,并在输出端进行输出。
  2. 如权利要求1所述的数据读取系统,其特征在于,所述配置单元根据卷积计算的参数信息和系统的总线位宽及内存的特性确定每行数据切分的次数及最后一次剩余数据的长度。
  3. 如权利要求1所述的数据读取系统,其特征在于,切分后的图像块的宽度在M到M+K-1之间。
  4. 如权利要求1所述的数据读取系统,其特征在于,当所述数据扩展及输出单元对数据缓存单元中存储的K行数据完成扩展输出后,所述数据读取单元读入下一行的数据,覆盖所述数据缓存单元编号最靠前的一行的数据。
  5. 如权利要求1所述的数据读取系统,其特征在于,所述数据扩展及输出单元将扩展后的数据以K倍读入带宽的速度被送至后级的MAU。
  6. 一种数据读取方法,包括:
    A)接收卷积计算参数,所述卷积计算参数包括图像尺寸、通道数、卷积核尺寸KxK、和/或步长;
    B)确定图像的每行数据切分的次数及最后一次剩余数据的长度,使得切分后的图像块每次产生M次卷积计算所需的数据;
    C)根据所确定的切分后的图像块宽度进行图像切分,对于图像块的第一通道,读入切分后的图像块的前K行数据,将其存入数据缓存单元中;
    D)读出数据缓存单元中存放的第一行图像数据,然后扩展前M次卷积计算内的所有第一个通道的第一行的数据,共产生M*K个数据;
    E)将数据缓存单元中存放的第二行至第K行的图像数据读出并扩展;
    F)读入图像块下一行的数据,覆盖数据缓存单元中编号最靠前的一行的数据,对数据缓存单元中存储的更新的K行的数据执行步骤D)和步骤E);
    重复步骤F),直至完成图像的最后一行;
    对于图像块的其余通道,重复步骤B)至步骤F);
  7. 如权利要求6所述的数据读取方法,其特征在于,切分后的图像块的宽度在M到M+K-1之间。
  8. 如权利要求6所述的数据读取方法,其特征在于,相邻图像块的数据之间有若干像素的重叠。
  9. 如权利要求6所述的数据读取方法,其特征在于,还包括:G)判断是否还存在未处理的图像块,如果不存在未处理的图像块,则数据读取操作结束;
    如果存在未处理的图像块,则将未处理的图像块作为当前图像块,返回当前图像块的第一通道,读入当前图像块的前K行数据,将其存入数据缓存单元中,重复步骤步骤D)至步骤G)。
  10. 如权利要求6所述的数据读取方法,其特征在于,根据卷积核尺寸、图像尺寸、系统的总线位宽及内存等参数确定每次连续产生的卷积计算的次数M。
PCT/CN2019/093539 2019-03-06 2019-06-28 一种数据读取系统和方法 WO2020177250A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201910166541.4A CN110032538B (zh) 2019-03-06 2019-03-06 一种数据读取系统和方法
CN201910166541.4 2019-03-06

Publications (1)

Publication Number Publication Date
WO2020177250A1 true WO2020177250A1 (zh) 2020-09-10

Family

ID=67235772

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2019/093539 WO2020177250A1 (zh) 2019-03-06 2019-06-28 一种数据读取系统和方法

Country Status (2)

Country Link
CN (1) CN110032538B (zh)
WO (1) WO2020177250A1 (zh)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112712457A (zh) * 2021-01-14 2021-04-27 清华大学 数据处理方法以及人工智能处理器
CN113570031A (zh) * 2021-06-08 2021-10-29 中国科学院深圳先进技术研究院 卷积运算的处理方法、电子设备及计算机可读存储介质

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111310115B (zh) * 2020-01-22 2024-05-24 深圳市商汤科技有限公司 数据处理方法、装置及芯片、电子设备、存储介质
CN112183732A (zh) * 2020-10-22 2021-01-05 中国人民解放军国防科技大学 卷积神经网络加速方法、装置和计算机设备
CN114202071B (zh) * 2022-02-17 2022-05-27 浙江光珀智能科技有限公司 一种基于数据流模式的深度卷积神经网络推理加速方法

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105869117A (zh) * 2016-03-28 2016-08-17 上海交通大学 一种针对深度学习超分辨率技术的gpu加速方法
US9665799B1 (en) * 2016-01-29 2017-05-30 Fotonation Limited Convolutional neural network
CN106874219A (zh) * 2016-12-23 2017-06-20 深圳云天励飞技术有限公司 一种卷积神经网络的数据调度方法、系统及计算机设备
CN108108809A (zh) * 2018-03-05 2018-06-01 山东领能电子科技有限公司 一种针对卷积神经元网络进行推理加速的硬件架构及其工作方法
CN108388537A (zh) * 2018-03-06 2018-08-10 上海熠知电子科技有限公司 一种卷积神经网络加速装置和方法
CN109886395A (zh) * 2019-03-06 2019-06-14 上海熠知电子科技有限公司 一种面向多核图像处理卷积神经网络的数据读取方法

Family Cites Families (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9836853B1 (en) * 2016-09-06 2017-12-05 Gopro, Inc. Three-dimensional convolutional neural networks for video highlight detection
CN107742150B (zh) * 2016-10-31 2020-05-12 腾讯科技(深圳)有限公司 一种卷积神经网络的数据处理方法和装置
CN108229645B (zh) * 2017-04-28 2021-08-06 北京市商汤科技开发有限公司 卷积加速和计算处理方法、装置、电子设备及存储介质
CN108304923B (zh) * 2017-12-06 2022-01-18 腾讯科技(深圳)有限公司 卷积运算处理方法及相关产品
CN108416434B (zh) * 2018-02-07 2021-06-04 复旦大学 针对神经网络的卷积层与全连接层进行加速的电路结构
CN108960408B (zh) * 2018-06-12 2021-07-13 杭州米绘科技有限公司 一种面向超高清分辨率图案的风格化系统及方法

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9665799B1 (en) * 2016-01-29 2017-05-30 Fotonation Limited Convolutional neural network
CN105869117A (zh) * 2016-03-28 2016-08-17 上海交通大学 一种针对深度学习超分辨率技术的gpu加速方法
CN106874219A (zh) * 2016-12-23 2017-06-20 深圳云天励飞技术有限公司 一种卷积神经网络的数据调度方法、系统及计算机设备
CN108108809A (zh) * 2018-03-05 2018-06-01 山东领能电子科技有限公司 一种针对卷积神经元网络进行推理加速的硬件架构及其工作方法
CN108388537A (zh) * 2018-03-06 2018-08-10 上海熠知电子科技有限公司 一种卷积神经网络加速装置和方法
CN109886395A (zh) * 2019-03-06 2019-06-14 上海熠知电子科技有限公司 一种面向多核图像处理卷积神经网络的数据读取方法

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112712457A (zh) * 2021-01-14 2021-04-27 清华大学 数据处理方法以及人工智能处理器
CN112712457B (zh) * 2021-01-14 2024-05-10 清华大学 数据处理方法以及人工智能处理器
CN113570031A (zh) * 2021-06-08 2021-10-29 中国科学院深圳先进技术研究院 卷积运算的处理方法、电子设备及计算机可读存储介质
CN113570031B (zh) * 2021-06-08 2024-02-02 中国科学院深圳先进技术研究院 卷积运算的处理方法、电子设备及计算机可读存储介质

Also Published As

Publication number Publication date
CN110032538A (zh) 2019-07-19
CN110032538B (zh) 2020-10-02

Similar Documents

Publication Publication Date Title
WO2020177251A1 (zh) 一种面向多核图像处理卷积神经网络的数据读取方法
WO2020177250A1 (zh) 一种数据读取系统和方法
US20190303731A1 (en) Target detection method and device, computing device and readable storage medium
US11645529B2 (en) Sparsifying neural network models
US10445638B1 (en) Restructuring a multi-dimensional array
WO2019170049A1 (zh) 一种卷积神经网络加速装置和方法
WO2018196863A1 (zh) 卷积加速和计算处理方法、装置、电子设备及存储介质
WO2019136764A1 (zh) 卷积器及其所应用的人工智能处理装置
WO2019227322A1 (zh) 池化装置和池化方法
CN109117950B (zh) 基于人工智能设备的分层稀疏张量压缩方法
US20200110604A1 (en) Energy-efficient memory systems and methods
CN111626405A (zh) 一种cnn加速方法、加速装置及计算机可读存储介质
WO2022016925A1 (zh) 神经网络计算装置
WO2022110386A1 (zh) 数据处理方法及人工智能处理器
CN104809161B (zh) 一种对稀疏矩阵进行压缩和查询的方法及系统
JP2013511106A (ja) 画素速度での画像処理のための方法および装置
CN112966807B (zh) 基于存储资源受限fpga的卷积神经网络实现方法
JP2002511984A (ja) シストリックアレーのメモリ帯域巾要求を低減する装置及び方法
CN111984189A (zh) 神经网络计算装置和数据读取、数据存储方法及相关设备
CN111783967A (zh) 一种适用于专用神经网络加速器的数据双层缓存方法
CN114003201A (zh) 矩阵变换方法、装置及卷积神经网络加速器
CN111008691A (zh) 一种权值和激活值都二值化的卷积神经网络加速器架构
CN113743587A (zh) 一种卷积神经网络池化计算方法、系统、及存储介质
CN110674934B (zh) 一种神经网络池化层及其运算方法
CN110490312B (zh) 一种池化计算方法和电路

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 19918094

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 19918094

Country of ref document: EP

Kind code of ref document: A1