Data loading
AssigneeHangzhou Zhicun Intelligent Technology Co., Ltd.
InventorsXuguang Sun, Xiaodi Xing, Shaodi Wang
Life of this patent
Estimating the term…
Abstract
A data loading circuit and method are provided. The circuit is configured to load data for a feature map calculated by a neural network into a calculation circuit, wherein the size of the convolution kernel of the neural network is K*K data, and a window corresponding to the convolution kernel slides with a step size of S in the feature map, where K and S are positive integers and S<K, the circuit comprising: two data loaders comprising a first data loader and a second data loader; and a controller configured to: control the first data loader to be in a data outputting mode and control the second data loader to be in a data reading mode, when the window slides within K consecutive rows of the feature map.
Claims18
A data loading circuit being configured to load data in a feature map into a calculation circuit, wherein the feature map is calculated by a neural network, a size of a convolution kernel of the neural network is K*K data, and a window corresponding to the convolution kernel slides with a step size of S in the feature map, where K and S are positive integers and S<K, the data loading circuit comprising:
- two data loaders comprising a first data loader and a second data loader, wherein each data loader comprises a respective hardware component for loading and outputting data;
- and
- a controller configured to:
- control the first data loader to be in a data outputting mode and control the second data loader to be in a data reading mode, when the window slides within K consecutive rows of the feature map at the step size of S in a width direction,
- wherein the first data loader in the data outputting mode is configured to output data in a matrix corresponding to the window to the calculation circuit, and output data in the last (K−S) columns of the matrix corresponding to the window to the second data loader in the data reading mode, and the second data loader in the data reading mode is configured to receive data from the first data loader in the data outputting mode, and read, from a memory, data in S columns after the matrix corresponding to the window in K consecutive rows, and
- the controller is further configured to:
- determine, after the second data loader in the data reading mode completes a process of receiving the data from the first data loader in the data outputting mode and reading the data from the memory, whether a difference between a column address of the last column of the feature map and a column address of the last column of the matrix corresponding to the window is greater than or equal to 2S;
- and
- in accordance with a determination that the difference between the column address of the last column of the feature map and the column address of the last column of the matrix corresponding to the window is greater than or equal to 2S, clear data stored in the first data loader, switch the first data loader from the data outputting mode to the data reading mode, and switch the second data loader from the data reading mode to the data outputting mode.
A data loading circuit configured to load data in a feature map into a calculation circuit, wherein the feature map is calculated by a neural network, the feature map of the neural network has M channels, the size of a convolution kernel of the neural network is K*K data, and a window corresponding to the convolution kernel slides with a step size of S in the feature map, where M, K and S are positive integers and S<K, the data loading circuit comprising:
- two registers comprising a first register and a second register, each of the two registers being configured to sequentially store, based on column addresses, data in various columns of a matrix corresponding to the window;
- two shifters comprising a first shifter and a second shifter, each of the two shifters being configured to shift received data forward by (S*M*K) bits;
- and
- a controller configured to:
- control the first register to be in a data outputting mode and control the second register to be in a data reading mode, when the window slides within K consecutive rows of the feature map at the step size of S in a width direction,
- wherein the first register in the data outputting mode is configured to simultaneously output data in the matrix corresponding to the window to the calculation circuit and the first shifter, the first shifter is configured to shift the received data, and output, to the second register in the data reading mode, the shifted data, and the second register in the data reading mode is configured to receive data from the first shifter, and read, from a memory, data in S columns after the matrix corresponding to the window in the K consecutive rows, and
- the controller is further configured to:
- determine whether the second register in the data reading mode completes a process of receiving the data from the first shifter and reading the data from the memory, and if so, determine whether a difference between a column address of the last column of the feature map and a column address of the last column of the matrix corresponding to the window is greater than or equal to 2S,
- wherein if the difference between the column address of the last column of the feature map and the column address of the last column of the matrix corresponding to the window is greater than or equal to 2S, data stored in the first register in the data outputting mode is cleared, the first register in the data outputting mode is controlled to switch to the data reading mode, and the second register in the data reading mode is controlled to switch to the data outputting mode.
A data loading method, comprising loading data in a feature map into a calculation circuit, wherein the feature map is calculated by a neural network, and the size of a convolution kernel of the neural network is K*K data, and a window corresponding to the convolution kernel slides with a step size of S in the feature map, where K and S are positive integers and S<K, the method comprising:
- controlling a first data loader to be in a data outputting mode and controlling a second data loader to be in a data reading mode, when the window slides within K consecutive rows of the feature map at the step size of S in a width direction, wherein each of the first data loader and the second data loader comprises a respective hardware component for loading and outputting data,
- wherein the first data loader in the data outputting mode outputs data in a matrix corresponding to the window to the calculation circuit, and outputs data in the last (K−S) columns of the matrix corresponding to the window to the second data loader in the data reading mode, and the second data loader in the data reading mode receives data from the first data loader in the data outputting mode, and reads, from a memory, data in S columns after the matrix corresponding to the window in the K consecutive rows, and
- the method further comprising:
- determining, after the second data loader in the data reading mode completes a process of receiving the data from the first data loader in the data outputting mode and reading the data from the memory, whether a difference between a column address of the last column of the feature map and a column address of the last column of the matrix corresponding to the window is greater than or equal to 2S,
- wherein if the difference between the column address of the last column of the feature map and the column address of the last column of the matrix corresponding to the window is greater than or equal to 2S, data stored in the first data loader in the data outputting mode is cleared, the first data loader in the data outputting mode is controlled to switch to the data reading mode, and the second data loader in the data reading mode is controlled to switch to the data outputting mode.
Dependencies are inferred from the claim text.