WO2018196863A1 - 卷积加速和计算处理方法、装置、电子设备及存储介质 - Google Patents
卷积加速和计算处理方法、装置、电子设备及存储介质 Download PDFInfo
- Publication number
- WO2018196863A1 WO2018196863A1 PCT/CN2018/084948 CN2018084948W WO2018196863A1 WO 2018196863 A1 WO2018196863 A1 WO 2018196863A1 CN 2018084948 W CN2018084948 W CN 2018084948W WO 2018196863 A1 WO2018196863 A1 WO 2018196863A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- data
- buffer area
- input
- output
- processed
- Prior art date
- Legal status (The legal status 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 status listed.)
- Ceased
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F17/00—Digital computing or data processing equipment or methods, specially adapted for specific functions
- G06F17/10—Complex mathematical operations
- G06F17/15—Correlation function computation including computation of convolution operations
- G06F17/153—Multidimensional correlation or convolution
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06N—COMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
- G06N3/00—Computing arrangements based on biological models
- G06N3/02—Neural networks
- G06N3/06—Physical realisation, i.e. hardware implementation of neural networks, neurons or parts of neurons
- G06N3/063—Physical realisation, i.e. hardware implementation of neural networks, neurons or parts of neurons using electronic means
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F17/00—Digital computing or data processing equipment or methods, specially adapted for specific functions
- G06F17/10—Complex mathematical operations
- G06F17/16—Matrix or vector computation, e.g. matrix-matrix or matrix-vector multiplication, matrix factorization
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/46—Multiprogramming arrangements
- G06F9/50—Allocation of resources, e.g. of the central processing unit [CPU]
- G06F9/5005—Allocation of resources, e.g. of the central processing unit [CPU] to service a request
- G06F9/5027—Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/46—Multiprogramming arrangements
- G06F9/54—Interprogram communication
- G06F9/544—Buffers; Shared memory; Pipes
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06N—COMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
- G06N3/00—Computing arrangements based on biological models
- G06N3/02—Neural networks
- G06N3/04—Architecture, e.g. interconnection topology
- G06N3/045—Combinations of networks
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06N—COMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
- G06N3/00—Computing arrangements based on biological models
- G06N3/02—Neural networks
- G06N3/04—Architecture, e.g. interconnection topology
- G06N3/0464—Convolutional networks [CNN, ConvNet]
Definitions
- the present application relates to computer vision technology, and more particularly to a convolution acceleration and computation processing method, apparatus, electronic device and storage medium.
- CNN Deep Convolutional Neural Network
- FPGA Field Programmable Gate Array
- ASIC Application Specific Integrated Circuit
- the embodiments of the present application provide a technical solution for accelerating CNN by using an FPGA, including: a convolution acceleration method and an accelerator, a convolution calculation processing method and device, an electronic device, and a computer storage medium.
- a convolution acceleration method including:
- the on-chip memory includes a first buffer area, a second buffer area, and a third buffer area, the first buffer area includes at least one input buffer area, and the second buffer area is buffered with at least one set of convolution kernel data; Responding to the data to be processed stored in the input buffer, sequentially reading the input window data to be processed from the at least one input buffer, and performing convolution calculation on the input window data to be processed by the convolution kernel data Obtaining output window data and storing it in the third buffer area;
- the output window data in the third buffer area is sequentially stored into the off-chip memory through the FIFO port.
- a convolution calculation processing method including:
- the convolution kernel data is obtained by converting the convolution kernel by the first constant matrix
- the point multiplied matrix is converted using a third constant matrix to obtain a convolution result.
- a convolution accelerator including:
- a data reading module configured to sequentially read, by the FIFO port, the to-be-processed data of a preset size in the to-be-processed task from the off-chip memory of the accelerator, and store the data in the at least one input buffer area of the first buffer area;
- the first buffer area includes at least one input buffer area for buffering the to-be-processed data
- a second buffer area for buffering at least one set of convolution kernel data
- a calculation module configured to sequentially read the input window data to be processed from the at least one input buffer area when the data to be processed is stored in the input buffer area, and use the convolution kernel data to input the input window to be processed Data is convoluted to obtain output window data and stored in the third buffer area;
- a third buffer area including at least one output buffer area, for buffering output window data
- a data output module configured to sequentially store the output window data in the third buffer area into the off-chip memory through the FIFO port.
- a convolution calculation processing apparatus including:
- a first conversion module configured to convert the input window data to be processed by using the second constant matrix, and obtain input window data after conversion
- a point multiplication module configured to perform a matrix point multiplication operation on the converted input window data and the convolution kernel data to obtain a point multiplied matrix;
- the convolution kernel data is obtained by converting the convolution kernel by the first constant matrix;
- a second conversion module configured to convert the point multiplied matrix by using a third constant matrix to obtain a convolution result.
- an electronic device including the convolution accelerator of any of the embodiments of the present application.
- another electronic device including:
- a memory for storing executable instructions
- a processor for communicating with the memory to execute the executable instructions to perform the operations of the convolution acceleration method of any of the embodiments of the present application.
- a computer storage medium for storing computer readable instructions that, when executed, perform the operations of the convolution acceleration method of any of the embodiments of the present application.
- a further electronic device including the convolution calculation processing device according to any one of the embodiments of the present application.
- another electronic device including:
- a memory for storing executable instructions
- a processor for communicating with the memory to execute the executable instructions to perform the operations of the convolution calculation processing method of any of the embodiments of the present application.
- a computer storage medium for storing computer readable instructions that, when executed, perform the operations of the convolution calculation processing method of any of the embodiments of the present application.
- the on-chip memory of the accelerator includes a first buffer area, a second buffer area, and a third buffer area, the first buffer area, based on the convolution acceleration method and the accelerator provided by the above embodiments of the present application, and corresponding electronic devices and computer storage media. At least one input buffer is included, and at least one set of convolution kernel data is cached in the second buffer.
- the embodiment of the present application reads the to-be-processed data of the preset size from the off-chip memory of the accelerator into the on-chip memory for processing, and realizes that the to-be-processed data is read from the off-chip memory and stored in the on-chip memory, and
- the pipeline processing of the process of convolution calculation processing of the processed data can make full use of the on-chip memory, bandwidth, DSP and other resources of the accelerator, and significantly improve the efficiency of the convolution calculation processing, and can be applied to hardware platforms such as FPGA and ASIC. Therefore, the convolution acceleration processing is implemented on a hardware platform such as an FPGA or an ASIC.
- the FPGA platform can be fully utilized, such as reconfigurable, parallel computing, short development cycle, low power consumption, and high flexibility. .
- the convolution calculation processing method and apparatus can adopt the second constant matrix to process the input window data for any input channel and any output channel. Perform conversion to obtain input window data after conversion; perform matrix point multiplication operation on converted input window data and convolution kernel data to obtain a point-multiplied matrix; use a third constant matrix to convert the dot-multiplied matrix to obtain a convolution result .
- the embodiment of the present application provides a method for face-to-face convolution calculation of input window data based on the Winograd algorithm, which reduces the number of multiplications compared to the conventional point-to-point convolution algorithm, thereby reducing the occupation of processor resources, and Increased computational efficiency.
- the embodiments of the present application can be applied to hardware platforms such as an FPGA and an ASIC to implement convolution acceleration processing on a hardware platform such as an FPGA or an ASIC.
- the FPGA platform can be fully utilized for reconfigurable and parallel computing. Sex, short development cycle, low power consumption, high flexibility.
- FIG. 1 is a flow chart of an embodiment of a convolution acceleration method of the present application
- FIG. 2 is a diagram showing an example of on-chip memory in the embodiment of the present application.
- FIG. 3 is a flowchart of an embodiment of convolution calculation of input window data to be processed in an embodiment of the present application
- FIG. 4 is a schematic diagram of performing a calculation processing operation on Pn input channels in parallel in an embodiment of the present application
- FIG. 5 is a schematic diagram of performing a calculation processing operation on Pm output channels in parallel according to an embodiment of the present application
- FIG. 6 is a flow chart of an embodiment of a convolution calculation processing method of the present application.
- FIG. 7 is a flow chart of another embodiment of a convolution calculation processing method of the present application.
- Figure 8 is a schematic diagram of a calculation process of the embodiment shown in Figures 3, 6, and 7;
- FIG. 9 is a schematic structural view of an embodiment of a convolution accelerator of the present application.
- FIG. 10 is a schematic structural diagram of an embodiment of a computing module according to an embodiment of the present application.
- FIG. 11 is a schematic structural diagram of an embodiment of a convolution calculation processing apparatus of the present application.
- FIG. 12 is a schematic structural diagram of another embodiment of a convolution calculation processing apparatus of the present application.
- FIG. 13 is a schematic structural diagram of an application embodiment of an electronic device according to the present application.
- Embodiments of the present application can be applied to electronic devices such as terminal devices, computer systems, servers, etc., which can operate with numerous other general purpose or special purpose computing system environments or configurations.
- Examples of well-known terminal devices, computing systems, environments, and/or configurations suitable for use with electronic devices such as terminal devices, computer systems, servers, and the like include, but are not limited to, personal computer systems, server computer systems, thin clients, thick clients Machines, handheld or laptop devices, microprocessor-based systems, set-top boxes, programmable consumer electronics, networked personal computers, small computer systems, mainframe computer systems, and distributed cloud computing technology environments including any of the above, and the like.
- Electronic devices such as terminal devices, computer systems, servers, etc., can be described in the general context of computer system executable instructions (such as program modules) being executed by a computer system.
- program modules may include routines, programs, target programs, components, logic, data structures, and the like that perform particular tasks or implement particular abstract data types.
- the computer system/server can be implemented in a distributed cloud computing environment where tasks are performed by remote processing devices that are linked through a communication network.
- program modules may be located on a local or remote computing system storage medium including storage devices.
- FIG. 1 is a flow chart of an embodiment of a convolution acceleration method of the present application. As shown in FIG. 1, the method for accelerating the convolution of the embodiment of the present application includes:
- a first input first output (FIFO) port Read, by a first input first output (FIFO) port, a preset size of the to-be-processed data in the to-be-processed task from the accelerator's off-chip memory, and store the at least one of the first buffer areas in the on-chip memory of the accelerator.
- An input buffer area and in response to storing the to-be-processed data in the input buffer area, sequentially reading the input window data to be processed from the at least one input buffer area, and convolving the input window data to be processed by convolution kernel data Calculate, the output window data is obtained and stored in the third buffer area.
- the on-chip memory includes a first buffer area, a second buffer area, and a third buffer area.
- the first buffer area includes at least one input buffer area, and the second buffer area is buffered with at least one set of convolution kernel data.
- the convolution acceleration method of the embodiments of the present application can be applied to any accelerator, especially an embedded platform such as an FPGA or an ASIC with relatively small on-chip memory and bandwidth resources.
- the task to be processed may include, for example, an input image of at least one channel or an input feature map of at least one channel, and after the processing of the to-be-processed task is completed, an output feature map of at least one channel may be obtained.
- the channel for inputting the image and the input feature map is referred to as an input channel
- the channel for outputting the feature map is referred to as an output channel.
- Each gray of the input image and the input feature map corresponds to one channel.
- each set of convolution kernel data corresponds to one output channel
- each set of convolution kernel data includes at least one convolution kernel data
- each convolution kernel data corresponds to one input channel.
- the operation 102 may be performed by a processor invoking a corresponding instruction stored in a memory, or by a data reading module and a computing module executed by the processor.
- the output window data in the third buffer area is sequentially stored into the off-chip memory through the FIFO port.
- the on-chip memory of the accelerator includes a first buffer area, a second buffer area, and a third buffer area, where the first buffer area includes at least one input buffer area, and the second buffer area is cached.
- the embodiment of the present application reads the to-be-processed data of the preset size from the off-chip memory of the accelerator into the on-chip memory for processing, and realizes reading the to-be-processed data from the off-chip memory and storing it on the on-chip memory, and treating
- the pipeline processing of processing data for convolution calculation processing, etc. can make full use of the on-chip memory, bandwidth, DSP and other resources of the accelerator, and significantly improve the efficiency of convolution calculation processing, and can be applied to hardware platforms such as FPGA and ASIC, thereby
- the convolution acceleration processing is implemented on a hardware platform such as an FPGA or an ASIC.
- the FPGA platform can fully utilize the reconfigurable, parallel computing, short development cycle, low power consumption, and high flexibility.
- the operation 104 may be performed by a processor invoking a corresponding instruction stored in a memory or by a data output module executed by the processor.
- the first buffer area includes two input buffers.
- one of the input buffers of the two input buffers is stored in turn to be processed data, read the input window data to be processed, and another input buffer in the two input buffers.
- the input window data to be processed is read in turn and stored in the data to be processed.
- the other input window data to be processed is read in the previous one.
- the input window data is to be processed, the other is stored in the data to be processed, thereby implementing pipeline processing for storing the data to be processed, reading the input window data to be processed, overlapping the time required to store the data to be processed, and reading the data to be processed.
- the time required to process the input window data reduces the time required for the entire acceleration process and improves the acceleration efficiency of CNN.
- the size of the convolution kernel corresponding to the convolution kernel data is represented as r ⁇ r
- the size of the input window corresponding to the input window data is represented as n ⁇ n
- the sliding step of the input window corresponding to the input window data is Expressed as m
- the size of the output window corresponding to the input window data is expressed as m ⁇ m.
- the value of m is less than or equal to the value of n.
- the value of r is greater than 1
- the value of m is smaller than the value of n.
- the value of r is 1
- the value of m is equal to the value of n.
- the input buffer area is a line buffer area
- the first buffer area is: a circular buffer formed by n+m line buffer areas, and each line buffer area is used for each line buffer area.
- FIG. 2 it is an exemplary diagram of on-chip memory in the embodiment of the present application.
- M represents the number of channels of the input feature map, ie: the number of input channels
- H represents the height of the input feature map
- W represents the width of the input feature map
- M ⁇ W represents the size of the input feature map
- the calculation module represents the A unit for convolution calculation of input window data in a buffer area
- C represents the number of channels of the output feature map, that is, the number of output channels
- R represents the height of the output feature map
- N represents the width of the output feature map
- N ⁇ C represents Enter the size of the feature map.
- the to-be-processed data of a preset size in the to-be-processed task is read from the off-chip memory of the accelerator, and sequentially stored in the on-chip memory of the accelerator, at least one input of the first buffer area.
- Cache area including:
- the first n rows of data of all channels of the to-be-processed task are read from the off-chip memory for the first time, and each row of data of the first n rows of data is correspondingly stored in the first buffer area, and the first n row buffer regions determined based on the predetermined cycle direction are respectively corresponding. in;
- each subsequent row of m rows of data of the to-be-processed task is read from the off-chip memory, and each row of the m rows of data to be read is correspondingly stored in the first buffer zone, based on a predetermined cycle direction. Determined in the adjacent subsequent m line buffers.
- n can be stored in the m line buffer area in the first buffer area adjacent to the data that has not been read last time; or can read the adjacent sequence of all channels of the to-be-processed task from the off-chip memory each time n rows of data, and stored in the first buffer, n rows of buffers determined based on the predetermined cycle direction, n rows of buffers that are not first stored in the data include the last cached data last (r-1 In the row buffer area and the adjacent m line buffer areas, overlapping coverage of the r-1 line buffer area data occurs at this time.
- the scheme of storing m rows of data from the off-chip memory into the first buffer area every time for the first time can reduce data transmission. Quantity, thereby saving transmission bandwidth and improving data reading, transmission and storage efficiency.
- the first 6 rows of data of all channels of the task to be processed can be read from the off-chip memory for the first time and stored in the first buffer area, and the first n rows determined based on the predetermined cycle direction. In the line buffer area.
- the adjacent four rows of buffers are determined to be adjacent; or, the subsequent 6 rows of data of all channels of the to-be-processed task may be read from the off-chip memory each time, and the 6 rows of data read this time are stored in
- the first buffer area is determined based on the predetermined cyclic direction, and is determined by the adjacent four line buffer areas and the six line buffer areas determined in the last two line buffer areas of the last data stored.
- the to-be-processed data of a preset size in the to-be-processed task is read from the off-chip memory of the accelerator, and sequentially stored in the on-chip memory of the accelerator, at least one input buffer area of the first buffer area.
- each row of the first n rows of data is correspondingly stored in the first buffer area determined in the first buffer area and determined based on the predetermined cycle direction;
- the n rows of data read for the first time based on the predetermined cycle direction, store the first n row buffers of the n rows of data read last time in the first buffer area, and the corresponding n row buffers after the m rows are used as the current read.
- the target row buffer area of the n rows of data is fetched, and the n rows of data read this time are correspondingly stored in the row buffers in the target row buffer area.
- the input window data to be processed is sequentially read from at least one input buffer, and convolution calculation is performed on the input window data to be processed by the convolution kernel data, including :
- the first n line buffer areas are selected as the current calculation buffer area, and the size of the current calculation buffer area is read as n ⁇ n according to the sliding step size m.
- the third buffer area includes at least one output buffer area, and when the output window data is obtained and stored in the third buffer area, the output window data is obtained and sequentially stored in the third buffer area.
- the operation 104 includes: in response to the first output buffer storing the output window data, sequentially reading the output window data in the at least one output buffer, and outputting the read through the FIFO port Window data is stored in off-chip memory.
- the third buffer area may include two output buffer areas.
- one of the output buffers of the two output buffers is stored in the output window data, the output window data is read, and the other output buffer in the two output buffers is read in turn.
- Output window data and store it in the output window data.
- the other is read out of the output window data.
- the other is stored in the output window data, thereby implementing the storage and output window.
- Pipeline processing of data, read output window data, overlapping the time required to store the output window data and the time required to read the output window data further reduces the time required for the entire acceleration process and improves the efficiency of the accelerator.
- each output buffer may include m line buffers.
- the output window data is obtained and sequentially stored in the at least one output buffer area, including:
- the output window data in the third buffer area is sequentially stored into the off-chip memory, including:
- the output window data obtained by performing the convolution calculation in response to all the input window data in the current calculation buffer area is stored, and the output window data in the current output buffer area is stored in the off-chip memory.
- the input buffer area is a column buffer area;
- the first buffer area is: a circular buffer formed by n+m column buffer areas, and each column buffer area Used to sequentially store the same column of data in all channels of the task to be processed;
- the to-be-processed data of a preset size in the to-be-processed task is read from the off-chip memory of the accelerator, and sequentially stored in the on-chip memory of the accelerator, at least one input of the first buffer area.
- Cache area including:
- the first n columns of data of all channels of the task to be processed are read from the off-chip memory for the first time, and the column data of the first n columns of data are correspondingly stored in the first buffer area, and the first n column buffers are determined based on the predetermined cycle direction.
- the district In the district;
- the adjacent subsequent m-column data of all channels of the to-be-processed task is read from the off-chip memory, and each row of data in the m-column data read this time is correspondingly stored in the first buffer area, based on a predetermined cycle direction. Determined in the adjacent subsequent m column buffers.
- the to-be-processed data of a preset size in the to-be-processed task is read from the off-chip memory of the accelerator, and sequentially stored in the on-chip memory of the accelerator, at least one input buffer area of the first buffer area, include:
- the column data in the first n columns of data are respectively correspondingly stored in the first n column buffer regions determined in the first buffer area and determined based on the predetermined cycle direction; n columns of data that are not read for the first time, based on the predetermined cycle direction, the first n column buffers of the n columns of data that were last read in the first buffer area are swept by m columns and the corresponding n column buffers are used as the current
- the target column buffer area of the n column data is read, and the n column data read this time is correspondingly stored in each column buffer in the target column buffer area.
- the input window data to be processed is sequentially read from the at least one input buffer area, and the convolution calculation is performed on the input window data to be processed by the convolution kernel data, including:
- the first n column buffer areas are selected as the current calculation buffer area, and the size of the current calculation buffer area is read as n ⁇ n according to the sliding step size m.
- the output buffer may also include m column buffers.
- the output window data is obtained and sequentially stored in at least one output buffer, including:
- the output window data in the third buffer area is sequentially stored into the off-chip memory, including:
- the output window data obtained by performing the convolution calculation in response to all the input window data in the current calculated column buffer is stored, and the output window data in the current output buffer is stored in the off-chip memory.
- the input buffer area is similar to the technical solution of the input buffer area being a line buffer area, and related places may be referred to each other.
- FIG. 3 is a flow chart of one embodiment of convolution calculation of input window data to be processed in an embodiment of the present application. As shown in FIG. 3, the convolution calculation is performed on the input window data to be processed by the convolution kernel data, and the output window data is obtained, including:
- the at least one set of convolution kernel data in the foregoing embodiment includes at least one set of converted convolution kernels, wherein any one of the converted convolution kernels corresponds to an output channel by a corresponding first constant matrix pair.
- the convolution kernel is obtained by conversion.
- the operation 302 may be performed by a processor invoking a corresponding instruction stored in a memory or by a processing unit executed by the processor.
- the following operations may also be performed: using corresponding first constant matrices, respectively corresponding to at least one output channel
- the convolution kernel is converted to obtain at least one set of converted convolution kernels.
- the corresponding first constant matrix may be used to convert the convolution kernel corresponding to the at least one output channel to obtain at least one set of converted convolution kernels, and stored in the second buffer. In this way, the temporary execution of the operation consumes computing resources, which further improves the calculation efficiency.
- the operation 304 may be performed by a processor invoking a corresponding instruction stored in a memory or by an accumulation unit executed by the processor.
- converting the input window data to be processed by using the corresponding second constant matrix may be implemented by: following the logic in the accelerator according to the corresponding second constant matrix.
- the resource performs a bit operation on the input window data to be processed in any input channel.
- converting the dot-multiplied matrix by using the corresponding third constant matrix may be implemented by: respectively, according to the corresponding third constant matrix, the dot-multiplied matrix of any input channel is respectively performed by the logic resources in the accelerator. Bit operation.
- converting the convolution kernel corresponding to the at least one output channel by using the corresponding first constant matrix may be implemented by: corresponding to the corresponding first constant matrix, the logical resources in the accelerator respectively correspond to The convolution kernel of at least one output channel performs a bit operation.
- the logic resources in the accelerator are used to realize the conversion operation of the input window data, the convolution kernel data, and the point multiplication matrix by binary bit operation, so that it is not necessary to set a multiplier in the accelerator to implement the corresponding conversion operation, thereby reducing the number of conversion operations.
- the number of multiplications in the convolution calculation saves the digital signal processor (DSP) resources in the accelerator, thereby improving the calculation efficiency of the accelerator and improving the utilization of DSP resources in the accelerator.
- DSP digital signal processor
- the method may further include:
- the first constant matrix corresponding to the size r ⁇ r of the convolution kernel and the size n ⁇ n of the input window shown as: G in the embodiment of the present application
- the second constant matrix is queried (this application)
- B a third constant matrix
- the first matrix, the second constant matrix, and the third constant matrix respectively corresponding to the size of the at least one convolution kernel and the size of the input window are respectively preset in the constant matrix table, that is, the size and input window of the convolution kernel. After the size is determined, the first constant matrix, the second constant matrix, and the third constant matrix can be determined.
- calculation operations are performed for any input channel, respectively, including: performing computation processing operations for Pm output channels and Pn input channels simultaneously, where Pm and Pn are respectively An integer greater than 0.
- operation 304 is: for Pm output channels, in response to obtaining convolution results of all input channels, respectively accumulating corresponding points in the convolution results of all input channels for the same output channel to obtain Pm outputs. The output window data of the channel.
- the value of Pm is 1, and the value of Pn is an integer greater than 1.
- the calculation processing operation for Pm output channels and Pn input channels may include: sequentially for one output channel, All input channels or some input channels in all input channels perform calculation processing operations in parallel. With this embodiment, parallel processing for one output channel, Pn input channels at a time is achieved.
- the value of Pm is the total number of output channels, and the value of Pn is 1.
- the calculation processing operation is performed for Pm output channels and Pn input channels at the same time, which may include: simultaneously targeting all output channels. , in turn performing computational processing operations on one input channel;
- operation 304 may include, for all output channels, in response to obtaining convolution results for all input channels, accumulating corresponding points in the convolution results of all input channels for the same output channel, respectively, to obtain all output channels Output window data.
- the value of Pm is greater than 1 and less than the total number of output channels, and the value of Pn is 1.
- the calculation processing operation is performed for Pm output channels and Pn input channels simultaneously, including: Part of the output channels in the output channel, in turn, perform computational processing operations on one input channel.
- FIG. 4 it is a schematic diagram of performing computation processing operations on Pn input channels in parallel in the embodiment of the present application.
- Pn input channels are only a part of all input channels, and corresponding convolution results are accumulated to form a corresponding
- the accumulated results of all the groups corresponding to all input channels are added to obtain output window data of one output channel.
- the method may further include:
- the optimal value of the parameter in the convolution calculation is obtained by the transmission bandwidth of the FIFO port and the resource condition of the accelerator, wherein the parameters in the convolution calculation include: the size of the input window, the parallelism of the output channel, and the input channel.
- the degree of parallelism, the optimal values of the above parameters include: the optimal value of the size of the input window n, the optimal value Pm of the parallelism of the output channel, and the optimal value Pn of the parallelism of the input channel.
- the data to be processed of a preset size in the to-be-processed task is sequentially read from the off-chip memory of the accelerator through the FIFO port, and may include:
- the accelerator receives the task processing instruction sent by the processor through the FIFO port, and sequentially reads the to-be-processed data of the preset size in the to-be-processed task from the off-chip memory of the accelerator through the FIFO port.
- the convolution acceleration method of the embodiment of the present application may further include:
- the accelerator feeds back to the processor a response message of the task completion through the FIFO port.
- the above operations for obtaining the optimal values of the parameters in the convolution calculation may be performed by a processor such as a central processing unit (CPU) or an advanced RISC machine (ARM).
- CPU central processing unit
- ARM advanced RISC machine
- the CPU, ARM and other processors obtain the optimal values of the parameters in the convolution calculation, and use the optimal values of the parameters in the convolution calculation to configure the accelerator.
- the accelerator can execute the corresponding acceleration method flow based on the optimal value of the above parameters, and process the processing task, thereby achieving optimal resource utilization and maximizing the acceleration effect for the accelerator.
- Pm output channels and Pn input channels are sequentially selected based on the values of Pm and Pn in the optimal values of parameters, and Pm outputs are simultaneously selected.
- the channel and Pn input channels perform computational processing operations.
- the method may further include:
- the right side of the convolution kernel of the current task to be processed is filled with a column 0 and the bottom is filled with b row 0, respectively, so that the convolution kernel of the current task to be processed is converted into a new convolution kernel of size tr ⁇ tr.
- k, t, a, and b are respectively integers greater than 0.
- the size of the convolution kernel required for the task to be processed this time corresponds to the existing accelerator.
- the size of the convolution kernel required for the task to be processed can be converted into a convolution kernel corresponding to the t2 accelerators, thereby realizing a convolution kernel corresponding to the existing accelerator.
- the multiplexing avoids the recalculation of acquiring the first constant matrix, the second constant matrix, and the third constant matrix, and re-converting based on the convolution kernel, improving processing efficiency.
- the accelerator of the embodiment of the present application can be used in the acceleration of convolution calculation of any network layer in the CNN, for example, can be used for convolution layer, full connection (FC), pooling, activation function ReLU (linear) in CNN Correction unit), padding, upsample, etc. Convolution acceleration operation of the network layer.
- the exemplary description of the embodiments of the present application does not constitute a limitation on the application environment of the embodiment of the present application, in addition to the convolution acceleration in the CNN, and other convolution operations with any other non-CNN.
- the method may further include:
- the calculation result data in the third buffer area is sequentially stored into the off-chip memory through the FIFO port.
- the method may further include:
- the to-be-processed data of a preset size in the to-be-processed task is sequentially read from the off-chip memory of the accelerator through the FIFO port, and stored in the first buffer area;
- the calculation result data in the third buffer area is sequentially stored into the off-chip memory through the FIFO port.
- the method may further include:
- the to-be-processed data of a preset size in the to-be-processed task is sequentially read from the off-chip memory of the accelerator through the FIFO port, and stored in the first buffer area;
- the calculation result of 0 as any data is stored in the third buffer area; if the value of any data is not less than 0, the value of any data is directly stored as the calculation result. In the three buffer area;
- the calculation results in the third buffer area are sequentially stored into the off-chip memory through the FIFO port.
- the method may further include:
- an element data in the task to be processed is sequentially read from the off-chip memory of the accelerator through the FIFO port, and the element data is copied into an element matrix of 2s ⁇ 2s, with the element matrix as the to-be-processed
- the data begins to perform an operation of sequentially storing at least one input buffer of the first buffer in the on-chip memory of the accelerator; wherein the value of s is an integer greater than zero.
- the method may further include:
- all data of the task to be processed is read from the off-chip memory of the accelerator through the FIFO port, and stored in the first buffer area;
- the edge data is to be filled according to the preset manner, so that the data size of the to-be-processed task after the filling is equal to the preset size, and the filled pending task is stored in the first If the data size of the to-be-processed task is not less than the preset size, the task to be processed is directly stored in the third buffer area;
- the to-be-processed task data in the third buffer area is sequentially stored into the off-chip memory through the FIFO port.
- the convolution calculation processing method of the embodiment of the present application includes, for each input channel and any output channel:
- the operation 602 may be performed by a processor invoking a corresponding instruction stored in a memory, or may be performed by a first conversion module executed by the processor.
- a digital signal processor may be used to perform a matrix point multiplication operation on the converted input window data and the convolution kernel data to obtain a dot-multiplied matrix U ⁇ V.
- a matrix point multiplication operation can be performed on the converted input window data V and the convolution kernel data U by the formula U ⁇ V to obtain a point multiplied matrix.
- the convolution kernel data U is obtained by converting a pre-set convolution kernel (indicated as: X in the embodiment of the present application) by the corresponding first constant matrix G.
- the operation 604 may be performed by a processor invoking a corresponding instruction stored in a memory, or by a point multiply module executed by the processor.
- the third constant matrix A is a third constant matrix corresponding to the output window size and the convolution kernel size.
- the operation 606 may be performed by a processor invoking a corresponding instruction stored in a memory or by a second conversion module executed by the processor.
- the input window data to be processed by the second constant matrix may be converted for any input channel and any output channel, and the input window data after conversion is obtained;
- the input window data and the convolution kernel data are subjected to matrix point multiplication operation to obtain a point multiplied matrix;
- the third constant matrix is used to convert the dot multiplied matrix to obtain a convolution result.
- the embodiment of the present application provides a method for face-to-face convolution calculation of input window data based on the Winograd algorithm, which reduces the number of multiplications compared to the conventional point-to-point convolution algorithm, thereby reducing the occupation of processor resources, and Increased computational efficiency.
- the embodiments of the present application can be applied to hardware platforms such as an FPGA and an ASIC to implement convolution acceleration processing on a hardware platform such as an FPGA or an ASIC.
- the FPGA platform can be fully utilized for reconfigurable and parallel computing. Sex, short development cycle, low power consumption, high flexibility.
- the method may further include:
- the convolution kernel X of any of the output channels is converted by the first constant matrix G corresponding to the output window size and the convolution kernel size in advance, and the convolution kernel data U is obtained and stored.
- each convolution kernel data corresponds to one input channel respectively.
- FIG. 7 is a flow chart of another embodiment of a convolution calculation processing method of the present application.
- the method may further include:
- the first constant matrix G is a first constant matrix corresponding to an output window size and a convolution kernel size.
- the operation 600 may be performed by a processor invoking a corresponding instruction stored in a memory, or may be performed by a third conversion module executed by the processor.
- the input window data to be processed is converted by using the second constant matrix, which may be: performing bit operations on the input window data to be processed by the logic resources in the accelerator according to the second constant matrix; using the third constant matrix pair
- the matrix is converted, which may be: according to the third constant matrix, the bitwise multiplication of the matrix is performed by using the logic resources in the accelerator;
- the first constant matrix is used to convert the convolution kernel, which may be: according to the first
- the constant matrix uses a logic resource in the accelerator to perform bit operations on the convolution kernel.
- the logic operation in the accelerator is used to perform the bit operation, thereby realizing the conversion of the convolution kernel, the input window data, and the dot-multiplied matrix without using DSP resources, reducing the number of multiplications and saving DSP resources, thereby improving the accelerator.
- the method may further include:
- n and r are respectively integers greater than 0; the constant matrix table is pre-set with a first constant matrix, a second constant matrix, and a third corresponding to the size of at least one convolution kernel and the size of the input window, respectively. Constant matrix.
- the method may further include:
- any output channel in response to obtaining a convolution result of all the input channels, accumulate corresponding points in the convolution results of all input channels corresponding to any of the output channels to obtain output window data of any output channel. That is, through a set of convolution kernel data corresponding to an output channel, using the flow of the embodiment shown in FIG. 7, convolution calculation is performed on input window data of all input channels to obtain output window data of the output channel.
- the output window data of one output channel is represented by Out
- the operation 608 may be performed by a processor invoking a corresponding instruction stored in a memory, or may be performed by an accumulation unit executed by the processor.
- the convolution calculation processing method of the embodiment shown in FIG. 8 corresponds to the operation of 302 in the embodiment shown in FIG. 3, that is, the operation 302 in the embodiment of the at least one convolution acceleration method can be processed by at least one convolution calculation of the present application.
- the corresponding operations in the method embodiments are implemented.
- the embodiment shown in FIG. 8 corresponds to at least one embodiment shown in FIG. 6 and FIG. 7.
- the embodiments of the present application can refer to each other.
- FIG. 8 is a schematic diagram of a calculation process of the embodiment shown in FIGS. 3, 7, and 8. As shown in FIG. 8, the convolution calculation processing method of the embodiment of the present application can be divided into four stages: stage 1 (stage 1) represents the stages of operations 600 and 602 in FIGS.
- stage 2 represents the diagram. 6 to the stage of operation 604 in FIG. 7
- stage 3 represents the stage of operation 606 in FIGS. 6-7
- stage 4 represents the stage of operation 608 in FIG.
- stage1 to stage3 also represent the stage of operation 302 in the embodiment shown in Fig. 3
- stage 4 also represents the stage of operation 304 in the embodiment shown in Fig. 3.
- any of the methods provided by the embodiments of the present application may be performed by any suitable device having data processing capabilities, including but not limited to: a terminal device and a server.
- any of the methods provided by the embodiments of the present application may be executed by a processor, such as a processor, by executing a corresponding instruction stored in a memory to perform any one of the methods mentioned in the embodiments of the present application. This will not be repeated below.
- the foregoing program may be stored in a computer readable storage medium, and the program is executed when executed.
- the method includes the steps of the foregoing method embodiments; and the foregoing storage medium includes at least one medium that can store program codes, such as a ROM, a RAM, a magnetic disk, or an optical disk.
- FIG. 9 is a schematic structural view of an embodiment of a convolution accelerator of the present application.
- the convolution accelerator of this embodiment can be used as an accelerator in at least one of the above embodiments of the present application to implement the function of the accelerator in the above-described embodiment of at least one convolution acceleration method of the present application.
- the accelerator in at least one embodiment of the present application may be, for example, an embedded platform such as an FPGA or an ASIC.
- the accelerator of this embodiment includes: a data reading module, a first buffer area, a second buffer area, a calculation module, a third buffer area, and a data output module. among them:
- a data reading module configured to sequentially read, by the FIFO port, the to-be-processed data of a preset size in the to-be-processed task from the off-chip memory of the accelerator, and store the data in the at least one input buffer area of the first buffer area.
- the task to be processed may include, for example, an input image of at least one input channel, or an input feature map of at least one input channel.
- each set of convolution kernel data corresponds to one output channel
- each set of convolution kernel data includes at least one convolution kernel data
- each convolution kernel data corresponds to one input channel.
- the first buffer area includes at least one input buffer for buffering data to be processed.
- a second buffer area for buffering at least one set of convolution kernel data.
- a calculation module configured to read the input window data to be processed from at least one input buffer area in turn when the data to be processed is stored in the input buffer area, and perform convolution calculation on the input window data to be processed by the convolution kernel data , the output window data is obtained and stored in the third buffer area.
- the third buffer area includes at least one output buffer area for buffering output window data.
- the data output module is configured to sequentially store the output window data in the third buffer area into the off-chip memory through the FIFO port.
- the on-chip memory includes a first buffer area, a second buffer area, and a third buffer area, where the first buffer area includes at least one input buffer area, and the second buffer area has at least one buffer cache.
- Group convolution kernel data Reading, by the FIFO port, the to-be-processed data of a preset size in the to-be-processed task from the on-chip memory of the accelerator, and storing the at least one input buffer area of the first buffer area in the on-chip memory of the accelerator; responsive to having an input buffer area Depositing data to be processed, sequentially reading the input window data to be processed from at least one input buffer area, and performing convolution calculation on the input window data to be processed by convolution kernel data, obtaining output window data and storing in the third buffer area And then output the output window data in the third buffer area to the off-chip memory through the FIFO port.
- the embodiment of the present application reads the to-be-processed data of the preset size from the off-chip memory of the accelerator into the on-chip memory for processing, and realizes that the to-be-processed data is read from the off-chip memory and stored in the on-chip memory, and
- the pipeline processing of the two processes of convolution calculation processing for processing data can avoid the situation that the memory and bandwidth of the accelerator are insufficient, the processor resources are limited, and the efficiency of the convolution calculation processing is improved, and can be applied to hardware platforms such as FPGA and ASIC. Therefore, the acceleration processing of CNN is implemented on a hardware platform such as an FPGA or an ASIC.
- the FPGA platform can be fully utilized for reconfigurability, parallel computing, short development cycle, low power consumption, high flexibility, etc. advantage.
- the data output module is configured to: in response to the first output buffer storing the output window data, sequentially reading the output window data in the at least one output buffer, and passing the FIFO The port stores the read output window data into off-chip memory.
- the third buffer area includes two output buffer areas.
- one of the output buffers of the two output buffers is stored in the output window data, the output window data is read, and the other output buffer in the two output buffers is read in turn.
- Output window data and store it in the output window data.
- the other is read out of the window data.
- the other is stored in the window data, thereby implementing the storage and output window.
- Pipeline processing of data and read output window data further enhances the efficiency of the accelerator.
- the first buffer area includes two input buffers.
- one of the input buffers of the two input buffers is stored in turn to be processed data, read the input window data to be processed, and another input buffer in the two input buffers.
- the input window data to be processed is read in turn and stored in the data to be processed.
- the other input window data to be processed is read in the previous one.
- the other is stored in the data to be processed, thereby implementing pipeline processing for storing the data to be processed and reading the input window data to be processed.
- the size of the convolution kernel corresponding to the convolution kernel data is represented as r ⁇ r
- the size of the input window corresponding to the input window data is represented as n ⁇ n
- the sliding step of the input window corresponding to the input window data is
- the size of the output window is expressed as m.
- the input buffer area is a line buffer area
- the first buffer area is: a circular buffer formed by n+m line buffer areas, and each line buffer area is used for Stores the same row of data in all channels of the pending task in sequence.
- the data reading module is used to:
- the first n rows of data of all channels of the to-be-processed task are read from the off-chip memory for the first time, and each row of data of the first n rows of data is correspondingly stored in the first buffer area, and the first n row buffer regions determined based on the predetermined cycle direction are respectively corresponding. in;
- each subsequent row of m rows of data of the to-be-processed task is read from the off-chip memory, and each row of the m rows of data to be read is correspondingly stored in the first buffer zone, based on a predetermined cycle direction. Determined in the adjacent subsequent m line buffers; or
- the data reading module is used to:
- each row of the first n rows of data is correspondingly stored in the first buffer area determined in the first buffer area and determined based on the predetermined cycle direction;
- the n rows of data read for the first time based on the predetermined cycle direction, store the first n row buffers of the n rows of data read last time in the first buffer area, and the corresponding n row buffers after the m rows are used as the current read.
- the target row buffer area of the n rows of data is fetched, and the n rows of data read this time are correspondingly stored in the row buffers in the target row buffer area.
- the computing module sequentially reads the input window data to be processed from the at least one input buffer, and performs convolution calculation on the input window data to be processed by the convolution kernel data, for:
- the first n line buffer areas are selected as the current calculation buffer area, and the size of the current calculation buffer area is read as n ⁇ n according to the sliding step size m.
- each output buffer includes m line buffers.
- the calculation module obtains the output window data and sequentially stores it in at least one output buffer area, it is used for:
- a data output module configured to: output the output window data obtained by performing convolution calculation in response to all the input window data in the current calculation buffer area, and store the output window data in the current output buffer area to the off-chip through the FIFO port In memory.
- the input buffer area is a column buffer area; the first buffer area is: a circular buffer formed by n+m column buffer areas, and each column buffer area is used for Stores the same column of data in all channels of the pending task in sequence.
- the data reading module is used to:
- the first n columns of data of all channels of the task to be processed are read from the off-chip memory for the first time, and the column data of the first n columns of data are correspondingly stored in the first buffer area, and the first n column buffers are determined based on the predetermined cycle direction.
- the district In the district;
- the adjacent subsequent m-column data of all channels of the to-be-processed task is read from the off-chip memory, and each row of data in the m-column data read this time is correspondingly stored in the first buffer area, based on a predetermined cycle direction. Determined in the adjacent subsequent m column buffers.
- the calculating module sequentially reads the input window data to be processed from the at least one input buffer, and performs convolution calculation on the input window data to be processed by the convolution kernel data, including:
- the first n column buffer areas are selected as the current calculation buffer area, and the size of the current calculation buffer area is read as n ⁇ n according to the sliding step size m.
- the column data in the first n columns of data are respectively correspondingly stored in the first n column buffer regions determined in the first buffer area and determined based on the predetermined cycle direction; n columns of data that are not read for the first time, based on the predetermined cycle direction, the first n column buffers of the n columns of data that were last read in the first buffer area are swept by m columns and the corresponding n column buffers are used as the current
- the target column buffer area of the n column data is read, and the n column data read this time is correspondingly stored in each column buffer in the target column buffer area.
- the output buffer includes m column buffers.
- the computing module obtains output window data and sequentially stores it in at least one output buffer for:
- the data output module is configured to: store the output window data obtained by performing convolution calculation in response to all the input window data in the current calculation buffer area, and store the output window data in the current output buffer area through the FIFO port. To the off-chip memory.
- FIG. 10 is a schematic structural diagram of an embodiment of a computing module in an embodiment of the present application.
- the calculation module includes: a processing unit (PE) and an accumulating unit.
- PE processing unit
- the convolution kernel data is a convolved convolution kernel.
- the convolution kernel data is a convolved convolution kernel.
- the processing unit is configured to perform the following calculation processing operations for each input channel: converting the input window data to be processed by using the corresponding second constant matrix to obtain the converted input window data; and converting the input window to any input channel
- the data and the converted convolution kernel are subjected to matrix point multiplication operation to obtain a point multiplied matrix; the corresponding third constant matrix is used to convert the point multiplied matrix to obtain a convolution result;
- the accumulating unit is configured to accumulate the corresponding points in the convolution results of all the input channels after obtaining the convolution result of all the input channels corresponding to one output channel, and obtain the output window data of one output channel.
- the convolution kernel data is an unconverted convolution kernel.
- the convolution kernel data is an unconverted convolution kernel.
- a processing unit configured to perform a calculation processing operation on each of the input channels: converting the convolution kernel corresponding to the at least one output channel by using the corresponding first constant matrix to obtain at least one set of converted convolution kernels And converting the input window data to be processed by using the corresponding second constant matrix to obtain the input window data after conversion; performing matrix point multiplication operation on the converted input window data of any input channel and the converted convolution kernel to obtain Dot-multiply the matrix; use the corresponding third constant matrix to convert the dot-multiplied matrix to obtain a convolution result;
- the accumulating unit is configured to accumulate corresponding points in the convolution result of all the input channels after obtaining the convolution result of all the input channels corresponding to one output channel, and obtain output window data of an output channel.
- the input window data to be processed when the input window data to be processed is converted by using the corresponding second constant matrix, the input window data to be processed of any input channel may be respectively bit according to the corresponding second constant matrix.
- Operation operation when the corresponding third constant matrix is used to convert the dot-multiplied matrix, the bit-multiplied matrix of any input channel may be bit-operated according to the corresponding third constant matrix; the corresponding first constant is adopted.
- the matrix when converting the convolution kernel corresponding to the at least one output channel, respectively, may perform a bit operation operation on the convolution kernel corresponding to the at least one output channel according to the corresponding first constant matrix.
- the calculation module includes Pm ⁇ Pn processing units for performing computation processing operations for Pm output channels and Pn input channels, wherein Pm and Pn are integers greater than 0, respectively.
- the accumulating unit is configured to accumulate corresponding points in the convolution result of all the input channels for the Pm output channels, in response to obtaining the convolution result of all the input channels, respectively, to obtain the Pm for the same output channel.
- the output window data of the output channels is configured to accumulate corresponding points in the convolution result of all the input channels for the Pm output channels, in response to obtaining the convolution result of all the input channels, respectively, to obtain the Pm for the same output channel.
- the value of Pm is 1, and the value of Pn is an integer greater than 1.
- the value of Pm is the total number of output channels, and the value of Pn is 1;
- the value of Pm is greater than 1 and less than the total number of output channels, and the value of Pn is 1.
- FIG. 11 is a schematic structural diagram of an embodiment of a convolution calculation processing apparatus of the present application.
- the convolution calculation processing apparatus of this embodiment can be used to implement the above-described at least one convolution calculation processing method embodiment of the present application.
- the convolution calculation processing apparatus of this embodiment includes: a first conversion module, a dot multiplication module, and a second conversion module. among them:
- the first conversion module is configured to convert the input window data to be processed by using the second constant matrix, and obtain the converted input window data.
- the point multiplication module is configured to perform matrix point multiplication operation on the converted input window data and the convolution kernel data to obtain a point multiplied matrix.
- the convolution kernel data is obtained by converting the pre-set convolution kernel by the corresponding first constant matrix.
- the second conversion module is configured to convert the point multiplied matrix by using a third constant matrix to obtain a convolution result.
- the convolution calculation processing apparatus may perform conversion on the input window data to be processed by using the second constant matrix for any input channel and any output channel, and obtain input window data after conversion;
- the input window data and the convolution kernel data are subjected to matrix point multiplication operation to obtain a point multiplied matrix;
- the third constant matrix is used to convert the dot multiplied matrix to obtain a convolution result.
- the embodiment of the present application provides a method for face-to-face convolution calculation of input window data based on the Winograd algorithm, which reduces the number of multiplications compared to the conventional point-to-point convolution algorithm, thereby reducing the occupation of processor resources, and Increased computational efficiency.
- the embodiments of the present application can be applied to hardware platforms such as an FPGA and an ASIC to implement convolution acceleration processing on a hardware platform such as an FPGA or an ASIC.
- the FPGA platform can be fully utilized for reconfigurable and parallel computing. Sex, short development cycle, low power consumption, high flexibility.
- FIG. 12 is a schematic structural diagram of another embodiment of a convolution calculation processing apparatus of the present application. As shown in FIG. 12, the convolution calculation processing apparatus of this embodiment further includes a third conversion module as compared with the embodiment shown in FIG.
- the third conversion module is configured to acquire pre-stored convolution kernel data.
- the third conversion module is configured to convert the input convolution kernel corresponding to any input channel and any output channel by using the corresponding first constant matrix to obtain any input channel and any output. Convolution kernel data corresponding to the channel.
- the first conversion module is configured to: perform a bit operation operation on the input window data to be processed respectively according to the corresponding second constant matrix;
- a second conversion module configured to: perform a bit operation on the matrix after the point multiplication according to the third constant matrix
- the third conversion module is configured to perform a bit operation on the convolution kernel according to the first constant matrix.
- the convolution calculation processing apparatus may further include:
- the query module respectively queries, from the constant matrix table, the size r ⁇ r of the convolution kernel corresponding to the convolution kernel data and the first constant matrix and the second constant matrix corresponding to the size n ⁇ n of the input window corresponding to the input window data. And a third constant matrix;
- n and r are respectively integers greater than 0; the constant matrix table is pre-set with a first constant matrix, a second constant matrix, and a third corresponding to the size of at least one convolution kernel and the size of the input window, respectively. Constant matrix.
- the embodiment of the present application further provides an electronic device, including the convolution accelerator of any of the above embodiments of the present application, or the convolution calculation processing device of any of the above embodiments of the present application.
- the embodiment of the present application further provides another electronic device, including:
- a memory for storing executable instructions
- a processor configured to communicate with the memory to execute executable instructions to perform the operations of any of the above-described convolution acceleration method embodiments of the present application, or the operations of any of the foregoing convolutional computing processing method embodiments of the present application.
- the embodiment of the present application further provides a computer storage medium for storing a computer readable instruction, when the instruction is executed, performing the operation of any of the foregoing convolution acceleration method embodiments of the present application, or any of the foregoing The operation of the embodiment of the convolution calculation processing method.
- FIG. 13 is a schematic structural diagram of an embodiment of an electronic device according to the present application.
- Figure 13 is a block diagram showing the structure of an electronic device suitable for implementing the embodiments of the present application.
- the electronic device includes a double rate synchronous dynamic random access memory (DDR SDRAM), a processing system (PS), and a programmable logic circuit (PL).
- DDR SDRAM double rate synchronous dynamic random access memory
- PS processing system
- PL programmable logic circuit
- the PL is provided with a convolution accelerator of the embodiment of the present application.
- FIG. 13 is only an optional implementation manner. In a specific practice, the number and type of the components in FIG. 13 may be selected, deleted, added, or replaced according to actual needs; Different functional component settings, such as separate settings or integrated settings, may also be employed, and all of these alternative embodiments fall within the scope of protection disclosed herein.
- Embodiments of the present application can be applied to electronic devices such as computer systems/servers that can operate with numerous other general purpose or special purpose computing system environments or configurations.
- Examples of well-known computing systems, environments, and/or configurations suitable for use with electronic devices such as computer systems/servers include, but are not limited to, embedded platforms, personal computer systems, server computer systems, thin clients, thick clients, Handheld or laptop devices, microprocessor based systems, set top boxes, programmable consumer electronics, networked personal computers, small computer systems, mainframe computer systems, and distributed cloud computing technology environments including any of the above, and the like.
- Electronic devices such as computer systems/servers can be described in the general context of computer system executable instructions (such as program modules) being executed by a computer system.
- program modules may include routines, programs, target programs, components, logic, data structures, and the like that perform particular tasks or implement particular abstract data types.
- the computer system/server can be implemented in a distributed cloud computing environment where tasks are performed by remote processing devices that are linked through a communication network.
- program modules may be located on a local or remote computing system storage medium including storage devices.
- the foregoing program may be stored in a computer readable storage medium, and the program is executed when executed.
- the foregoing steps include the steps of the foregoing method embodiments; and the foregoing storage medium includes: a medium that can store program codes, such as a ROM, a RAM, a magnetic disk, or an optical disk.
- the methods and apparatus of the present application may be implemented in a number of ways.
- the methods and apparatus of the present application can be implemented in software, hardware, firmware, or any combination of software, hardware, and firmware.
- the above-described sequence of steps for the method is for illustrative purposes only, and the steps of the method of the present application are not limited to the order specifically described above unless otherwise specifically stated.
- the present application can also be implemented as a program recorded in a recording medium, the programs including machine readable instructions for implementing the method according to the present application.
- the present application also covers a recording medium storing a program for executing the method according to the present application.
Landscapes
- Engineering & Computer Science (AREA)
- Physics & Mathematics (AREA)
- Theoretical Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Software Systems (AREA)
- Mathematical Physics (AREA)
- General Engineering & Computer Science (AREA)
- Data Mining & Analysis (AREA)
- Biophysics (AREA)
- Biomedical Technology (AREA)
- Life Sciences & Earth Sciences (AREA)
- Health & Medical Sciences (AREA)
- Computing Systems (AREA)
- Molecular Biology (AREA)
- Artificial Intelligence (AREA)
- Computational Linguistics (AREA)
- Evolutionary Computation (AREA)
- General Health & Medical Sciences (AREA)
- Computational Mathematics (AREA)
- Pure & Applied Mathematics (AREA)
- Mathematical Optimization (AREA)
- Mathematical Analysis (AREA)
- Neurology (AREA)
- Databases & Information Systems (AREA)
- Algebra (AREA)
- Complex Calculations (AREA)
- Memory System Of A Hierarchy Structure (AREA)
Abstract
一种卷积加速和计算处理方法、装置、电子设备及存储介质,其中,加速方法包括:通过FIFO端口依次从加速器的片外存储器读取待处理任务中预设大小的待处理数据,并存储在所述加速器的片上内存中第一缓存区的至少一个输入缓存区;响应于有输入缓存区中存入待处理数据,依次从至少一个输入缓存区读取待处理的输入窗口数据,并通过所述卷积核数据对所述待处理的输入窗口数据进行卷积计算,获得输出窗口数据并存储在第三缓存区中;通过FIFO端口依次将第三缓存区中的输出窗口数据存储至所述片外存储器中。本卷积加速和计算处理方法、装置、电子设备及存储介质可以避免加速器片上内存和带宽不足、处理器资源有限的情况,并且提高了卷积计算处理的效率,可以适用于FPGA、ASIC等硬件平台。
Description
本申请要求在2017年04月28日提交中国专利局、申请号为CN 201710300171.X、发明名称为“卷积加速和计算处理方法、装置、电子设备及存储介质”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
本申请涉及计算机视觉技术,尤其是一种卷积加速和计算处理方法、装置、电子设备及存储介质。
神经网络作为一种模仿生物神经结构的信息处理技术,在近年来得到了迅速的发展。神经网络有着非常强大的非线性映射能力,其中,深度卷积神经网络(Deep convolutional neural network,CNN)在图像分类、物体检测、语义分割等各种计算机视觉任务处理中,表现出了显著性能。
由于需要对图像中区域的特征图进行处理,CNN计算精度的提升,其计算复杂度也成倍增加。针对巨大的计算压力,采用图形处理器(Graphics Processing Unit,GPU)、现场可编程门阵列(Field Programmable Gate Array,FPGA)、专用集成电路(Application Specific Integrated Circuit,ASIC)等硬件加速器来加速CNN的计算过程。在现有加速器中,FPGA作为嵌入式平台中的高效加速器,拥有可重构、并行计算性、开发周期短、低功耗、灵活性高等特点,近年来,使用FPGA加速CNN的技术得到快速发展。
发明内容
本申请实施例提供一种使用FPGA加速CNN的技术方案,包括:卷积加速方法和加速器、卷积计算处理方法和装置、电子设备,计算机存储介质。
根据本申请实施例的一个方面,提供的一种卷积加速方法,包括:
通过先进先出FIFO端口依次从加速器的片外存储器读取待处理任务中预设大小的待处理数据,并存储在所述加速器的片上内存中第一缓存区的至少一个输入缓存区;其中,所述片上内存包括第一缓存区、第二缓存区和第三缓存区,所述第一缓存区包括至少一个输入缓存区,所述第二缓存区中缓存有至少一组卷积核数据;响应于有输入缓存区中存入待处理数据,依次从至少一个输入缓存区读取待处理的输入窗口数据,并通过所述卷积核数据对所述待处理的输入窗口数据进行卷积计算,获得输出窗口数据并存储在第三缓存区中;
通过FIFO端口依次将第三缓存区中的输出窗口数据存储至所述片外存储器中。
根据本申请实施例的另一个方面,提供的一种卷积计算处理方法,包括:
采用第二常数矩阵对待处理的输入窗口数据进行转换,获得转换后输入窗口数据;
对所述转换后输入窗口数据与卷积核数据进行矩阵点乘操作,获得点乘后矩阵;所述卷积核数据由第一常数矩阵对卷积核进行转换获得;
采用第三常数矩阵对所述点乘后矩阵进行转换,获得卷积结果。
根据本申请实施例的又一个方面,提供的一种卷积加速器,包括:
数据读取模块,用于通过FIFO端口依次从加速器的片外存储器读取待处理任务中预设大小的待处理数据,并存储在第一缓存区的至少一个输入缓存区;
第一缓存区,包括至少一个输入缓存区,用于缓存所述待处理数据;
第二缓存区,用于缓存至少一组卷积核数据;
计算模块,用于在有输入缓存区中存入待处理数据时,依次从至少一个输入缓存区读取待处理的输入窗口数据,并通过所述卷积核数据对所述待处理的输入窗口数据进行卷积计算,获得输出窗口数据并存储在第三缓存区中;
第三缓存区,包括至少一个输出缓存区,用于缓存输出窗口数据;
数据输出模块,用于通过FIFO端口,依次将第三缓存区中的输出窗口数据存储至所述片外存储器中。
根据本申请实施例的又一个方面,提供的一种卷积计算处理装置,包括:
第一转换模块,用于采用第二常数矩阵对待处理的输入窗口数据进行转换,获得转换后输入窗口数据;
点乘模块,用于对所述转换后输入窗口数据与卷积核数据进行矩阵点乘操作,获得点乘后矩阵;所述卷积核数据由第一常数矩阵对卷积核进行转换获得;
第二转换模块,用于采用第三常数矩阵对所述点乘后矩阵进行转换,获得卷积结果。
根据本申请实施例的又一个方面,提供的一种电子设备,包括本申请任一实施例所述的卷积加速器。
根据本申请实施例的又一个方面,提供的另一种电子设备,包括:
存储器,用于存储可执行指令;以及
处理器,用于与所述存储器通信以执行所述可执行指令从而完成本申请任一实施例所述的卷积加速方法的操作。
根据本申请实施例的又一个方面,提供的计算机存储介质,用于存储计算机可读取的指令,所述指令被执行时执行本申请任一实施例所述的卷积加速方法的操作。
根据本申请实施例的又一个方面,提供的又一种电子设备,包括本申请任一实施例所述的卷积计算处理装置。
根据本申请实施例的又一个方面,提供的另一种电子设备,包括:
存储器,用于存储可执行指令;以及
处理器,用于与所述存储器通信以执行所述可执行指令从而完成本申请任一实施例所述的卷积计算处理方法的操作。
根据本申请实施例的又一个方面,提供的计算机存储介质,用于存储计算机可读取的指令,所述指令被执行时执行本申请任一实施例所述的卷积计算处理方法的操作。
基于本申请上述实施例提供的卷积加速方法和加速器、及其相应的电子设备和计算机存储介质,加速器的片上内存包括第一缓存区、第二缓存区和第三缓存区,第一缓存区包括至少一个输入缓存区,第二缓存区中缓存有至少一组卷积核数据。通过FIFO端口依次从加速器的片外存储器读取待处理任务中预设大小的待处理数据,并存储在加速器的片上内存中第一缓存区的至少一个输入缓存区;响应于有输入缓存区中存入待处理数据,依次从至少一个输入缓存区读取待处理的输入窗口数据,并通过所述卷积核数据对所述待处理的输入窗口数据进行卷积计算,获得输出窗口数据并存储在第三缓存区中;然后通过FIFO端口依次将第三缓存区中的输出窗口数据存储至所述片外存储器中。本申请实施例每次从加速器的片外存储器读取待处理任务中预设大小的待处理数据存入片上内存进行处理,并实现了从片外存储器读取待处理数据存入片上内存、和对待处理数据进行卷积计算处理等过程的流水线处理,可以充分利用加速器较为有限的片上内存、带宽、DSP等资源,显著提高了卷积计算处理的效率,可以适用于FPGA、ASIC等硬件平台,从而在FPGA、ASIC等硬件平台上实现卷积加速处理,本申请实施例应用于FPGA平台时,可以充分发挥FPGA平台可重构、并行计算性、开发周期短、低功耗、灵活性高等优点。
基于本申请上述实施例提供的卷积计算处理方法和装置、及其相应的电子设备和计算机存储介质,可以针对任一输入通道和任一输出通道,采用第二常数矩阵对待处理的输入窗口数据进行转换,获得转换后输入窗口数据;对转换后输入窗口数据与卷积核数据进行矩阵点乘操作,获得点乘后矩阵;采用第三常数矩阵对点乘后矩阵进行转换,获得卷积结果。本申请实施例提供了一种基于Winograd算法对输入窗口数据进行面对面的卷积计算的方法,相对于传统的点对点的卷积算法,减少了乘法次数,从而减少了对处理器资源的占用,并提升了计算效率。本申请实施例可以应用于FPGA、ASIC等硬件平台,从而在FPGA、ASIC等硬件平台上实现卷积加速处理,本申请实施例应用于FPGA平台时,可以充分发挥FPGA平台可重构、并行计算性、开发周期短、低功耗、灵活性高等优点。
下面通过附图和实施例,对本申请的技术方案做进一步的详细描述。
构成说明书的一部分的附图描述了本申请的实施例,并且连同描述一起用于解释本申请的原理。
参照附图,根据下面的详细描述,可以更加清楚地理解本申请,其中:
图1为本申请卷积加速方法一个实施例的流程图;
图2为本申请实施例中片上内存的一个示例图;
图3为本申请实施例中对待处理的输入窗口数据进行卷积计算一个实施例的流程图;
图4为本申请实施例中对Pn个输入通道并行执行计算处理操作的示意图;
图5为本申请实施例中对Pm个输出通道并行执行计算处理操作的示意图;
图6为本申请卷积计算处理方法一个实施例的流程图;
图7为本申请卷积计算处理方法另一个实施例的流程图;
[根据细则91更正 11.07.2018]
图8为图3、图6、图7所示实施例的一个计算过程示意;
图8为图3、图6、图7所示实施例的一个计算过程示意;
图9为本申请卷积加速器一个实施例的结构示意图;
图10为本申请实施例中计算模块一个实施例的结构示意图;
图11为本申请卷积计算处理装置一个实施例的结构示意图;
图12为本申请卷积计算处理装置另一个实施例的结构示意图;
图13为本申请电子设备一个应用实施例的结构示意图。
现在将参照附图来详细描述本申请的各种示例性实施例。应注意到:除非另外具体说明,否则在这些实施例中阐述的部件和步骤的相对布置、数字表达式和数值不限制本申请的范围。
同时,应当明白,为了便于描述,附图中所示出的各个部分的尺寸并不是按照实际的比例关系绘制的。
以下对至少一个示例性实施例的描述实际上仅仅是说明性的,决不作为对本申请及其应用或使用的任何限制。
对于相关领域普通技术人员已知的技术、方法和设备可能不作详细讨论,但在适当情况下,所述技术、方法和设备应当被视为说明书的一部分。
应注意到:相似的标号和字母在下面的附图中表示类似项,因此,一旦某一项在一个附图中被定义,则在随后的附图中不需要对其进行进一步讨论。
本申请实施例可以应用于终端设备、计算机系统、服务器等电子设备,其可与众多其它通用或专用计算系统环境或 配置一起操作。适于与终端设备、计算机系统、服务器等电子设备一起使用的众所周知的终端设备、计算系统、环境和/或配置的例子包括但不限于:个人计算机系统、服务器计算机系统、瘦客户机、厚客户机、手持或膝上设备、基于微处理器的系统、机顶盒、可编程消费电子产品、网络个人电脑、小型计算机系统﹑大型计算机系统和包括上述任何系统的分布式云计算技术环境,等等。
终端设备、计算机系统、服务器等电子设备可以在由计算机系统执行的计算机系统可执行指令(诸如程序模块)的一般语境下描述。通常,程序模块可以包括例程、程序、目标程序、组件、逻辑、数据结构等等,它们执行特定的任务或者实现特定的抽象数据类型。计算机系统/服务器可以在分布式云计算环境中实施,分布式云计算环境中,任务是由通过通信网络链接的远程处理设备执行的。在分布式云计算环境中,程序模块可以位于包括存储设备的本地或远程计算系统存储介质上。
图1为本申请卷积加速方法一个实施例的流程图。如图1所示,本申请实施例卷积加速方法包括:
102,通过先进先出(First Input First Output,FIFO)端口依次从加速器的片外存储器读取待处理任务中预设大小的待处理数据,并存储在加速器的片上内存中第一缓存区的至少一个输入缓存区;以及响应于有输入缓存区中存入待处理数据,依次从至少一个输入缓存区读取待处理的输入窗口数据,并通过卷积核数据对待处理的输入窗口数据进行卷积计算,获得输出窗口数据并存储在第三缓存区中。
其中,片上内存包括第一缓存区、第二缓存区和第三缓存区,第一缓存区包括至少一个输入缓存区,第二缓存区中缓存有至少一组卷积核数据。
本申请各实施例的卷积加速方法可应用于任何加速器,特别是在片上内存和带宽资源相对较小的FPGA、ASIC等嵌入式平台。
本申请各实施例中,待处理任务例如可以包括:至少一个通道的输入图像、或者至少一个通道的输入特征图,待处理任务处理完成后,可以得到至少一个通道的输出特征图。为了便于对输入图像、输入特征图和输出特征图的通道进行区分,本申请各实施例中,将输入图像、输入特征图的通道称为输入通道,将输出特征图的通道称为输出通道。输入图像、输入特征图的每个灰度对应一个通道,例如,红绿蓝(RGB)三种色彩的输入图像、输入特征图分别对应一个通道,同时包含红绿蓝三种色彩的输入图像、输入特征图具有三个输入通道。另外,每组卷积核数据分别对应于一个输出通道,每组卷积核数据包括至少一个卷积核数据,每个卷积核数据分别对应于一个输入通道。
在一个可选示例中,该操作102可以由处理器调用存储器存储的相应指令执行,也可以由被处理器运行的数据读取模块和计算模块执行。
104,通过FIFO端口依次将第三缓存区中的输出窗口数据存储至片外存储器中。
基于本申请上述实施例提供的卷积加速方法,加速器的片上内存包括第一缓存区、第二缓存区和第三缓存区,第一缓存区包括至少一个输入缓存区,第二缓存区中缓存有至少一组卷积核数据。通过FIFO端口依次从加速器的片外存储器读取待处理任务中预设大小的待处理数据,并存储在加速器的片上内存中第一缓存区的至少一个输入缓存区;响应于有输入缓存区中存入待处理数据,依次从至少一个输入缓存区读取待处理的输入窗口数据,并通过卷积核数据对待处理的输入窗口数据进行卷积计算,获得输出窗口数据并存储在第三缓存区中;然后通过FIFO端口依次将第三缓存区中的输出窗口数据存储至片外存储器中。本申请实施例每次从加速器的片外存储器读取待处理任务中预设大小的待处理数据存入片上内存进行处理,实现了从片外存储器读取待处理数据存入片上内存、和对待处理数据进行卷积计算处理等过程的流水线处理,可以充分利用加速器较为有限的片上内存、带宽、DSP等资源,显著提高了卷积计算处理的效率,可以适用于FPGA、ASIC等硬件平台,从而在FPGA、ASIC等硬件平台上实现卷积加速处理,本申请实施例应用于FPGA平台时,可以充分发挥FPGA平台可重构、并行计算性、开发周期短、低功耗、灵活性高等优点。
在一个可选示例中,该操作104可以由处理器调用存储器存储的相应指令执行,也可以由被处理器运行的数据输出模块执行。
在图1所示实施例的一个可选示例中,第一缓存区包括两个输入缓存区。在待处理任务的处理过程中,这两个输入缓存区的其中一个输入缓存区被轮流存入待处理数据、读取待处理的输入窗口数据,两个输入缓存区中的另一个输入缓存区被轮流读取待处理的输入窗口数据、存入待处理数据,两个输入缓存区中一个被存入待处理数据时,另一个被读取待处理的输入窗口数据,在前述一个被读取待处理的输入窗口数据时,另一个被存入待处理数据,从而实现存入待处理数据、读取待处理的输入窗口数据的流水线处理,重叠存入待处理数据所需时间和读取待处理的输入窗口数据所需时间,减少整个加速过程所需时间,提高了CNN的加速效率。
本申请实施例中,将卷积核数据对应的卷积核的尺寸表示为r×r,输入窗口数据对应的输入窗口的尺寸表示为n×n,输入窗口数据对应的输入窗口的滑动步长表示为m,输入窗口数据对应的输出窗口的尺寸表示为m×m。其中,r、m、n的取值分别为大于0的整数,且满足n=m+r-1。由此,m的取值小于或等于n的取值。在r的取值大于1时,m的取值均小于n的取值。在r的取值为1时,m的取值等于n的取值。
在图1所示实施例的另一个可选示例中,输入缓存区为行缓存区,第一缓存区为:由n+m个行缓存区形成的循环缓冲区,每个行缓存区用于顺序存储待处理任务所有通道中的同一行数据。如图2所示,为本申请实施例中片上内存的一个示例图。其中,M表示输入特征图的通道数,即:输入通道数,H表示输入特征图的高度,W表示输入特征图的宽度,M×W表示输入特征图的尺寸,计算模块表示用于对第一缓存区中的输入窗口数据进行卷积计算的单元,C表示输出特征图的通道数,即:输出通道数,R表示输出特征图的高度,N表示输出特征图的宽度,N×C表示输入特征图的尺寸。
相应地,在该另一个可选示例中,从加速器的片外存储器读取待处理任务中预设大小的待处理数据,并依次存储在加速器的片上内存中、第一缓存区的至少一个输入缓存区,包括:
首次从片外存储器读取待处理任务所有通道的前n行数据,并将前n行数据中的各行数据分别对应存储在第一缓存区中、基于预定循环方向确定的前n个行缓存区中;
之后每次从片外存储器读取待处理任务所有通道的相邻后续m行数据,并将本次读取的m行数据中的各行数据分别对应存储在第一缓存区中、基于预定循环方向确定的相邻后续m个行缓存区中。
由此,在r的取值为1时,m的取值等于n的取值,此时每次均从片外存储器读取待处理任务所有通道的m(=n)行数据,与上次读取的数据不重叠的相邻存入第一缓存区中的m个行缓存区中。
在r的取值大于1时,m的取值均小于n的取值,此时非首次读取从片外存储器读取待处理任务的数据的行数m小于首次读取的数据的行数n,可以与上次读取的数据不重叠的相邻存入第一缓存区中的m个行缓存区中;也可以每次均从片外存储器读取待处理任务所有通道的相邻后续n行数据,并将其存入第一缓存区中、基于预定循环方向确定的n个行缓存区中,非首次存入数据的n个行缓存区包括上次缓存数据的最后(r-1)个行缓存区和相邻后续m个行缓存区中,此时会发生上述r-1个行缓存区数据的重叠覆盖。相对于每次从片外存储器读取n行数据存入第一缓存区中而言,非首次每次从片外存储器读取m行数据存入第一缓存区中的方案,可以减少数据传输量,从而节约传输带宽,提高数据读取、传输和存入效率。
例如,n=6、m=4、r=3时,可以首次从片外存储器读取待处理任务所有通道的前6行数据存入第一缓存区中、基于预定循环方向确定的前n个行缓存区中。后续每次从片外存储器读取待处理任务所有通道的相邻后续4行数据,并将本次读取的4行数据中的各行数据分别对应存储在第一缓存区中、基于预定循环方向确定的相邻后续4个行缓存区中;或者,也可以后续每次从片外存储器读取待处理任务所有通道的相邻后续6行数据,并将本次读取的6行数据存储在第一缓存区中、基于预定循环方向确定的,由相邻后续4个行缓存区与上次存入数据的最后2个行缓存区中确定的6个行缓存区中。
或者,在又一个可选示例中,从加速器的片外存储器读取待处理任务中预设大小的待处理数据,并依次存储在加速器的片上内存中、第一缓存区的至少一个输入缓存区,包括:
每次从片外存储器读取待处理任务所有通道的n行数据;
对于首次从待处理任务中读取的前n行数据,将前n行数据中的各行数据分别对应存储在第一缓存区中、基于预定循环方向确定的前n个行缓存区中;对于非首次读取的n行数据,基于预定循环方向,将第一缓存区中存储上一次读取的n行数据的前n个行缓冲区滑动m行后对应的n个行缓冲区作为本次读取的n行数据的目标行缓存区,并将本次读取的n行数据对应存入目标行缓存区中的各行缓冲区中。
在该又一个可选示例中,将非首次读取的n行数据存入第一缓存区中时,会覆盖掉上一次存入第一缓存区中的n个行缓存区中的最后n-m个行缓存区中的数据。与上述另一个可选示例和又一个可选示例相应地,依次从至少一个输入缓存区读取待处理的输入窗口数据,并通过卷积核数据对待处理的输入窗口数据进行卷积计算,包括:
针对待处理任务,首次读取待处理的输入窗口数据时,选取前n个行缓存区作为当前计算缓存区,按照滑动步长m,依次顺序从当前计算缓存区读取大小为n×n的输入窗口数据,并通过卷积核数据对待处理的输入窗口数据进行卷积计算,直至当前计算缓存区中的待处理数据均被读取;
之后每次基于预定循环方向,按照滑动步长m从上一计算缓存区开始滑动,选取n个行缓存区作为新的计算缓存区,按照滑动步长m,依次顺序从新的计算缓存区读取大小为n×n的输入窗口数据,并通过卷积核数据对待处理的输入窗口数据进行卷积计算,直至新的计算缓存区中的待处理数据均被读取。
另外,在本申请上述各卷积加速方法实施例中,第三缓存区包括至少一个输出缓存区,则获得输出窗口数据并存储在第三缓存区中时,是获得输出窗口数据并依次存储在至少一个输出缓存区中;相应地,操作104包括:响应于首个输出缓存区存入输出窗口数据,依次读取至少一个输出缓存区中的输出窗口数据,并通过FIFO端口将读取的输出窗口数据存储至片外存储器中。
可选地,第三缓存区可以包括两个输出缓存区。在待处理任务的处理过程中,两个输出缓存区的其中一个输出缓存区被轮流存入输出窗口数据、读取输出窗口数据,两个输出缓存区中的另一个输出缓存区被轮流读取输出窗口数据、存入输出窗口数据。两个输出缓存区中一个被存入输出窗口数据时,另一个被读取输出窗口数据,在前述一个被存入输出窗口数据时,另一个被存入输出窗口数据,从而实现存入输出窗口数据、读取输出窗口数据的流水线处理,重叠存入输出窗口数据所需时间和读取输出窗口数据所需时间,进一步减少了整个加速过程所需时间,提升了加速器的工作效率。
可选地,每个输出缓存区可以包括m个行缓存区。相应地,上述各实施例中,获得输出窗口数据并依次存储在至少一个输出缓存区中,包括:
选取其中一个输出缓存区作为当前输出缓存区,依次将对每个输入窗口数据进行卷积计算获得的输出窗口数据顺序存储在当前输出缓冲区的m个行缓存区中;响应于一个计算缓存区中的所有输入窗口数据进行卷积计算获得的输出窗口数据被存储完毕,选取另一个输出缓存区作为当前输出缓存区,执行依次将对每个输入窗口数据进行卷积计算获得的输出窗口数据顺序存储在当前输出缓冲区的m个行缓存区中的操作;
依次将第三缓存区中的输出窗口数据存储至片外存储器中,包括:
响应于当前计算缓存区中的所有输入窗口数据进行卷积计算获得的输出窗口数据被存储完毕,将当前输出缓存区中 的输出窗口数据存储至片外存储器中。
另外,在图1所示实施例的再一个可选示例中,输入缓存区为列缓存区;第一缓存区为:由n+m个列缓存区形成的循环缓冲区,每个列缓存区用于顺序存储待处理任务所有通道中的同一列数据;
相应地,在该再一个可选示例中,从加速器的片外存储器读取待处理任务中预设大小的待处理数据,并依次存储在加速器的片上内存中、第一缓存区的至少一个输入缓存区,包括:
首次从片外存储器读取待处理任务所有通道的前n列数据,并将前n列数据中的各列数据分别对应存储在第一缓存区中、基于预定循环方向确定的前n个列缓存区中;
之后每次从片外存储器读取待处理任务所有通道的相邻后续m列数据,并将本次读取的m列数据中的各行数据分别对应存储在第一缓存区中、基于预定循环方向确定的相邻后续m个列缓存区中。
或者,在下一个可选示例中,从加速器的片外存储器读取待处理任务中预设大小的待处理数据,并依次存储在加速器的片上内存中、第一缓存区的至少一个输入缓存区,包括:
每次从片外存储器读取待处理任务所有通道的n列数据;
对于首次从待处理任务中读取的前n列数据,将前n列数据中的各列数据分别对应存储在第一缓存区中、基于预定循环方向确定的前n个列缓存区中;对于非首次读取的n列数据,基于预定循环方向,将第一缓存区中存储上一次读取的n列数据的前n个列缓冲区滑动m列后对应的n个列缓冲区作为本次读取的n列数据的目标列缓存区,并将本次读取的n列数据对应存入目标列缓存区中的各列缓冲区中。
在该下一个可选示例中,将非首次读取的n列数据存入第一缓存区中时,会覆盖掉上一次存入第一缓存区中的n个列缓存区中的最后n-m个列缓存区中的数据。
与上述再一个可选示例相应地,依次从至少一个输入缓存区读取待处理的输入窗口数据,并通过卷积核数据对待处理的输入窗口数据进行卷积计算,包括:
针对待处理任务,首次读取待处理的输入窗口数据时,选取前n个列缓存区作为当前计算缓存区,按照滑动步长m,依次顺序从当前计算缓存区读取大小为n×n的输入窗口数据,并通过卷积核数据对待处理的输入窗口数据进行卷积计算,直至当前计算缓存区中的待处理数据均被读取;
之后每次基于预定循环方向,按照滑动步长m从上一计算缓存区开始滑动,选取n个列缓存区作为新的计算缓存区,按照滑动步长m,依次顺序从新的计算缓存区读取大小为n×n的输入窗口数据,并通过卷积核数据对待处理的输入窗口数据进行卷积计算,直至新的计算缓存区中的待处理数据均被读取。
与上述又一个可选示例相应地,输出缓存区也可以包括m个列缓存区。相应地,获得输出窗口数据并依次存储在至少一个输出缓存区中,包括:
选取其中一个输出缓存区作为当前输出缓存区,依次将对每个输入窗口数据进行卷积计算获得的输出窗口数据顺序存储在当前输出缓冲区的m个列缓存区中;响应于一个计算缓存区中的所有输入窗口数据进行卷积计算获得的输出窗口数据被存储完毕,选取另一个输出缓存区作为当前输出缓存区,执行依次将对每个输入窗口数据进行卷积计算获得的输出窗口数据顺序存储在当前输出缓冲区的m个列缓存区中的操作;
依次将第三缓存区中的输出窗口数据存储至片外存储器中,包括:
响应于当前计算列缓存区中的所有输入窗口数据进行卷积计算获得的输出窗口数据被存储完毕,将当前输出缓存区中的输出窗口数据存储至片外存储器中。
可选地,输入缓存区为列缓存区与输入缓存区为行缓存区的技术方案类似,相关之处可相互参考。
图3为本申请实施例中对待处理的输入窗口数据进行卷积计算的一个实施例的流程图。如图3所示,通过卷积核数据对待处理的输入窗口数据进行卷积计算,获得输出窗口数据,包括:
302,分别针对任一输入通道执行如下计算处理操作:采用对应的第二常数矩阵对待处理的输入窗口数据进行转换,获得转换后输入窗口数据;对任一输入通道的转换后输入窗口数据与转换后的卷积核进行矩阵点乘操作,获得点乘后矩阵;采用对应的第三常数矩阵对点乘后矩阵进行转换,获得卷积结果。
其中,上述实施例中的至少一组卷积核数据包括至少一组转换后的卷积核,其中,任一组转换后的卷积核由对应的第一常数矩阵对对应于一个输出通道的卷积核进行转换获得。
在一个可选示例中,该操作302可以由处理器调用存储器存储的相应指令执行,也可以由被处理器运行的处理单元执行。
304,响应于获得所有输入通道的卷积结果,对一个输出通道对应的所有输入通道的卷积结果中的对应点进行累加,获得该一个输出通道的输出窗口数据。
可选地,在另一个实施例中,采用对应的第二常数矩阵对待处理的输入窗口数据进行转换时,还可以执行如下操作:采用对应的第一常数矩阵,分别对对应于至少一个输出通道的卷积核进行转换,获得至少一组转换后的卷积核。
或者,可选地,也可以预先采用对应的第一常数矩阵,分别对对应于至少一个输出通道的卷积核进行转换,获得至少一组转换后的卷积核,并存储在第二缓冲区中,这样就避免了临时执行该操作消耗计算资源,进一步提升了计算效率。
在一个可选示例中,该操作304可以由处理器调用存储器存储的相应指令执行,也可以由被处理器运行的累加单元执行。
示例性地,在图3所示至少一个实施例中,采用对应的第二常数矩阵对待处理的输入窗口数据进行转换,可以通过 如下方式实现:根据对应的第二常数矩阵,通过加速器中的逻辑资源分别对任一输入通道待处理的输入窗口数据进行位运算操作。
类似地,采用对应的第三常数矩阵对点乘后矩阵进行转换,可以通过如下方式实现:根据对应的第三常数矩阵,通过加速器中的逻辑资源分别对任一输入通道的点乘后矩阵进行位运算操作。
类似地,采用对应的第一常数矩阵,分别对对应于至少一个输出通道的卷积核进行转换,可以通过如下方式实现:根据对应的第一常数矩阵,通过加速器中的逻辑资源分别对对应于至少一个输出通道的卷积核进行位运算操作。采用加速器中的逻辑资源,通过二进制的位运算操作来实现对输入窗口数据、卷积核数据、点乘后矩阵的转换操作,便无需在加速器中设置乘法器来实现相应的转换操作,减少了卷积计算中的乘法次数,从而节省了加速器中的数字信号处理器(Digital Signal Processor,DSP)资源,从而提高了加速器的计算效率,提高了加速器中DSP资源的利用率。
可选地,在图3所示实施例的流程之前,还可以包括:
分别从常数矩阵表中,查询与卷积核的尺寸r×r和输入窗口的尺寸n×n对应的第一常数矩阵(本申请实施例中表示为:G)、第二常数矩阵(本申请实施例中表示为:B)和第三常数矩阵(本申请实施例中表示为:A)。
其中,常数矩阵表中预先设置有分别与至少一个卷积核的尺寸和输入窗口的尺寸对应的第一常数矩阵、第二常数矩阵和第三常数矩阵,即:卷积核的尺寸和输入窗口的尺寸确定后,便可以确定第一常数矩阵、第二常数矩阵和第三常数矩阵。
另外,在上述图3所示的各实施例中,分别针对任一输入通道执行如下计算操作,包括:同时针对Pm个输出通道和Pn个输入通道执行计算处理操作,其中,Pm和Pn分别为大于0的整数。相应地,操作304为:针对Pm个输出通道,响应于获得所有输入通道的卷积结果,分别针对同一个输出通道,将所有输入通道的卷积结果中的对应点进行累加,获得Pm个输出通道的输出窗口数据。通过该实施例,实现了对Pm个输出通道和Pn个输入通道的并行处理,提升了计算处理效率。
在其中一个可选示例中,Pm的取值为1,Pn的取值为大于1的整数;则同时针对Pm个输出通道和Pn个输入通道执行计算处理操作可以包括:依次针对一个输出通道、全部输入通道或者全部输入通道中的部分输入通道,并行执行计算处理操作。通过该实施例,实现了每次针对一个输出通道、Pn个输入通道的并行处理。
在另一个可选示例中,Pm的取值为全部输出通道数,Pn的取值为1;则同时针对Pm个输出通道和Pn个输入通道执行计算处理操作,可以包括:同时针对全部输出通道,依次针对一个输入通道执行计算处理操作;
相应地,操作304可以包括:针对全部输出通道,响应于获得所有输入通道的卷积结果,分别针对同一个输出通道,对所有输入通道的卷积结果中的对应点进行累加,获得全部输出通道的输出窗口数据。
通过该实施例,实现了每次针对一个输入通道、全部输出通道的并行处理。
在又一个可选示例中,Pm的取值大于1且小于全部输出通道数,Pn的取值为1;则同时针对Pm个输出通道和Pn个输入通道执行计算处理操作,包括:同时针对全部输出通道中的部分输出通道,依次针对一个输入通道执行计算处理操作。
通过该实施例,实现了每次针对一个输入通道、Pm个部分输出通道的并行处理。
如图4所示,为本申请实施例中对Pn个输入通道并行执行计算处理操作的示意图,图4中,Pn个输入通道只是所有输入通道的一部分,其对应的卷积结果累加可以形成对应于该Pn个输入通道的一组累加结果,所有输入通道对应的所有组的累加结果相加,得到一个输出通道的输出窗口数据。如图5所示,为本申请实施例中对Pm个输出通道并行执行计算处理操作的示意图,由于对每个输入通道的输入窗口数据的操作只能获得一部分输出窗口数据,针对同一输出通道,将所有输入通道的输入窗口数据对应的卷积结果累加,得到一个输出通道的输出窗口数据。
另外,在本申请卷积加速方法的上述各实施例之前,还可以包括:
根据参数优化模型,由FIFO端口的传输带宽、加速器的资源条件获取卷积计算中参数的最优取值,其中,卷积计算中参数包括:输入窗口的尺寸、输出通道的并行度和输入通道的并行度,上述参数的最优取值包括:输入窗口的尺寸的最优取值n、输出通道的并行度的最优取值Pm和输入通道的并行度的最优取值Pn。
在本申请卷积加速方法的上述各实施例中,通过FIFO端口依次从加速器的片外存储器读取待处理任务中预设大小的待处理数据可以包括:
加速器通过FIFO端口接收处理器发送的任务处理指令,并通过FIFO端口依次从加速器的片外存储器读取待处理任务中预设大小的待处理数据的操作。
另外,本申请实施例的卷积加速方法还可以包括:
响应于对待处理任务的卷积加速完成,加速器通过FIFO端口向处理器反馈任务完成的响应消息。上述获取卷积计算中参数的最优取值的操作可以有中央处理器(CPU)、高级RISC处理器(Advanced RISC Machines,ARM)等处理器完成。在需要调度加速器进行加速计算时,CPU、ARM等处理器获取卷积计算中参数的最优取值,并利用该卷积计算中参数的最优取值对加速器进行配置,在配置完成后,加速器便可以基于上述参数的最优取值执行相应的加速方法流程,对待处理任务进行处理,从而针对加速器达到最佳资源利用率、实现加速效果的最大化。则同时针对Pm个输出通道和Pn个输入通道执行计算处理操作时,基于参数的最优取值中Pm和Pn的取值,依次选取Pm个输出通道和Pn个输入通道,同时针对Pm个输出通道和Pn个输入通道执行计算处理操作。
在本申请的又一个实施例中,在卷积加速方法的上述各实施例之前,还可以包括:
比较当前待处理任务的卷积核尺寸k×k与加速器对应的卷积核的尺寸r×r是否一致;
若不一致,对当前待处理任务的卷积核的右方填充a列0、下方分别填充b行0,使当前待处理任务的卷积核转换成尺寸为tr×tr的新卷积核。
其中,k、t、a、b的取值分别为大于0的整数。
由于不同的卷积核的尺寸和输入窗口的尺寸对应不同的第一常数矩阵、第二常数矩阵和第三常数矩阵,在本次待处理任务所需卷积核的尺寸与已有加速器对应的卷积核的尺寸不同时,基于上述实施例,可以将本次待处理任务所需卷积核的尺寸转换为t2个加速器对应的卷积核,从而实现了对已有加速器对应的卷积核的复用,避免了重新计算获取第一常数矩阵、第二常数矩阵和第三常数矩阵,以及重新基于卷积核进行转换的操作,提升了处理效率。
另外,本申请实施例的加速器可用于CNN中任何网络层的卷积计算的加速中,例如,可用于CNN中卷积层、全连接(FC)、池化(pooling)、激活函数ReLU(线性修正单元)、填充(padding)、上采样(upsample)等网络层的卷积加速操作。另外,除了应用于CNN中的卷积加速,还可应用与其他任何非CNN的其他卷积操作中,本申请实施例的示例性说明并不会构成对本申请实施例应用环境的限制。
例如,在本申请上述各实施例中,兼容处理CNN中的全连接操作时,还可以包括:
响应于需要对待处理任务进行全连接操作,通过FIFO端口从加速器的片外存储器读取待处理任务的全部待处理数据,并存储在第一缓存区中;
对全部待处理数据与第二缓存区中存储的转换后的卷积核进行矩阵点乘操作,获得点乘后矩阵;
采用对应的第三常数矩阵对点乘后矩阵进行转换,获得计算结果数据并存储在第三缓存区中;
通过FIFO端口依次将第三缓存区中的计算结果数据存储至片外存储器中。
在本申请上述各实施例中,兼容处理CNN中的池化操作时,还可以包括:
响应于需要对待处理任务进行池化操作,通过FIFO端口依次从加速器的片外存储器读取待处理任务中预设大小的待处理数据,并存储在第一缓存区中;
从预设大小的待处理数据中选取一个取值最大的数据作为计算结果数据,并存储在第三缓存区中;
通过FIFO端口依次将第三缓存区中的计算结果数据存储至片外存储器中。
在本申请上述各实施例中,兼容处理CNN中的激活函数操作时,还可以包括:
响应于需要对待处理任务进行激活函数操作,通过FIFO端口依次从加速器的片外存储器读取待处理任务中预设大小的待处理数据,并存储在第一缓存区中;
依次比较待处理数据中任一数据的数值是否小于0;
若任一数据的数值小于0,将以0作为任一数据的计算结果存储在第三缓存区中;若任一数据的数值不小于0,直接将任一数据的数值作为计算结果存储在第三缓存区中;
通过FIFO端口依次将第三缓存区中的计算结果存储至片外存储器中。
在本申请上述各实施例中,兼容处理CNN中的上采样操作时,还可以包括:
响应于需要对待处理任务进行上采样操作,通过FIFO端口依次从加速器的片外存储器读取待处理任务中的一个元素数据,将元素数据复制为2s×2s的元素矩阵,以元素矩阵作为待处理数据,开始执行依次存储在加速器的片上内存中第一缓存区的至少一个输入缓存区的操作;其中,s的取值为大于0的整数。
在本申请上述各实施例中,兼容处理CNN中的填充操作时,还可以包括:
响应于需要对待处理任务进行填充处理,通过FIFO端口从加速器的片外存储器读取待处理任务的全部数据,并存储在第一缓存区中;
比较待处理任务的数据大小是否小于预设大小;
若待处理任务的数据大小小于预设大小,按照预设方式对待处理任务进行边缘数据填充,使得填充后的待处理任务的数据大小等于预设大小,并将填充后的待处理任务存储在第三缓存区中;若待处理任务的数据大小不小于预设大小,直接将待处理任务存储在第三缓存区中;
通过FIFO端口依次将第三缓存区中的待处理任务数据存储至片外存储器中。
图6为本申请卷积计算处理方法一个实施例的流程图。如图6所示,本申请实施例的卷积计算处理方法包括,分别针对任一输入通道和任一输出通道:
602,采用第二常数矩阵B对待处理的输入窗口数据Z进行转换,获得转换后输入窗口数据V。
例如,可以通过公式V=BTZB,采用与输出窗口尺寸和卷积核尺寸对应的第二常数矩阵B对待处理的输入窗口数据Z进行转换,获得转换后输入窗口数据V。
在一个可选示例中,该操作602可以由处理器调用存储器存储的相应指令执行,也可以由被处理器运行的第一转换模块执行。
604,对转换后输入窗口数据V与卷积核数据U进行矩阵点乘(EWMM)操作,获得点乘后矩阵U⊙V。
在一个可选示例中,可以采用数字信号处理器,对转换后输入窗口数据与卷积核数据进行矩阵点乘操作,获得点乘后矩阵U⊙V。
例如,可以通过公式U⊙V,对转换后输入窗口数据V与卷积核数据U进行矩阵点乘操作,获得点乘后矩阵。
其中,卷积核数据U由对应的第一常数矩阵G对预先设置的卷积核(本申请实施例中表示为:X)进行转换获得。
在一个可选示例中,该操作604可以由处理器调用存储器存储的相应指令执行,也可以由被处理器运行的点乘模块执行。
606,采用第三常数矩阵A对点乘后矩阵U⊙V进行转换,获得卷积结果Y,可以表示为:Y=AT[U⊙V]A。
其中的第三常数矩阵A为与输出窗口尺寸和卷积核尺寸对应的第三常数矩阵。
在一个可选示例中,该操作606可以由处理器调用存储器存储的相应指令执行,也可以由被处理器运行的第二转换模块执行。
基于本申请上述实施例提供的卷积计算处理方法,可以针对任一输入通道和任一输出通道,采用第二常数矩阵对待处理的输入窗口数据进行转换,获得转换后输入窗口数据;对转换后输入窗口数据与卷积核数据进行矩阵点乘操作,获得点乘后矩阵;采用第三常数矩阵对点乘后矩阵进行转换,获得卷积结果。本申请实施例提供了一种基于Winograd算法对输入窗口数据进行面对面的卷积计算的方法,相对于传统的点对点的卷积算法,减少了乘法次数,从而减少了对处理器资源的占用,并提升了计算效率。本申请实施例可以应用于FPGA、ASIC等硬件平台,从而在FPGA、ASIC等硬件平台上实现卷积加速处理,本申请实施例应用于FPGA平台时,可以充分发挥FPGA平台可重构、并行计算性、开发周期短、低功耗、灵活性高等优点。
可选地,在本申请卷积计算处理方法的另一个实施例中,还可以包括:
预先采用与输出窗口尺寸和卷积核尺寸对应的第一常数矩阵G,分别对任一输出通道的卷积核X进行转换,获得卷积核数据U并存储。例如,可以通过公式U=GXGT,预先采用对应的第一常数矩阵G,分别对卷积核X进行转换,获得卷积核数据U。其中,每个卷积核数据分别对应于一个输入通道。
如图7所示,为本申请卷积计算处理方法另一个实施例的流程图。可选地,在本申请卷积计算处理方法的另一个实施例中,在操作604之前,还可以包括:
600,采用第一常数矩阵G,分别对卷积核进行转换,获得闪送卷积核数据。
可选地,上述第一常数矩阵G为与输出窗口尺寸和卷积核尺寸对应的第一常数矩阵。
在一个可选示例中,该操作600可以由处理器调用存储器存储的相应指令执行,也可以由被处理器运行的第三转换模块执行。
示例性地,采用第二常数矩阵对待处理的输入窗口数据进行转换,可以是:根据第二常数矩阵,采用加速器中的逻辑资源对待处理的输入窗口数据进行位运算操作;采用第三常数矩阵对点乘后矩阵进行转换,可以是:根据第三常数矩阵,采用加速器中的逻辑资源对点乘后矩阵进行位运算操作;采用第一常数矩阵对卷积核进行转换,可以是:根据第一常数矩阵,采用加速器中的逻辑资源对卷积核进行位运算操作。采用加速器中的逻辑资源进行位运算操作,从而实现对卷积核、输入窗口数据、点乘后矩阵的转换,而无需借助于DSP资源,减少了乘法次数、节省了DSP资源,从而提高了加速器的计算效率,并提高了DSP资源的利用率。
基于图7所示实施例的上述实施例中,还可以包括:
分别从常数矩阵表中,查询与卷积核数据对应的卷积核的尺寸r×r和输入窗口数据对应的输入窗口的尺寸n×n对应的第一常数矩阵、第二常数矩阵和第三常数矩阵;
其中,n和r的取值分别为大于0的整数;常数矩阵表中预先设置有分别与至少一个卷积核的尺寸和输入窗口的尺寸对应的第一常数矩阵、第二常数矩阵和第三常数矩阵。
可选地,再参见图7,在本申请卷积计算处理方法的又一个实施例中,还可以包括:
608,针对任一输出通道,响应于获得所有输入通道的卷积结果,对上述任一输出通道对应的所有输入通道的卷积结果中的对应点进行累加,获得任一输出通道的输出窗口数据,即:通过一个输出通道对应的一组卷积核数据,采用图7所示实施例的流程,对所有输入通道的输入窗口数据进行卷积计算,获得该输出通道的输出窗口数据。以Out表示一个输出通道的输出窗口数据,in表示所有输入通道的输入窗口数据,则:图7所示实施例的卷积计算处理过程可以表示为基于以下公式对所有输入通道的输入窗口数据和卷积核数据的处理过程:Out=A
T[(GXG
T)⊙(B
TinB)]A。
在一个可选示例中,该操作608可以由处理器调用存储器存储的相应指令执行,也可以由被处理器运行的累加单元执行。
图8所示实施例的卷积计算处理方法对应于图3所示实施例中302的操作,即:上述至少一个卷积加速方法实施例中的操作302可以通过本申请至少一个卷积计算处理方法实施例中的相应操作实现。图8所示实施例对应于图6、图7所示至少一个实施例,本申请实施例中可以相互参考。图8为图3、图7、图8所示实施例的一个计算过程示意。如图8所示,本申请实施例的卷积计算处理方法可以分为4个阶段:阶段1(stage1)表示图6~图7中的操作600和602的阶段;阶段2(stage2)表示图6~图7中的操作604的阶段;阶段3(stage3)表示图6~图7中的操作606的阶段;阶段4(stage4)表示图7中的操作608的阶段。其中,stage1~stage3也表示图3所示实施例中操作302的阶段,stage4也表示图3所示实施例中操作304的阶段。
图8中仅示例性地示出三个输入通道的输入窗口数据Z和对应于一个输出通道的一组卷积核数据,该一组卷积核数据包括分别对应上述三个输入通道的卷积核X。
本申请实施例提供的任一种方法可以由任意适当的具有数据处理能力的设备执行,包括但不限于:终端设备和服务 器等。或者,本申请实施例提供的任一种方法可以由处理器执行,如处理器通过调用存储器存储的相应指令来执行本申请实施例提及的任一种方法。下文不再赘述。
本领域普通技术人员可以理解:实现上述方法实施例的全部或部分步骤可以通过程序指令相关的硬件来完成,前述的程序可以存储于一计算机可读取存储介质中,该程序在执行时,执行包括上述方法实施例的步骤;而前述的存储介质包括:ROM、RAM、磁碟或者光盘等至少一个种可以存储程序代码的介质。
图9为本申请卷积加速器一个实施例的结构示意图。该实施例的卷积加速器可作为本申请上述至少一个实施例中的加速器,实现本申请上述至少一个卷积加速方法实施例中加速器的功能。本申请至少一个实施例中的加速器例如可以是FPGA、ASIC等嵌入式平台。如图9所示,该实施例的加速器包括:数据读取模块,第一缓存区,第二缓存区,计算模块,第三缓存区和数据输出模块。其中:
数据读取模块,用于通过FIFO端口依次从加速器的片外存储器读取待处理任务中预设大小的待处理数据,并存储在第一缓存区的至少一个输入缓存区。
本申请至少一个实施例中,待处理任务例如可以包括:至少一个输入通道的输入图像、或者至少一个输入通道的输入特征图。另外,每组卷积核数据分别对应于一个输出通道,每组卷积核数据包括至少一个卷积核数据,每个卷积核数据分别对应于一个输入通道。
第一缓存区,包括至少一个输入缓存区,用于缓存待处理数据。
第二缓存区,用于缓存至少一组卷积核数据。
计算模块,用于在有输入缓存区中存入待处理数据时,依次从至少一个输入缓存区读取待处理的输入窗口数据,并通过卷积核数据对待处理的输入窗口数据进行卷积计算,获得输出窗口数据并存储在第三缓存区中。
第三缓存区,包括至少一个输出缓存区,用于缓存输出窗口数据。
数据输出模块,用于通过FIFO端口,依次将第三缓存区中的输出窗口数据存储至片外存储器中。
基于本申请上述实施例提供的卷积加速器,片上内存包括第一缓存区、第二缓存区和第三缓存区,第一缓存区包括至少一个输入缓存区,第二缓存区中缓存有至少一组卷积核数据。通过FIFO端口依次从加速器的片外存储器读取待处理任务中预设大小的待处理数据,并存储在加速器的片上内存中第一缓存区的至少一个输入缓存区;响应于有输入缓存区中存入待处理数据,依次从至少一个输入缓存区读取待处理的输入窗口数据,并通过卷积核数据对待处理的输入窗口数据进行卷积计算,获得输出窗口数据并存储在第三缓存区中;然后通过FIFO端口依次将第三缓存区中的输出窗口数据存储至片外存储器中。本申请实施例每次从加速器的片外存储器读取待处理任务中预设大小的待处理数据存入片上内存进行处理,并实现了从片外存储器读取待处理数据存入片上内存、和对待处理数据进行卷积计算处理两个过程的流水线处理,可以避免加速器片上内存和带宽不足、处理器资源有限的情况,并且提高了卷积计算处理的效率,可以适用于FPGA、ASIC等硬件平台,从而在FPGA、ASIC等硬件平台上实现CNN的加速处理,本申请实施例应用于FPGA平台时,可以充分发挥FPGA平台可重构、并行计算性、开发周期短、低功耗、灵活性高等优点。
在图9所示实施例的一个可选示例中,数据输出模块用于:响应于首个输出缓存区存入输出窗口数据,依次读取至少一个输出缓存区中的输出窗口数据,并通过FIFO端口将读取的输出窗口数据存储至片外存储器中。
示例性地,第三缓存区包括两个输出缓存区。在待处理任务的处理过程中,两个输出缓存区的其中一个输出缓存区被轮流存入输出窗口数据、读取输出窗口数据,两个输出缓存区中的另一个输出缓存区被轮流读取输出窗口数据、存入输出窗口数据。两个输出缓存区中一个被存入输出窗口数据时,另一个被读取输出窗口数据,在前述一个被读取输出窗口数据时,另一个被存入出窗口数据,从而实现存入输出窗口数据、读取输出窗口数据的流水线处理,进一步提升加速器的工作效率。
在图9所示实施例的另一个可选示例中,第一缓存区包括两个输入缓存区。在待处理任务的处理过程中,这两个输入缓存区的其中一个输入缓存区被轮流存入待处理数据、读取待处理的输入窗口数据,两个输入缓存区中的另一个输入缓存区被轮流读取待处理的输入窗口数据、存入待处理数据,两个输入缓存区中一个被存入待处理数据时,另一个被读取待处理的输入窗口数据,在前述一个被读取待处理的输入窗口数据时,另一个被存入待处理数据,从而实现存入待处理数据、读取待处理的输入窗口数据的流水线处理。
本申请实施例中,将卷积核数据对应的卷积核的尺寸表示为r×r,输入窗口数据对应的输入窗口的尺寸表示为n×n,输入窗口数据对应的输入窗口的滑动步长和输出窗口的尺寸表示为m。其中,r、m、n的取值分别为大于0的整数,且满足n=m+r-1。
在图9所示实施例的又一个可选示例中,输入缓存区为行缓存区,第一缓存区为:由n+m个行缓存区形成的循环缓冲区,每个行缓存区用于顺序存储待处理任务所有通道中的同一行数据。该实施例中,数据读取模块用于:
首次从片外存储器读取待处理任务所有通道的前n行数据,并将前n行数据中的各行数据分别对应存储在第一缓存区中、基于预定循环方向确定的前n个行缓存区中;
之后每次从片外存储器读取待处理任务所有通道的相邻后续m行数据,并将本次读取的m行数据中的各行数据分别对应存储在第一缓存区中、基于预定循环方向确定的相邻后续m个行缓存区中;或者
数据读取模块用于:
每次从片外存储器读取待处理任务所有通道的n行数据;
对于首次从待处理任务中读取的前n行数据,将前n行数据中的各行数据分别对应存储在第一缓存区中、基于预定 循环方向确定的前n个行缓存区中;对于非首次读取的n行数据,基于预定循环方向,将第一缓存区中存储上一次读取的n行数据的前n个行缓冲区滑动m行后对应的n个行缓冲区作为本次读取的n行数据的目标行缓存区,并将本次读取的n行数据对应存入目标行缓存区中的各行缓冲区中。
与上述又一个可选示例相应地,计算模块依次从至少一个输入缓存区读取待处理的输入窗口数据,并通过卷积核数据对待处理的输入窗口数据进行卷积计算时,用于:
针对待处理任务,首次读取待处理的输入窗口数据时,选取前n个行缓存区作为当前计算缓存区,按照滑动步长m,依次顺序从当前计算缓存区读取大小为n×n的输入窗口数据,并通过卷积核数据对待处理的输入窗口数据进行卷积计算,直至当前计算缓存区中的待处理数据均被读取;
之后每次基于预定循环方向,按照滑动步长m从上一计算缓存区开始滑动,选取n个行缓存区作为新的计算缓存区,按照滑动步长m,依次顺序从新的计算缓存区读取大小为n×n的输入窗口数据,并通过卷积核数据对待处理的输入窗口数据进行卷积计算,直至新的计算缓存区中的待处理数据均被读取。
与上述又一个可选示例相应地,每个输出缓存区包括m个行缓存区。相应地,计算模块获得输出窗口数据并依次存储在至少一个输出缓存区中时,用于:
选取其中一个输出缓存区作为当前输出缓存区,依次将对每个输入窗口数据进行卷积计算获得的输出窗口数据顺序存储在当前输出缓冲区的m个行缓存区中;响应于一个计算缓存区中的所有输入窗口数据进行卷积计算获得的输出窗口数据被存储完毕,选取另一个输出缓存区作为当前输出缓存区,执行依次将对每个输入窗口数据进行卷积计算获得的输出窗口数据顺序存储在当前输出缓冲区的m个行缓存区中的操作。
数据输出模块,用于:响应于当前计算缓存区中的所有输入窗口数据进行卷积计算获得的输出窗口数据被存储完毕,通过FIFO端口,将当前输出缓存区中的输出窗口数据存储至片外存储器中。
在图9所示实施例的再一个可选示例中,输入缓存区为列缓存区;第一缓存区为:由n+m个列缓存区形成的循环缓冲区,每个列缓存区用于顺序存储待处理任务所有通道中的同一列数据。相应地,数据读取模块,用于:
首次从片外存储器读取待处理任务所有通道的前n列数据,并将前n列数据中的各列数据分别对应存储在第一缓存区中、基于预定循环方向确定的前n个列缓存区中;
之后每次从片外存储器读取待处理任务所有通道的相邻后续m列数据,并将本次读取的m列数据中的各行数据分别对应存储在第一缓存区中、基于预定循环方向确定的相邻后续m个列缓存区中。
与上述再一个可选示例相应地,计算模块依次从至少一个输入缓存区读取待处理的输入窗口数据,并通过卷积核数据对待处理的输入窗口数据进行卷积计算时,包括:
针对待处理任务,首次读取待处理的输入窗口数据时,选取前n个列缓存区作为当前计算缓存区,按照滑动步长m,依次顺序从当前计算缓存区读取大小为n×n的输入窗口数据,并通过卷积核数据对待处理的输入窗口数据进行卷积计算,直至当前计算缓存区中的待处理数据均被读取;
之后每次基于预定循环方向,按照滑动步长m从上一计算缓存区开始滑动,选取n个列缓存区作为新的计算缓存区,按照滑动步长m,依次顺序从新的计算缓存区读取大小为n×n的输入窗口数据,并通过卷积核数据对待处理的输入窗口数据进行卷积计算,直至新的计算缓存区中的待处理数据均被读取;或者
数据读取模块,用于:
每次从片外存储器读取待处理任务所有通道的n列数据;
对于首次从待处理任务中读取的前n列数据,将前n列数据中的各列数据分别对应存储在第一缓存区中、基于预定循环方向确定的前n个列缓存区中;对于非首次读取的n列数据,基于预定循环方向,将第一缓存区中存储上一次读取的n列数据的前n个列缓冲区滑动m列后对应的n个列缓冲区作为本次读取的n列数据的目标列缓存区,并将本次读取的n列数据对应存入目标列缓存区中的各列缓冲区中。
与上述再一个可选示例相应地,输出缓存区包括m个列缓存区。该可选示例中,计算模块获得输出窗口数据并依次存储在至少一个输出缓存区中时,用于:
选取其中一个输出缓存区作为当前输出缓存区,依次将对每个输入窗口数据进行卷积计算获得的输出窗口数据顺序存储在当前输出缓冲区的m个列缓存区中;响应于一个计算缓存区中的所有输入窗口数据进行卷积计算获得的输出窗口数据被存储完毕,选取另一个输出缓存区作为当前输出缓存区,执行依次将对每个输入窗口数据进行卷积计算获得的输出窗口数据顺序存储在当前输出缓冲区的m个列缓存区中的操作。
相应地,数据输出模块,用于:响应于当前计算缓存区中的所有输入窗口数据进行卷积计算获得的输出窗口数据被存储完毕,通过FIFO端口,将当前输出缓存区中的输出窗口数据存储至片外存储器中。
图10为本申请实施例中计算模块一个实施例的结构示意图。如图10所示,在本申请上述至少一个实施例的加速器中,计算模块包括:处理单元(PE)和累加单元。
在图10所示实施例的一个可选示例中,卷积核数据为转换后的卷积核。该实施例中:
处理单元,用于分别针对任一输入通道执行如下计算处理操作:采用对应的第二常数矩阵对待处理的输入窗口数据进行转换,获得转换后输入窗口数据;对任一输入通道的转换后输入窗口数据与转换后的卷积核进行矩阵点乘操作,获得点乘后矩阵;采用对应的第三常数矩阵对点乘后矩阵进行转换,获得卷积结果;
累加单元,用于在获得一个输出通道对应的所有输入通道的卷积结果后,对所有输入通道的卷积结果中的对应点进 行累加,获得一个输出通道的输出窗口数据。
在图10所示实施例的一个可选示例中,卷积核数据为未经转换的卷积核。该实施例中:
处理单元,用于分别针对任一输入通道执行如下计算处理操作:采用对应的第一常数矩阵,分别对对应于至少一个输出通道的卷积核进行转换,获得至少一组转换后的卷积核,以及采用对应的第二常数矩阵对待处理的输入窗口数据进行转换,获得转换后输入窗口数据;对任一输入通道的转换后输入窗口数据与转换后的卷积核进行矩阵点乘操作,获得点乘后矩阵;采用对应的第三常数矩阵对点乘后矩阵进行转换,获得卷积结果;
累加单元,用于在获得一个输出通道对应的所有输入通道的卷积结果后,对所有输入通道的卷积结果中的对应点进行累加,获得一个输出通道的输出窗口数据。
与图10所示实施例相应地,采用对应的第二常数矩阵对待处理的输入窗口数据进行转换时,可以根据对应的第二常数矩阵,分别对任一输入通道待处理的输入窗口数据进行位运算操作;采用对应的第三常数矩阵对点乘后矩阵进行转换时,可以根据对应的第三常数矩阵,分别对任一输入通道的点乘后矩阵进行位运算操作;采用对应的第一常数矩阵,分别对对应于至少一个输出通道的卷积核进行转换时,可以根据对应的第一常数矩阵,分别对对应于至少一个输出通道的卷积核进行位运算操作。
可选地,计算模块包括Pm×Pn个处理单元,用于同时针对Pm个输出通道和Pn个输入通道执行计算处理操作,其中,Pm和Pn分别为大于0的整数。相应地,累加单元,用于:针对Pm个输出通道,响应于获得所有输入通道的卷积结果,分别针对同一个输出通道,将所有输入通道的卷积结果中的对应点进行累加,获得Pm个输出通道的输出窗口数据。
在应用中,可以根据实际需求和加速器资源配置:Pm的取值为1,Pn的取值为大于1的整数;或者,Pm的取值为全部输出通道数,Pn的取值为1;或者,Pm的取值大于1且小于全部输出通道数,Pn的取值为1。
图11为本申请卷积计算处理装置一个实施例的结构示意图。该实施例的卷积计算处理装置可用于实现本申请上述至少一个卷积计算处理方法实施例。如图11所示,该实施例的卷积计算处理装置包括:第一转换模块,点乘模块和第二转换模块。其中:
第一转换模块,用于采用第二常数矩阵对待处理的输入窗口数据进行转换,获得转换后输入窗口数据。
点乘模块,用于对转换后输入窗口数据与卷积核数据进行矩阵点乘操作,获得点乘后矩阵。其中的卷积核数据由对应的第一常数矩阵对预先设置的卷积核进行转换获得。
第二转换模块,用于采用第三常数矩阵对点乘后矩阵进行转换,获得卷积结果。
基于本申请上述实施例提供的卷积计算处理装置,可以针对任一输入通道和任一输出通道,采用第二常数矩阵对待处理的输入窗口数据进行转换,获得转换后输入窗口数据;对转换后输入窗口数据与卷积核数据进行矩阵点乘操作,获得点乘后矩阵;采用第三常数矩阵对点乘后矩阵进行转换,获得卷积结果。本申请实施例提供了一种基于Winograd算法对输入窗口数据进行面对面的卷积计算的方法,相对于传统的点对点的卷积算法,减少了乘法次数,从而减少了对处理器资源的占用,并提升了计算效率。本申请实施例可以应用于FPGA、ASIC等硬件平台,从而在FPGA、ASIC等硬件平台上实现卷积加速处理,本申请实施例应用于FPGA平台时,可以充分发挥FPGA平台可重构、并行计算性、开发周期短、低功耗、灵活性高等优点。
图12为本申请卷积计算处理装置另一个实施例的结构示意图。如图12所示,与图11所示的实施例相比,该实施例的卷积计算处理装置还包括第三转换模块。
在其中一个可选示例中,第三转换模块用于获取预先存储的卷积核数据。
在另一个可选示例中,第三转换模块用于采用对应的第一常数矩阵,分别对任一输入通道和任一输出通道对应的卷积核进行转换,获得任一输入通道和任一输出通道对应的卷积核数据。
示例性地,第一转换模块,可用于:根据对应的第二常数矩阵,分别对待处理的输入窗口数据进行位运算操作;
第二转换模块,可用于:根据第三常数矩阵,分别对点乘后矩阵进行位运算操作;
第三转换模块,可用于:根据第一常数矩阵,对卷积核进行位运算操作。
可选地,再参见图12,在又一个实施例中,卷积计算处理装置还可以包括:
查询模块,分别从常数矩阵表中,查询与卷积核数据对应的卷积核的尺寸r×r和输入窗口数据对应的输入窗口的尺寸n×n对应的第一常数矩阵、第二常数矩阵和第三常数矩阵;
其中,n和r的取值分别为大于0的整数;常数矩阵表中预先设置有分别与至少一个卷积核的尺寸和输入窗口的尺寸对应的第一常数矩阵、第二常数矩阵和第三常数矩阵。
本申请实施例提供还提供了一种电子设备,包括本申请上述任一实施例的卷积加速器,或者本申请上述任一实施例的卷积计算处理装置。
本申请实施例提供还提供了另一种电子设备,包括:
存储器,用于存储可执行指令;以及
处理器,用于与存储器通信以执行可执行指令从而完成本申请上述任一卷积加速方法实施例的操作,或者本申请上述任一卷积计算处理方法实施例的操作。
本申请实施例提供还提供了一种计算机存储介质,用于存储计算机可读取的指令,该指令被执行时执行本申请上述任一卷积加速方法实施例的操作,或者本申请上述任一卷积计算处理方法实施例的操作。
图13为本申请电子设备一个实施例的结构示意图。图13示出了适于用来实现本申请实施例的电子设备的结构示意 图。如图13所示,该电子设备包括双倍速率同步动态随机存储器(DDR SDRAM)、处理系统(PS)和可编程逻辑电路(PL),PL中设置有本申请实施例的卷积加速器。
需要说明的,如图13所示的架构仅为一种可选实现方式,在具体实践过程中,可根据实际需要对上述图13的部件数量和类型进行选择、删减、增加或替换;在不同功能部件设置上,也可采用分离设置或集成设置等实现方式,这些可替换的实施方式均落入本申请公开的保护范围。
本申请实施例可以应用于计算机系统/服务器等电子设备,其可与众多其它通用或专用计算系统环境或配置一起操作。适于与计算机系统/服务器等电子设备一起使用的众所周知的计算系统、环境和/或配置的例子包括但不限于:嵌入式平台、个人计算机系统、服务器计算机系统、瘦客户机、厚客户机、手持或膝上设备、基于微处理器的系统、机顶盒、可编程消费电子产品、网络个人电脑、小型计算机系统﹑大型计算机系统和包括上述任何系统的分布式云计算技术环境,等等。
计算机系统/服务器等电子设备可以在由计算机系统执行的计算机系统可执行指令(诸如程序模块)的一般语境下描述。通常,程序模块可以包括例程、程序、目标程序、组件、逻辑、数据结构等等,它们执行特定的任务或者实现特定的抽象数据类型。计算机系统/服务器可以在分布式云计算环境中实施,分布式云计算环境中,任务是由通过通信网络链接的远程处理设备执行的。在分布式云计算环境中,程序模块可以位于包括存储设备的本地或远程计算系统存储介质上。
本领域普通技术人员可以理解:实现上述方法实施例的全部或部分步骤可以通过程序指令相关的硬件来完成,前述的程序可以存储于一计算机可读取存储介质中,该程序在执行时,执行包括上述方法实施例的步骤;而前述的存储介质包括:ROM、RAM、磁碟或者光盘等各种可以存储程序代码的介质。
本说明书中各个实施例均采用递进的方式描述,每个实施例重点说明的都是与其它实施例的不同之处,各个实施例之间相同或相似的部分相互参见即可。对于系统实施例而言,由于其与方法实施例基本对应,所以描述的比较简单,相关之处参见方法实施例的部分说明即可。
可能以许多方式来实现本申请的方法和装置。例如,可通过软件、硬件、固件或者软件、硬件、固件的任何组合来实现本申请的方法和装置。用于所述方法的步骤的上述顺序仅是为了进行说明,本申请的方法的步骤不限于以上具体描述的顺序,除非以其它方式特别说明。此外,在一些实施例中,还可将本申请实施为记录在记录介质中的程序,这些程序包括用于实现根据本申请的方法的机器可读指令。因而,本申请还覆盖存储用于执行根据本申请的方法的程序的记录介质。
本申请的描述是为了示例和描述起见而给出的,而并不是无遗漏的或者将本申请限于所公开的形式。很多修改和变化对于本领域的普通技术人员而言是显然的。选择和描述实施例是为了更好说明本申请的原理和实际应用,并且使本领域的普通技术人员能够理解本申请从而设计适于特定用途的带有各种修改的各种实施例。
Claims (64)
- 一种卷积加速方法,其特征在于,包括:通过先进先出FIFO端口依次从加速器的片外存储器读取待处理任务中预设大小的待处理数据,并存储在所述加速器的片上内存中第一缓存区的至少一个输入缓存区;其中,所述片上内存包括第一缓存区、第二缓存区和第三缓存区,所述第一缓存区包括至少一个输入缓存区,所述第二缓存区中缓存有至少一组卷积核数据;响应于有输入缓存区中存入待处理数据,依次从至少一个输入缓存区读取待处理的输入窗口数据,并通过所述卷积核数据对所述待处理的输入窗口数据进行卷积计算,获得输出窗口数据并存储在第三缓存区中;通过FIFO端口依次将第三缓存区中的输出窗口数据存储至所述片外存储器中。
- 根据权利要求1所述的方法,其特征在于,所述待处理任务包括:至少一个输入通道的输入图像、或者至少一个输入通道的输入特征图;每组卷积核数据分别对应于一个输出通道,每组卷积核数据包括至少一个卷积核数据,每个卷积核数据分别对应于一个输入通道。
- 根据权利要求1或2所述的方法,其特征在于,所述第三缓存区包括至少一个输出缓存区;所述获得输出窗口数据并存储在第三缓存区中,包括:获得输出窗口数据并依次存储在至少一个输出缓存区中;所述通过FIFO端口依次将第三缓存区中的输出窗口数据存储至所述片外存储器中,包括:响应于首个输出缓存区存入输出窗口数据,依次读取至少一个输出缓存区中的输出窗口数据,并通过FIFO端口将读取的输出窗口数据存储至所述片外存储器中。
- 根据权利要求3所述的方法,其特征在于,所述第三缓存区包括两个输出缓存区;在所述待处理任务的处理过程中,所述两个输出缓存区的其中一个输出缓存区被轮流存入输出窗口数据、读取输出窗口数据,所述两个输出缓存区中的另一个输出缓存区被轮流读取输出窗口数据、存入输出窗口数据。
- 根据权利要求1~4任一所述的方法,其特征在于,所述第一缓存区包括两个输入缓存区;在所述待处理任务的处理过程中,所述两个输入缓存区的其中一个输入缓存区被轮流存入待处理数据、读取待处理的输入窗口数据,所述两个输入缓存区中的另一个输入缓存区被轮流读取待处理的输入窗口数据、存入待处理数据。
- 根据权利要求1~4任一所述的方法,其特征在于,所述卷积核数据对应的卷积核的尺寸为r×r,所述输入窗口数据对应的输入窗口的尺寸为n×n,所述输入窗口数据对应的输入窗口的滑动步长和输出窗口的尺寸为m;其中,m、n、r的取值分别为大于0的整数,且满足n=m+r-1;所述输入缓存区为行缓存区;所述第一缓存区为:由n+m个行缓存区形成的循环缓冲区,每个行缓存区用于顺序存储所述待处理任务所有通道中的同一行数据;所述从加速器的片外存储器读取待处理任务中预设大小的待处理数据,并依次存储在所述加速器的片上内存中、第一缓存区的至少一个输入缓存区,包括:首次从片外存储器读取所述待处理任务所有通道的前n行数据,并将所述前n行数据中的各行数据分别对应存储在第一缓存区中、基于预定循环方向确定的前n个行缓存区中;之后每次从片外存储器读取所述待处理任务所有通道的相邻后续m行数据,并将本次读取的m行数据中的各行数据分别对应存储在第一缓存区中、基于所述预定循环方向确定的相邻后续m个行缓存区中。
- 根据权利要求1~4所述的方法,其特征在于,所述卷积核数据对应的卷积核的尺寸为r×r,所述输入窗口数据对应的输入窗口的尺寸为n×n,所述输入窗口数据对应的输入窗口的滑动步长和输出窗口的尺寸为m;其中,m、n、r的取值分别为大于0的整数,且满足n=m+r-1;所述输入缓存区为行缓存区;所述第一缓存区为:由n+m个行缓存区形成的循环缓冲区,每个行缓存区用于顺序存储所述待处理任务所有通道中的同一行数据;所述从加速器的片外存储器读取待处理任务中预设大小的待处理数据,并依次存储在所述加速器的片上内存中、第一缓存区的至少一个输入缓存区,包括:每次从片外存储器读取所述待处理任务所有通道的n行数据;对于首次从所述待处理任务中读取的前n行数据,将所述前n行数据中的各行数据分别对应存储在第一缓存区中、基于预定循环方向确定的前n个行缓存区中;对于非首次读取的n行数据,基于所述预定循环方向,将第一缓存区中存储上一次读取的n行数据的前n个行缓冲区滑动m行后对应的n个行缓冲区作为本次读取的n行数据的目标行缓存区,并将本次读取的n行数据对应存入所述目标行缓存区中的各行缓冲区中。
- 根据权利要求6或7所述的方法,其特征在于,所述依次从至少一个输入缓存区读取待处理的输入窗口数据,并通过所述卷积核数据对所述待处理的输入窗口数据进行卷积计算,包括:针对所述待处理任务,首次读取待处理的输入窗口数据时,选取所述前n个行缓存区作为当前计算缓存区,按照滑动步长m,依次顺序从当前计算缓存区读取大小为n×n的输入窗口数据,并通过所述卷积核数据对所述待处理的输入窗口数据进行卷积计算,直至当前计算缓存区中的待处理数据均被读取;之后每次基于所述预定循环方向,按照滑动步长m从上一计算缓存区开始滑动,选取n个行缓存区作为新的计算缓存区,按照滑动步长m,依次顺序从新的计算缓存区读取大小为n×n的输入窗口数据,并通过所述卷积核数据对所述待 处理的输入窗口数据进行卷积计算,直至所述新的计算缓存区中的待处理数据均被读取。
- 根据权利要求6~8任一所述的方法,其特征在于,所述输出缓存区包括m个行缓存区;所述获得输出窗口数据并依次存储在至少一个输出缓存区中,包括:选取其中一个输出缓存区作为当前输出缓存区,依次将对每个输入窗口数据进行卷积计算获得的输出窗口数据顺序存储在当前输出缓冲区的m个行缓存区中;响应于一个计算缓存区中的所有输入窗口数据进行卷积计算获得的输出窗口数据被存储完毕,选取另一个输出缓存区作为当前输出缓存区,执行所述依次将对每个输入窗口数据进行卷积计算获得的输出窗口数据顺序存储在当前输出缓冲区的m个行缓存区中的操作;所述依次将第三缓存区中的输出窗口数据存储至所述片外存储器中,包括:响应于当前计算缓存区中的所有输入窗口数据进行卷积计算获得的输出窗口数据被存储完毕,将所述当前输出缓存区中的输出窗口数据存储至所述片外存储器中。
- 根据权利要求1~4任一所述的方法,其特征在于,所述卷积核数据对应的卷积核的尺寸为r×r,所述输入窗口数据对应的输入窗口的尺寸为n×n,所述输入窗口数据对应的输入窗口的滑动步长为m;其中,m、n、r的取值分别为大于0的整数,且满足n=m+r-1;所述输入缓存区为列缓存区;所述第一缓存区为:由n+m个列缓存区形成的循环缓冲区,每个列缓存区用于顺序存储所述待处理任务所有通道中的同一列数据;所述从加速器的片外存储器读取待处理任务中预设大小的待处理数据,并依次存储在所述加速器的片上内存中、第一缓存区的至少一个输入缓存区,包括:首次从片外存储器读取所述待处理任务所有通道的前n列数据,并将所述前n列数据中的各列数据分别对应存储在第一缓存区中、基于预定循环方向确定的前n个列缓存区中;之后每次从片外存储器读取所述待处理任务所有通道的相邻后续m列数据,并将本次读取的m列数据中的各行数据分别对应存储在第一缓存区中、基于所述预定循环方向确定的相邻后续m个列缓存区中。
- 根据权利要求1~4任一所述的方法,其特征在于,所述卷积核数据对应的卷积核的尺寸为r×r,所述输入窗口数据对应的输入窗口的尺寸为n×n,所述输入窗口数据对应的输入窗口的滑动步长和输出窗口的尺寸为m;其中,m、n、r的取值分别为大于0的整数,且满足n=m+r-1;所述输入缓存区为列缓存区;所述第一缓存区为:由n+m个列缓存区形成的循环缓冲区,每个列缓存区用于顺序存储所述待处理任务所有通道中的同一列数据;所述从加速器的片外存储器读取待处理任务中预设大小的待处理数据,并依次存储在所述加速器的片上内存中、第一缓存区的至少一个输入缓存区,包括:每次从片外存储器读取所述待处理任务所有通道的n列数据;对于首次从所述待处理任务中读取的前n列数据,将所述前n列数据中的各列数据分别对应存储在第一缓存区中、基于预定循环方向确定的前n个列缓存区中;对于非首次读取的n列数据,基于所述预定循环方向,将第一缓存区中存储上一次读取的n列数据的前n个列缓冲区滑动m列后对应的n个列缓冲区作为本次读取的n列数据的目标列缓存区,并将本次读取的n列数据对应存入所述目标列缓存区中的各列缓冲区中。
- 根据权利要求10或11所述的方法,其特征在于,所述依次从至少一个输入缓存区读取待处理的输入窗口数据,并通过所述卷积核数据对所述待处理的输入窗口数据进行卷积计算,包括:针对所述待处理任务,首次读取待处理的输入窗口数据时,选取所述前n个列缓存区作为当前计算缓存区,按照滑动步长m,依次顺序从当前计算缓存区读取大小为n×n的输入窗口数据,并通过所述卷积核数据对所述待处理的输入窗口数据进行卷积计算,直至当前计算缓存区中的待处理数据均被读取;之后每次基于所述预定循环方向,按照滑动步长m从上一计算缓存区开始滑动,选取n个列缓存区作为新的计算缓存区,按照滑动步长m,依次顺序从新的计算缓存区读取大小为n×n的输入窗口数据,并通过所述卷积核数据对所述待处理的输入窗口数据进行卷积计算,直至所述新的计算缓存区中的待处理数据均被读取。
- 根据权利要求10~12任一所述的方法,其特征在于,所述输出缓存区包括m个列缓存区;所述获得输出窗口数据并依次存储在至少一个输出缓存区中,包括:选取其中一个输出缓存区作为当前输出缓存区,依次将对每个输入窗口数据进行卷积计算获得的输出窗口数据顺序存储在当前输出缓冲区的m个列缓存区中;响应于一个计算缓存区中的所有输入窗口数据进行卷积计算获得的输出窗口数据被存储完毕,选取另一个输出缓存区作为当前输出缓存区,执行所述依次将对每个输入窗口数据进行卷积计算获得的输出窗口数据顺序存储在当前输出缓冲区的m个列缓存区中的操作;所述依次将第三缓存区中的输出窗口数据存储至所述片外存储器中,包括:响应于当前计算缓存区中的所有输入窗口数据进行卷积计算获得的输出窗口数据被存储完毕,将所述当前输出缓存区中的输出窗口数据存储至所述片外存储器中。
- 根据权利要求1~13任一所述的方法,其特征在于,所述至少一组卷积核数据包括至少一组转换后的卷积核,其中,任一组转换后的卷积核由对应的第一常数矩阵对对应于一个输出通道的卷积核进行转换获得;通过所述卷积核数据对所述待处理的输入窗口数据进行卷积计算,获得输出窗口数据,包括:分别针对任一输入通道执行如下计算处理操作:采用对应的第二常数矩阵对待处理的输入窗口数据进行转换,获得 转换后输入窗口数据;对所述任一输入通道的转换后输入窗口数据与转换后的卷积核进行矩阵点乘操作,获得点乘后矩阵;采用对应的第三常数矩阵对所述点乘后矩阵进行转换,获得卷积结果;响应于获得所有输入通道的卷积结果,对所有输入通道的所述卷积结果中的对应点进行累加,获得一个输出通道的输出窗口数据。
- 根据权利要求14所述的方法,其特征在于,还包括:预先采用对应的第一常数矩阵,分别对对应于所述至少一个输出通道的卷积核进行转换,获得所述至少一组转换后的卷积核,并存储在所述第二缓冲区中;或者采用对应的第一常数矩阵,分别对对应于所述至少一个输出通道的卷积核进行转换,获得所述至少一组转换后的卷积核。
- 根据权利要求14或15所述的方法,其特征在于,所述采用对应的第二常数矩阵对待处理的输入窗口数据进行转换,包括:根据所述对应的第二常数矩阵,分别对所述任一输入通道待处理的输入窗口数据进行位运算操作;和/或所述采用对应的第三常数矩阵对所述点乘后矩阵进行转换,包括:根据所述对应的第三常数矩阵,分别对所述任一输入通道的所述点乘后矩阵进行位运算操作;和/或所述采用对应的第一常数矩阵,分别对对应于所述至少一个输出通道的卷积核进行转换,包括:根据所述对应的第一常数矩阵,分别对对应于所述至少一个输出通道的卷积核进行位运算操作。
- 根据权利要求14~16任一所述的方法,其特征在于,还包括:分别从常数矩阵表中,查询与所述卷积核的尺寸r×r和输入窗口的尺寸n×n对应的第一常数矩阵、第二常数矩阵和第三常数矩阵;其中,所述常数矩阵表中预先设置有分别与至少一个卷积核的尺寸和输入窗口的尺寸对应的第一常数矩阵、第二常数矩阵和第三常数矩阵。
- 根据权利要求14~17任一所述的方法,其特征在于,所述分别针对任一输入通道执行如下计算处理操作,包括:同时针对Pm个输出通道和Pn个输入通道执行所述计算处理操作,其中,Pm和Pn分别为大于0的整数;所述响应于获得所有输入通道的卷积结果,对所有输入通道的所述卷积结果中的对应点进行累加,获得一个输出通道的输出窗口数据,包括:针对所述Pm个输出通道,响应于获得所有输入通道的卷积结果,分别针对同一个输出通道,将所述所有输入通道的所述卷积结果中的对应点进行累加,获得所述Pm个输出通道的输出窗口数据。
- 根据权利要求18所述的方法,其特征在于,Pm的取值为1,Pn的取值为大于1的整数;所述同时针对Pm个输出通道和Pn个输入通道执行所述计算处理操作,包括:依次针对一个输出通道、全部输入通道或者所述全部输入通道中的部分输入通道,并行执行所述计算处理操作。
- 根据权利要求19所述的方法,其特征在于,Pm的取值为全部输出通道数,Pn的取值为1;所述同时针对Pm个输出通道和Pn个输入通道执行所述计算处理操作,包括:同时针对全部输出通道,依次针对一个输入通道执行所述计算处理操作;所述响应于获得所有输入通道的卷积结果,对所有输入通道的所述卷积结果中的对应点进行累加,获得一个输出通道的输出窗口数据,包括:针对所述全部输出通道,响应于获得所有输入通道的卷积结果,分别针对同一个输出通道,对所有输入通道的所述卷积结果中的对应点进行累加,获得全部输出通道的输出窗口数据。
- 根据权利要求18所述的方法,其特征在于,Pm的取值大于1且小于全部输出通道数,Pn的取值为1;所述同时针对Pm个输出通道和Pn个输入通道执行所述计算处理操作,包括:同时针对全部输出通道中的部分输出通道,依次针对一个输入通道执行所述计算处理操作。
- 根据权利要求18~21任一所述的方法,其特征在于,还包括:根据参数优化模型,由FIFO端口的传输带宽、加速器的资源条件获取所述卷积计算中参数的最优取值,所述卷积计算中参数包括:输入窗口的尺寸、输出通道的并行度和输入通道的并行度,所述参数的最优取值包括:输入窗口的尺寸的最优取值n、输出通道的并行度的最优取值Pm和输入通道的并行度的最优取值Pn。
- 根据权利要求22所述的方法,其特征在于,所述同时针对Pm个输出通道和Pn个输入通道执行所述计算处理操作,包括:基于所述参数的最优取值中Pm和Pn的取值,依次选取Pm个输出通道和Pn个输入通道,执行所述同时针对Pm个输出通道和Pn个输入通道执行所述计算处理操作。
- 根据权利要求1~23任一所述的方法,其特征在于,还包括:比较当前待处理任务的卷积核尺寸k×k与加速器对应的卷积核的尺寸r×r是否一致;若不一致,对所述当前待处理任务的卷积核的右方填充a列0、下方分别填充b行0,使所述当前待处理任务的卷积核转换成尺寸为tr×tr的新卷积核,其中,k、t、a、b的取值分别为大于0的整数。
- 根据权利要求1~24任一所述的方法,其特征在于,还包括:响应于需要对所述待处理任务进行全连接操作,通过FIFO端口从加速器的片外存储器读取所述待处理任务的全部待处理数据,并存储在所述第一缓存区中;对所述全部待处理数据与所述第二缓存区中存储的转换后的卷积核进行矩阵点乘操作,获得点乘后矩阵;采用对应的第三常数矩阵对所述点乘后矩阵进行转换,获得计算结果数据并存储在所述第三缓存区中;通过FIFO端口依次将所述第三缓存区中的计算结果数据存储至所述片外存储器中。
- 根据权利要求1~25任一所述的方法,其特征在于,还包括:响应于需要对所述待处理任务进行池化操作,通过FIFO端口依次从加速器的片外存储器读取所述待处理任务中预设大小的待处理数据,并存储在所述第一缓存区中;从所述预设大小的待处理数据中选取一个取值最大的数据作为计算结果数据,并存储在所述第三缓存区中;通过FIFO端口依次将所述第三缓存区中的计算结果数据存储至所述片外存储器中。
- 根据权利要求1~26任一所述的方法,其特征在于,还包括:响应于需要对所述待处理任务进行激活函数操作,通过FIFO端口依次从加速器的片外存储器读取所述待处理任务中预设大小的待处理数据,并存储在所述第一缓存区中;依次比较所述待处理数据中任一数据的数值是否小于0;若所述任一数据的数值小于0,将以0作为所述任一数据的计算结果存储在所述第三缓存区中;若所述任一数据的数值不小于0,直接将所述任一数据的数值作为计算结果存储在所述第三缓存区中;通过FIFO端口依次将所述第三缓存区中的计算结果存储至所述片外存储器中。
- 根据权利要求1~27任一所述的方法,其特征在于,还包括:响应于需要对所述待处理任务进行上采样操作,通过FIFO端口依次从加速器的片外存储器读取待处理任务中的一个元素数据,将所述元素数据复制为2s×2s的元素矩阵,以所述元素矩阵作为所述待处理数据,开始执行所述依次存储在所述加速器的片上内存中第一缓存区的至少一个输入缓存区的操作;其中,s的取值为大于0的整数。
- 根据权利要求1~28任一所述的方法,其特征在于,还包括:响应于需要对所述待处理任务进行填充处理,通过FIFO端口从加速器的片外存储器读取待处理任务的全部数据,并存储在所述第一缓存区中;比较所述待处理任务的数据大小是否小于预设大小;若所述待处理任务的数据大小小于预设大小,按照预设方式对所述待处理任务进行边缘数据填充,使得填充后的待处理任务的数据大小等于所述预设大小,并将填充后的待处理任务存储在所述第三缓存区中;若所述待处理任务的数据大小不小于预设大小,直接将所述待处理任务存储在所述第三缓存区中;通过FIFO端口依次将所述第三缓存区中的待处理任务数据存储至所述片外存储器中。
- 根据权利要求1~29任一所述的方法,其特征在于,所述加速器包括:现场可编程门阵列FPGA或专用集成电路ASIC。
- 根据权利要求1~30任一所述的方法,其特征在于,所述通过FIFO端口依次从加速器的片外存储器读取待处理任务中预设大小的待处理数据包括:加速器通过FIFO端口接收处理器发送的任务处理指令,并通过FIFO端口依次从加速器的片外存储器读取待处理任务中预设大小的待处理数据的操作;所述方法还包括:响应于对所述待处理任务的卷积加速完成,加速器通过FIFO端口向所述处理器反馈任务完成的响应消息。
- 一种卷积计算处理方法,其特征在于,包括:采用第二常数矩阵对待处理的输入窗口数据进行转换,获得转换后输入窗口数据;对所述转换后输入窗口数据与卷积核数据进行矩阵点乘操作,获得点乘后矩阵;所述卷积核数据由第一常数矩阵对卷积核进行转换获得;采用第三常数矩阵对所述点乘后矩阵进行转换,获得卷积结果。
- 根据权利要求32所述的方法,其特征在于,还包括:预先采用第一常数矩阵对预先设置的卷积核进行转换,获得所述卷积核数据并存储。
- 根据权利要求32所述的方法,其特征在于,采用第二常数矩阵对待处理的输入窗口数据进行转换时,还包括:采用第一常数矩阵对预先设置的卷积核进行转换,获得所述卷积核数据。
- 根据权利要求32~34任一所述的方法,其特征在于,对所述转换后输入窗口数据与卷积核数据进行矩阵点乘操作,包括:采用数字信号处理器,对所述转换后输入窗口数据与卷积核数据进行矩阵点乘操作。
- 根据权利要求32~35任一所述的方法,其特征在于,所述采用第二常数矩阵对待处理的输入窗口数据进行转换,包括:根据所述第二常数矩阵,采用逻辑资源对所述待处理的输入窗口数据进行位运算操作;和/或所述采用第三常数矩阵对所述点乘后矩阵进行转换,包括:根据所述第三常数矩阵,采用逻辑资源对所述点乘后矩阵进行位运算操作;和/或采用第一常数矩阵对卷积核进行转换,包括:根据所述第一常数矩阵,采用逻辑资源对所述卷积核进行位运算操作。
- 根据权利要求32~36任一所述的方法,其特征在于,还包括:分别从常数矩阵表中,查询与所述卷积核数据对应的卷积核的尺寸r×r和输入窗口数据对应的输入窗口的尺寸n×n对应的第一常数矩阵、第二常数矩阵和第三常数矩阵;其中,n和r的取值分别为大于0的整数;所述常数矩阵表中预先设置有分别与至少一个卷积核的尺寸和输入窗口的尺寸对应的第一常数矩阵、第二常数矩阵和第三常数矩阵。
- 一种卷积加速器,其特征在于,包括:数据读取模块,用于通过FIFO端口依次从加速器的片外存储器读取待处理任务中预设大小的待处理数据,并存储在第一缓存区的至少一个输入缓存区;第一缓存区,包括至少一个输入缓存区,用于缓存所述待处理数据;第二缓存区,用于缓存至少一组卷积核数据;计算模块,用于在有输入缓存区中存入待处理数据时,依次从至少一个输入缓存区读取待处理的输入窗口数据,并通过所述卷积核数据对所述待处理的输入窗口数据进行卷积计算,获得输出窗口数据并存储在第三缓存区中;第三缓存区,包括至少一个输出缓存区,用于缓存输出窗口数据;数据输出模块,用于通过FIFO端口,依次将第三缓存区中的输出窗口数据存储至所述片外存储器中。
- 根据权利要求38所述的加速器,其特征在于,所述待处理任务包括:至少一个输入通道的输入图像、或者至少一个输入通道的输入特征图;每组卷积核数据分别对应于一个输出通道,每组卷积核数据包括至少一个卷积核数据,每个卷积核数据分别对应于一个输入通道;所述卷积核数据包括卷积核或转换后的卷积核,所述转换后的卷积核由对应的第一常数矩阵对卷积核进行转换获得。
- 根据权利要求38或39所述的加速器,其特征在于,所述数据输出模块用于:响应于首个输出缓存区存入输出窗口数据,依次读取至少一个输出缓存区中的输出窗口数据,并通过FIFO端口将读取的输出窗口数据存储至所述片外存储器中。
- 根据权利要求40所述的加速器,其特征在于,所述第三缓存区包括两个输出缓存区;在所述待处理任务的处理过程中,所述两个输出缓存区的其中一个输出缓存区被轮流存入输出窗口数据、读取输出窗口数据,所述两个输出缓存区中的另一个输出缓存区被轮流读取输出窗口数据、存入输出窗口数据。
- 根据权利要求38~41任一所述的加速器,其特征在于,所述第一缓存区包括两个输入缓存区;在所述待处理任务的处理过程中,所述两个输入缓存区的其中一个输入缓存区被轮流存入待处理数据、读取待处理的输入窗口数据,所述两个输入缓存区中的另一个输入缓存区被轮流读取待处理的输入窗口数据、存入待处理数据。
- 根据权利要求38~41任一所述的加速器,其特征在于,所述卷积核数据对应的卷积核的尺寸为r×r,所述输入窗口数据对应的输入窗口的尺寸为n×n,所述输入窗口数据对应的输入窗口的滑动步长为m;其中,m、n、r的取值分别为大于0的整数,且满足n=m+r-1;所述输入缓存区为行缓存区;所述第一缓存区为:由n+m个行缓存区形成的循环缓冲区,每个行缓存区用于顺序存储所述待处理任务所有通道中的同一行数据;所述数据读取模块用于:首次从片外存储器读取所述待处理任务所有通道的前n行数据,并将所述前n行数据中的各行数据分别对应存储在第一缓存区中、基于预定循环方向确定的前n个行缓存区中;之后每次从片外存储器读取所述待处理任务所有通道的相邻后续m行数据,并将本次读取的m行数据中的各行数据分别对应存储在第一缓存区中、基于所述预定循环方向确定的相邻后续m个行缓存区中。
- 根据权利要求38~41任一所述的加速器,其特征在于,所述卷积核数据对应的卷积核的尺寸为r×r,所述输入窗口数据对应的输入窗口的尺寸为n×n,所述输入窗口数据对应的输入窗口的滑动步长和输出窗口的尺寸为m;其中,m、n、r的取值分别为大于0的整数,且满足n=m+r-1;所述输入缓存区为行缓存区;所述第一缓存区为:由n+m个行缓存区形成的循环缓冲区,每个行缓存区用于顺序存储所述待处理任务所有通道中的同一行数据;所述数据读取模块用于:每次从片外存储器读取所述待处理任务所有通道的n行数据;对于首次从所述待处理任务中读取的前n行数据,将所述前n行数据中的各行数据分别对应存储在第一缓存区中、基于预定循环方向确定的前n个行缓存区中;对于非首次读取的n行数据,基于所述预定循环方向,将第一缓存区中存储上一次读取的n行数据的前n个行缓冲区滑动m行后对应的n个行缓冲区作为本次读取的n行数据的目标行缓存区,并将本次读取的n行数据对应存入所述目标行缓存区中的各行缓冲区中。
- 根据权利要求43或44所述的加速器,其特征在于,所述计算模块依次从至少一个输入缓存区读取待处理的输入窗口数据,并通过所述卷积核数据对所述待处理的输入窗口数据进行卷积计算时,用于:针对所述待处理任务,首次读取待处理的输入窗口数据时,选取所述前n个行缓存区作为当前计算缓存区,按照滑动步长m,依次顺序从当前计算缓存区读取大小为n×n的输入窗口数据,并通过所述卷积核数据对所述待处理的输入窗口数据进行卷积计算,直至当前计算缓存区中的待处理数据均被读取;之后每次基于所述预定循环方向,按照滑动步长m从上一计算缓存区开始滑动,选取n个行缓存区作为新的计算缓存区,按照滑动步长m,依次顺序从新的计算缓存区读取大小为n×n的输入窗口数据,并通过所述卷积核数据对所述待处理的输入窗口数据进行卷积计算,直至所述新的计算缓存区中的待处理数据均被读取。
- 根据权利要求43~45任一所述的加速器,其特征在于,所述输出缓存区包括m个行缓存区;所述计算模块获得输出窗口数据并依次存储在至少一个输出缓存区中时,用于:选取其中一个输出缓存区作为当前输出缓存区,依次将对每个输入窗口数据进行卷积计算获得的输出窗口数据顺序存储在当前输出缓冲区的m个行缓存区中;响应于一个计算缓存区中的所有输入窗口数据进行卷积计算获得的输出窗口数据被存储完毕,选取另一个输出缓存区作为当前输出缓存区,执行所述依次将对每个输入窗口数据进行卷积计算获得的输出窗口数据顺序存储在当前输出缓冲区的m个行缓存区中的操作;所述数据输出模块,用于:响应于当前计算缓存区中的所有输入窗口数据进行卷积计算获得的输出窗口数据被存储完毕,通过FIFO端口,将所述当前输出缓存区中的输出窗口数据存储至所述片外存储器中。
- 根据权利要求38~41任一所述的加速器,其特征在于,所述卷积核数据对应的卷积核的尺寸为r×r,所述输入窗口数据对应的输入窗口的尺寸为n×n,所述输入窗口数据对应的输入窗口的滑动步长为m;其中,m、n、r的取值分别为大于0的整数,且满足n=m+r-1;所述输入缓存区为列缓存区;所述第一缓存区为:由n+m个列缓存区形成的循环缓冲区,每个列缓存区用于顺序存储所述待处理任务所有通道中的同一列数据;所述数据读取模块,用于:首次从片外存储器读取所述待处理任务所有通道的前n列数据,并将所述前n列数据中的各列数据分别对应存储在第一缓存区中、基于预定循环方向确定的前n个列缓存区中;之后每次从片外存储器读取所述待处理任务所有通道的相邻后续m列数据,并将本次读取的m列数据中的各行数据分别对应存储在第一缓存区中、基于所述预定循环方向确定的相邻后续m个列缓存区中。
- 根据权利要求38~41任一所述的加速器,其特征在于,所述卷积核数据对应的卷积核的尺寸为r×r,所述输入窗口数据对应的输入窗口的尺寸为n×n,所述输入窗口数据对应的输入窗口的滑动步长和输出窗口的尺寸为m;其中,m、n、r的取值分别为大于0的整数,且满足n=m+r-1;所述输入缓存区为列缓存区;所述第一缓存区为:由n+m个列缓存区形成的循环缓冲区,每个列缓存区用于顺序存储所述待处理任务所有通道中的同一列数据;所述数据读取模块,用于:每次从片外存储器读取所述待处理任务所有通道的n列数据;对于首次从所述待处理任务中读取的前n列数据,将所述前n列数据中的各列数据分别对应存储在第一缓存区中、基于预定循环方向确定的前n个列缓存区中;对于非首次读取的n列数据,基于所述预定循环方向,将第一缓存区中存储上一次读取的n列数据的前n个列缓冲区滑动m列后对应的n个列缓冲区作为本次读取的n列数据的目标列缓存区,并将本次读取的n列数据对应存入所述目标列缓存区中的各列缓冲区中。
- 根据权利要求47或48所述的加速器,其特征在于,所述计算模块依次从至少一个输入缓存区读取待处理的输入窗口数据,并通过所述卷积核数据对所述待处理的输入窗口数据进行卷积计算时,包括:针对所述待处理任务,首次读取待处理的输入窗口数据时,选取所述前n个列缓存区作为当前计算缓存区,按照滑动步长m,依次顺序从当前计算缓存区读取大小为n×n的输入窗口数据,并通过所述卷积核数据对所述待处理的输入窗口数据进行卷积计算,直至当前计算缓存区中的待处理数据均被读取;之后每次基于所述预定循环方向,按照滑动步长m从上一计算缓存区开始滑动,选取n个列缓存区作为新的计算缓存区,按照滑动步长m,依次顺序从新的计算缓存区读取大小为n×n的输入窗口数据,并通过所述卷积核数据对所述待处理的输入窗口数据进行卷积计算,直至所述新的计算缓存区中的待处理数据均被读取。
- 根据权利要求47~49任一所述的加速器,其特征在于,所述输出缓存区包括m个列缓存区;所述计算模块获得输出窗口数据并依次存储在至少一个输出缓存区中时,用于:选取其中一个输出缓存区作为当前输出缓存区,依次将对每个输入窗口数据进行卷积计算获得的输出窗口数据顺序存储在当前输出缓冲区的m个列缓存区中;响应于一个计算缓存区中的所有输入窗口数据进行卷积计算获得的输出窗口数据被存储完毕,选取另一个输出缓存区作为当前输出缓存区,执行所述依次将对每个输入窗口数据进行卷积计算获得的输出窗口数据顺序存储在当前输出缓冲区的m个列缓存区中的操作;所述数据输出模块,用于:响应于当前计算缓存区中的所有输入窗口数据进行卷积计算获得的输出窗口数据被存储完毕,通过FIFO端口,将所述当前输出缓存区中的输出窗口数据存储至所述片外存储器中。
- 根据权利要求39~50任一所述的加速器,其特征在于,所述卷积核数据为转换后的卷积核;所述计算模块包括:处理单元,用于分别针对任一输入通道执行如下计算处理操作:采用对应的第二常数矩阵对待处理的输入窗口数据进行转换,获得转换后输入窗口数据;对所述任一输入通道的转换后输入窗口数据与转换后的卷积核进行矩阵点乘操作,获得点乘后矩阵;采用对应的第三常数矩阵对所述点乘后矩阵进行转换,获得卷积结果;累加单元,用于在获得一个输出通道对应的所有输入通道的卷积结果后,对所有输入通道的所述卷积结果中的对应点进行累加,获得所述一个输出通道的输出窗口数据。
- 根据权利要求39~50任一所述的加速器,其特征在于,所述卷积核数据为卷积核;所述计算模块包括:处理单元,用于分别针对任一输入通道执行如下计算处理操作:采用对应的第一常数矩阵,分别对对应于所述至少一个输出通道的卷积核进行转换,获得至少一组转换后的卷积核,以及采用对应的第二常数矩阵对待处理的输入窗口数据进行转换,获得转换后输入窗口数据;对所述任一输入通道的转换后输入窗口数据与转换后的卷积核进行矩阵点乘操作,获得点乘后矩阵;采用对应的第三常数矩阵对所述点乘后矩阵进行转换,获得卷积结果;累加单元,用于在获得一个输出通道对应的所有输入通道的卷积结果后,对所有输入通道的所述卷积结果中的对应点进行累加,获得所述一个输出通道的输出窗口数据。
- 根据权利要求51或52所述的加速器,其特征在于,所述采用对应的第二常数矩阵对待处理的输入窗口数据进行转换,包括:根据所述对应的第二常数矩阵,分别对所述任一输入通道待处理的输入窗口数据进行位运算操作;和/或所述采用对应的第三常数矩阵对所述点乘后矩阵进行转换,包括:根据所述对应的第三常数矩阵,分别对所述任一输入通道的所述点乘后矩阵进行位运算操作;和/或所述采用对应的第一常数矩阵,分别对对应于所述至少一个输出通道的卷积核进行转换,包括:根据所述对应的第一常数矩阵,分别对对应于所述至少一个输出通道的卷积核进行位运算操作。
- 根据权利要求51~53任一所述的加速器,其特征在于,所述计算模块包括Pm×Pn个处理单元,用于同时针对Pm个输出通道和Pn个输入通道执行所述计算处理操作,其中,Pm和Pn分别为大于0的整数;所述累加单元,用于:针对所述Pm个输出通道,响应于获得所有输入通道的卷积结果,分别针对同一个输出通道,将所述所有输入通道的所述卷积结果中的对应点进行累加,获得所述Pm个输出通道的输出窗口数据。
- 根据权利要求54所述的加速器,其特征在于,Pm的取值为1,Pn的取值为大于1的整数;或者,Pm的取值为全部输出通道数,Pn的取值为1;或者,Pm的取值大于1且小于全部输出通道数,Pn的取值为1。
- 根据权利要求38~55任一所述的加速器,其特征在于,所述加速器包括:FPGA或者ASIC。
- 根据权利要求38~56任一所述的加速器,其特征在于,所述数据读取模块,还用于:通过FIFO端口接收处理器发送的加速指令,所述加速指令中包括卷积计算中参数的最优取值;以及根据所述卷积计算中参数的最优取值,开始执行所述通过FIFO端口依次从加速器的片外存储器读取待处理任务中预设大小的待处理数据的操作;所述数据输出模块,还用于在对所述待处理任务的卷积加速完成后,通过FIFO端口向所述处理器反馈任务完成的响应消息。
- 一种卷积计算处理装置,其特征在于,包括:第一转换模块,用于采用第二常数矩阵对待处理的输入窗口数据进行转换,获得转换后输入窗口数据;点乘模块,用于对所述转换后输入窗口数据与卷积核数据进行矩阵点乘操作,获得点乘后矩阵;所述卷积核数据由第一常数矩阵对卷积核进行转换获得;第二转换模块,用于采用第三常数矩阵对所述点乘后矩阵进行转换,获得卷积结果。
- 根据权利要求58所述的装置,其特征在于,还包括:第三转换模块,用于获取预先存储的所述卷积核数据;或者,采用对应的第一常数矩阵,分别对任一输入通道和任一输出通道对应的卷积核进行转换,获得所述任一输入通道和任一输出通道对应的卷积核数据。
- 根据权利要求58或59所述的装置,其特征在于,所述第一转换模块,用于:根据对应的第二常数矩阵,分别对所述待处理的输入窗口数据进行位运算操作;和/或所述第二转换模块,用于:根据所述第三常数矩阵,分别对所述点乘后矩阵进行位运算操作;和/或所述第三转换模块,用于:根据所述第一常数矩阵,对所述卷积核进行位运算操作。
- 根据权利要求58~60任一所述的装置,其特征在于,还包括:查询模块,分别从常数矩阵表中,查询与所述卷积核数据对应的卷积核的尺寸r×r和输入窗口数据对应的输入窗口的尺寸n×n对应的第一常数矩阵、第二常数矩阵和第三常数矩阵;其中,n和r的取值分别为大于0的整数;所述常数矩阵表中预先设置有分别与至少一个卷积核的尺寸和输入窗口的尺寸对应的第一常数矩阵、第二常数矩阵和第三常数矩阵。
- 一种电子设备,其特征在于,包括:权利要求38~57任意一项所述的卷积加速器,或者权利要求58~61任意一项所述的卷积计算处理装置。
- 一种电子设备,其特征在于,包括:存储器,用于存储可执行指令;以及处理器,用于与所述存储器通信以执行所述可执行指令从而完成权利要求1至31任意一项所述的操作,或者权利要求32至37任意一项所述的操作。
- 一种计算机存储介质,用于存储计算机可读取的指令,其特征在于,所述指令被执行时执行权利要求1至31任意一项所述的操作,或者权利要求32至37任意一项所述的操作。
Priority Applications (2)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| SG11201910024P SG11201910024PA (en) | 2017-04-28 | 2018-04-27 | Convolution acceleration and computing processing methods and apparatuses, electronic device, and storage medium |
| US16/662,493 US11429852B2 (en) | 2017-04-28 | 2019-10-24 | Convolution acceleration and computing processing method and apparatus, electronic device, and storage medium |
Applications Claiming Priority (2)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN201710300171.X | 2017-04-28 | ||
| CN201710300171.XA CN108229645B (zh) | 2017-04-28 | 2017-04-28 | 卷积加速和计算处理方法、装置、电子设备及存储介质 |
Related Child Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| US16/662,493 Continuation US11429852B2 (en) | 2017-04-28 | 2019-10-24 | Convolution acceleration and computing processing method and apparatus, electronic device, and storage medium |
Publications (1)
| Publication Number | Publication Date |
|---|---|
| WO2018196863A1 true WO2018196863A1 (zh) | 2018-11-01 |
Family
ID=62658071
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| PCT/CN2018/084948 Ceased WO2018196863A1 (zh) | 2017-04-28 | 2018-04-27 | 卷积加速和计算处理方法、装置、电子设备及存储介质 |
Country Status (4)
| Country | Link |
|---|---|
| US (1) | US11429852B2 (zh) |
| CN (1) | CN108229645B (zh) |
| SG (1) | SG11201910024PA (zh) |
| WO (1) | WO2018196863A1 (zh) |
Cited By (5)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN110991609A (zh) * | 2019-11-27 | 2020-04-10 | 天津大学 | 提高数据传输效率的行缓存器 |
| WO2020258528A1 (zh) * | 2019-06-25 | 2020-12-30 | 东南大学 | 一种可配置的通用卷积神经网络加速器 |
| EP3771999A1 (en) * | 2019-07-30 | 2021-02-03 | Beijing Baidu Netcom Science And Technology Co. Ltd. | Method and apparatus for extracting image data in parallel from multiple convolution windows, device, and computer-readable storage medium |
| EP3846036A1 (en) * | 2019-12-31 | 2021-07-07 | Beijing Baidu Netcom Science And Technology Co. Ltd. | Matrix storage method, matrix access method, apparatus and electronic device |
| CN114090231A (zh) * | 2021-10-11 | 2022-02-25 | 深圳鲲云信息科技有限公司 | 一种数据处理方法、控制器及可读存储介质 |
Families Citing this family (47)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| WO2020019174A1 (zh) * | 2018-07-24 | 2020-01-30 | 深圳市大疆创新科技有限公司 | 数据存取的方法、处理器、计算机系统和可移动设备 |
| CN109165723B (zh) * | 2018-08-03 | 2021-03-19 | 北京字节跳动网络技术有限公司 | 用于处理数据的方法和装置 |
| CN108984426B (zh) * | 2018-08-03 | 2021-01-26 | 北京字节跳动网络技术有限公司 | 用于处理数据的方法和装置 |
| CN110826707B (zh) * | 2018-08-10 | 2023-10-31 | 北京百度网讯科技有限公司 | 应用于卷积神经网络的加速方法和硬件加速器 |
| CN109343826B (zh) * | 2018-08-14 | 2021-07-13 | 西安交通大学 | 一种面向深度学习的可重构处理器运算单元 |
| WO2020073164A1 (zh) * | 2018-10-08 | 2020-04-16 | 深圳市大疆创新科技有限公司 | 数据存储的装置、方法、处理器和可移动设备 |
| CN111124626B (zh) * | 2018-11-01 | 2024-09-03 | 北京灵汐科技有限公司 | 一种众核系统及其数据处理方法和处理装置 |
| CN111258653B (zh) * | 2018-11-30 | 2022-05-24 | 上海寒武纪信息科技有限公司 | 原子访存方法、存储介质、计算机设备、装置和系统 |
| CN109558329A (zh) * | 2018-12-10 | 2019-04-02 | 广东浪潮大数据研究有限公司 | 一种程序检测方法、装置、设备及可读存储介质 |
| CN109800867B (zh) * | 2018-12-17 | 2020-09-29 | 北京理工大学 | 一种基于fpga片外存储器的数据调用方法 |
| CN109816093B (zh) * | 2018-12-17 | 2020-12-04 | 北京理工大学 | 一种单路式卷积实现方法 |
| CN109740732B (zh) * | 2018-12-27 | 2021-05-11 | 深圳云天励飞技术有限公司 | 神经网络处理器、卷积神经网络数据复用方法及相关设备 |
| CN109948784B (zh) * | 2019-01-03 | 2023-04-18 | 重庆邮电大学 | 一种基于快速滤波算法的卷积神经网络加速器电路 |
| CN109919310B (zh) * | 2019-01-15 | 2021-05-18 | 中国科学院信息工程研究所 | 一种面向深度学习训练任务的gpu内存优化方法及系统 |
| CN110032538B (zh) * | 2019-03-06 | 2020-10-02 | 上海熠知电子科技有限公司 | 一种数据读取系统和方法 |
| CN111832713B (zh) * | 2019-04-19 | 2024-06-18 | 北京灵汐科技有限公司 | 一种基于行缓冲Linebuffer的并行计算方法及计算设备 |
| CN111950718B (zh) * | 2019-05-16 | 2021-12-07 | 北京知存科技有限公司 | 利用存算一体芯片实现递进式cnn运算的方法 |
| CN110276444B (zh) * | 2019-06-04 | 2021-05-07 | 北京清微智能科技有限公司 | 基于卷积神经网络的图像处理方法及装置 |
| CN110704019B (zh) * | 2019-08-26 | 2020-12-22 | 深圳芯英科技有限公司 | 数据缓存器及数据读取方法 |
| CN110673786B (zh) | 2019-09-03 | 2020-11-10 | 浪潮电子信息产业股份有限公司 | 数据缓存的方法和装置 |
| CN110766133B (zh) * | 2019-09-18 | 2020-12-25 | 开放智能机器(上海)有限公司 | 嵌入式设备中的数据处理方法、装置、设备和存储介质 |
| US11423644B1 (en) * | 2019-09-19 | 2022-08-23 | Ambarella International Lp | Hardware efficient RoI align |
| WO2021092941A1 (zh) * | 2019-11-15 | 2021-05-20 | 深圳市大疆创新科技有限公司 | 感兴趣区域-池化层的计算方法与装置、以及神经网络系统 |
| US11372644B2 (en) * | 2019-12-09 | 2022-06-28 | Meta Platforms, Inc. | Matrix processing instruction with optional up/down sampling of matrix |
| CN113050988A (zh) * | 2019-12-27 | 2021-06-29 | 上海商汤智能科技有限公司 | 数据处理方法和装置 |
| CN113052291B (zh) * | 2019-12-27 | 2024-04-16 | 上海商汤智能科技有限公司 | 数据处理方法和装置 |
| US12361266B2 (en) * | 2020-05-14 | 2025-07-15 | Samsung Electronics Co., Ltd. | Hierarchical weight preprocessing for neural network accelerator |
| CN111898743A (zh) * | 2020-06-02 | 2020-11-06 | 深圳市九天睿芯科技有限公司 | 一种cnn加速方法及加速器 |
| CN111899147B (zh) * | 2020-06-16 | 2022-08-09 | 北京大学 | 一种卷积核计算加速器及卷积核计算方法 |
| CN112257859B (zh) * | 2020-10-30 | 2024-07-05 | 地平线(上海)人工智能技术有限公司 | 特征数据处理方法及装置、设备、存储介质 |
| CN112396165B (zh) * | 2020-11-30 | 2024-06-11 | 珠海零边界集成电路有限公司 | 用于卷积神经网络的运算装置和方法 |
| US12094531B2 (en) | 2021-01-11 | 2024-09-17 | Micron Technology, Inc. | Caching techniques for deep learning accelerator |
| CN112862091B (zh) * | 2021-01-26 | 2022-09-27 | 合肥工业大学 | 一种基于快速卷积的资源复用型神经网络硬件加速电路 |
| CN112966729B (zh) * | 2021-02-26 | 2023-01-31 | 成都商汤科技有限公司 | 一种数据处理方法、装置、计算机设备及存储介质 |
| CN112949845B (zh) * | 2021-03-08 | 2022-08-09 | 内蒙古大学 | 一种基于fpga的深度卷积神经网络的加速器 |
| CN112686377B (zh) * | 2021-03-18 | 2021-07-02 | 北京地平线机器人技术研发有限公司 | 利用卷积硬件对特征数据进行反卷积处理的方法和装置 |
| CN112989270B (zh) * | 2021-04-27 | 2024-11-22 | 南京风兴科技有限公司 | 一种基于混合并行的卷积计算装置 |
| CN113255898B (zh) * | 2021-06-16 | 2022-08-02 | 合肥工业大学 | 基于Winograd算法的卷积神经网络硬件加速器及计算方法 |
| CN113516235B (zh) * | 2021-07-13 | 2024-10-18 | 南京大学 | 一种可变形卷积加速器和可变形卷积加速方法 |
| CN113448624B (zh) * | 2021-07-15 | 2023-06-27 | 安徽聆思智能科技有限公司 | 数据存取方法及装置、系统、ai加速器 |
| CN113642724B (zh) * | 2021-08-11 | 2023-08-01 | 西安微电子技术研究所 | 一种高带宽存储的cnn加速器 |
| CN116681114B (zh) * | 2022-02-22 | 2024-07-30 | 深圳鲲云信息科技有限公司 | 池化计算芯片、方法、加速器及系统 |
| CN114936349A (zh) * | 2022-03-31 | 2022-08-23 | 上海阵量智能科技有限公司 | 数据处理装置及方法、处理器、芯片、计算机设备 |
| CN114758209B (zh) * | 2022-06-14 | 2022-09-02 | 深圳思谋信息科技有限公司 | 卷积结果获取方法、装置、计算机设备及存储介质 |
| TWI842180B (zh) * | 2022-11-04 | 2024-05-11 | 瑞昱半導體股份有限公司 | 卷積電路與卷積計算方法 |
| WO2024263962A2 (en) * | 2023-06-23 | 2024-12-26 | Rain Neuromorphics Inc. | Flexible compute engine microarchitecture |
| CN116861149B (zh) * | 2023-09-05 | 2024-01-09 | 之江实验室 | 卷积运算的优化方法、装置及处理器 |
Citations (4)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN102339386A (zh) * | 2011-08-16 | 2012-02-01 | 杭州晟元芯片技术有限公司 | 一种嵌入式指纹特征提取加速方法 |
| CN105869117A (zh) * | 2016-03-28 | 2016-08-17 | 上海交通大学 | 一种针对深度学习超分辨率技术的gpu加速方法 |
| CN106228240A (zh) * | 2016-07-30 | 2016-12-14 | 复旦大学 | 基于fpga的深度卷积神经网络实现方法 |
| CN106547885A (zh) * | 2016-10-27 | 2017-03-29 | 桂林电子科技大学 | 一种文本分类系统及方法 |
Family Cites Families (3)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US8363535B2 (en) * | 2003-04-28 | 2013-01-29 | Marvell International Ltd. | Frequency domain echo and next cancellation |
| CN105956660A (zh) * | 2016-05-16 | 2016-09-21 | 浪潮集团有限公司 | 一种用于实时图像识别的神经元网络芯片实现方法 |
| US10891538B2 (en) * | 2016-08-11 | 2021-01-12 | Nvidia Corporation | Sparse convolutional neural network accelerator |
-
2017
- 2017-04-28 CN CN201710300171.XA patent/CN108229645B/zh active Active
-
2018
- 2018-04-27 SG SG11201910024P patent/SG11201910024PA/en unknown
- 2018-04-27 WO PCT/CN2018/084948 patent/WO2018196863A1/zh not_active Ceased
-
2019
- 2019-10-24 US US16/662,493 patent/US11429852B2/en active Active
Patent Citations (4)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN102339386A (zh) * | 2011-08-16 | 2012-02-01 | 杭州晟元芯片技术有限公司 | 一种嵌入式指纹特征提取加速方法 |
| CN105869117A (zh) * | 2016-03-28 | 2016-08-17 | 上海交通大学 | 一种针对深度学习超分辨率技术的gpu加速方法 |
| CN106228240A (zh) * | 2016-07-30 | 2016-12-14 | 复旦大学 | 基于fpga的深度卷积神经网络实现方法 |
| CN106547885A (zh) * | 2016-10-27 | 2017-03-29 | 桂林电子科技大学 | 一种文本分类系统及方法 |
Cited By (12)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| WO2020258528A1 (zh) * | 2019-06-25 | 2020-12-30 | 东南大学 | 一种可配置的通用卷积神经网络加速器 |
| EP3771999A1 (en) * | 2019-07-30 | 2021-02-03 | Beijing Baidu Netcom Science And Technology Co. Ltd. | Method and apparatus for extracting image data in parallel from multiple convolution windows, device, and computer-readable storage medium |
| KR20210014561A (ko) * | 2019-07-30 | 2021-02-09 | 베이징 바이두 넷컴 사이언스 앤 테크놀로지 코., 엘티디. | 다수 컨벌루션 윈도우 중의 이미지 데이터를 추출하는 방법, 장치, 기기 및 컴퓨터 판독 가능한 저장매체 |
| JP2021022362A (ja) * | 2019-07-30 | 2021-02-18 | 北京百度网▲訊▼科技有限公司Beijing Baidu Netcom Science And Technology Co.,Ltd. | 複数の畳み込みウィンドウ内の画像データの並行抽出方法、装置、機器及びコンピュータ可読記憶媒体 |
| US11481994B2 (en) | 2019-07-30 | 2022-10-25 | Beijing Baidu Netcom Science And Technology Co., Ltd. | Method and apparatus for extracting image data in parallel from multiple convolution windows, device, and computer-readable storage medium |
| KR102470027B1 (ko) | 2019-07-30 | 2022-11-24 | 베이징 바이두 넷컴 사이언스 앤 테크놀로지 코., 엘티디. | 다수 컨벌루션 윈도우 중의 이미지 데이터를 추출하는 방법, 장치, 기기 및 컴퓨터 판독 가능한 저장매체 |
| EP3771999B1 (en) * | 2019-07-30 | 2023-01-18 | Kunlunxin Technology (Beijing) Company Limited | Method and apparatus for extracting image data in parallel from multiple convolution windows, device, and computer-readable storage medium |
| CN110991609A (zh) * | 2019-11-27 | 2020-04-10 | 天津大学 | 提高数据传输效率的行缓存器 |
| CN110991609B (zh) * | 2019-11-27 | 2023-12-26 | 天津大学 | 用于数据传输的行缓存器 |
| EP3846036A1 (en) * | 2019-12-31 | 2021-07-07 | Beijing Baidu Netcom Science And Technology Co. Ltd. | Matrix storage method, matrix access method, apparatus and electronic device |
| US11635904B2 (en) | 2019-12-31 | 2023-04-25 | Kunlunxin Technology (Beijing) Company Limited | Matrix storage method, matrix access method, apparatus and electronic device |
| CN114090231A (zh) * | 2021-10-11 | 2022-02-25 | 深圳鲲云信息科技有限公司 | 一种数据处理方法、控制器及可读存储介质 |
Also Published As
| Publication number | Publication date |
|---|---|
| CN108229645A (zh) | 2018-06-29 |
| US20200057938A1 (en) | 2020-02-20 |
| SG11201910024PA (en) | 2019-11-28 |
| CN108229645B (zh) | 2021-08-06 |
| US11429852B2 (en) | 2022-08-30 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| WO2018196863A1 (zh) | 卷积加速和计算处理方法、装置、电子设备及存储介质 | |
| US20230305808A1 (en) | Accelerated mathematical engine | |
| KR102368970B1 (ko) | 지능형 고 대역폭 메모리 장치 | |
| CN111445012A (zh) | 一种基于fpga的分组卷积硬件加速器及其方法 | |
| CN112840356B (zh) | 运算加速器、处理方法及相关设备 | |
| CN110991634B (zh) | 人工智能加速器、设备、芯片及数据处理方法 | |
| US11775430B1 (en) | Memory access for multiple circuit components | |
| CN107657581B (zh) | 一种卷积神经网络cnn硬件加速器及加速方法 | |
| US20200234124A1 (en) | Winograd transform convolution operations for neural networks | |
| CN109409511B (zh) | 一种用于动态可重构阵列的卷积运算数据流调度方法 | |
| CN111758107B (zh) | 用于基于硬件的池化的系统和方法 | |
| CN111247527B (zh) | 在卷积神经网络模型中确定特征图像的方法和装置 | |
| US9697176B2 (en) | Efficient sparse matrix-vector multiplication on parallel processors | |
| US11709911B2 (en) | Energy-efficient memory systems and methods | |
| CN111582465B (zh) | 基于fpga的卷积神经网络加速处理系统、方法以及终端 | |
| US10671288B2 (en) | Hierarchical sparse tensor compression method in artificial intelligent devices | |
| JP6978467B2 (ja) | 疎要素を密行列に変換するためのシステムおよび方法 | |
| CN106228238A (zh) | 现场可编程门阵列平台上加速深度学习算法的方法和系统 | |
| EP4071619B1 (en) | Address generation method, related device and storage medium | |
| WO2022151779A1 (zh) | 卷积运算的实现方法、数据处理方法及装置 | |
| CN113989169A (zh) | 一种膨胀卷积加速计算方法及装置 | |
| CN110929854B (zh) | 一种数据处理方法、装置及硬件加速器 | |
| JP2017138966A (ja) | 疎要素を密行列に変換するためのシステムおよび方法 | |
| CN112799599B (zh) | 一种数据存储方法、计算核、芯片和电子设备 | |
| CN113962376B (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: 18790345 Country of ref document: EP Kind code of ref document: A1 |
|
| NENP | Non-entry into the national phase |
Ref country code: DE |
|
| 32PN | Ep: public notification in the ep bulletin as address of the adressee cannot be established |
Free format text: NOTING OF LOSS OF RIGHTS PURSUANT TO RULE 112(1) EPC (EPO FORM 1205A DATED 13.02.2020) |
|
| 122 | Ep: pct application non-entry in european phase |
Ref document number: 18790345 Country of ref document: EP Kind code of ref document: A1 |