Convolution operation device, method, electronic device and medium

By designing a convolution operation device in the CNN FPGA accelerator and using horizontal and vertical data processing modules to share input matrix data, the problem of repeated data reading in matrix convolution operations is solved, energy consumption is reduced and calculation speed is maintained. flexibility.

CN113971261BActive Publication Date: 2024-09-20EHIWAY MICROELECTRONIC SCI & TECH (SUZHOU) CO LTD +1
View PDF 9 Cites 0 Cited by

Patent Information

Application Number
CN202010719685.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-07-23
Publication Date
2024-09-20
Estimated Expiration
2040-07-23

AI Technical Summary

Technical Problem

Existing CNN FPGA accelerators have repeated reading of input data during matrix convolution operations, resulting in increased dynamic power consumption and reduced timing performance, and the optimized structure often sacrifices flexibility and computing speed.

Method used

Design a convolution operation device that performs row data conversion on the input matrix through the horizontal data processing module and performs multiplication, cross addition and accumulation operations in combination with the vertical data processing module to achieve data sharing of the input matrix and avoid repeated reading. The preset timing optimizes storage and output methods and reduces redundant memory access.

Benefits of technology

It significantly reduces the repeated reading of data in convolution operations, reduces energy consumption, and maintains the flexibility of calculation speed to adapt to the design of different matrix sizes and convolution spans.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113971261B
    Figure CN113971261B
Patent Text Reader

Abstract

The present disclosure provides a convolution operation device for performing convolution operation on an input matrix and a weight matrix, comprising: a horizontal data processing module for converting the order of row data of the input matrix to realize sharing of the read row data, wherein one horizontal data processing module processes one row of row data; a vertical data processing module for multiplying the weight matrix with the matrix data output by the horizontal data processing module, performing cross addition operation on the multiplication result, performing accumulation operation on the cross addition result, and obtaining the convolution operation result of the input matrix; wherein the vertical data processing module includes multiple inputs, each input is connected to the output of one horizontal data processing module. The present disclosure also provides a convolution operation method, an electronic device, and a computer-readable storage medium.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of convolutional neural network hardware acceleration, and in particular to a convolution operation device, method, electronic device and medium. Background Art

[0002] Convolutional Neural Networks (CNN) is one of the representative algorithms of deep learning. Due to its outstanding performance in the field of artificial intelligence, CNN has attracted extensive attention and has been applied to high-tech applications such as image classification, speech recognition, face recognition, autonomous driving, and medical imaging. At present, CNN structures with excellent performance such as AlexNet, VGG, and ResNet have emerged. With the continuous development of CNN, the network structure has become increasingly complex and the number of parameters has exploded, posing new challenges to the design of CNN hardware accelerators.

[0003] Due to the excellent flexible programmability and outstanding performance-to-power ratio of Field Programmable Gate Array (FPGA), most of the current mainstream CNN forward inference accelerators use FPGA-based acceleration solutions. CNN is a computationally intensive structure, in which massive matrix convolution calculations pose challenges to accelerator design. In order to achieve better acceleration effects, many classic CNN FPGA accelerator designs focus on the optimization of matrix convolution calculation structures.

[0004] During the matrix convolution operation, adjacent convolution windows have a large amount of data overlap. In the CNN FPGA accelerator, this data overlap often leads to repeated reading of input data during circuit implementation. Usually, input data is stored in storage modules, and repeated access to these storage modules will not only bring additional dynamic power consumption, but also reduce the timing performance of the accelerator. In order to optimize the matrix convolution calculation structure, it is necessary to minimize the repeated reading of input matrix data.

[0005] In the traditional matrix convolution computing structure, the data overlap of adjacent convolution windows is achieved at the cost of multiple repeated accesses to the input data. In some optimized matrix convolution computing structures, although the reuse of input data is achieved through structural innovation, there is still a certain degree of repeated reading of input data. In contrast, there are some optimized matrix convolution computing structures that avoid repeated reading of input matrix data, but sacrifice the flexibility of the structure and the output speed of the calculation results. Summary of the invention

[0006] 1. Technical issues to be resolved

[0007] In response to the above technical problems, the present disclosure proposes a convolution operation device, method, electronic device and medium, which are used to at least partially solve the above technical problems.

[0008] (II) Technical solution

[0009] According to the first aspect of the present disclosure, a convolution operation device is provided for performing convolution operation on an input matrix and a weight matrix, including: a horizontal data processing module, for converting the order of row data of the input matrix to realize sharing of the read row data, wherein one horizontal data processing module processes row data; a vertical data processing module, for multiplying the weight matrix with the matrix data output by the horizontal data processing module, performing cross addition operation on the multiplication result, performing accumulation operation on the cross addition result, to obtain the convolution operation result of the input matrix; wherein the vertical data processing module includes multiple inputs, each input is connected to the output of a horizontal data processing module.

[0010] Optionally, the horizontal data processing module includes: a first shift register chain, a second shift register chain and a first multiplexer, the output of the first shift register chain is connected to the input of the second shift register chain, and the output of the second shift register chain is connected to the input of the first shift register chain; the first shift register chain, the second shift register chain and the first multiplexer are implemented based on an FPGA chip; the first multiplexer is used to select the shift register chain for row data input; the first shift register chain and the second shift register chain are used to shift the row data and convert the row data into a single row data sequence required by the convolution window; wherein, when the output data of the last shift register of the first shift register chain or the second shift register chain is the overlapping data of adjacent convolution windows, the first shift register chain inputs the output data of the last shift register at this time to the second shift register chain, or the second shift register chain inputs the output data of the last shift register at this time to the first shift register chain.

[0011] Optionally, the vertical data processing module includes: a multiplier, an addition tree, an accumulator and a second multiplexer, and the multiplier, the addition tree, the accumulator and the second multiplexer are implemented based on an FPGA chip; the second multiplexer is used to select the data operation path currently being executed; the multiplier is used to multiply each row of data of the weight matrix with the matrix data output by the corresponding horizontal data processing module; the addition tree is used to perform a cross-addition operation on the result of the multiplication operation; the accumulator is used to perform an accumulation operation on the result of the cross-addition operation to obtain a convolution operation result.

[0012] Optionally, the convolution operation device also includes: storage units, the number of storage units is the same as the number of rows of the input matrix, and each storage unit is used to store row data of a row of the input matrix.

[0013] Optionally, the storage unit inputs row data to the horizontal data processing module according to a preset timing, including: when the convolution operation starts, the storage unit inputs one element of the row data to the horizontal data processing module in each clock cycle for k consecutive clock cycles according to the arrangement order of the elements in the row data; then, after an interval of (ks) clock cycles, the storage unit does not input data to the horizontal data processing module; after an interval of (ks) clock cycles, the storage unit inputs one element of the row data to the horizontal data processing module in each clock cycle for s consecutive clock cycles according to the arrangement order of the elements in the row data; wherein k is the size of the weight matrix, and s is the span size of the convolution operation.

[0014] Optionally, the length of the first shift register chain and the second shift register chain is (ks), wherein k is the size of the weight matrix and s is the span size of the convolution operation.

[0015] Optionally, during the process of performing the accumulation operation, the accumulator outputs the result of the accumulation operation every k clock cycles and clears the starting value of the accumulation operation to zero.

[0016] According to the second aspect of the present disclosure, a convolution operation method is provided for performing convolution operation on an input matrix and a weight matrix, including: dividing the input matrix into rows, and storing each row of data in a storage unit; the storage unit inputs the row data to its corresponding horizontal data processing module according to a preset timing to convert the order of the row data of the input matrix; the matrix data converted by each horizontal data processing module is input into the vertical data processing module, so that the vertical data processing module performs multiplication operation, cross addition operation and accumulation operation on the weight matrix and the converted matrix data in sequence to obtain the convolution operation result.

[0017] According to a third aspect of the present disclosure, there is provided an electronic device, comprising: one or more processors; and a memory for storing one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors implement the above-mentioned convolution operation method.

[0018] According to a fourth aspect of the present disclosure, a computer-readable storage medium is provided, storing computer-executable instructions, which are used to implement the above-mentioned convolution operation method when executed.

[0019] (III) Beneficial effects

[0020] The present disclosure provides a convolution operation device, method, electronic device and medium, which have the following beneficial effects:

[0021] 1. The convolution operation device first divides the input matrix into rows and then sequentially converts each row of data to convert the input matrix data into the single row data sequence required by the horizontal convolution window, thereby realizing the sharing of data read from the input matrix in the horizontal direction. Then, the converted row data is sequentially multiplied, cross-added, and accumulated with the weight matrix in the vertical direction, thereby realizing the sharing of data in the vertical direction of the input matrix. The combination of the two avoids the repeated reading of data in the matrix convolution operation, thereby significantly reducing redundant memory access and reducing the energy consumption required for the overall algorithm operation.

[0022] 2. Matrix data of different rows are stored in different storage units respectively. The storage units input the row data of the input matrix to the horizontal data processing module according to the preset timing. By optimizing the storage and output methods of the data, the sharing of the read data during the convolution operation is further optimized.

[0023] 3. The size or quantity or data output mode or operation mode of the hardware unit of the convolution operation device can be flexibly designed according to the parameters of the convolution operation to adapt to different matrix sizes and convolution spans, that is, the convolution operation device has a high degree of flexibility. BRIEF DESCRIPTION OF THE DRAWINGS

[0024] For a more complete understanding of the present disclosure and its advantages, reference will now be made to the following description in conjunction with the accompanying drawings, which are incorporated into and constitute a part of the specification, illustrate embodiments consistent with the present disclosure, and together with the description are used to explain the principles of the present disclosure. Among them:

[0025] Figure 1 The flowchart of the convolution operation process is schematically shown;

[0026] Figure 2 The structure diagram of the input matrix divided by rows according to the embodiment of the present disclosure is schematically shown;

[0027] Figure 3 A result diagram schematically shows outputting data according to a preset time sequence according to an embodiment of the present disclosure;

[0028] Figure 4 A circuit structure diagram of a horizontal data processing unit according to an embodiment of the present disclosure is shown schematically;

[0029] Figure 5 Schematically showing a single row of data in a convolution window generated after being processed by a horizontal data processing unit according to an embodiment of the present disclosure;

[0030] Figure 6 A schematic diagram of a circuit structure of a vertical data processing unit according to an embodiment of the present disclosure;

[0031] Figure 7The flowchart of the convolution operation method according to the embodiment of the present disclosure is schematically shown;

[0032] Figure 8 A block diagram of an electronic device according to an embodiment of the present disclosure is schematically shown. DETAILED DESCRIPTION

[0033] Hereinafter, embodiments of the present disclosure will be described with reference to the accompanying drawings. However, it should be understood that these descriptions are exemplary only and are not intended to limit the scope of the present disclosure. In the following detailed description, for ease of explanation, many specific details are set forth to provide a comprehensive understanding of the embodiments of the present disclosure. However, it is apparent that one or more embodiments may also be implemented without these specific details. In addition, in the following description, descriptions of known structures and technologies are omitted to avoid unnecessary confusion of the concepts of the present disclosure.

[0034] The terms used herein are only for describing specific embodiments and are not intended to limit the present invention. The terms "comprise", "include", etc. used herein indicate the existence of the features, steps, operations and / or components, but do not exclude the existence or addition of one or more other features, steps, operations or components.

[0035] The present invention provides a convolution operation method and a convolution operation device capable of using the method, which can perform convolution operation on an input matrix and a weight matrix. The convolution operation device includes: a horizontal data processing unit and a vertical data processing unit, a horizontal data processing module, which is used to convert the order of the row data of the input matrix to realize the sharing of the read row data, wherein one horizontal data processing module processes one row of the row data. The vertical data processing module is used to multiply the weight matrix with the matrix data output by the horizontal data processing module, perform cross addition operation on the multiplication result, perform accumulation operation on the cross addition result, and obtain the convolution operation result of the input matrix; wherein the vertical data processing module includes multiple inputs, each input is connected to the output of a horizontal data processing module. The device realizes the data sharing of the horizontal and vertical directions of the input matrix by performing operations on the input matrix data in the horizontal direction and the vertical direction respectively, avoiding the repeated reading of data during the convolution operation, and ensuring the flexibility and operation speed of the convolution operation.

[0036] In one embodiment of the present disclosure, the convolution operation device may further include storage units, the number of the storage units is the same as the number of rows of the input matrix, and each storage unit is used to store row data of a row of the input matrix, thereby storing data of different rows in different storage units.

[0037] The storage unit can, for example, input the row data to the horizontal data processing module according to a preset timing, specifically including: when the convolution operation starts, the storage unit inputs one element of the row data to the horizontal data processing module in each clock cycle for k consecutive clock cycles according to the arrangement order of the elements in the row data. After that, at an interval of (ks) clock cycles, the storage unit does not input data to the horizontal data processing module. After an interval of (ks) clock cycles, the storage unit inputs one element of the row data to the horizontal data processing module in each clock cycle for s consecutive clock cycles according to the arrangement order of the elements in the row data. Wherein, k is the size of the weight matrix, and s is the span size of the convolution operation.

[0038] In one embodiment of the present disclosure, the horizontal data processing module may include, for example, a first shift register chain, a second shift register chain, and a first multiplexer. The output of the first shift register chain is connected to the input of the second shift register chain, and the output of the second shift register chain is connected to the input of the first shift register chain; the first shift register chain, the second shift register chain, and the first multiplexer are implemented based on an FPGA chip. The first multiplexer is used to select the shift register chain for row data input, and the first shift register chain and the second shift register chain are used to shift the row data and convert the row data into a single row data sequence required by the convolution window. When the output data of the last shift register of the first shift register chain or the second shift register chain is the overlapping data of the adjacent convolution windows, the first shift register chain inputs the output data of the last shift register at this time to the second shift register chain, or the second shift register chain inputs the output data of the last shift register at this time to the first shift register chain. The lengths of the first shift register chain and the second shift register chain may be, for example, (ks).

[0039] In one embodiment of the present disclosure, the vertical data processing module may include, for example: a multiplier, an adder tree, an accumulator and a second multiplexer. The multiplier, the adder tree, the accumulator and the second multiplexer may be implemented based on an FPGA chip.

[0040] The second multiplexer is used to select the data operation path currently being executed. The multiplier is used to perform multiplication operation on each row of the weight matrix with the matrix data output by the corresponding horizontal data processing module. The addition tree is used to perform cross addition operation on the result of the multiplication operation. The accumulator is used to perform accumulation operation on the result of the cross addition operation to obtain the convolution operation result.

[0041] In order to more clearly explain the structure of the above convolution operation device, the convolution operation device is introduced below with a specific example. It should be understood that the example is only illustrative and is not used to limit the present disclosure.

[0042] Before going into detail, let's first give a brief introduction to the convolution operation of the matrix.

[0043] Figure 1 The flowchart of the convolution operation process is schematically shown.

[0044] like Figure 1 As shown in the figure, the size of the convolution operation is 7*7, the size of the weight matrix is ​​3*3, the convolution span is 2, and the size of the output matrix is ​​3*3. The 3*3 convolution window slides on the input matrix with a step size of 2. The 9 input data in each convolution window are multiplied by the weight data at the corresponding position, and the multiplication results are accumulated to obtain a value in the output matrix, which is the final convolution operation result.

[0045] To simplify the description, the embodiment of the present disclosure takes a 5*5 input matrix, a 3*3 weight matrix, a 3*3 output matrix, and a matrix convolution process with a convolution span of 1 as an example for illustration.

[0046] Figure 2 The structure diagram of dividing the input matrix into rows according to an embodiment of the present disclosure is schematically shown.

[0047] like Figure 2 As shown, the input matrix is ​​divided into rows, and the input data of different rows are stored in different storage units (BRAM). Each storage unit independently provides data for a horizontal data processing module (Data Conversion Unit, DCU). The storage unit can be on-chip storage.

[0048] The storage unit outputs data to the DCU in a certain timing sequence. The specific execution timing sequence is:

[0049] (1) When the calculation starts, one element of the input matrix data is output every clock for k consecutive clock cycles.

[0050] (2) After that, there is an interval of ks clock cycles, during which the storage unit does not output data.

[0051] (3) After the interval, one element of the input matrix data is outputted every clock for s consecutive clock cycles.

[0052] The above step (1) is only executed once when the storage unit initially outputs data, and then (2) and (3) are repeatedly executed until all elements of each row of data are output to the DCU.

[0053] Figure 3 The result diagram of outputting data according to a preset time sequence according to an embodiment of the present disclosure is schematically shown.

[0054] like Figure 3As shown, at this time, the value of k is 3, the value of s is 1, and initially, one element of the input matrix data is output in each clock for three consecutive clock cycles ( Figure 3 0, 1, 2 shown in FIG3 ); and then, after every 2 clock cycles, an element of the input matrix data is output (3, 4 shown in FIG3 ).

[0055] Figure 4 A circuit structure diagram of a horizontal data processing unit according to an embodiment of the present disclosure is shown.

[0056] like Figure 4 As shown, DCU consists of a multiplexer, two groups of shift register chains AB and a control state machine, where the length of each group of shift register chains is (ks). CLK represents the clock signal, D is the register input, Q is the register output, MUX is the multiplexer, and C is the path switching switch.

[0057] Under the control of the state machine, the data input from the storage unit first enters the shift register chain of group A. When the output value of the last register of the shift register chain of group A is the overlapping data of horizontally adjacent convolution windows, the output data of group A is simultaneously transmitted to the output register and the shift register chain of group B. When group A completes the output of a single row of data of a convolution window, the input data is transmitted to the shift register chain of group B. Afterwards, the overlapping convolution window data shared from group A and the new input data stored in group B together constitute the single row of data required for the adjacent horizontal convolution window. Similarly, when the output value of group B is the overlapping data of horizontally adjacent convolution windows, the output data of group B is simultaneously transmitted to the output register and the shift register chain of group A. Through the above process, the data passes through the shift register chains of groups A and B alternately, and as shown below: Figure 5 The timing shown converts a single row of input matrix data into the single row of data sequence required by the horizontal convolution window. The data in the dashed boxes on both sides of the figure are the single row of data of the convolution window generated by the A group of shift register chains, and the data in the middle dashed box are the single row of data of the convolution window generated by the B group of shift register chains. Through the above data processing process, the DCU can realize the sharing of data read from the input matrix, thereby avoiding repeated reading of data in the horizontal direction of the input matrix.

[0058] Figure 6 A schematic circuit structure diagram of a vertical data processing unit according to an embodiment of the present disclosure.

[0059] like Figure 6As shown, the vertical data processing module consists of a multiplier, an adder tree, and an accumulator. IN represents the input data from the DCU, Wi is the i-th row data of the weight matrix, Adder Tree is the adder tree, MUX is the multiplexer, ACC is the accumulator, OUTtemp is the intermediate calculation result, and OUT is the calculation output result of the matrix convolution.

[0060] The output data of each DCU is fanned out to the corresponding multiplier as needed. The weight matrix is ​​divided by row, and the weight data of each row is periodically input to the corresponding multiplier. The calculation results of the multiplier are cross-transmitted to the addition tree to complete the summation of the multiplication results corresponding to the vertical convolution window. The calculation results of the addition tree are accumulated in the accumulator, and the accumulated results are output every k clock cycles and the accumulation start value is cleared.

[0061] Combination Figure 2 , Figure 3 , Figure 5 and Figure 6 , the input data of IN0 (0 1 2 1 2 3 2 3 4) is multiplied with the first row data of the periodic input weight matrix (0 1 2 0 1 2 0 1 2), and the result is input into Adder Tree 0. The input data of IN1 (5 6 7 6 7 8 7 8 9) fans out into two data paths, one of which is multiplied with the second row data of the periodic input weight matrix (3 4 5 3 4 5 3 4 5), and the result is input into Adder Tree 0. The input data of IN2 (10 11 12 11 12 13 12 13 14) fans out into three data paths, one of which is multiplied with the third row data of the periodic input weight matrix (6 7 8 6 7 8 6 7 8), and the result is input into Adder Tree 0. 0 performs addition operation on the three input results. Similarly, Adder Tree 1 and Adder Tree 2 perform similar operations as AdderTree 0, thereby realizing cross-addition operation on the results of each multiplier.

[0062] The vertical data processing unit realizes data sharing in the vertical direction of the input matrix through DCU data fan-out and cross-summation of multiplier results, thereby avoiding repeated reading of data in the vertical direction of the input matrix.

[0063] Through the embodiment of the present disclosure, the horizontal data processing module and the vertical data processing module together constitute a matrix convolution operation device, thereby avoiding repeated reading of the input matrix data and ensuring that other performances of the matrix convolution are not disturbed. In addition, the convolution operation device is highly flexible and can be adjusted according to the parameter changes of the matrix convolution to adapt to different matrix sizes and convolution spans. The specific adjustment method is: adjust the length of the shift register chain in the horizontal data processing module according to demand; adjust the fan-out method of the DCU data, the weight data supply method, the cross-supply method of the addition tree input data, and the accumulator accumulation cycle in the vertical data processing module.

[0064] In summary, the embodiment of the present disclosure provides a matrix convolution operation device, which first divides the input matrix into rows and sequentially converts each row of data to convert the input matrix data into the single row data sequence required by the horizontal convolution window, so as to realize the sharing of the data read by the input matrix in the horizontal direction. Then, the converted row data is sequentially multiplied, cross-added and accumulated with the weight matrix in the vertical direction, so as to realize the data sharing in the vertical direction of the input matrix. The combination of the two avoids the repeated reading of data in the matrix convolution operation, thereby significantly reducing the redundant memory access and reducing the energy consumption required for the overall algorithm operation. Further, the matrix data of different rows are stored in different storage units respectively, and the storage unit inputs the row data of the input matrix to the horizontal data processing module according to the preset timing, and by optimizing the storage mode and output mode of the data, the sharing of the read data during the convolution operation is further optimized. In addition, the size or number of the hardware unit of the convolution operation device or the data output mode or the operation mode can be flexibly designed according to the parameters of the convolution operation to adapt to different matrix sizes and convolution spans, that is, the convolution operation device has a high degree of flexibility.

[0065] Figure 7 A flowchart of a convolution operation method according to an embodiment of the present disclosure is schematically shown, and the method is implemented based on the convolution operation device described above.

[0066] like Figure 7 As shown, the convolution operation method may include, for example, operations S701 to S703.

[0067] In operation S701, the input matrix is ​​divided into rows, and each row of data is stored in a storage unit.

[0068] In operation S702, the storage unit inputs row data to its corresponding horizontal data processing module according to a preset timing to convert the order of the row data of the input matrix.

[0069] In operation S703, the matrix data converted by each horizontal data processing module is input into the vertical data processing module, so that the vertical data processing module sequentially performs multiplication, cross addition and accumulation operations on the weight matrix and the converted matrix data to obtain a convolution operation result.

[0070] The implementation method and technical effects of the method embodiment part are similar to those of the device embodiment part. Please refer to the device embodiment part for specific details, which will not be repeated here.

[0071] Figure 8 A block diagram of an electronic device according to an embodiment of the present disclosure is schematically shown. Figure 8 The electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.

[0072] like Figure 8 As shown, the electronic device 800 includes a processor 810 and a computer-readable storage medium 820. The electronic device 800 can execute the method according to the embodiment of the present disclosure.

[0073] Specifically, the processor 810 may include, for example, a general-purpose microprocessor, an instruction set processor and / or a related chipset and / or a special-purpose microprocessor (e.g., an application-specific integrated circuit (ASIC)), etc. The processor 810 may also include an onboard memory for cache purposes. The processor 810 may be a single processing unit or multiple processing units for performing different actions of the method flow according to an embodiment of the present disclosure.

[0074] Computer-readable storage medium 820, for example, can be a non-volatile computer-readable storage medium, and specific examples include but are not limited to: magnetic storage devices, such as magnetic tapes or hard disks (HDD); optical storage devices, such as compact disks (CD-ROM); memories, such as random access memory (RAM) or flash memory; and the like.

[0075] The computer-readable storage medium 820 may include a computer program 821 , which may include code / computer-executable instructions that, when executed by the processor 810 , cause the processor 810 to perform a method according to an embodiment of the present disclosure or any variation thereof.

[0076] The computer program 821 may be configured to have, for example, a computer program code including a computer program module. For example, in an example embodiment, the code in the computer program 821 may include one or more program modules, for example, including 821A, module 821B, ... It should be noted that the division method and number of modules are not fixed, and those skilled in the art may use appropriate program modules or program module combinations according to actual conditions, and when these program module combinations are executed by the processor 810, the processor 810 may execute the method according to the embodiment of the present disclosure or any variation thereof.

[0077] The present disclosure also provides a computer-readable storage medium, which may be included in the device / apparatus / system described in the above embodiments; or may exist independently without being assembled into the device / apparatus / system. The above computer-readable storage medium carries one or more programs, and when the above one or more programs are executed, the method according to the embodiment of the present disclosure is implemented.

[0078] The flow charts and block diagrams in the accompanying drawings illustrate the possible architecture, functions and operations of the systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each box in the flow chart or block diagram can represent a module, a program segment, or a part of a code, and the above-mentioned module, program segment, or a part of a code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flow chart, and the combination of the boxes in the block diagram or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0079] It will be appreciated by those skilled in the art that, although the present disclosure has been shown and described with reference to specific exemplary embodiments of the present disclosure, it will be appreciated by those skilled in the art that, without departing from the spirit and scope of the present disclosure as defined by the appended claims and their equivalents, various changes in form and detail may be made to the present disclosure. Therefore, the scope of the present disclosure should not be limited to the above-described embodiments, but should be determined not only by the appended claims, but also by the equivalents of the appended claims.

Claims

1. A convolution operation device, for performing a convolution operation on an input matrix and a weight matrix, comprising: A horizontal data processing module, used for converting the order of the row data of the input matrix to realize the sharing of the read row data, wherein one horizontal data processing module processes one row of the row data; A vertical data processing module, used for performing a multiplication operation on the weight matrix and the matrix data output by the horizontal data processing module, performing a cross addition operation on the multiplication operation result, and performing an accumulation operation on the cross addition operation result to obtain a convolution operation result of the input matrix; wherein the vertical data processing module comprises a plurality of inputs, each input being connected to an output of one of the horizontal data processing modules; Wherein, the horizontal data processing module includes: A first shift register chain, a second shift register chain and a first multiplexer, wherein the output of the first shift register chain is connected to the input of the second shift register chain, and the output of the second shift register chain is connected to the input of the first shift register chain; the first shift register chain, the second shift register chain and the first multiplexer are implemented based on an FPGA chip; the first multiplexer is used to select the shift register chain for inputting the row data; the first shift register chain and the second shift register chain are used to shift the row data and convert the row data into a single row data sequence required by a convolution window; when the output data of the last shift register of the first shift register chain or the second shift register chain is overlapping data of adjacent convolution windows, the first shift register chain inputs the output data of the last shift register at this time to the second shift register chain, or the second shift register chain inputs the output data of the last shift register at this time to the first shift register chain.

2. The convolution operation device according to claim 1, wherein: The vertical data processing module comprises: A multiplier, an adder tree, an accumulator and a second multiplexer, wherein the multiplier, the adder tree, the accumulator and the second multiplexer are implemented based on an FPGA chip; The second multiplexer is used to select the data operation path currently being executed; The multiplier is used to perform multiplication operation on each row of data of the weight matrix and the matrix data output by the corresponding horizontal data processing module; The addition tree is used to perform cross addition operation on the result of multiplication operation; The accumulator is used to perform accumulation operation on the results of the cross addition operation to obtain the convolution operation result.

3. The convolution operation device according to claim 1, wherein: The convolution operation device also includes: Storage units, the number of the storage units is the same as the number of rows of the input matrix, and each of the storage units is used to store a row of row data of the input matrix.

4. The convolution operation device according to claim 3, wherein: The storage unit inputs the row data to the horizontal data processing module according to a preset timing, including: When the convolution operation starts, the storage unit inputs one element of the row data to the horizontal data processing module in each clock cycle according to the arrangement order of the elements in the row data for k consecutive clock cycles; After that, at an interval of (ks) clock cycles, the storage unit does not input data to the horizontal data processing module; After an interval of (ks) clock cycles, the storage unit inputs one element of the row data to the horizontal data processing module in each clock cycle according to the arrangement order of the elements in the row data within s consecutive clock cycles; Among them, the k is the size of the weight matrix, and the s is the span size of the convolution operation.

5. The convolution operation device according to claim 1, wherein: The lengths of the first shift register chain and the second shift register chain are (ks), wherein k is the size of the weight matrix, and s is the span size of the convolution operation.

6. The convolution operation device according to claim 2, wherein: During the process of performing the accumulation operation, the accumulator outputs the result of the accumulation operation every k clock cycles and clears the starting value of the accumulation operation to zero.

7. A convolution operation method based on the convolution operation device according to any one of claims 1 to 6, for performing a convolution operation on an input matrix and a weight matrix, comprising: Splitting the input matrix into rows, and storing each row of data in a storage unit; The storage unit inputs row data to its corresponding horizontal data processing module according to a preset timing sequence to convert the order of the row data of the input matrix; The matrix data converted by each horizontal data processing module is input into the vertical data processing module, so that the vertical data processing module sequentially performs multiplication, cross addition and accumulation operations on the weight matrix and the converted matrix data to obtain a convolution operation result.

8. An electronic device comprising: one or more processors; a memory for storing one or more programs, Wherein, when the one or more programs are executed by the one or more processors, the one or more processors implement the method of claim 7.

9. A computer-readable storage medium storing computer-executable instructions, wherein the instructions are used to implement the method of claim 7 when executed.

Citation Information

Patent Citations

  • Convolution operation chip and communication equipment

    CN106844294A

  • Calculation device and method for neural network calculation

    CN108304922A

  • Circuit structure for accelerating convolutional layer and fully connected layer of neural network

    CN108416434A

  • Hardware interconnection architecture of reconfigurable convolutional neural network

    CN108647773A

  • System and method for extracting convolution window in convolutional neural network

    CN110647978A