WO2021102946A1 - 计算装置、方法、处理器和可移动设备 - Google Patents

计算装置、方法、处理器和可移动设备 Download PDF

Info

Publication number
WO2021102946A1
WO2021102946A1 PCT/CN2019/122083 CN2019122083W WO2021102946A1 WO 2021102946 A1 WO2021102946 A1 WO 2021102946A1 CN 2019122083 W CN2019122083 W CN 2019122083W WO 2021102946 A1 WO2021102946 A1 WO 2021102946A1
Authority
WO
WIPO (PCT)
Prior art keywords
feature map
convolution
data loading
chip memory
data
Prior art date
Application number
PCT/CN2019/122083
Other languages
English (en)
French (fr)
Inventor
杨康
麻津铭
颜钊
林蔓虹
Original Assignee
深圳市大疆创新科技有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 深圳市大疆创新科技有限公司 filed Critical 深圳市大疆创新科技有限公司
Priority to CN201980048907.6A priority Critical patent/CN112470138A/zh
Priority to PCT/CN2019/122083 priority patent/WO2021102946A1/zh
Publication of WO2021102946A1 publication Critical patent/WO2021102946A1/zh

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F15/00Digital computers in general; Data processing equipment in general
    • G06F15/76Architectures of general purpose stored program computers
    • G06F15/78Architectures of general purpose stored program computers comprising a single central processing unit
    • G06F15/7807System on chip, i.e. computer system on a single chip; System in package, i.e. computer system on one or more chips in a single package
    • G06F15/781On-chip cache; Off-chip memory
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/04Architecture, e.g. interconnection topology
    • G06N3/045Combinations of networks
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/06Physical realisation, i.e. hardware implementation of neural networks, neurons or parts of neurons
    • G06N3/063Physical realisation, i.e. hardware implementation of neural networks, neurons or parts of neurons using electronic means

Definitions

  • This application relates to the field of information technology, and more specifically, to a computing device, a method, a processor, and a mobile device.
  • CNN Convolutional Neural Network
  • the present application provides a computing device, a method, a processor, and a movable device, which can improve the performance of a convolutional neural network.
  • a computing device including: an on-chip memory for caching an input feature map and a convolution kernel; and a reading circuit for reading the input feature map and convolution kernel from the off-chip memory to all In the on-chip memory; a control circuit for determining the target data loading mode in the multiple data loading modes according to the data movement amount of each data loading mode in the multiple data loading modes, and controlling the reading circuit
  • the input feature map and the convolution kernel are read from the off-chip memory to the on-chip memory, wherein the multiple data loading modes are loading to the on-chip memory
  • the input feature map and the convolution kernel mode, and the data movement amount of each data loading mode is the total data amount that needs to be moved to perform the convolution operation on the input feature map and the convolution kernel
  • the convolution calculation circuit is configured to perform convolution calculation on the input feature map and the convolution kernel in the on-chip memory to obtain an output feature map.
  • a calculation method which includes: determining a target data loading mode in the multiple data loading modes according to the data movement amount of each data loading mode in the multiple data loading modes, wherein the The multiple data loading methods are the method of loading the input feature map and the convolution kernel to the on-chip memory of the device, and the amount of data movement of each data loading method is to transfer the input feature map and the volume The total amount of data that the product core needs to move for convolution operations; according to the target data loading mode, the input feature map and the convolution core are read from the off-chip memory to the on-chip memory of the device; Perform convolution calculation on the input feature map and the convolution kernel in the on-chip memory to obtain an output feature map.
  • a processor including the computing device of the first aspect.
  • a mobile device including the computing device of the first aspect; or, the processor of the third aspect.
  • a computer storage medium is provided, and program code is stored in the computer storage medium, and the program code can be used to instruct the execution of the method of the second aspect.
  • a suitable data loading method can be selected among multiple data loading methods according to the amount of data movement of multiple data loading methods, which is beneficial to reduce the data movement in the convolution calculation process, and reduces the input and The bandwidth of the output data can improve the efficiency of convolution calculation.
  • Fig. 1 is a schematic diagram of a convolution operation process of a convolutional neural network according to an embodiment of the present application.
  • Fig. 2 is an architecture diagram of a system to which the technical solution of the embodiment of the present application is applied.
  • Fig. 3 is a schematic flowchart of a calculation method according to an embodiment of the present application.
  • Fig. 4 is a schematic diagram of a calculation sequence of convolution calculation.
  • Fig. 5 is a schematic diagram of another calculation sequence of convolution calculation.
  • Fig. 6 is a schematic diagram of a cache allocation method of an on-chip memory according to an embodiment of the present application.
  • Fig. 7 is a schematic block diagram of a computing device according to an embodiment of the present application.
  • FIG. 8 is a schematic structural diagram of a movable device according to an embodiment of the present application.
  • Figure 1 shows a schematic diagram of the convolution operation process of a convolutional neural network.
  • the convolution operation of the convolutional neural network is to calculate the input weight and the input feature map (Input Feature Map, IFM) to obtain the output feature map (Output Feature Map, OFM).
  • the weight is also called filter (FILT) or convolution kernel.
  • the input feature map is the output feature map of the previous layer or the feature map that has not been processed by the convolutional neural network.
  • the output feature map is the feature map obtained after the input feature map is processed by the current layer.
  • the convolution kernel, the input feature map, and the output feature map can all be expressed as a multi-dimensional matrix.
  • a convolution operation of the convolutional layer of the convolutional neural network is at least part of the eigenvalues (data units) of the input feature matrix and the convolution kernel The weight value of the matrix is multiplied and added.
  • the convolution operation of the convolutional layer can adopt a sliding window method, starting from the upper left corner of the input eigenvalue matrix, taking the size of the convolution kernel as the window, and then sliding the windows to the lower right corner of the input eigenvalue matrix. Generate a complete two-dimensional output feature matrix. After each sliding window, the convolution computing device extracts an input eigenvalue of the window size from the input eigenvalue matrix, and performs multiplication and addition operations with the convolution kernel to generate an output eigenvalue. According to the above method, after all the two-dimensional output feature matrices are sequentially generated, the three-dimensional output feature matrix of the convolutional layer can be obtained.
  • the size of the input feature map is W ⁇ H ⁇ M, where W can represent the width direction, H can represent the height direction, and C represents the channel direction (also called the depth direction or the thickness direction), so the input feature map can be called 3D Feature map.
  • the convolution kernel can also be 3D, W can represent the width direction of the convolution kernel, H can represent the height direction of the convolution kernel, C represents the channel direction of the convolution kernel, the number of convolution kernels can be N, N Being a positive integer, the size of the N convolution kernels can be the same, but the parameters can be different.
  • a convolution kernel and a 3D input feature map to perform multiplication and addition operations can output a 2D feature map, and then use N convolution kernels to perform convolution operations with the 3D input feature map to obtain 3D output features.
  • Figure, where the size of the channel direction of the convolution kernel can be the same as the size of the channel direction of the input feature map.
  • the system may include a processor 100 and an off-chip memory 200.
  • the processor 100 may also be referred to as a convolutional neural network accelerator.
  • the processor 100 may include a control circuit 110, a calculation circuit 120, a direct memory access (DMA) 130, and an on-chip memory 140, such as a static random access memory (Static Random-Access Memory, SRAM). ).
  • DMA direct memory access
  • SRAM static random access memory
  • control circuit 110 can control the calculation of the calculation circuit 120 (for example, the size of the data involved in the calculation and the timing of the calculation, etc.), control the DMA130 to read or store data, for example, control the DMA130 to read data from the external memory 200 To the on-chip memory 140 or write data from the on-chip memory 140 to the external memory 200.
  • control circuit 110 may read instructions from the off-chip memory 200 for controlling the calculation circuit 120 and the DMA 130.
  • the calculation circuit 120 may implement the processing of the convolutional layer or other layers of the convolutional neural network. That is, the calculation circuit 120 may include a convolution calculation circuit, or may include other calculation circuits, such as a pooling layer circuit, etc. In an embodiment, the calculation circuit 120 may read data from the on-chip memory 140 to perform operations on the convolutional layer, and output the operation results to the on-chip memory 140 for storage.
  • the calculation circuit 120 may also include other on-chip memories distinguished from the on-chip memory 140 for storing data in the calculation circuit 120, for example, intermediate results obtained by convolution calculations.
  • the DMA130 can read data from the off-chip memory 200 (for example, data that can be used for convolution operations) and store it in the on-chip memory 140, or it can read data from the on-chip memory 140 (for example, the convolution calculation circuit 120), and store the data in the off-chip memory 200.
  • the off-chip memory 200 for example, data that can be used for convolution operations
  • the on-chip memory 140 for example, the convolution calculation circuit 120
  • FIG. 2 is only an implementation manner of the embodiment of the present application, and should not constitute a special limitation to the embodiment of the present application.
  • a suitable data loading method can be selected among the multiple data loading methods according to the data movement amount of the multiple data loading methods, and the input feature map and volume can be further based on the data loading method.
  • the product kernel is read from the off-chip memory into the on-chip memory, so that the convolution calculation circuit can perform convolution calculation according to the read input feature map and the convolution kernel to obtain the input feature map, which is beneficial to improve the utilization of the on-chip memory Rate, reduce the amount of data movement of convolution operations, and improve the performance of convolutional neural network accelerators.
  • FIG. 3 is a schematic flowchart of a calculation method according to an embodiment of the present application, where the method 400 may be executed by a convolution calculation apparatus, specifically, may be executed by a processing device in the convolution calculation apparatus.
  • the processing device may include, for example, the processor 100 shown in FIG. 2.
  • the method 400 may include the following steps:
  • S410 Determine a target data loading mode among the multiple data loading modes according to the data movement amount of each data loading mode in the multiple data loading modes, where the multiple data loading modes are transfers to the device
  • the on-chip memory loads the input feature map and the convolution kernel, and the data movement amount of each data loading method is the total movement required to perform the convolution operation on the input feature map and the convolution kernel.
  • the amount of data
  • S430 Perform convolution calculation on the input feature map and the convolution kernel in the on-chip memory to obtain an output feature map.
  • the processing device may be implemented by a Field Programmable Gate Array (Field Programmable Gate Array, FPGA or Application Specific Integrated Circuit, ASIC).
  • FPGA or ASCI is a dedicated Integrated circuits, which can implement specific functions through customized hardware accelerators, and are more efficient in processing.
  • this application is not limited to this.
  • the processing device may include a reading circuit, a control circuit, and a calculation circuit, which correspond to the DMA130, the control circuit 110, and the calculation circuit 120 in FIG. 2 respectively, wherein the control circuit may be used to execute the diagram.
  • the reading circuit may be used to execute S420 in the method 400 shown in FIG. 3
  • the calculation circuit may be used to execute S430 in the method 400 shown in FIG.
  • the processing device is taken as the execution subject as an example for description.
  • reading circuit and the control circuit may be separate circuits, or the reading circuit may also be integrated in the control circuit, which is not limited in the embodiment of the present application.
  • the processing device may divide the IFM and FILT to be loaded into multiple blocks (Block, BLK), and then load the IFM and FILT into the on-chip memory according to the determined target loading mode. Of each block.
  • the input feature map and the convolution kernel may be segmented in at least one of the height direction, the width direction, and the channel direction to obtain a plurality of blocks, and then transfer the input feature map and the convolution kernel to the slice based on the target loading mode.
  • the multiple blocks are loaded in the memory.
  • the input feature map can be segmented in the height direction H and the channel direction C to obtain the ⁇ row and ⁇ column feature map block matrix, and FILT is performed in the channel direction C and the number direction (N direction) Divide, get the convolution kernel block array of ⁇ row and ⁇ column, the ⁇ row ⁇ column feature map block matrix and the ⁇ row ⁇ column convolution kernel block array can be convolved to get the ⁇ row ⁇ column output
  • the feature map block matrix Among them, ⁇ represents the number of BLKs of IFM in the H direction, ⁇ represents the number of BLKs of IFM in the C direction, and ⁇ represents the number of BLKs of OFM in the C direction.
  • the IFM and FILT can also be split in other directions, for example, the IFM can be split in the W and C directions, or it can also be split in one direction, for example, only in the C direction or the H direction.
  • the segmentation is performed in the direction, and the embodiment of the present application is not limited to this.
  • the description will be given only by taking the example of dividing the IFM into the H direction and the C direction, and dividing the FILT into the C direction and the N direction, but the embodiments of the present application are not limited to this.
  • A is used to represent IFM
  • a is used to represent a BLK of IFM
  • K is used to represent FILT
  • k is used to represent a FILTBLK
  • V is used to represent OFM
  • v is used to represent an OFMBLK.
  • using Indicates a specific FILT BLK where the subscript i represents the index of FILT BLK in the C direction, and the superscript j represents the index in the N direction.
  • C A and C a are used to indicate the size of IFM and IFM BLK in the C direction
  • H K and H k indicate FILT and FILT BLK in the H direction
  • N K and N k respectively represent the size of FILT and FILT BLK in the N direction.
  • the data movement amount for loading all the feature values in IFM to the on-chip memory is denoted as B A
  • the data movement amount for loading all the weight values in FILT into the on-chip memory is denoted as B K
  • B total The total amount of data movement required for one convolution operation of IFM and FILT is recorded as B total .
  • the processing device may calculate the amount of data movement required by the multiple data loading methods, and then select a suitable data loading method according to the data movement amount of each data loading method, for example, select data The data loading method with the lowest amount of movement.
  • the processing device may also calculate the data transfer time of each data loading mode, and further select an appropriate data loading mode, for example, the data loading mode with the shortest data transfer time may be selected.
  • the convolution calculation can have two calculation sequences, which are respectively denoted as NRM and NMR.
  • NRM the output of OFM follows the following sequence: Output the first column of COFM, and then output the other columns C of OFM in turn, that is, output in the following order:
  • the output of OFM is in the following order: first output the first line of OFM, and then output other lines of OFM, that is, output in the following order:
  • the first type of data loading method can be used.
  • the basic idea is to multiplex FILT, keep FILT in the on-chip memory, and load each block of IFM into the on-chip memory in order for convolution calculation.
  • the processing device may load the weight value in the FILT into the on-chip memory, then retain the weight value in the FILT in the on-chip memory, and then The sub-blocks of the IFM can be loaded into the on-chip memory in sequence, so that the weight value in the FILT and the feature value in each sub-block of the loaded IFM can be convolutionally calculated, that is, for a complete
  • the amount of data movement of FILT can be B K
  • the amount of data movement of IFM can be one or more times B A.
  • the second type of data loading method can be used.
  • the basic idea is to multiplex the IFM, keep the IFM in the on-chip memory, and load each block of FILT into the on-chip memory in order for convolution calculation.
  • the processing device may load the characteristic values in the IFM into the on-chip memory, then retain the characteristic values in the IFM in the on-chip memory, and then may Load each block in FILT into the on-chip memory in turn, so that the feature value in the IFM and the weight value in the loaded FILT block are convolutionally calculated, that is, for a complete volume
  • the data transfer volume of IFM can be B A
  • the data transfer volume of FILT can be one or more times B K.
  • the multiple data loading modes may include at least one of the following: a first data loading mode, a second data loading mode, a third data loading mode, a fourth data loading mode, and a fifth data loading mode.
  • the loading methods correspond to (a)-(e) in Figure 6 respectively. Of course, more data loading methods may also be included, and the embodiment of the present application is not limited thereto.
  • the processing device loads the feature value in the IFM into the on-chip memory only once, and loads the weight value in the FILT into the on-chip memory only once.
  • the loaded FILT can be retained in the on-chip memory to multiplex the FILT with each sub-block of the subsequently loaded IFM for convolution operation, and each sub-block of the loaded IFM can also be retained in the on-chip memory In order to facilitate the convolution operation of the subsequently loaded FILT and each sub-block of the IFM. It can be seen that, based on the first data loading method, a convolution operation is performed, the data movement amount of IFM is B A , and the data movement amount of FILT can be B K.
  • the processing device loads the weight value in the FILT into the on-chip memory only once, and loads the IFM into the on-chip memory multiple times, that is, performs one roll Product operation, the data movement of IFM is multiple B A , and the data movement of FILT can be B K ;
  • the processing circuit loads the weight value in the FILT into the on-chip memory multiple times, and loads the IFM into the on-chip memory multiple times, that is, performs one roll Product operation, the data movement of IFM is multiple B A , and the data movement of FILT can be multiple B K ;
  • the processing circuit loads the IFM to the on-chip memory once.
  • the difference from the first data loading mode is that the loaded IFM is retained in the on-chip memory for reproducing Perform a convolution operation with IFM and each sub-block of FILT sequentially loaded subsequently, and perform a convolution operation.
  • the data movement amount of IFM is B A
  • the data movement amount of FILT is B K ;
  • the IFM can be loaded to the on-chip memory once, and the FILT can be loaded into the on-chip memory multiple times, that is, a convolution operation is performed, and the data transfer amount of the IFM is B A.
  • the data transfer volume of FILT can be multiple times B K.
  • the first data loading mode, the second data loading mode, and the third data loading mode correspond to the order of convolution calculation as NRM, the fourth data loading mode and the fifth data loading mode.
  • the order of convolution calculation corresponding to the data loading method is NMR.
  • loading the IFM to the on-chip memory once or loading the IFM to the on-chip memory once does not mean that all the characteristic values of the IFM are loaded into the on-chip memory at one time, but it means that all the characteristic values of the IFM are loaded into the on-chip memory once.
  • the data volume of the IFM that needs to be moved is the entire data volume of the IFM, that is, there is no need to repeatedly load the IFM into the on-chip memory.
  • the meaning of loading FILT into the on-chip memory once is the same. Go into details again.
  • the processing device may combine the data amount of the input feature map, the space size of the on-chip memory, and the processing of the convolution calculation circuit according to the amount of data movement of the multiple data loading methods. At least one of the capability and the data volume of the convolution kernel, and the target data loading mode is determined in the multiple data loading modes.
  • the first data loading method :
  • the processing device can determine whether the space size of the on-chip memory is sufficient to load the total data volume of the IFM. If the space size of the on-chip memory is sufficient to load the total data volume of the IFM, the processing device can further determine Whether the size of the memory is still sufficient to load the amount of data in the C direction of the FILT, and if the size of the on-chip memory is sufficient to load the amount of data in the C direction of the FILT, the processing device may determine to use the first Data loading method.
  • the data amount in the C direction of the FILT may be the total data amount of each block of the FILT in the C direction, for example, a column in the block matrix of the convolution kernel in FIG. 6, such as
  • the space size of the on-chip memory is sufficient to load the amount of data in the C direction of the FILT may refer to whether the space size of the on-chip memory is sufficient to load one column of the convolution kernel block matrix.
  • the amount of data that can be cached on the on-chip memory includes the entire amount of data of IFM, FILT
  • the amount of data in the C direction may also include the size of a block of OFM calculated by convolution.
  • the processing device loads the first row of IFM BLK in the IFM into the on-chip memory, that is, And load the first column of FILT BLK into the on-chip memory, that is
  • the first row of IFM BLK and the first column of FILT BLK may be loaded at the same time, or may be loaded sequentially, which is not limited in the embodiment of the present application.
  • the processing device loads the second row of IFM BLK into the on-chip memory, At this point, the first line of IFM BLK And the first column FILT BLK It remains in the on-chip memory. Further, it can be based on the second line IFM BLK loaded And the first column FILT BLK Perform convolution operation to get V 1 0 .
  • the second column FILT BLK can be loaded into the on-chip memory, that is wherein, the second column FILT BLK covers the first column FILT BLK, that is, after the second column FILT BLK is loaded, the first column FILT BLK is not retained in the on-chip memory.
  • each row of IFM BLK retained in the on-chip storage is convolved with the second column FILT BLK to obtain the output result of the second column of OFM, namely
  • the output result of the OFM can be cached on the on-chip memory, or can also be output to the off-chip memory.
  • each row of IFM BLK in the IFM is loaded, each row of IFM BLK and a column of FILT BLK may be subjected to convolution calculation, or, After loading a row of IFM BLK, the row of IFM BLK can be convolved with the loaded column of FILT BLK, or when the second row of IFM BLK is loaded, the loaded row of IFM BLK can be combined with the first column of FILT. BLK performs convolution calculations and so on.
  • each row of IFM BLK is loaded in sequence by row. It can be considered that the IFM is not divided in the C direction, and the size in the H direction can be a preset size, or it can be based on the convolutional neural network accelerator. For example, the size in the IFM BLKH direction may be equal to the maximum amount of data that the convolutional neural network accelerator can process in parallel in the H direction of the input feature map.
  • the on-chip memory may include a first on-chip memory and a second on-chip memory, wherein the first on-chip memory is located outside the arithmetic circuit, and the second on-chip memory is located
  • the arithmetic circuit performs the convolution operation on part of the IFM BLK and FILT BLK
  • the part of the IFM BLK and FILT BLK convolution operation results can be stored in the second on-chip memory, and wait until After the convolution operations of all IFM BLK and FILT BLK are calculated, the convolution operation results of all IFM BLK and FILT BLK are combined for processing, such as accumulation processing, to obtain the output result of a convolution kernel or a 2D feature map, and combine It is output to the first on-chip memory, or the arithmetic circuit may also output an intermediate result to the first on-chip memory, which is not limited in the embodiment of the present application.
  • the second data loading mode and the third data loading mode are identical to each other data loading mode and the third data loading mode:
  • the processing device may determine whether FILT can be reused, specifically, the control circuit may determine the size of the on-chip memory Whether the size of the space is sufficient for the amount of data in the C direction of the FILT, if the size of the on-chip memory is sufficient to load the amount of data in the C direction of FILT, that is, the size of the on-chip memory is sufficient to load the convolution kernel block matrix In one column, the FILT can be reused, and the control circuit can determine to adopt the second data loading mode; otherwise, it can be determined that the FILT cannot be reused, and then the third data loading mode can be determined to be adopted.
  • the processing device may determine that the size of the FILT in the C direction is the size of the IFM in the C direction; otherwise, determine that the size of the FILT in the C direction is the IFM.
  • the size of the BLK in the C direction, and the manner of determining the size of the IFM BLK is described below.
  • the processing circuit loads the first row of IFM BLK into the on-chip memory, namely And load the first column FILT BLK in the block matrix of the convolution kernel to the on-chip memory, namely Further, the arithmetic circuit may perform a convolution operation according to the loaded first row IFM BLK and the first column FILT BLK to obtain
  • the processing circuit loading the first row of IFM BLK to the on-chip memory may load one row at a time, or may also be loaded in multiple times, for example, load one IFM BLK at a time.
  • the specific method may be based on the on-chip memory. The size of the space is determined.
  • the first column FILT BLK remains in the on-chip memory, and the processing circuit loads the second row IFM BLK into the on-chip memory.
  • the difference from the first data loading method is that the The second row of IFM BLK needs to cover the first row of IFM BLK, that is, in the second clock cycle, the first row of IFM BLK is not in the on-chip memory.
  • the arithmetic circuit may perform a convolution operation based on the loaded second row IFM BLK and the first column FILT BLK retained in the on-chip memory to obtain V 1 0 .
  • the second column FILT BLK is loaded into the on-chip memory, and the second column FILT BLK covers the first column FILT BLK, that is, the second column FILT BLK is retained in the on-chip memory at this time, and then the IFM Each row of IFM BLK in the ⁇ row of IFM BLK is sequentially loaded into the on-chip memory to perform convolution operation with the second column of FILT BLK to obtain the output result of the second column of OFM, namely
  • the size of IFM BLK in the C direction can be considered to be equal to the size of IFM in the C direction, that is, the IFM is not in the C direction.
  • the processing device loads the first IFM BLK of the first row into the on-chip memory, namely And load the first FILT BLK of the first column into the on-chip memory, that is Further, it can be based on the loaded with Perform multiplication and get Intermediate result
  • the processing device loads the second IFM BLK of the first row into the on-chip memory, namely And the second FILT BLK in the first column, which is At this time, the Overwrite Said Overwrite That is, in the second clock cycle, with Not cached in the on-chip memory, further, it can be based on the loaded with Perform multiplication and get Another intermediate result of
  • the processing device sequentially loads each IFM BLK in the first row of IFM BLKs in an overlaid manner until the last IFM BLK in the first row, that is, And load each FILT BLK in the first column of FILT BLK in an overlay loading mode until the last FILT BLK, that is Then multiply the last IFM BLK with the last FILT BLK to get The intermediate results of, can further accumulate these intermediate results to get the first output result of the first column of OFM
  • the processing device can load each IFM BLK in the second row of IFM BLK and each FILT BLK in the first column of FILT BLK to the on-chip memory in a similar manner as described above, and then use the second row of IFM to load each IFM BLK in the second row of IFM BLK and each FILT BLK in the first column of FILT BLK.
  • Each IFM BLK in the BLK is multiplied and added with each FILT BLK in the FILT BLK of the first column to obtain the second output result V 1 0 of the first column of the OFM.
  • a convolution operation here can refer to all IFM BLK and convolution in the input feature map block matrix. Convolution operation required for a column of FILT BLK in the core block matrix.
  • the processing device may also determine the size of the feature map block in the splitting direction, such as the size H a in the H direction and the C direction On the size C a .
  • H a and C a in order to reduce the amount of data transfer, H a and C a can be set as large as possible.
  • H a at least one of the following:
  • H a is smaller than the space size of the on-chip memory
  • H a obtained in the next iteration process is greater than the space size of the on-chip memory
  • H a obtained in this iteration process satisfies that H a is less than the on-chip memory space, and therefore can be used as the size of the IFM BLK in the H directions, i.e. H a can be cut in units of IFM in the H direction points obtained IFM BLK.
  • the reasonable value that the convolution calculation circuit can process in parallel in the first direction of the input feature map is determined according to the processing capability of the convolution calculation circuit.
  • the reasonable value may be slightly smaller than the input feature
  • C a satisfies at least one of the following:
  • just satisfying that C a is less than the space size of the on-chip memory may mean that if the C a obtained in the next iteration process is greater than the space size of the on-chip memory, it can be considered that the C a obtained in this iteration process satisfies that C a is less
  • the space size of the on-chip memory can therefore be used as the size of the IFM BLK in the C direction, that is, the IFM can be divided in the C direction in the unit of C a to obtain the IFM BLK.
  • the reasonable value that can be processed in parallel by the convolution calculation circuit in the C direction of the input feature map is determined according to the processing capacity of the convolution calculation circuit.
  • the reasonable value may be slightly smaller than that of the input feature map.
  • the maximum amount of data that can be processed in parallel by the convolution calculation circuit in the direction C or may also be a typical value corresponding to the processing capacity, an empirical value, etc.
  • the fourth data loading mode and the fifth data loading mode are identical to The fourth data loading mode and the fifth data loading mode:
  • the processing device may also determine whether to use the fourth data loading mode or the fifth data loading mode according to whether the space size of the on-chip memory is sufficient to load the total data volume of FILT.
  • FILT can be loaded only once, and the fourth data loading mode is determined as the target data loading mode
  • the space size of the on-chip memory is less than the total data amount of the FILT, it may be necessary to load the FILT multiple times, and the fifth data loading mode is determined as the target data loading mode.
  • the processing circuit loads the first row of IFM BLK into the on-chip memory, namely And load the first column of FILT BLK into the on-chip memory, that is
  • the first row of IFM BLK and the first column of FILT BLK may be loaded at the same time, or may be loaded sequentially, which is not limited in the embodiment of the present application.
  • the convolution operation can be performed according to the loaded first row IFM BLK and the first column FILT BLK to obtain
  • the convolution operation can be performed based on the loaded first row IFM BLK and second column FILT BLK to obtain
  • the processing circuit loads the first row of IFM BLK into the on-chip memory, namely And load the first column of FILT BLK into the on-chip memory, that is
  • the first row of IFM BLK and the first column of FILT BLK may be loaded at the same time, or may be loaded sequentially, which is not limited in the embodiment of the present application.
  • the convolution operation can be performed according to the loaded first row IFM BLK and the first column FILT BLK to obtain
  • the second column FILT BLK In the second clock cycle, load the second column FILT BLK to the on-chip memory, and the second column FILT BLK covers the first column FILT BLK, that is, the first row IFM BLK and the second column are cached in the on-chip memory FILT BLK.
  • the convolution operation can be performed based on the loaded second column FILT BLK and the first row IFM BLK to obtain
  • the data transfer amount B total B A +B K ⁇ . That is, IFM needs to be loaded once, and FILT needs to be loaded multiple times, that is, IFM can be reused for convolution operations.
  • a convolution operation here may refer to the convolution operation required for all FILT BLKs in the block matrix of the convolution kernel and a row of IFM BLKs in the block matrix of the input feature map.
  • the fourth and fifth data loading methods can be implemented using the following procedures:
  • the processing device may also determine the size of the feature map block in the splitting direction, such as the size H a in the H direction and The size C a in the C direction and the size of the convolution kernel block in the segmentation direction, such as the size C k in the C direction and the size N k in the N direction.
  • H a and C a in order to reduce the amount of data transfer, H a and C a can be set as large as possible.
  • the C a may be equal to C A , that is, the size of the feature map block in the C direction is equal to the size of the IFM in the C direction, that is, the IFM is not divided in the C direction.
  • the C k may be equal to C K , that is, the size of the convolution kernel block in the C direction is equal to the size of the FILT in the C direction, that is, the FILT is not divided in the C direction.
  • the size of the convolution kernel block in the C direction can be smaller than the size of FILT in the C direction, that is to say, FILT can be divided in the C direction, or in other words, it can be loaded multiple times.
  • FILB BLK One column of FILB BLK.
  • H a at least one of the following:
  • the size of the space of the on-chip memory, or H a reaches the maximum amount of data or a reasonable value that can be processed in parallel by the convolution calculation circuit in the first direction of the input feature map.
  • H a is smaller than the space size of the on-chip memory
  • H a obtained in the next iteration process is greater than the space size of the on-chip memory
  • H a obtained in this iteration process satisfies that H a is less than the on-chip memory space, and therefore can be used as the size of the IFM BLK in the H directions, i.e. H a can be cut in units of IFM in the H direction points obtained IFM BLK.
  • the reasonable value that the convolution calculation circuit can process in parallel in the first direction of the input feature map is determined according to the processing capability of the convolution calculation circuit.
  • the reasonable value may be slightly smaller than the input feature
  • the size of the FILT BLK in the N direction is equal to the size of the FILT in the N direction, that is, the FILT is not divided in the N direction.
  • the size of the FILT BLK in the N direction is equal to the maximum or reasonable value of the OFM that the convolutional neural network accelerator can output in the C direction, where the convolutional neural network accelerator can output
  • the meaning of the reasonable value of OFM in the C direction can refer to the meaning of the reasonable value that can be processed in parallel by the convolution calculation circuit in the first direction of the input feature map, which will not be repeated here.
  • each row of IFM BLK in the IFM may be convolved, or, Each time a row of IFM BLK is loaded, the row of IFM BLK can be convolved with the loaded column of FILT BLK, or when the second row of IFM BLK is loaded, the loaded row of IFM BLK can be combined with the first column of FILT BLK. Perform convolution calculations, etc.
  • processing device of the embodiment of the present application may not have a substantial block division operation, and only performs reading and calculation in blocks during reading and calculation.
  • the on-chip memory may be two-dimensional, for example, the storage format may be 4096 ⁇ 128b, and the storage of the input feature map (for example, reading data that has not yet been processed by convolutional neural network or after processing The obtained intermediate output result) may be an expansion in the 2D space. Specifically, an address may be introduced for each 2D feature map to achieve access to the 3D space.
  • the FILT sharing or IFM sharing characteristics of the convolutional neural network are used to reduce data movement in the calculation process, thereby reducing the bandwidth of input and output data, thereby improving the efficiency of convolution calculation.
  • FIG. 7 is a schematic block diagram of a computing device 600 according to an embodiment of the present application.
  • the device 600 includes:
  • the on-chip memory 610 is used to cache the input feature map and the convolution kernel
  • the reading circuit 620 is configured to read the input feature map and the convolution kernel from the off-chip memory to the on-chip memory;
  • the control circuit 630 is configured to determine a target data loading mode among the multiple data loading modes according to the data movement amount of each data loading mode in the multiple data loading modes, and control the reading circuit according to the target data loading mode.
  • Data loading mode reading the input feature map and the convolution kernel from the off-chip memory to the on-chip memory, wherein the multiple data loading modes are loading the input feature to the on-chip memory Figure and the mode of the convolution kernel, the data transfer amount of each data loading mode is the total amount of data that needs to be transferred for the convolution operation of the input feature map and the convolution kernel;
  • the convolution calculation circuit 640 is configured to perform convolution calculation on the input feature map and the convolution kernel in the on-chip memory to obtain an output feature map.
  • the on-chip memory 610, the reading circuit 620, the control circuit 630, and the convolution calculation circuit 640 may correspond to the on-chip memory 140, DMA 130, control circuit 110, and arithmetic circuit 120 in FIG. 2.
  • the relevant description above For the sake of brevity, I won't repeat them here.
  • control circuit 630 is also used to:
  • the target data loading mode is determined among the multiple data loading modes.
  • the multiple data loading modes include a first type of data loading mode and/or a second type of data loading mode, where:
  • the reading circuit loads the weight value in the convolution kernel into the on-chip memory only once, and the convolution calculation circuit multiplexes the weight value in the convolution kernel A weight value to perform a convolution operation on the weight value in the convolution kernel and the input feature map;
  • the reading circuit loads the feature values in the input feature map into the on-chip memory only once, and the convolution calculation circuit multiplexes the input feature map to Perform a convolution operation on the input feature map and the convolution kernel.
  • the reading circuit 620 is specifically configured to:
  • the target data loading mode is the first type of data loading mode
  • all the input feature maps required for the convolution operation are loaded in the on-chip memory After calculating the weight value of and outputting the calculation result of the corresponding output feature map, load the weight value needed for the next convolution operation; or
  • the target data loading mode is the second type of data loading mode
  • all the weight values that need to be used in the convolution operation and the input loaded in the on-chip memory After the feature map is calculated and the calculation result of the corresponding output feature map is output, the input feature map required for the next convolution operation is loaded.
  • the first type of data loading mode includes a first data loading mode and/or a second data loading mode, wherein, based on the first data loading mode, the reading circuit only Load the feature values in the input feature map into the on-chip memory once; based on the second data loading method, the read circuit loads the feature values in the input feature map into the on-chip memory repeatedly;
  • the second type of data loading mode includes a fourth data loading mode and/or a fifth data loading mode, wherein, based on the fourth data loading mode, the reading circuit only changes the weight value in the convolution kernel Load the on-chip memory once; based on the fifth data loading mode, the read circuit loads the weight value in the convolution kernel into the on-chip memory multiple times.
  • the multiple data loading modes further include a third data loading mode.
  • the reading circuit Based on the third data loading mode, converts the weight value in the convolution kernel to The on-chip memory is loaded multiple times, and the feature values in the input characteristic map are loaded into the on-chip memory multiple times.
  • the input feature map in a convolution operation, includes a feature map block array of ⁇ rows and ⁇ columns, and the feature map blocks in the feature map block array are all
  • the input feature map is obtained by segmenting along the first direction and the third direction, wherein the ⁇ is the number of blocks of the input feature map along the first direction, and the ⁇ is the number of blocks along the input feature map.
  • the number of blocks in the third direction where ⁇ and ⁇ are integers;
  • the convolution kernel includes a convolution kernel block array of ⁇ rows and ⁇ columns, and the convolution kernel block array in the convolution kernel block array divides the convolution kernel into a third direction and a fourth direction. Obtained, wherein the ⁇ is the number of blocks of the convolution kernel along the third direction, and the ⁇ is the number of blocks of the convolution kernel along the fourth direction, where ⁇ is Integer.
  • control circuit 630 is also used to:
  • the on-chip memory can cache the total data volume of the feature map block array required for one convolution operation and the data volume of the convolution kernel block array in the third direction
  • the first data The loading mode is determined as the target data loading mode, and the reading circuit is controlled to load all the feature map block arrays required for the convolution operation into the on-chip memory at the same time, and the convolution will be performed.
  • the convolution kernel block array associated with the convolution calculation in the third direction is simultaneously loaded in the on-chip memory; or
  • the second The data loading mode is determined as the target data loading mode, and the reading circuit is controlled to sequentially load the feature map block arrays required for the convolution operation on the on-chip memory, and the convolution is performed During operation, the convolution kernel block array associated with the convolution calculation in the third direction is simultaneously loaded in the on-chip memory; or
  • the third data loading mode is determined as the target data loading mode, and the reading circuit is controlled to sequentially load the feature map block array required for the convolution operation on the chip A memory, and the convolution kernel block array required for performing the convolution operation are sequentially loaded into the on-chip memory.
  • control circuit 630 is also used to:
  • the size of the feature map block in the first direction satisfies at least one of the following:
  • the size of the feature map block in the third direction satisfies at least one of the following:
  • control circuit 630 is specifically configured to:
  • the fourth data loading mode is determined as the target data loading mode, and the reading circuit is controlled All convolution kernel block arrays required for performing the convolution operation are loaded into the on-chip memory at the same time, and the convolution calculation in the third direction when performing the convolution operation is associated with the The feature map block array is loaded into the on-chip memory at the same time; or
  • the fifth data loading mode is determined as the target data loading mode, and the reading circuit is controlled
  • the convolution kernel block array is sequentially loaded in the on-chip memory, and the feature map block array associated with the convolution calculation in the third direction during the convolution operation is simultaneously loaded in all The on-chip memory.
  • control circuit 630 is also used to:
  • the fourth data loading mode is the target data loading mode, determining that the size of the convolution kernel block in the fourth direction is the size of the convolution kernel in the fourth direction;
  • the fifth data loading mode is the target data loading mode, determine that the size of the convolution kernel block in the fourth direction is the third party of the output feature map that can be output by the convolution calculation circuit The maximum amount of data up.
  • control circuit 630 is also used to:
  • the size of the convolution kernel block in the third direction is the size of the convolution kernel in the third direction.
  • control circuit 630 is also used to:
  • the size of the feature map block in the first direction satisfies at least one of the following:
  • the first direction is a height direction
  • the third direction is a channel direction
  • the fourth direction is a number direction of convolution kernels
  • the first direction is a width direction
  • the third direction is a channel direction
  • the fourth direction is a number direction of convolution kernels.
  • the technical solutions of the embodiments of the present application can be applied to portable devices.
  • the movable device may be an unmanned aerial vehicle, an unmanned boat, an autonomous vehicle or a robot, etc., which is not limited in the embodiment of the present application.
  • FIG. 8 is a schematic block diagram of a movable device 700 according to an embodiment of the present application.
  • the movable device 700 may include a power system 710, a sensing system 720, and a processor 730.
  • the movable device 700 may be a drone, an unmanned boat, an autonomous vehicle, or a robot, etc., which is not limited in the embodiment of the present application.
  • the power system of the unmanned aerial vehicle may include an electronic governor (referred to as an ESC for short), a propeller, and a motor corresponding to the propeller.
  • the motor is connected between the electronic governor and the propeller, and the motor and the propeller are arranged on the corresponding arm; the electronic governor is used to receive the drive signal generated by the control system, and provide the drive current to the motor according to the drive signal to control the motor's Rotating speed.
  • the motor is used to drive the propeller to rotate, thereby providing power for the flight of the drone.
  • the sensing system 720 includes a sensor for collecting images, such as a camera 722, etc., which can be used to measure the attitude information of the drone, that is, the position information and status information of the drone in space, such as three-dimensional position, three-dimensional angle, three-dimensional Speed, three-dimensional acceleration and three-dimensional angular velocity, etc.
  • a sensor for collecting images such as a camera 722, etc.
  • the attitude information of the drone that is, the position information and status information of the drone in space, such as three-dimensional position, three-dimensional angle, three-dimensional Speed, three-dimensional acceleration and three-dimensional angular velocity, etc.
  • the sensing system 720 may include, for example, at least one of sensors such as a gyroscope, an electronic compass, an inertial measurement unit (IMU), a vision sensor, a global positioning system (GPS), a barometer, and an airspeed meter.
  • sensors such as a gyroscope, an electronic compass, an inertial measurement unit (IMU), a vision sensor, a global positioning system (GPS), a barometer, and an airspeed meter.
  • the camera 722 may also be referred to as a camera component, or the camera may be a part of a camera component included in the drone for acquiring image frames.
  • the processor 730 may be used to implement the calculation method in the foregoing method embodiment, and for the sake of brevity, details are not described herein again.
  • the processor 730 may be placed in the flight controller.
  • the processor 730 may be composed of multiple processors. For example, one processor may be used to control the flight of the drone, and one processor may be used to perform the processing of the convolutional neural network mentioned in the embodiment of the present application.
  • the removable device may further include an off-chip memory 740, which stores data input to the processor 730, and may store data output by the processor 730.
  • an off-chip memory 740 which stores data input to the processor 730, and may store data output by the processor 730.
  • the movable device 700 may further include other components not shown in FIG. 8, which is not limited in the embodiment of the present application.
  • the size of the sequence number of each process does not mean the order of execution, and the execution order of each process should be determined by its function and internal logic, and should not correspond to the embodiments of the present application.
  • the implementation process constitutes any limitation.
  • the computer program product includes one or more computer instructions.
  • the computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices.
  • the computer instructions may be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions may be transmitted from a website, computer, server, or data center.
  • the computer-readable storage medium may be any available medium that can be accessed by a computer or a data storage device such as a server or a data center integrated with one or more available media.
  • the usable medium may be a magnetic medium (for example, a floppy disk, a hard disk, a magnetic tape), an optical medium (for example, a digital video disc (DVD)), or a semiconductor medium (for example, a solid state disk (SSD)), etc.
  • the disclosed system, device, and method can be implemented in other ways.
  • the device embodiments described above are only illustrative.
  • the division of the units is only a logical function division, and there may be other divisions in actual implementation, for example, multiple units or components may be combined or It can be integrated into another system, or some features can be ignored or not implemented.
  • the displayed or discussed mutual coupling or direct coupling or communication connection may be indirect coupling or communication connection through some interfaces, devices or units, and may be in electrical, mechanical or other forms.
  • the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the objectives of the solutions of the embodiments.
  • the functional units in the various embodiments of the present application may be integrated into one processing unit, or each unit may exist alone physically, or two or more units may be integrated into one unit.

Landscapes

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

Abstract

提供一种计算装置、方法、处理器和可移动设备,该装置包括:片上存储器,用于缓存输入特征图和卷积核;读取电路,用于将输入特征图和卷积核从片外存储器读取到片上存储器中;控制电路,用于根据多种数据装载方式中的每种数据装载方式的数据搬移量,在多种数据装载方式中确定目标数据装载方式,并控制读取电路根据目标数据装载方式,将输入特征图和卷积核从片外存储器读取到片上存储器,其中,所述多种数据装载方式为向片上存储器装载输入特征图和卷积核的方式,每种数据装载方式的数据搬移量为将输入特征图和卷积核进行卷积运算所需搬移的总数据量;卷积计算电路,用于对片上存储器中的输入特征图和卷积核进行卷积计算,得到输出特征图。

Description

计算装置、方法、处理器和可移动设备
版权申明
本专利文件披露的内容包含受版权保护的材料。该版权为版权所有人所有。版权所有人不反对任何人复制专利与商标局的官方记录和档案中所存在的该专利文件或者该专利披露。
技术领域
本申请涉及信息技术领域,并且更具体地,涉及一种计算装置、方法、处理器和可移动设备。
背景技术
卷积神经网络(Convolutional Neural Network,CNN)是一种机器学习算法,它被广泛应用于目标识别、目标检测以及图像的语义分割等计算机视觉任务。
目前卷积神经网络的卷积计算过程中,对内存的访问量较大,导致CNN加速器对带宽的需求越来越大,影响卷积神经网络加速器的性能。因此,如何提高卷积计算的性能,成为卷积神经网络设计中一个亟待解决的技术问题。
发明内容
本申请提供一种计算装置、方法、处理器和可移动设备,能够提升卷积神经网络的性能。
第一方面,提供一种计算装置,包括:片上存储器,用于缓存输入特征图和卷积核;读取电路,用于将所述输入特征图和卷积核从片外存储器读取到所述片上存储器中;控制电路,用于根据多种数据装载方式中的每种数据装载方式的数据搬移量,在所述多种数据装载方式中确定目标数据装载方式,并控制所述读取电路根据所述目标数据装载方式,将所述输入特征图和所述卷积核从所述片外存储器读取到所述片上存储器,其中,所述多种数据装载方式为向所述片上存储器装载所述输入特征图和所述卷积核的方式,所述每种数据装载方式的数据搬移量为将所述输入特征图和所述卷积核进行 卷积运算所需搬移的总数据量;卷积计算电路,用于对所述片上存储器中的所述输入特征图和所述卷积核进行卷积计算,得到输出特征图。
第二方面,提供了一种计算方法,包括:根据多种数据装载方式中的每种数据装载方式的数据搬移量,在所述多种数据装载方式中确定目标数据装载方式,其中,所述多种数据装载方式为向所述装置的片上存储器装载所述输入特征图和所述卷积核的方式,所述每种数据装载方式的数据搬移量为将所述输入特征图和所述卷积核进行卷积运算所需搬移的总数据量;根据所述目标数据装载方式,将所述输入特征图和所述卷积核从所述片外存储器读取到所述装置的片上存储器;对所述片上存储器中的所述输入特征图和所述卷积核进行卷积计算,得到输出特征图。
第三方面,提供了一种处理器,包括第一方面的计算装置。
第四方面,提供了一种可移动设备,包括第一方面的计算装置;或者,第三方面的处理器。
第五方面,提供了一种计算机存储介质,该计算机存储介质中存储有程序代码,该程序代码可以用于指示执行上述第二方面的方法。
本申请实施例的技术方案,可以根据多种数据装载方式的数据搬移量,在多种数据装载方式中选择合适的数据装载方式,有利于减少卷积计算过程中的数据搬移,降低了输入和输出数据的带宽,从而能够提高卷积计算的效率。
附图说明
图1是本申请实施例的卷积神经网络的卷积操作过程的示意图。
图2是应用本申请实施例的技术方案的系统的架构图。
图3是根据本申请实施例的计算方法的示意性流程图。
图4是卷积计算的一种计算顺序的示意图。
图5是卷积计算的另一种计算顺序的示意图。
图6是根据本申请实施例的片上存储器的缓存分配方式的示意图。
图7是根据本申请实施例的计算装置的示意性框图。
图8是本申请实施例的可移动设备的示意性架构图。
具体实施方式
下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行描述,显然,所描述的实施例是本申请一部分实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本申请保护的范围。
除非另有说明,本申请实施例所使用的所有技术和科学术语与本申请的技术领域的技术人员通常理解的含义相同。本申请中所使用的术语只是为了描述具体的实施例的目的,不是旨在限制本申请的范围。
图1示出了卷积神经网络的卷积操作过程的示意图。如图1所示,卷积神经网络的卷积操作是对输入的权重和输入特征图(Input Feature Map,IFM)进行运算后得到输出特征图(Output Feature Map,OFM)。权重也被称为滤波器(Filter,FILT)或卷积核。输入特征图为上一层的输出特征图或未经卷积神经网络的处理的特征图。输出特征图为输入特征图经过当前层运算后得到的特征图。卷积核和输入特征图、输出特征图都可以被表示为一个多维矩阵,卷积神经网络的卷积层的一次卷积运算为输入特征矩阵的至少部分特征值(数据单元)与卷积核矩阵的权重值进行乘加操作。
如图1所示,卷积层的卷积运算可以采用滑动窗口方式,以输入特征值矩阵的左上角为起点,以卷积核的大小为窗口,依次滑动窗口到输入特征矩阵的右下角,产生一个完整的二维输出特征矩阵。每次滑动窗口后,卷积计算装置都会从输入特征值矩阵中提取一个窗口大小的输入特征值,将其与卷积核进行乘加操作,产生一个输出特征值。依照上述方式,依次产生所有的二维输出特征矩阵后,便可得到该卷积层的三维输出特征矩阵。
输入特征图的大小为W×H×M,其中,W可以代表宽度方向,H可以代表高度方向,C代表通道方向(也可以称为深度方向或厚度方向),故输入特征图可以称为3D特征图。卷积核也可以是3D的,W可以代表卷积核的宽度方向,H可以代表卷积核的高度方向,C代表卷积核的通道方向,卷积核的个数可以为N个,N为正整数,该N个卷积核的大小可以是相同的,但是参数可以是不同的。
因此,利用一个卷积核和3D的输入特征图进行乘加运算后可以输出一个2D特征图,则采用N个卷积核分别和3D的输入特征图进行卷积运算,可以得到3D的输出特征图,其中,卷积核的通道方向的大小可以与输入特征图的通道方向的大小相同。
以下,结合图2,描述本申请实施例所应用的卷积神经网络的系统架构图,其中,该系统可以包括处理器100和片外存储器200。其中,处理器100也可称为卷积神经网络加速器。
如图2所示,处理器100可以包括控制电路110、计算电路120、直接内存存取(Direct Memory Access,DMA)130和片上存储器140,例如静态随机存取存储器(Static Random-Access Memory,SRAM)。
其中,控制电路110可以控制计算电路120的运算(例如,参与运算的数据的大小以及运算的时序等),控制DMA130进行数据的读取或存储,例如,控制DMA130将数据从外部存储器200读入到片上存储器140中或将数据从片上存储器140写出到外部存储器200。在一些实施例中,控制电路110可以从片外存储器200中读取指令,用于实现对计算电路120和DMA130的控制。
计算电路120可以实现卷积神经网络的卷积层或其他层的处理,也就是说,该计算电路120可以包括卷积计算电路,也可以包括其他计算电路,例如池化层电路等,在一些实施例中,所述计算电路120可以从片上存储器140中读取数据进行卷积层的运算,以及将运算结果输出到片上存储器140中进行存储。
在一些实施例中,计算电路120内也可以包括区分于片上存储器140的其他片上存储器,用于存储计算电路120中的数据,例如,卷积计算得到的中间结果。
DMA130可以从片外存储器200中读取数据(例如,可以用于卷积运算的数据),并存储到片上存储器140中,或者,可以从片上存储器140中读取数据(例如,卷积计算电路120的输出的运算结果),并将数据存储到片外存储器200中。
应理解,图2所示的系统仅仅是本申请实施例的一种实现方式,不应对本申请实施例构成特别的限定。
随着卷积神经网络加速器的处理能力的提升,单位时间内对片外存储器的访问量也就越大,导致卷积神经网络加速器对带宽的需求越来越大,在对IFM或FILT中的一些数据在进行卷积运算之后,如果将这些数据存储在片外存储器中,下次需要使用这些数据进行卷积计算时,则需要反复从片外存 储器上读取数据,增加了数据搬移量,影响卷积神经网络的性能。
在本申请实施例中,可以根据多种数据装载方式的数据搬移量,在所述多种数据装载方式中选择合适的数据装载方式,进一步根据该数据装载方式,将所述输入特征图和卷积核从片外存储器读取到所述片上存储器中,从而卷积计算电路可以根据读取的该输入特征图和卷积核进行卷积计算,得到输入特征图,有利于提高片上存储器的利用率,降低卷积运算的数据搬移量,提升卷积神经网络加速器的性能。
图3是根据本申请实施例的计算方法的示意性流程图,其中,该方法400可以由卷积计算的装置来执行,具体地,可以由卷积计算的装置中的处理设备来执行,该处理设备例如可以包括图2所示的处理器100。该方法400可以包括如下步骤:
S410,根据多种数据装载方式中的每种数据装载方式的数据搬移量,在所述多种数据装载方式中确定目标数据装载方式,其中,所述多种数据装载方式为向所述装置的片上存储器装载所述输入特征图和所述卷积核的方式,所述每种数据装载方式的数据搬移量为将所述输入特征图和所述卷积核进行卷积运算所需搬移的总数据量;
S420,根据所述目标数据装载方式,将所述输入特征图和所述卷积核从所述装置的片外存储器读取到所述片上存储器;
S430,对所述片上存储器中的所述输入特征图和所述卷积核进行卷积计算,得到输出特征图。
可选地,在本申请实施例中,该处理设备可以由现场可编程门阵列(Field Programmable Gate Array,FPGA或特定应用的集成电路(Application Specific Integrated Circuit,ASIC)实现。由于FPGA或ASCI属于专用集成电路,其可以通过定制硬件加速器实现特定的功能,处理更高效。但本申请并不限于此。
在一些实施例中,所述处理设备可以包括读取电路,控制电路和计算电路,分别对应于图2中的DMA130,控制电路110和计算电路120,其中,所述控制电路可以用于执行图3所示方法400中的S410,所述读取电路可以用于执行图3所示方法400中的S420,所述计算电路可以用于执行图3所示方法400中的S430。以下,以处理设备为执行主体为例进行说明。
应理解,所述读取电路和所述控制电路可以为单独的电路,或者所述读取电路也可以集成于所述控制电路中,本申请实施例对此不作限定。
在本申请一些实施例中,该处理设备可以将待装载的IFM和FILT分割为多个分块(Block,BLK),然后根据确定的所述目标装载方式向所述片上存储器中装载IFM和FILT的各个分块。
例如,可以在高度方向、宽度方向和通道方向中的至少一个方向上,将所述输入特征图和卷积核进行切分,得到多个分块,然后基于所述目标装载方式向所述片上存储器中装载所述多个分块。
在一种实现方式中,可以将输入特征图在高度方向H和通道方向C进行切分,得到α行β列特征图分块矩阵,将FILT在通道方向C和个数方向(N方向)进行切分,得到β行γ列的卷积核分块阵列,该α行β列特征图分块矩阵和该β行γ列的卷积核分块阵列进行卷积运算可以得到α行γ列输出特征图分块矩阵。其中,α表示IFM在H方向的BLK个数,β表示IFM在C方向上的BLK个数,γ表示OFM在C方向上的BLK个数。
在其他实现方式中,也可以沿其他方向切分所述IFM和FILT,例如,将IFM在W和C方向进行切分,或者也可以按照一个方向进行切分,例如,只在C方向或H方向上进行切分,本申请实施例并不限于此。以下,仅以将IFM在H方向和C方向进行切分,以及将FILT在C方向和N方向进行切分为例进行说明,但本申请实施例并不限于此。
为了便于区分和说明,在本申请实施例中,用A表示IFM,用a表示IFM的一个BLK,用K表示FILT,用k表示一个FILTBLK,用V表示OFM,用v表示一个OFMBLK,采用
Figure PCTCN2019122083-appb-000001
表示特定的IFM BLK,其中,下标i表示IFM BLK在H方向上的索引,上标j表示IFM BLK在C方向上的索引。类似地,采用
Figure PCTCN2019122083-appb-000002
表示特定的FILT BLK,其中,下标i表示FILT BLK在C方向上的索引,上标j表示在N方向上的索引。
并且,采用方向加下标的方式表示该方向上的大小,如采用C A和C a分别表示IFM和IFM BLK在C方向上的大小,H K和H k分别表示FILT和FILT BLK在H方向上的大小,N K和N k分别表示FILT和FILT BLK在N方向上的大小等。
一次卷积运算可以表示为:f Conv(A)=A*K=V。
将基于上述切分方式得到的IFM BLK和FILT BLK装载到片上存储器进 行卷积运算,则一次卷积运算在卷积神经网络加速器中的对应运算可以表示为:
Figure PCTCN2019122083-appb-000003
在本申请实施例中,将IFM中的全部特征值都装载到片上存储器的数据搬移量记为B A,将FILT中的全部权重值都装载到片上存储器中的数据搬移量记为B K,将IFM和FILT进行一次卷积运算所需的总的数据搬移量记为B total
在本申请实施例中,所述处理设备可以计算所述多种数据装载方式所需的数据搬移量,然后根据每种数据装载方式的数据搬移量,选择合适的数据装载方式,例如,选择数据搬移量最低的数据装载方式。
在其他实施例中,所述处理设备也可以计算每种数据装载方式的数据搬移时间,进一步选择合适的数据装载方式,例如可以选择数据搬移时间最短的数据装载方式。
以下,结合几种典型的数据装载方式,说明根据本申请实施例的计算方法。应理解,以下所示例的数据装载方式仅为示例,根据所示例的数据装载方式所得出的其他数据装载方式,都落入本申请的保护范围。
在本申请实施例中,卷积计算可以有两种计算顺序,分别记为NRM和NMR,如图4和图5所示,一次卷积运算中,对于NRM,OFM的输出按照如下顺序:先输出COFM的第一列,再依次输出OFM的其他列C,即按照如下顺序输出:
Figure PCTCN2019122083-appb-000004
一次卷积运算中,对于NMR,OFM的输出按照如下顺序:先输出OFM的第一行,再输出OFM的其他行,即按照如下顺序输出:
Figure PCTCN2019122083-appb-000005
根据上述两种计算顺序,可以有相应的缓存分配方式,也就是对应相应的数据加载方式。
对于NRM的计算顺序,可以采用第一类数据数据加载方式,基本思想是复用FILT,将FILT保留在片上存储器中,向片上存储器中依次装载IFM的各个分块以进行卷积计算。
具体地,基于所述第一类数据装载方式,所述处理设备可以将所述FILT中的权重值装载至所述片上存储器中后,将所述FILT中的权重值保留在片 上存储器中,然后可以依次向所述片上存储器中依次装载IFM的各个分块,以使所述FILT中的权重值与装载的IFM的各个分块中的特征值进行卷积计算,也就是说,对于一次完整的卷积运算,FILT的数据搬移量可以为B K,IFM的数据搬移量可以为一倍或多倍B A
对于NMR的计算顺序,可以采用第二类数据数据加载方式,基本思想是复用IFM,将IFM保留在片上存储器中,向片上存储器中依次装载FILT的各个分块以进行卷积计算。
具体地,基于所述第二类数据装载方式,所述处理设备可以将所述IFM中的特征值装载至所述片上存储器后,将所述IFM中的特征值保留在片上存储器中,然后可以依次向所述片上存储器中依次装载FILT中的各个分块,以使所述IFM中的特征值与装载的FILT的分块中的权重值进行卷积计算,也就是说,对于一次完整的卷积运算而言,IFM的数据搬移量可以为B A,FILT的数据搬移量可以为一倍或多倍B K
在一些具体实施例中,所述多种数据加载方式可以包括以下中的至少一种:第一数据装载方式、第二数据加载方式、第三数据装载方式、第四数据装载方式和第五数据加载方式,分别对应图6中的(a)-(e)。当然,也可以包括更多种数据加载方式,本申请实施例并不限于此。
基于所述第一数据装载方式,所述处理设备只将所述IFM中的特征值向所述片上存储器中装载一次,并且只将所述FILT中的权重值向所述片上存储器中装载一次。其中,装载的FILT可以保留在所述片上存储器中,以复用该FILT与后续依次装载的IFM的各个分块进行卷积运算,并且装载的IFM的各个分块也可以保留在所述片上存储器中,以便于后续加载的FILT与该IFM的各个分块进行卷积运算。由此可见,基于该第一数据加载方式,进行一次卷积运算,IFM的数据搬移量为B A,FILT的数据搬移量可以为B K
基于所述第二数据装载方式,所述处理设备只将所述FILT中的权重值向所述片上存储器中装载一次,以及将所述IFM向所述片上存储器中装载多次,即进行一次卷积运算,IFM的数据搬移量为多倍B A,FILT的数据搬移量可以为B K
基于所述第三数据装载方式,所述处理电路将所述FILT中的权重值向所述片上存储器中装载多次,以及将所述IFM向所述片上存储器中装载多次,即进行一次卷积运算,IFM的数据搬移量为多倍B A,FILT的数据搬移 量可以为多倍B K
基于所述第四数据装载方式,所述处理电路将所述IFM向所述片上存储器装载一次,与所述第一数据加载方式不同的是,装载的IFM保留在所述片上存储器中,以复用IFM与后续依次加载的FILT的各个分块进行卷积运算,进行一次卷积运算,IFM的数据搬移量为B A,FILT的数据搬移量为B K
基于所述第五数据装载方式,可以将所述IFM向所述片上存储器加载一次,将所述FILT向所述片上存储器中装载多次,即进行一次卷积运算,IFM的数据搬移量为B A,FILT的数据搬移量可以为多倍B K
应理解,上述五种数据装载方式中,第一数据装载方式,第二数据装载方式,第三数据装载方式对应的卷积计算的顺序为NRM,所述第四数据装载方式和所述第五数据装载方式对应的卷积计算的顺序为NMR。
还应理解,在本申请实施例中,向片上存储器装载一次IFM或将所述IFM向片上存储器装载一次,并不表示一次向所述片上存储器中加载IFM的全部特征值,而是指进行一次完整的卷积运算,需要搬移的IFM的数据量为IFM的全部数据量,即不需要重复向所述片上存储器重复装载IFM,类似地,对于向片上存储器装载一次FILT的含义也是如此,这里不再赘述。
在一些实施例中,所述处理设备可以根据所述多种数据装载方式的数据搬移量,结合所述输入特征图的数据量,所述片上存储器的空间大小,所述卷积计算电路的处理能力和所述卷积核的数据量中的至少一项,在所述多种数据装载方式中确定所述目标数据装载方式。
以下,结合图6,说明几种典型的数据装载方式的具体实现方式。
第一数据装载方式:
作为一个实施例,所述处理设备可以确定片上存储器的空间大小是否足够装载IFM的总数据量,若所述片上存储器的空间大小足够装载IFM的总数据量,所述处理设备还可以进一步判断片上存储器的空间大小是否还足够装载所述FILT的C方向上的数据量,若所述片上存储器的空间大小足够装载所述FILT的C方向上的数据量,则所述处理设备可以确定采用第一数据装载方式。
这里,所述FILT的C方向上的数据量可以为FILT在C方向上的各个分块的总数据量,例如,图6中的卷积核分块矩阵中的一列,如
Figure PCTCN2019122083-appb-000006
所述片上存储器的空间大小足够装载所述FILT的C方向上的数据量可以指 所述片上存储器的空间大小是否足够装载卷积核分块矩阵中的一列。
应理解,图6中的(a)-(e)中示出了上述五种数据装载方式的缓存分配方式,或者说,在同一时间段内,所述片上存储器上能够装载的数据。
如图6中的(a)所示,基于该第一数据数据装载方式,在同一时间段(例如一个时钟周期)内,所述片上存储器上能够缓存的数据量包括IFM的全部数据量,FILT的C方向上的数据量,可选地,还可以包括卷积计算得到的OFM的一个分块的大小。
结合图6中的(a),说明基于该第一数据加载方式具体的加载过程。
在第一时钟周期内,所述处理设备向所述片上存储器装载IFM中的第一行IFM BLK,即
Figure PCTCN2019122083-appb-000007
并向所述片上存储器装载FILT BLK的第一列,即
Figure PCTCN2019122083-appb-000008
这里,该第一行IFM BLK和该第一列FILT BLK可以是同时装载的,或者也可以是先后装载的,本申请实施例对此不作限定。
进一步地,可以根据装载的第一行IFM BLK
Figure PCTCN2019122083-appb-000009
和该第一列FILT BLK
Figure PCTCN2019122083-appb-000010
进行卷积运算,得到
Figure PCTCN2019122083-appb-000011
在第二时钟周期内,所述处理设备向所述片上存储器装载第二行IFM BLK,
Figure PCTCN2019122083-appb-000012
此时,第一行IFM BLK
Figure PCTCN2019122083-appb-000013
和第一列FILT BLK
Figure PCTCN2019122083-appb-000014
依然保留在片上存储器中。进一步地,可以基于根据装载的第二行IFM BLK
Figure PCTCN2019122083-appb-000015
和第一列FILT BLK
Figure PCTCN2019122083-appb-000016
进行卷积运算,得到V 1 0
然后,依次装载每行IFM BLK直至最后一行IFM BLK,即
Figure PCTCN2019122083-appb-000017
并将每行IFM BLK都与该第一列FILT BLK进行卷积运算,得到OFM的第一列输出结果
Figure PCTCN2019122083-appb-000018
此时,IFM的全部特征值都保留在片上存储器中。
其后,可以向所述片上存储器加载第二列FILT BLK,即
Figure PCTCN2019122083-appb-000019
其中,该第二列FILT BLK覆盖掉第一列FILT BLK,即在装载第二列FILT BLK之后,第一列FILT BLK不保留在片上存储器中。
然后,依次将片上存储中中保留的每行IFM BLK都与该第二列FILT BLK进行卷积运算,得到OFM的第二列输出结果,即
Figure PCTCN2019122083-appb-000020
继续执行上述类似步骤,直到装载至最后一列FILT BLK,进一步根据该每行IFM BLK和该最后一列FILT BLK进行卷积计算,得到OFM的最后一列输出结果,即
Figure PCTCN2019122083-appb-000021
由此可见,基于该第一数据加载方式,一次卷积运算所需的总的数据搬移量B total=B A+B K。即IFM和FILT都只需装载一次。
应理解,在本申请实施例中,OFM的输出结果可以缓存在该片上存储器上,或者也可以输出到片外存储器上。
还应理解,在本申请实施例对于卷积运算的时机不作具体限定,例如可以在装载完IFM中的每行IFM BLK之后将所述每行IFM BLK与一列FILT BLK进行卷积计算,或者,也可以每装载完一行IFM BLK,将该一行IFM BLK与已装载的一列FILT BLK进行卷积计算,或者也可以在装载第二行IFM BLK时,将装载的上一行IFM BLK与第一列FILT BLK进行卷积计算等。
在该第一数据加载方式中,按行依次装载每行IFM BLK,可以认为IFM在C方向上未切分,在H方向上的大小可以是预设大小,或者也可以根据卷积神经网络加速器的处理能力确定,例如,可以IFM BLKH方向上的大小可以等于在输入特征图的H方向上所述卷积神经网络加速器能够并行处理的最大数据量。
需要说明的是,在本申请实施例中,所述片上存储器可以包括第一片上存储器和第二片上存储器,其中,所述第一片上存储器位于运算电路外,所述第二片上存储器位于运算电路内,在进行卷积运算时,运算电路对部分IFM BLK和FILT BLK进行卷积运算之后,可以在所述第二片上存储器中存储该部分IFM BLK和FILT BLK卷积运算结果,在等到所有IFM BLK和FILT BLK的卷积运算计算完毕之后,结合所有IFM BLK和FILT BLK的卷积运算结果进行处理,例如累加处理,以得到一个卷积核的输出结果或一个2D特征图,并将其输出到所述第一片上存储器中,或者所述运算电路也可以将中间结果输出到所述第一片上存储器,本申请实施例对此不作限定。
第二数据装载方式和第三数据装载方式:
在另一些实施例中,若所述片上存储器的空间大小不足够装载IFM的总数据量,所述处理设备可以确定是否可以复用FILT,具体地,所述控制电路可以确定所述片上存储器的空间大小是否足够所述FILT的C方向上的数据量,若所述片上存储器的空间大小足够装载FILT的C方向上的数据量,即所述片上存储器的空间大小足够装载卷积核分块矩阵中的一列,则可以复用所述FILT,所述控制电路可以确定采用第二数据加载方式,否则,可以确定 不能复用FILT,则可以确定采用第三数据加载方式。
在本申请实施例中,若确定可以复用所述FILT,所述处理设备可以确定FILT的C方向上的大小为IFM的C方向上的大小,否则,确定FILT的C方向上的大小为IFM BLK的C方向上的大小,所述IFM BLK的大小的确定方式在下文中描述。
结合图6中的(b),说明基于该第二数据加载方式的具体的加载过程。
在第一时钟周期内,所述处理电路向所述片上存储器装载第一行IFM BLK,即
Figure PCTCN2019122083-appb-000022
以及向所述片上存储器装载卷积核分块矩阵中的第一列FILT BLK,即
Figure PCTCN2019122083-appb-000023
进一步地,所述运算电路可以根据装载的该第一行IFM BLK和该第一列FILT BLK进行卷积运算,得到
Figure PCTCN2019122083-appb-000024
应理解,这里,所述处理电路向所述片上存储器装载该第一行IFM BLK可以是一次装载一行,或者也可以是分多次装载,例如,一次装载一个IFM BLK,具体方式可以根据片上存储器的空间大小确定。
在第二时钟周期内,所述第一列FILT BLK保留在片上存储器中,所述处理电路向所述片上存储器装载第二行IFM BLK,这里,与第一数据加载方式不同的是,所述第二行IFM BLK需要覆盖掉该第一行IFM BLK,即在第二时钟周期内,第一行IFM BLK不在片上存储器中。
进一步地,所述运算电路可以基于根据装载的第二行IFM BLK和所述片上存储器中保留的该第一列FILT BLK进行卷积运算,得到V 1 0
继续采用覆盖的方式依次向片上存储器中装载IFM中的每行数据直至最后一行IFM BLK,并根据该装载的每行IFM BLK与该片上存储器中保留的第一列FILT BLK进行卷积运算,得到OFM的第一列输出结果
Figure PCTCN2019122083-appb-000025
进一步地,向所述片上存储器加载第二列FILT BLK,该第二列FILT BLK覆盖第一列FILT BLK,即此时将所述第二列FILT BLK保留在片上存储器中,然后依次将该IFM中的α行IFM BLK中每行IFM BLK依次装载到片上存储器中以与该第二列FILT BLK进行卷积运算,得到OFM的第二列输出结果,即
Figure PCTCN2019122083-appb-000026
继续执行上述类似步骤,直到加载到卷积核分块矩阵中的最后一列FILT BLK,并且将该α行IFM BLK中每行IFM BLK依次装载到该片上存储器中与该最后一列FILT BLK进行卷积运算,得到OFM的最后一列输出结果, 即
Figure PCTCN2019122083-appb-000027
由此可见,基于该第二数据加载方式,进行一次卷积运算,所需的数据搬移量B total=B Aγ+B K。即IFM需要多次重复装载,FILT只需装载一次。
对于所述第二数据加载方式,若一次装载一整行IFM BLK,这种情况下,可以认为IFM BLK在C方向的大小等于IFM在C方向上的大小,也就是说,IFM在C方向不切分。
结合图6中的(c),介绍基于该第三数据加载方式的具体的加载过程。
在第一时钟周期内,所述处理设备向所述片上存储器装载第一行第一个IFM BLK,即
Figure PCTCN2019122083-appb-000028
并向所述片上存储器装载第一列第一个FILT BLK,即
Figure PCTCN2019122083-appb-000029
进一步地,可以根据装载的该
Figure PCTCN2019122083-appb-000030
Figure PCTCN2019122083-appb-000031
进行乘法运算,得到
Figure PCTCN2019122083-appb-000032
的中间结果;
在第二时钟周期内,所述处理设备向所述片上存储器装载第一行第二个IFM BLK,即
Figure PCTCN2019122083-appb-000033
以及第一列第二个FILT BLK,即
Figure PCTCN2019122083-appb-000034
此时,所述
Figure PCTCN2019122083-appb-000035
覆盖掉
Figure PCTCN2019122083-appb-000036
所述
Figure PCTCN2019122083-appb-000037
覆盖掉
Figure PCTCN2019122083-appb-000038
即在该第二时钟周期内,
Figure PCTCN2019122083-appb-000039
Figure PCTCN2019122083-appb-000040
不缓存在片上存储器中,进一步地,可以基于根据装载的
Figure PCTCN2019122083-appb-000041
Figure PCTCN2019122083-appb-000042
进行乘法运算,得到
Figure PCTCN2019122083-appb-000043
的另一中间结果;
所述处理设备依次以覆盖的方式装载所述第一行IFM BLK中的每个IFM BLK直至该第一行中的最后一个IFM BLK,即
Figure PCTCN2019122083-appb-000044
以及以覆盖式装载方式装载第一列FILT BLK中的每个FILT BLK直至最后一个FILT BLK,即
Figure PCTCN2019122083-appb-000045
然后根据该最后一个IFM BLK与最后一个FILT BLK进行乘法运算,得到
Figure PCTCN2019122083-appb-000046
的中间结果,进一步可以对这些中间结果进行累加,得到OFM的第一列第一个输出结果
Figure PCTCN2019122083-appb-000047
进一步地,所述处理设备可以采用上述类似方式向所述片上存储器装载第二行IFM BLK中的每个IFM BLK,以及第一列FILT BLK中的每个FILT BLK,然后将该第二行IFM BLK中的每个IFM BLK与该第一列FILT BLK中的每个FILT BLK进行乘加运算,得到OFM的第一列第二个输出结果V 1 0
继续执行上述类似步骤,向所述片上存储器装载每行IFM BLK中的每个IFM BLK直到装载到最后一行IFM BLK中的最后一个IFM BLK,以及向片上存储器装置每列FILT BLK中的每个FILT BLK直至最后一列FILT BLK中的最后一个FILT BLK,得到OFM的最后一个的输出结果。
由此可见,基于该第三数据加载方式,一次卷积运算所需的总的数据搬移量B total=B Aγ+B Kα。即IFM需要多次重复装载,FILT也需要装载多次。
综上,对于所述第一类数据装载方式,当一次卷积运算时,则在所述卷积运算时所需用到的所有输入特征图与装载于所述片上存储器中的权重值进行计算并输出对应的输出特征图的计算结果之后,再装载下一次卷积运算时所需用到的权重值,这里的一次卷积运算可以指输入特征图分块矩阵中的所有IFM BLK和卷积核分块矩阵中的一列FILT BLK所需进行的卷积运算。
例如对于图6中的(a)所示,在第一列FILT BLK
Figure PCTCN2019122083-appb-000048
与所有的IFM BLK都进行卷积运算后,再加载下一次进行卷积运算所需的权重值,即第二列FILT BLK
Figure PCTCN2019122083-appb-000049
综上上述三种数据加载过程,可以采用如下程序实现:
Figure PCTCN2019122083-appb-000050
在本申请实施例中,需要按分块向所述片上存储器上加载IFM时,所述处理设备还可以确定特征图分块在切分方向上的大小,例如H方向上的大小H a以及C方向上的大小C a
在本申请实施例中,为了降低数据搬移量,可以设置H a和C a尽可能的大。
在一些实施例中,H a满足以下中的至少一项:
等于所述输入特征图在所述第一方向的数据量大小;
小于所述片上存储器的空间大小;
等于在输入特征图的所述第一方向上所述卷积计算电路能够并行处理 的最大数据量。
在一种实现方式中,可以将H a初始化为H K,其中,H K表示FILT在H方向上的大小,然后采用同特定的算法进行迭代处理,直至H a=H A,或者刚好满足H a小于所述片上存储器的空间大小,或者H a达到在输入特征图的所述第一方向上所述卷积计算电路能够并行处理的最大数据量或合理值。
应理解,刚好满足H a小于所述片上存储器的空间大小可以指若下一次迭代处理得到的H a大于所述片上存储器的空间大小,则可以认为这一次迭代处理得到的H a满足H a小于所述片上存储器的空间大小,因此可以作为IFM BLK在H方向上的大小,即可以以H a为单位在H方向上对IFM进行切分得到IFM BLK。
还应理解,在输入特征图的所述第一方向上所述卷积计算电路能够并行处理的合理值根据所述卷积计算电路的处理能力确定,例如,该合理值可以略小于在输入特征图的所述H方向上所述卷积计算电路能够并行处理的最大数据量,或者也可以为该处理能力所对应的典型值,经验值等。
在一些实施例中,C a满足以下中的至少一项:
等于所述输入特征图在所述第三方向的数据量大小;
小于所述片上存储器的空间大小;
等于在输入特征图的所述第三方向上所述卷积计算电路能够并行处理的最大数据量。
在具体实现中,可以将C a初始化为在IFM的C方向上卷积神经网络加速器能够并行处理的最大数据量,然后采用同特定的算法进行迭代处理,直至所述C a满足C a=C A,或者刚好满足C a小于所述片上存储器的空间大小,或者C a达到在输入特征图的所述第三方向上所述卷积计算电路能够并行处理的最大数据量或合理值。
应理解,刚好满足C a小于所述片上存储器的空间大小可以指若下一次迭代处理得到的C a大于所述片上存储器的空间大小,则可以认为这一次迭代处理得到的C a满足C a小于所述片上存储器的空间大小,因此可以作为IFM BLK在C方向上的大小,即可以以C a为单位在C方向上对IFM进行切分得到IFM BLK。
还应理解,在输入特征图的C方向上所述卷积计算电路能够并行处理的合理值根据所述卷积计算电路的处理能力确定,例如,该合理值可以略小于 在输入特征图的所述C方向上所述卷积计算电路能够并行处理的最大数据量,或者也可以为该处理能力所对应的典型值,经验值等。
第四数据装载方式和第五数据装载方式:
在本申请另一些实施例中,所述处理设备也可以根据所述片上存储器的空间大小是否足够装载FILT的总数据量,确定采用第四数据装载方式还是第五数据装载方式。
例如,若所述片上存储器的空间大小大于所述FILT的总数据量,即可以将FILT仅装载一次,将所述第四数据装载方式确定为所述目标数据装载方式;或者
若所述片上存储器的空间大小小于所述FILT的总数据量,即可以需要FILT装载多次,将所述第五数据装载方式确定为所述目标数据装载方式。
结合图6中的(d),介绍基于该第四数据加载方式具体的加载过程。
在第一时钟周期内,所述处理电路向所述片上存储器装载第一行IFM BLK,即
Figure PCTCN2019122083-appb-000051
并向所述片上存储器装载FILT BLK的第一列,即
Figure PCTCN2019122083-appb-000052
这里,该第一行IFM BLK和该第一列FILT BLK可以是同时装载的,或者也可以是先后装载的,本申请实施例对此不作限定。
进一步地,可以根据装载的第一行IFM BLK和第一列FILT BLK进行卷积运算,得到
Figure PCTCN2019122083-appb-000053
在第二时钟周期内,向所述片上存储器装载第二列FILT BLK,即
Figure PCTCN2019122083-appb-000054
此时,所述第一列FILT BLK和第一行IFM BLK都保留在片上存储器中,同时该第一行IFM BLK也保留在片上存储器中。
进一步地,可以基于根据装载的第一行IFM BLK和第二列FILT BLK进行卷积运算,得到
Figure PCTCN2019122083-appb-000055
依次按列装载卷积核分块矩阵中的每列FILT BLK直至最后一列FILT BLK,此时,FILT的全部权重都保留在片上存储器中,并且,将FILT中的每列FILT BLK和片上存储器中缓存的该第一行IFM BLK都进行卷积运算,得到OMF的第一行输出结果,即
Figure PCTCN2019122083-appb-000056
其后,向所述片上存储器装载第二行IFM BLK,即第二行IFM BLK覆盖第一行IFM BLK,即将所述第二行IFM BLK保留在片上存储器中,然后,依次将每列FILT BLK与该第二行IFM BLK进行卷积运算,得到OFM的第二行输出结果,即
Figure PCTCN2019122083-appb-000057
继续执行上述步骤,直到装载到IFM的最后一行IFM BLK,并根据该最后一行IFM BLK和片上存储器中缓存中的每列FILT BLK进行卷积运算,得到OFM的最后一行输出结果,即
Figure PCTCN2019122083-appb-000058
由此可见,基于该第四数据加载方式,进行一次卷积运算所需的总数据搬移量B total=B A+B K。即IFM和FILT都只需装载一次。
结合图6中的(e),介绍基于该第四数据加载方式具体的加载过程。
在第一时钟周期内,所述处理电路向所述片上存储器装载第一行IFM BLK,即
Figure PCTCN2019122083-appb-000059
并向所述片上存储器装载FILT BLK的第一列,即
Figure PCTCN2019122083-appb-000060
这里,该第一行IFM BLK和该第一列FILT BLK可以是同时装载的,或者也可以是先后装载的,本申请实施例对此不作限定。
进一步地,可以根据装载的第一行IFM BLK和第一列FILT BLK进行卷积运算,得到
Figure PCTCN2019122083-appb-000061
在第二时钟周期内,向所述片上存储器装载第二列FILT BLK,所述第二列FILT BLK覆盖掉第一列FILT BLK,即在片上存储器中缓存有第一行IFM BLK和第二列FILT BLK。
进一步地,可以基于根据装载的第二列FILT BLK和第一行IFM BLK进行卷积运算,得到
Figure PCTCN2019122083-appb-000062
采用上述类似方式向所述片上存储器中装载每列FILT BLK直至最后一列FILT BLK,并根据每列FILT BLK与第一行IFM BLK进行卷积运算,至此,得到OFM的第一行输出结果。
进一步地,向所述片上存储器加载第二行IFM BLK,将第二行IFM BLK覆盖第一行IFM BLK,该第二行IFM BLK保留在片上存储器中,然后依次将该γ列FILT BLK中的每列FILT BLK依次装载到片上存储器中与片上存储器中缓存的该第二行IFM BLK进行卷积运算,得到OFM的第二行输出结果。
继续执行上述类似步骤,直到装载到最后一行IFM BLK,然后依次将该γ列FILT BLK中的每列FILT BLK依次装载到片上存储器中与该最后一行IFM BLK进行卷积运算,得到OFM的最后一行输出结果。
由此可见,基于该第五数据加载方式,数据搬移量B total=B A+B Kα。即IFM需要装载一次,FILT需要装载多次,即可以复用IFM进行卷积运算。
对于上述第二类数据加载方式,当进行一次卷积运算时,在所述卷积运 算时需用到的所有权重值与装载于所述片上存储器中的输入特征图进行计算并输出对应的输出特征图的计算结果之后,再装载下一次卷积运算时所需用到的输入特征图。这里的一次卷积运算可以指卷积核分块矩阵中的所有FILT BLK和输入特征图分块矩阵中的一行IFM BLK所需进行的卷积运算。
例如对于图6中的(d)所示,在第一行IFM BLK
Figure PCTCN2019122083-appb-000063
与所有的FILT BLK都进行卷积运算后,再加载下一次进行卷积运算所需的输入特征图分块,即第二行IFM BLK。
综上该第四和第五数据加载方式,可以采用如下程序实现:
Figure PCTCN2019122083-appb-000064
在本申请实施例中,需要按分块向所述片上存储器上加载IFM和FILT时,所述处理设备还可以确定特征图分块在切分方向上的大小,例如H方向上的大小H a以及C方向上的大小C a,以及卷积核分块在切分方向上的大小,例如C方向上的大小C k以及N方向上的大小N k
在本申请实施例中,为了降低数据搬移量,可以设置H a和C a尽可能的大。
在一些实施例中,所述C a可以等于C A,即特征图分块在C方向上的大小等于IFM在C方向上的大小,即IFM在C方向上不切分。
在一些实施例中,所述C k可以等于C K,即卷积核分块在C方向上的大小等于FILT在C方向上的大小,即FILT在C方向上不切分。
在其他实施例中,所述卷积核分块在C方向上的大小可以小于FILT在C方向上的大小,也就是说FILT在C方向上可以进行切分,或者说,可以分多次加载一列FILB BLK。
在一些实施例中,H a满足以下中的至少一项:
等于所述输入特征图在所述第一方向的数据量大小;
小于所述片上存储器的空间大小;
等于在输入特征图的所述第一方向上所述卷积计算电路能够并行处理的最大数据量。
在具体实现中,可以将H a初始化为H K,其中,H K表示FILT在H方向上的大小,然后采用同特定的算法进行迭代处理,直至H a=H A,或者刚好满足H a小于所述片上存储器的空间大小,或者H a达到在输入特征图的所述第一方向上所述卷积计算电路能够并行处理的最大数据量或合理值。
应理解,刚好满足H a小于所述片上存储器的空间大小可以指若下一次迭代处理得到的H a大于所述片上存储器的空间大小,则可以认为这一次迭代处理得到的H a满足H a小于所述片上存储器的空间大小,因此可以作为IFM BLK在H方向上的大小,即可以以H a为单位在H方向上对IFM进行切分得到IFM BLK。
还应理解,在输入特征图的所述第一方向上所述卷积计算电路能够并行处理的合理值根据所述卷积计算电路的处理能力确定,例如,该合理值可以略小于在输入特征图的所述H方向上所述卷积计算电路能够并行处理的最大数据量,或者也可以为该处理能力所对应的典型值,经验值等。
在一些实施例中,若确定采用所述第四数据装载方式,所述FILT BLK在N方向上的大小等于所述FILT在N方向上的大小,即FILT在N方向上不切分。或者若确定采用第五数据装载方式,所述FILT BLK在N方向上的大小等于卷积神经网络加速器能够输出的OFM在C方向上的最大值或合理值,其中,卷积神经网络加速器能够输出的OFM在C方向上的合理值的含义可以参考在输入特征图的所述第一方向上所述卷积计算电路能够并行处理的合理值的含义,这里不再赘述。
应理解,在本申请实施例对于卷积运算的时机不作具体限定,例如可以在装载完IFM中的每行IFM BLK之后将所述每行IFM BLK与一列FILT BLK进行卷积计算,或者,也可以每装载完一行IFM BLK,将该一行IFM BLK与已装载的一列FILT BLK进行卷积计算,或者也可以在装载第二行IFM BLK时,将装载的上一行IFM BLK与第一列FILT BLK进行卷积计算等。
应理解,本申请实施例的处理设备可以不具有实质的分块的分割操作, 仅是在读取和计算时,按分块进行读取和计算。
应理解,在本申请实施例中,片上存储器可以是二维的,例如存储形式可以为4096×128b,输入特征图的存储(例如,读取还未进行卷积神经网络处理的数据或者经过处理得到的中间输出结果)可以是在2D空间上的扩展,具体可以为每个2D特征图分别引入一个地址,以实现3D空间的访问。
在本申请实施例中,利用卷积神经网络的FILT共享或IFM共享的特性,减少计算过程中的数据搬移,进而降低输入和输出数据的带宽,从而提高卷积计算的效率。
本申请实施例的技术方案可以应用于各种深度学习算法,例如卷积神经网络,但本申请实施例对此并不限定。
还应理解,本申请实施例的技术方案也可以应用于卷积运算,或者也可以应用于反卷积运算中,本申请实施例对此不作限定。
图7是根据本申请实施例的计算装置600的示意性框图。该装置600包括:
片上存储器610,用于缓存输入特征图和卷积核;
读取电路620,用于将所述输入特征图和卷积核从片外存储器读取到所述片上存储器中;
控制电路630,用于根据多种数据装载方式中的每种数据装载方式的数据搬移量,在所述多种数据装载方式中确定目标数据装载方式,并控制所述读取电路根据所述目标数据装载方式,将所述输入特征图和所述卷积核从所述片外存储器读取到所述片上存储器,其中,所述多种数据装载方式为向所述片上存储器装载所述输入特征图和所述卷积核的方式,所述每种数据装载方式的数据搬移量为将所述输入特征图和所述卷积核进行卷积运算所需搬移的总数据量;
卷积计算电路640,用于对所述片上存储器中的所述输入特征图和所述卷积核进行卷积计算,得到输出特征图。
其中,该片上存储器610,读取电路620,控制电路630和卷积计算电路640可以对应于图2中的片上存储器140,DMA130,控制电路110和运算电路120,具体实现参考前文的相关描述,为了简洁,这里不再赘述。
可选地,在一些实施例中,所述控制电路630还用于:
根据所述每种数据装载方式的数据搬移量,以及所述输入特征图的数据 量,所述片上存储器的空间大小,所述卷积计算电路的处理能力和所述卷积核的数据量中的至少一项,在所述多种数据装载方式中确定所述目标数据装载方式。
可选地,在一些实施例中,所述多种数据装载方式包括第一类数据装载方式和/或第二类数据装载方式,其中,
基于所述第一类数据装载方式,所述读取电路只将所述卷积核中的权重值向所述片上存储器中装载一次,所述卷积计算电路复用所述卷积核中的权重值,以将所述卷积核中的权重值和所述输入特征图进行卷积运算;
基于所述第二类数据装载方式,所述读取电路只将所述输入特征图中的特征值向所述片上存储器中装载一次,所述卷积计算电路复用所述输入特征图,以将所述输入特征图与所述卷积核进行卷积运算。
可选地,在一些实施例中,所述读取电路620具体用于:
当进行一次卷积运算时,若所述目标数据装载方式是所述第一类数据装载方式,则在所述卷积运算时所需用到的所有输入特征图与装载于所述片上存储器中的权重值进行计算并输出对应的输出特征图的计算结果之后,再装载下一次卷积运算时所需用到的权重值;或者
当进行一次卷积运算时,若所述目标数据装载方式是所述第二类数据装载方式,则在所述卷积运算时需用到的所有权重值与装载于所述片上存储器中的输入特征图进行计算并输出对应的输出特征图的计算结果之后,再装载下一次卷积运算时所需用到的输入特征图。
可选地,在一些实施例中,所述第一类数据装载方式包括第一数据装载方式和/或第二数据装载方式,其中,基于所述第一数据装载方式,所述读取电路只将所述输入特征图中的特征值向所述片上存储器中装载一次;基于所述第二数据装载方式,所述读取电路将所述输入特征图中的特征值向所述片上存储器中装载多次;
所述第二类数据装载方式包括第四数据装载方式和/或第五数据装载方式,其中,基于所述第四数据装载方式,所述读取电路只将所述卷积核中的权重值向所述片上存储器中装载一次;基于所述第五数据装载方式,所述读取电路将所述卷积核中的权重值向所述片上存储器中装载多次。
可选地,在一些实施例中,所述多种数据装载方式还包括第三数据装载方式,基于所述第三数据装载方式,所述读取电路将所述卷积核中的权重值 向所述片上存储器中装载多次,以及将所述输入特征图中的特征值向所述片上存储器中装载多次。
可选地,在一些实施例中,在一次卷积运算中,所述输入特征图包括α行β列的特征图分块阵列,所述特征图分块阵列中的特征图分块是将所述输入特征图沿第一方向和第三方向切分得到的,其中,所述α为所述输入特征图沿所述第一方向的分块个数,所述β为所述输入特征图沿所述第三方向的分块个数,其中α、β为整数;
所述卷积核包括β行γ列的卷积核分块阵列,所述卷积核分块阵列中的卷积核分块是将所述卷积核沿第三方向和第四方向切分得到的,其中,所述β为所述卷积核沿所述第三方向的分块个数,所述γ为所述卷积核沿所述第四方向的分块个数,其中γ为整数。
可选地,在一些实施例中,所述控制电路630还用于:
若所述片上存储器能够缓存一次卷积运算所需的所述特征图分块阵列的总数据量和所述卷积核分块阵列在所述第三方向上的数据量,将所述第一数据装载方式确定为所述目标数据装载方式,并控制所述读取电路将进行所述卷积运算时所需的所有特征图分块阵列同时装载于所述片上存储器,以及将进行所述卷积运算时在所述第三方向上的卷积计算相关联的所述卷积核分块阵列同时装载于所述片上存储器;或者
若所述片上存储器不能缓存一次卷积运算所需的所述特征图分块阵列的总数据量,但能够缓存所述卷积核分块阵列在第三方向上的数据量,将所述第二数据装载方式确定为所述目标数据装载方式,并控制所述读取电路将进行所述卷积运算时所需的特征图分块阵列依次装载于所述片上存储器,以及将进行所述卷积运算时在所述第三方向上的卷积计算相关联的所述卷积核分块阵列同时装载于所述片上存储器;或者
若所述片上存储器不能缓存一次卷积运算所需的所述特征图分块阵列的总数据量,并且不能缓存一次卷积运算所需的所述卷积核分块阵列在第三方向上的数据量,将所述第三数据装载方式确定为所述目标数据装载方式,并控制所述读取电路将进行所述卷积运算时所需的所述特征图分块阵列依次装载于所述片上存储器,以及将进行所述卷积运算时所需的所述卷积核分块阵列依次装载于所述片上存储器。
可选地,在一些实施例中,所述控制电路630还用于:
确定特征图分块在所述第一方向的大小以及在所述第三方向上的大小。
可选地,在一些实施例中,所述特征图分块在所述第一方向的大小满足以下中的至少一项:
等于所述输入特征图在所述第一方向的数据量大小;
小于所述片上存储器的空间大小;
等于在所述输入特征图的所述第一方向上所述卷积计算电路能够并行处理的最大数据量。
可选地,在一些实施例中,所述特征图分块在所述第三方向的大小满足以下中的至少一项:
等于所述输入特征图在所述第三方向的数据量大小;
小于所述片上存储器的空间大小;
等于在所述输入特征图的所述第三方向上所述卷积计算电路能够并行处理的最大数据量。
可选地,在一些实施例中,所述控制电路630具体用于:
若所述片上存储器的空间大小大于或等于一次卷积运算所需的卷积核的总数据量,将所述第四数据装载方式确定为所述目标数据装载方式,并控制所述读取电路将进行所述卷积运算时所需的所有卷积核分块阵列同时装载于所述片上存储器,以及将进行所述卷积运算时在所述第三方向上的卷积计算相关联的所述特征图分块阵列同时装载于所述片上存储器;或者
若所述片上存储器的空间大小小于一次卷积运算所需的所述卷积核的总数据量,将所述第五数据装载方式确定为所述目标数据装载方式,并控制所述读取电路将所述卷积核分块阵列依次装载于所述片上存储器,以及将进行所述卷积运算时在所述第三方向上的卷积计算相关联的所述特征图分块阵列同时装载于所述片上存储器。
可选地,在一些实施例中,所述控制电路630还用于:
若所述第四数据装载方式为所述目标数据装载方式,确定所述卷积核分块在所述第四方向上的大小为所述卷积核在所述第四方向上的大小;或者
若所述第五数据装载方式为所述目标数据装载方式,确定所述卷积核分块在所述第四方向上的大小为所述卷积计算电路所能输出的输出特征图的第三方向上的最大数据量。
可选地,在一些实施例中,所述控制电路630还用于:
确定所述卷积核分块在所述第三方向上的大小为所述卷积核在所述第三方向上的大小。
可选地,在一些实施例中,所述控制电路630还用于:
确定所述特征图分块在所述第三方向上的大小为所述输入特征图在所述第三方向上的大小;以及
确定所述特征图分块在所述第一方向上的大小满足以下中的至少一项:
等于所述输入特征图在所述第一方向的数据量大小;
小于所述片上存储器的空间大小;
等于在输入特征图的所述第一方向上所述卷积计算电路能够并行处理的最大数据量。
可选地,在一些实施例中,所述第一方向为高度方向,所述第三方向为通道方向,所述第四方向为卷积核的个数方向;或
所述第一方向为宽度方向,所述第三方向为通道方向,所述第四方向为卷积核的个数方向。
在一些实施例中,本申请实施例的技术方案可以应用于可移动设备中。该可移动设备可以是无人机、无人驾驶船、自动驾驶车辆或机器人等,本申请实施例对此并不限定。
图8是根据本申请实施例的可移动设备700的示意性框图。该可移动设备700可以包括动力系统710、传感系统720和处理器730。
在一些实施例中,该可移动设备700可以为无人机、无人驾驶船、自动驾驶车辆或机器人等,本申请实施例对此并不限定。
以可移动设备700为无人机为例,无人机的动力系统可以包括电子调速器(简称为电调)、螺旋桨以及与螺旋桨相对应的电机。电机连接在电子调速器与螺旋桨之间,电机和螺旋桨设置在对应的机臂上;电子调速器用于接收控制系统产生的驱动信号,并根据驱动信号提供驱动电流给电机,以控制电机的转速。电机用于驱动螺旋桨旋转,从而为无人机的飞行提供动力。
传感系统720包括用于采集图像的传感器,例如摄像头722等,可以用于测量无人机的姿态信息,即无人机在空间的位置信息和状态信息,例如,三维位置、三维角度、三维速度、三维加速度和三维角速度等。
传感系统720例如可以包括陀螺仪、电子罗盘、惯性测量单元(Inertial Measurement Unit,IMU)、视觉传感器、全球定位系统(Global Positioning  System,GPS)、气压计、空速计等传感器中的至少一种。
其中,该摄像头722还可以称为摄像组件,或者摄像头可以为无人机包括的用于获取图像帧的摄像组件的一部分。
其中,该处理器730可以用于实现上述方法实施例中的计算方法,为了简洁,在此不再赘述。
可选地,该处理器730可以置于飞行控制器中。该处理器730可以由多个处理器组成,例如一个处理器可以用于控制无人机的飞行,一个处理器可以用于进行本申请实施例提到的卷积神经网络的处理。
可选地,该可移动设备还可以包括片外存储器740,存储向处理器730输入的数据,以及可以存储处理器730输出的数据。
应理解,上述对于可移动设备700的各组成部件的划分和命名仅仅是示例性的,并不应理解为对本申请实施例的限制。
还应理解,可移动设备700还可以包括图8中未示出的其他部件,本申请实施例对此并不限定。
应理解,本文中的具体的例子只是为了帮助本领域技术人员更好地理解本申请实施例,而非限制本申请实施例的范围。
还应理解,在本申请的各种实施例中,各过程的序号的大小并不意味着执行顺序的先后,各过程的执行顺序应以其功能和内在逻辑确定,而不应对本申请实施例的实施过程构成任何限定。
还应理解,本说明书中描述的各种实施方式,既可以单独实施,也可以组合实施,本申请实施例对此并不限定。
在上述实施例中,可以全部或部分地通过软件、硬件、固件或者其他任意组合来实现。当使用软件实现时,可以全部或部分地以计算机程序产品的形式实现。所述计算机程序产品包括一个或多个计算机指令。在计算机上加载和执行所述计算机程序指令时,全部或部分地产生按照本发明实施例所述的流程或功能。所述计算机可以是通用计算机、专用计算机、计算机网络、或者其他可编程装置。所述计算机指令可以存储在计算机可读存储介质中,或者从一个计算机可读存储介质向另一个计算机可读存储介质传输,例如,所述计算机指令可以从一个网站站点、计算机、服务器或数据中心通过有线(例如同轴电缆、光纤、数字用户线(digital subscriber line,DSL))或无线(例如红外、无线、微波等)方式向另一个网站站点、计算机、服务器或数 据中心进行传输。所述计算机可读存储介质可以是计算机能够存取的任何可用介质或者是包含一个或多个可用介质集成的服务器、数据中心等数据存储设备。所述可用介质可以是磁性介质(例如,软盘、硬盘、磁带)、光介质(例如数字视频光盘(digital video disc,DVD))、或者半导体介质(例如固态硬盘(solid state disk,SSD))等。
在本申请所提供的几个实施例中,应该理解到,所揭露的系统、装置和方法,可以通过其它的方式实现。例如,以上所描述的装置实施例仅仅是示意性的,例如,所述单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,例如多个单元或组件可以结合或者可以集成到另一个系统,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通信连接可以是通过一些接口,装置或单元的间接耦合或通信连接,可以是电性,机械或其它的形式。
所述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部单元来实现本实施例方案的目的。
另外,在本申请各个实施例中的各功能单元可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。
以上所述,仅为本申请的具体实施方式,但本申请的保护范围并不局限于此,任何熟悉本技术领域的技术人员在本申请揭露的技术范围内,可轻易想到变化或替换,都应涵盖在本申请的保护范围之内。因此,本申请的保护范围应以所述权利要求的保护范围为准。

Claims (36)

  1. 一种计算装置,其特征在于,包括:
    片上存储器,用于缓存输入特征图和卷积核;
    读取电路,用于将所述输入特征图和所述卷积核从片外存储器读取到所述片上存储器中;
    控制电路,用于根据多种数据装载方式中的每种数据装载方式的数据搬移量,在所述多种数据装载方式中确定目标数据装载方式,并控制所述读取电路根据所述目标数据装载方式,将所述输入特征图和所述卷积核从所述片外存储器读取到所述片上存储器,其中,所述多种数据装载方式为向所述片上存储器装载所述输入特征图和所述卷积核的方式,所述每种数据装载方式的数据搬移量为将所述输入特征图和所述卷积核进行卷积运算所需搬移的总数据量;
    卷积计算电路,用于对所述片上存储器中的所述输入特征图和所述卷积核进行卷积计算,得到输出特征图。
  2. 根据权利要求1所述的装置,其特征在于,所述控制电路还用于:
    根据所述每种数据装载方式的数据搬移量,以及所述输入特征图的数据量,所述片上存储器的空间大小,所述卷积计算电路的处理能力和所述卷积核的数据量中的至少一项,在所述多种数据装载方式中确定所述目标数据装载方式。
  3. 根据权利要求1或2所述的装置,其特征在于,所述多种数据装载方式包括第一类数据装载方式和/或第二类数据装载方式,其中,
    基于所述第一类数据装载方式,所述读取电路只将所述卷积核中的权重值向所述片上存储器中装载一次,所述卷积计算电路复用所述卷积核中的权重值,以将所述卷积核中的权重值和所述输入特征图进行卷积运算;
    基于所述第二类数据装载方式,所述读取电路只将所述输入特征图中的特征值向所述片上存储器中装载一次,所述卷积计算电路复用所述输入特征图,以将所述输入特征图与所述卷积核进行卷积运算。
  4. 根据权利要求3所述的装置,其特征在于,所述读取电路具体用于:
    当进行一次卷积运算时,若所述目标数据装载方式是所述第一类数据装载方式,则在所述卷积运算时所需用到的所有输入特征图与装载于所述片上存储器中的权重值进行计算并输出对应的输出特征图的计算结果之后,再装 载下一次卷积运算时所需用到的权重值;或者
    当进行一次卷积运算时,若所述目标数据装载方式是所述第二类数据装载方式,则在所述卷积运算时需用到的所有权重值与装载于所述片上存储器中的输入特征图进行计算并输出对应的输出特征图的计算结果之后,再装载下一次卷积运算时所需用到的输入特征图。
  5. 根据权利要求3或4所述的装置,其特征在于,
    所述第一类数据装载方式包括第一数据装载方式和/或第二数据装载方式,其中,基于所述第一数据装载方式,所述读取电路只将所述输入特征图中的数据向所述片上存储器中装载一次;基于所述第二数据装载方式,所述读取电路将所述输入特征图中的数据向所述片上存储器中装载多次;
    所述第二类数据装载方式包括第四数据装载方式和/或第五数据装载方式,其中,基于所述第四数据装载方式,所述读取电路只将所述卷积核中的权重值向所述片上存储器中装载一次;基于所述第五数据装载方式,所述读取电路将所述卷积核中的权重值向所述片上存储器中装载多次。
  6. 根据权利要求5所述的装置,其特征在于,所述多种数据装载方式还包括第三数据装载方式,基于所述第三数据装载方式,所述读取电路将所述卷积核中的权重值向所述片上存储器中装载多次,以及将所述输入特征图中的数据向所述片上存储器中装载多次。
  7. 根据权利要求6所述的装置,其特征在于,在一次卷积运算中,所述输入特征图包括α行β列的特征图分块阵列,所述特征图分块阵列中的特征图分块是将所述输入特征图沿第一方向和第三方向切分得到的,其中,所述α为所述输入特征图沿所述第一方向的分块个数,所述β为所述输入特征图沿所述第三方向的分块个数,其中α、β为整数;
    所述卷积核包括β行γ列的卷积核分块阵列,所述卷积核分块阵列中的卷积核分块是将所述卷积核沿第三方向和第四方向切分得到的,其中,所述β为所述卷积核沿所述第三方向的分块个数,所述γ为所述卷积核沿所述第四方向的分块个数,其中γ为整数。
  8. 根据权利要求7所述的装置,其特征在于,所述控制电路还用于:
    若所述片上存储器能够缓存一次卷积运算所需的所述特征图分块阵列的总数据量和所述卷积核分块阵列在所述第三方向上的数据量,将所述第一数据装载方式确定为所述目标数据装载方式,并控制所述读取电路将进行所 述卷积运算时所需的所有特征图分块阵列同时装载于所述片上存储器,以及将进行所述卷积运算时在所述第三方向上的卷积计算相关联的所述卷积核分块阵列同时装载于所述片上存储器;或者
    若所述片上存储器不能缓存一次卷积运算所需的所述特征图分块阵列的总数据量,但能够缓存所述卷积核分块阵列在第三方向上的数据量,将所述第二数据装载方式确定为所述目标数据装载方式,并控制所述读取电路将进行所述卷积运算时所需的特征图分块阵列依次装载于所述片上存储器,以及将进行所述卷积运算时在所述第三方向上的卷积计算相关联的所述卷积核分块阵列同时装载于所述片上存储器;或者
    若所述片上存储器不能缓存一次卷积运算所需的所述特征图分块阵列的总数据量,并且不能缓存一次卷积运算所需的所述卷积核分块阵列在第三方向上的数据量,将所述第三数据装载方式确定为所述目标数据装载方式,并控制所述读取电路将进行所述卷积运算时所需的所述特征图分块阵列依次装载于所述片上存储器,以及将进行所述卷积运算时所需的所述卷积核分块阵列依次装载于所述片上存储器。
  9. 根据权利要求7或8所述的装置,其特征在于,所述控制电路还用于:
    确定特征图分块在所述第一方向的大小以及在所述第三方向上的大小。
  10. 根据权利要求9所述的装置,其特征在于,所述特征图分块在所述第一方向的大小满足以下中的至少一项:
    等于所述输入特征图在所述第一方向的数据量大小;
    小于所述片上存储器的空间大小;
    等于在所述输入特征图的所述第一方向上所述卷积计算电路能够并行处理的最大数据量。
  11. 根据权利要求9或10所述的装置,其特征在于,所述特征图分块在所述第三方向的大小满足以下中的至少一项:
    等于所述输入特征图在所述第三方向的数据量大小;
    小于所述片上存储器的空间大小;
    等于在输入特征图的所述第三方向上所述卷积计算电路能够并行处理的最大数据量。
  12. 根据权利要求7所述的装置,其特征在于,所述控制电路具体用于:
    若所述片上存储器的空间大小大于或等于一次卷积运算所需的卷积核的总数据量,将所述第四数据装载方式确定为所述目标数据装载方式,并控制所述读取电路将进行所述卷积运算时所需的所有卷积核分块阵列同时装载于所述片上存储器,以及将进行所述卷积运算时在所述第三方向上的卷积计算相关联的所述特征图分块阵列同时装载于所述片上存储器;或者
    若所述片上存储器的空间大小小于一次卷积运算所需的所述卷积核的总数据量,将所述第五数据装载方式确定为所述目标数据装载方式,并控制所述读取电路将所述卷积核分块阵列依次装载于所述片上存储器,以及将进行所述卷积运算时在所述第三方向上的卷积计算相关联的所述特征图分块阵列同时装载于所述片上存储器。
  13. 根据权利要求12所述的装置,其特征在于,所述控制电路还用于:
    若所述第四数据装载方式为所述目标数据装载方式,确定所述卷积核分块在所述第四方向上的大小为所述卷积核在所述第四方向上的大小;或者
    若所述第五数据装载方式为所述目标数据装载方式,确定所述卷积核分块在所述第四方向上的大小为所述卷积计算电路所能输出的输出特征图的第三方向上的最大数据量。
  14. 根据权利要求12或13所述的装置,其特征在于,所述控制电路还用于:
    确定所述卷积核分块在所述第三方向上的大小为所述卷积核在所述第三方向上的大小。
  15. 根据权利要求12至14中任一项所述的装置,其特征在于,所述控制电路还用于:
    确定所述特征图分块在所述第三方向上的大小为所述输入特征图在所述第三方向上的大小;以及
    确定所述特征图分块在所述第一方向上的大小满足以下中的至少一项:
    等于所述输入特征图在所述第一方向的数据量大小;
    小于所述片上存储器的空间大小;
    等于在所述输入特征图的所述第一方向上所述卷积计算电路能够并行处理的最大数据量。
  16. 根据权利要求7至15中任一项所述的装置,其特征在于,
    所述第一方向为高度方向,所述第三方向为通道方向,所述第四方向为 卷积核的个数方向;或
    所述第一方向为宽度方向,所述第三方向为通道方向,所述第四方向为卷积核的个数方向。
  17. 一种计算方法,其特征在于,应用于卷积计算的装置,所述计算方法包括:
    根据多种数据装载方式中的每种数据装载方式的数据搬移量,在所述多种数据装载方式中确定目标数据装载方式,其中,所述多种数据装载方式为向所述装置的片上存储器装载所述输入特征图和所述卷积核的方式,所述每种数据装载方式的数据搬移量为将所述输入特征图和所述卷积核进行卷积运算所需搬移的总数据量;
    根据所述目标数据装载方式,将所述输入特征图和所述卷积核从所述片外存储器读取到所述装置的片上存储器;
    对所述片上存储器中的所述输入特征图和所述卷积核进行卷积计算,得到输出特征图。
  18. 根据权利要求17所述的方法,其特征在于,所述根据多种数据装载方式中的每种数据装载方式的数据搬移量,在所述多种数据装载方式中确定目标数据装载方式,包括:
    根据所述每种数据装载方式的数据搬移量,以及所述输入特征图的数据量,所述片上存储器的空间大小,所述装置中的卷积计算电路的处理能力和所述卷积核的数据量中的至少一项,在所述多种数据装载方式中确定所述目标数据装载方式。
  19. 根据权利要求17或18所述的方法,其特征在于,所述多种数据装载方式包括第一类数据装载方式和/或第二类数据装载方式,其中,
    基于所述第一类数据装载方式,只将所述卷积核中的权重值向所述片上存储器中装载一次,复用所述卷积核中的权重值以将所述卷积核中的权重值和所述输入特征图进行卷积运算;
    基于所述第二类数据装载方式,只将所述输入特征图中的特征值向所述片上存储器中装载一次,复用所述输入特征图以将所述输入特征图与所述卷积核进行卷积运算。
  20. 根据权利要求19所述的方法,其特征在于,所述根据所述目标数据装载方式,将所述输入特征图和所述卷积核从所述片外存储器读取到所述 装置的片上存储器,包括:
    当进行一次卷积操作时,若所述目标数据装载方式是所述第一类数据装载方式,则在所述卷积运算时所需用到的所有输入特征图与装载于所述片上存储器中的权重值进行计算并输出对应的输出特征图的计算结果之后,再装载下一次卷积运算时所需用到的权重值;或者
    当进行一次卷积运算时,若所述目标数据装载方式是所述第二类数据装载方式,则在所述卷积运算时需用到的所有权重值与装载于所述片上存储器中的输入特征图进行计算并输出对应的输出特征图的计算结果之后,再装载下一次卷积运算时所需用到的输入特征图。
  21. 根据权利要求19或20所述的方法,其特征在于,
    所述第一类数据装载方式包括第一数据装载方式和/或第二数据装载方式,其中,基于所述第一数据装载方式,只将所述输入特征图中的数据向所述片上存储器中装载一次;基于所述第二数据装载方式,将所述输入特征图中的数据向所述片上存储器中装载多次;
    所述第二类数据装载方式包括第四数据装载方式和/或第五数据装载方式,其中,基于所述第四数据装载方式,只将所述卷积核中的权重值向所述片上存储器中装载一次;基于所述第五数据装载方式,将所述卷积核中的权重值向所述片上存储器中装载多次。
  22. 根据权利要求21所述的方法,其特征在于,所述多种数据装载方式还包括第三数据装载方式,基于所述第三数据装载方式,将所述卷积核中的权重值向所述片上存储器中装载多次,以及将所述输入特征图中的数据向所述片上存储器中装载多次。
  23. 根据权利要求22所述的方法,其特征在于,在一次卷积运算中,所述输入特征图包括α行β列的特征图分块阵列,所述特征图分块阵列中的特征图分块是将所述输入特征图沿第一方向和第三方向切分得到的,其中,所述α为所述输入特征图沿所述第一方向的分块个数,所述β为所述输入特征图沿所述第三方向的分块个数,其中α、β为整数;
    所述卷积核包括β行γ列的卷积核分块阵列,所述卷积核分块阵列中的卷积核分块是将所述卷积核沿第三方向和第四方向切分得到的,其中,所述β为所述卷积核沿所述第三方向的分块个数,所述γ为所述卷积核沿所述第四方向的分块个数,其中γ为整数。
  24. 根据权利要求23所述的方法,其特征在于,所述根据多种数据装载方式中的每种数据装载方式的数据搬移量,在所述多种数据装载方式中确定目标数据装载方式,包括:
    若所述片上存储器能够缓存一次卷积运算所需的所述特征图分块阵列的总数据量和所述卷积核分块阵列在所述第三方向上的数据量,将所述第一数据装载方式确定为所述目标数据装载方式;或者
    若所述片上存储器不能缓存一次卷积运算所需的所述特征图分块阵列的总数据量,但能够缓存所述卷积核分块阵列在第三方向上的数据量,将所述第二数据装载方式确定为所述目标数据装载方式;或者
    若所述片上存储器不能缓存一次卷积运算所需的所述特征图分块阵列的总数据量,并且不能缓存一次卷积运算所需的所述卷积核分块阵列在第三方向上的数据量,将所述第三数据装载方式确定为所述目标数据装载方式。
  25. 根据权利要求24所述的方法,其特征在于,所述根据所述目标数据装载方式,将所述输入特征图和所述卷积核从所述片外存储器读取到所述装置的片上存储器,包括:
    若所述目标数据装载方式为所述第一数据装载方式,将进行所述卷积运算时所需的所有特征图分块阵列同时装载于所述片上存储器,以及将进行所述卷积运算时在所述第三方向上的卷积计算相关联的所述卷积核分块阵列同时装载于所述片上存储器;或
    若所述目标数据装载方式为所述第二数据装载方式,将进行所述卷积运算时所需的特征图分块阵列依次装载于所述片上存储器,以及将进行所述卷积运算时在所述第三方向上的卷积计算相关联的所述卷积核分块阵列同时装载于所述片上存储器;或
    若所述目标数据装载方式为所述第三数据装载方式,将进行所述卷积运算时所需的所述特征图分块阵列依次装载于所述片上存储器,以及将进行所述卷积运算时所需的所述卷积核分块阵列依次装载于所述片上存储器。
  26. 根据权利要求24或25所述的方法,其特征在于,所述方法还包括:
    确定所述特征图分块在所述第一方向的大小以及在所述第三方向上的大小。
  27. 根据权利要求26所述的方法,其特征在于,所述特征图分块在所述第一方向的大小满足以下中的至少一项:
    等于所述输入特征图在所述第一方向的数据量大小;
    小于所述片上存储器的空间大小;
    等于在所述输入特征图的所述第一方向上所述装置中的卷积计算电路能够并行处理的最大数据量。
  28. 根据权利要求26或27所述的方法,其特征在于,所述特征图分块在所述第三方向的大小满足以下中的至少一项:
    等于所述输入特征图在所述第三方向的数据量大小;
    小于所述片上存储器的空间大小;
    等于在所述输入特征图的所述第三方向上所述装置中的卷积计算电路能够并行处理的最大数据量。
  29. 根据权利要求23所述的方法,其特征在于,所述方法还包括:
    若所述片上存储器的空间大小大于或等于一次卷积运算所需的卷积核的总数据量,将所述第四数据装载方式确定为所述目标数据装载方式;或者
    若所述片上存储器的空间大小小于一次卷积运算所需的所述卷积核的总数据量,将所述第五数据装载方式确定为所述目标数据装载方式。
  30. 根据权利要求29所述的方法,其特征在于,所述根据所述目标数据装载方式,将所述输入特征图和所述卷积核从所述片外存储器读取到所述装置的片上存储器,包括:
    若所述目标数据装载方式为所述第四数据装载方式,将进行所述卷积运算时所需的所有卷积核分块阵列同时装载于所述片上存储器,以及将进行所述卷积运算时在所述第三方向上的卷积计算相关联的所述特征图分块阵列同时装载于所述片上存储器;或
    若所述目标数据装载方式为所述第五数据装载方式,将进行所述卷积运算时在所述第三方向上的卷积计算相关联的所述特征图分块阵列同时装载于所述片上存储器。
  31. 根据权利要求29或30所述的方法,其特征在于,所述方法还包括:
    若所述第四数据装载方式为所述目标数据装载方式,确定所述卷积核分块在所述第四方向上的大小为所述卷积核在所述第四方向上的大小;或者
    若所述第五数据装载方式为所述目标数据装载方式,确定所述卷积核分块在所述第四方向上的大小为所述装置中的卷积计算电路所能输出的输出特征图的第三方向上的最大数据量。
  32. 根据权利要求29至31中任一项所述的方法,其特征在于,所述方法还包括:
    确定所述卷积核分块在所述第三方向上的大小为所述卷积核在所述第三方向上的大小。
  33. 根据权利要求29至32中任一项所述的方法,其特征在于,所述方法还包括:
    确定所述特征图分块在所述第三方向上的大小为所述输入特征图在所述第三方向上的大小;以及
    确定所述特征图分块在所述第一方向上的大小满足以下中的至少一项:
    等于所述输入特征图在所述第一方向的数据量大小;
    小于所述片上存储器的空间大小;
    等于在所述输入特征图的所述第一方向上所述装置中的卷积计算电路能够并行处理的最大数据量。
  34. 根据权利要求23至33中任一项所述的方法,其特征在于,
    所述第一方向为高度方向,所述第三方向为通道方向,所述第四方向为卷积核的个数方向;或
    所述第一方向为宽度方向,所述第三方向为通道方向,所述第四方向为卷积核的个数方向。
  35. 一种处理器,其特征在于,包括根据权利要求1至15中任一项所述的计算装置。
  36. 一种可移动设备,其特征在于,包括:
    根据权利要求1至15中任一项所述的计算装置;或者,
    根据权利要求35所述的处理器。
PCT/CN2019/122083 2019-11-29 2019-11-29 计算装置、方法、处理器和可移动设备 WO2021102946A1 (zh)

Priority Applications (2)

Application Number Priority Date Filing Date Title
CN201980048907.6A CN112470138A (zh) 2019-11-29 2019-11-29 计算装置、方法、处理器和可移动设备
PCT/CN2019/122083 WO2021102946A1 (zh) 2019-11-29 2019-11-29 计算装置、方法、处理器和可移动设备

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
PCT/CN2019/122083 WO2021102946A1 (zh) 2019-11-29 2019-11-29 计算装置、方法、处理器和可移动设备

Publications (1)

Publication Number Publication Date
WO2021102946A1 true WO2021102946A1 (zh) 2021-06-03

Family

ID=74806866

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2019/122083 WO2021102946A1 (zh) 2019-11-29 2019-11-29 计算装置、方法、处理器和可移动设备

Country Status (2)

Country Link
CN (1) CN112470138A (zh)
WO (1) WO2021102946A1 (zh)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115470176A (zh) * 2021-06-10 2022-12-13 中科寒武纪科技股份有限公司 计算装置、利用计算装置实施卷积运算的方法及相关产品

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113449852B (zh) * 2021-08-05 2023-02-03 安谋科技(中国)有限公司 卷积神经网络的计算方法、片上系统和电子设备

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107704923A (zh) * 2017-10-19 2018-02-16 珠海格力电器股份有限公司 卷积神经网络运算电路
US20180189643A1 (en) * 2017-01-05 2018-07-05 Electronics And Telecommunications Research Institute Convolution circuit, application processor including the same, and operating method thereof
CN109214504A (zh) * 2018-08-24 2019-01-15 北京邮电大学深圳研究院 一种基于fpga的yolo网络前向推理加速器设计方法
US20190138892A1 (en) * 2017-11-08 2019-05-09 Samsung Electronics Co., Ltd. Neural network device and method
CN110084739A (zh) * 2019-03-28 2019-08-02 东南大学 一种基于cnn的画质增强算法的fpga并行加速系统

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109886400B (zh) * 2019-02-19 2020-11-27 合肥工业大学 基于卷积核拆分的卷积神经网络硬件加速器系统及其计算方法

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20180189643A1 (en) * 2017-01-05 2018-07-05 Electronics And Telecommunications Research Institute Convolution circuit, application processor including the same, and operating method thereof
CN107704923A (zh) * 2017-10-19 2018-02-16 珠海格力电器股份有限公司 卷积神经网络运算电路
US20190138892A1 (en) * 2017-11-08 2019-05-09 Samsung Electronics Co., Ltd. Neural network device and method
CN109214504A (zh) * 2018-08-24 2019-01-15 北京邮电大学深圳研究院 一种基于fpga的yolo网络前向推理加速器设计方法
CN110084739A (zh) * 2019-03-28 2019-08-02 东南大学 一种基于cnn的画质增强算法的fpga并行加速系统

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115470176A (zh) * 2021-06-10 2022-12-13 中科寒武纪科技股份有限公司 计算装置、利用计算装置实施卷积运算的方法及相关产品
CN115470176B (zh) * 2021-06-10 2024-04-09 中科寒武纪科技股份有限公司 计算装置、利用计算装置实施卷积运算的方法及相关产品

Also Published As

Publication number Publication date
CN112470138A (zh) 2021-03-09

Similar Documents

Publication Publication Date Title
US11907830B2 (en) Neural network architecture using control logic determining convolution operation sequence
KR102499396B1 (ko) 뉴럴 네트워크 장치 및 뉴럴 네트워크 장치의 동작 방법
CN110036374B (zh) 使用专用计算单元的硬件双缓存
US20210133093A1 (en) Data access method, processor, computer system, and mobile device
JP2019087252A (ja) ニューラルネットワークにおいてデコンボルーション演算を実行する装置及びその方法
CN117217273A (zh) 实现卷积神经网络的硬件和非瞬态计算机可读存储介质
US20210192246A1 (en) Convolutional neural network-based image processing method and device, and unmanned aerial vehicle
JP2019533868A (ja) ニューラルネットワーク命令セットアーキテクチャ
US11112980B2 (en) Method and apparatus for allocating memory space for driving neural network
CN115516459B (zh) 用于均衡权重稀疏卷积处理的方法及系统
WO2021102946A1 (zh) 计算装置、方法、处理器和可移动设备
US11836971B2 (en) Method and device with convolution neural network processing
US20230289601A1 (en) Integrated circuit that extracts data, neural network processor including the integrated circuit, and neural network
US11188796B2 (en) Method and apparatus with data processing
TW202018598A (zh) 神經網路處理器及其卷積操作方法
EP3093757A2 (en) Multi-dimensional sliding window operation for a vector processor
WO2022041188A1 (zh) 用于神经网络的加速器、方法、装置及计算机存储介质
JP2022137247A (ja) 複数の入力データセットのための処理
JP7386542B2 (ja) 機械知覚および高密度アルゴリズム集積回路
WO2020155044A1 (zh) 卷积计算的装置、方法、处理器和可移动设备
US20200356844A1 (en) Neural network processor for compressing featuremap data and computing system including the same
WO2018165812A1 (zh) 处理图像的方法、芯片、处理器、计算机系统和移动设备
US20200134771A1 (en) Image processing method, chip, processor, system, and mobile device
WO2019041271A1 (zh) 处理图像的方法、集成电路、处理器、系统和可移动设备
CN115294280A (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: 19953894

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 19953894

Country of ref document: EP

Kind code of ref document: A1