Calling method and device for coarse-grained reconfigurable acceleration array matrix and storage medium
By introducing a coarse-grained reconstructable acceleration array matrix in data processing, the problem of narrow application scenarios of traditional matrix multiplication and acceleration methods is solved, and a wider and more flexible matrix multiplication data processing is achieved.
Patent Information
- Application Number
- CN202411541555.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-31
- Publication Date
- 2025-02-18
AI Technical Summary
The application scenarios of the traditional matrix multiplication acceleration method are not wide enough to meet a variety of different calling needs.
Provide a coarse-grained reconstructed acceleration array matrix calling method. By obtaining the target input matrix and calling requirements, it determines that the calling policy is a fixed weight call mapping policy or unit combination mapping policy, and calls the acceleration array matrix according to the policy to achieve Matrix multiplication data processing.
The application scope of matrix multiplication data processing has been expanded, so that the acceleration array matrix can be flexibly and accurately called under different calling requirements, improving the efficiency and accuracy of data processing.
Smart Images

Figure CN119474004A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of data processing technology, and in particular to a calling method, device and storage medium for a coarse-grained reconfigurable acceleration array matrix. Background Art
[0002] Neural network reasoning on terminal chips is an important form of AI application implementation and is widely used in various terminal chips, such as vehicle-mounted chips, mobile phone chips, etc. Its applications include video super-resolution, photography effect optimization, face recognition, intelligent driving, etc. The chip hardware architecture and supporting software solutions that support the accelerated operation of neural networks on terminals are the prerequisites for supporting the inference operation of neural networks on chips. The most critical operators in neural networks are convolution operators and FC operators, which can be implemented through matrix multiplication.
[0003] In traditional technology, matrix multiplication acceleration is usually achieved through TPU or FPGA. However, the application scenarios of traditional matrix multiplication acceleration methods are not wide enough. Summary of the invention
[0004] Based on this, it is necessary to provide a calling method, device and storage medium for a coarse-grained reconfigurable acceleration array matrix that can expand the application scenarios of the matrix multiplication acceleration method in order to address the above technical problems.
[0005] In a first aspect, the present application provides a method for calling a coarse-grained reconfigurable acceleration array matrix, comprising:
[0006] Obtaining a target input matrix and a target call requirement; the target input matrix includes a target feature matrix and a target weight matrix;
[0007] Determine a target calling strategy according to the target calling requirement; the target calling strategy is a fixed weight calling mapping strategy or a unit combination mapping strategy;
[0008] The acceleration array matrix is called according to the target calling strategy and the target input matrix to obtain a calling result corresponding to the target input matrix.
[0009] In one embodiment, the target calling strategy is the fixed weight calling mapping strategy, and calling the acceleration array matrix according to the target calling strategy and the target input matrix to obtain a calling result corresponding to the target input matrix includes:
[0010] Establishing an association relationship between the target weight matrix and the acceleration array matrix, and storing the target weight matrix in the acceleration array matrix;
[0011] The acceleration array matrix is called to read the target feature matrix, and multiplication and addition operations are performed on the target weight matrix in the acceleration array matrix to obtain a call result corresponding to the target input matrix.
[0012] In one embodiment, establishing an association relationship between the target weight matrix and the acceleration array matrix, and storing the target weight matrix in the acceleration array matrix, includes:
[0013] The memory access units in the acceleration array matrix are matched one by one with the weight elements in the target weight matrix in a preset order to obtain a first corresponding relationship between the memory access units and the weight elements;
[0014] Determine a second corresponding relationship between each of the processing units and each of the weight elements according to a positional relationship between each of the memory access units and each of the processing units in the acceleration array matrix, and the first corresponding relationship;
[0015] According to the second corresponding relationship, each of the weight elements is stored in a corresponding processing unit.
[0016] In one embodiment, calling the acceleration array matrix to read the target feature matrix, performing multiplication and addition operations with the target weight matrix in the acceleration array matrix, and obtaining a calling result corresponding to the target input matrix includes:
[0017] For each processing cycle, calling the memory access unit in the acceleration array matrix to read the data of the target number of rows in the target feature matrix;
[0018] The processing unit corresponding to each of the memory access units is called to perform multiplication and addition operations on the data of each of the target rows and the weight elements to obtain a calling result corresponding to the target input matrix.
[0019] In one embodiment, the target calling strategy is the unit combination mapping strategy, and calling the acceleration array matrix according to the target calling strategy and the target input matrix to obtain the calling result corresponding to the target input matrix includes:
[0020] Dividing the acceleration array matrix into a plurality of unit groups; each of the unit groups comprises a memory access unit, a processing unit and a routing unit;
[0021] For each unit group, obtaining processing data of a previous unit group of the unit group;
[0022] Calling the memory access unit in the cell group to read the data in the target feature matrix and the weight elements of the target weight matrix respectively, and calling the processing unit in the cell group to process the data in the target feature matrix, the weight elements of the target weight matrix and the processed data of the previous cell group to obtain processed data;
[0023] The routing unit in the unit group is called to route the processed data to the next unit group for accumulation, so as to obtain a calling result corresponding to the target input matrix.
[0024] In one embodiment, the processing unit in the unit group includes an addition unit and a multiplication unit, and the calling of the processing unit in the unit group processes the data in the target feature matrix, the weight elements of the target weight matrix and the processed data of the previous unit group to obtain the processed data, including:
[0025] Calling the multiplication unit to perform multiplication processing on the data in the target feature matrix and the weight elements of the target weight matrix to obtain initial processing data;
[0026] The adding unit is called to perform addition processing on the initial processing data and the processing data of the previous unit group to obtain processing data.
[0027] In a second aspect, the present application also provides a device for calling a coarse-grained reconfigurable acceleration array matrix, comprising:
[0028] An acquisition module is used to acquire a target input matrix and a target call requirement; the target input matrix includes a target feature matrix and a target weight matrix;
[0029] A determination module, used to determine a target call strategy according to the target call requirement; the target call strategy is a fixed weight call mapping strategy or a unit combination mapping strategy;
[0030] A calling module is used to call the acceleration array matrix according to the target calling strategy and the target input matrix to obtain a calling result corresponding to the target input matrix.
[0031] In a third aspect, the present application further provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the following steps are implemented:
[0032] Obtaining a target input matrix and a target call requirement; the target input matrix includes a target feature matrix and a target weight matrix;
[0033] Determine a target calling strategy according to the target calling requirement; the target calling strategy is a fixed weight calling mapping strategy or a unit combination mapping strategy;
[0034] The acceleration array matrix is called according to the target calling strategy and the target input matrix to obtain a calling result corresponding to the target input matrix.
[0035] In a fourth aspect, the present application further provides a computer-readable storage medium having a computer program stored thereon, wherein when the computer program is executed by a processor, the following steps are implemented:
[0036] Obtaining a target input matrix and a target call requirement; the target input matrix includes a target feature matrix and a target weight matrix;
[0037] Determine a target calling strategy according to the target calling requirement; the target calling strategy is a fixed weight calling mapping strategy or a unit combination mapping strategy;
[0038] The acceleration array matrix is called according to the target calling strategy and the target input matrix to obtain a calling result corresponding to the target input matrix.
[0039] In a fifth aspect, the present application further provides a computer program product, including a computer program, which implements the following steps when executed by a processor:
[0040] Obtaining a target input matrix and a target call requirement; the target input matrix includes a target feature matrix and a target weight matrix;
[0041] Determine a target calling strategy according to the target calling requirement; the target calling strategy is a fixed weight calling mapping strategy or a unit combination mapping strategy;
[0042] The acceleration array matrix is called according to the target calling strategy and the target input matrix to obtain a calling result corresponding to the target input matrix.
[0043] The above-mentioned coarse-grained reconfigurable acceleration array matrix calling method, device and storage medium obtain the target input matrix and the target calling requirement; the target input matrix includes the target feature matrix and the target weight matrix; the target calling strategy is determined according to the target calling requirement; the target calling strategy is a fixed weight calling mapping strategy or a unit combination mapping strategy; the acceleration array matrix is called according to the target calling strategy and the target input matrix to obtain the calling result corresponding to the target input matrix. The target input matrix is subjected to matrix multiplication data processing under different calling requirements, so as to obtain the calling result corresponding to the target input matrix, which expands the application scope of matrix multiplication data processing, and the acceleration array matrix is called according to the target calling requirement, so that the calling of the acceleration array matrix is more flexible and accurate. BRIEF DESCRIPTION OF THE DRAWINGS
[0044] In order to more clearly illustrate the technical solutions in the embodiments of the present application or related technologies, the drawings required for use in the embodiments of the present application or related technical descriptions will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.
[0045] FIG1 is an application environment diagram of a method for calling a coarse-grained reconfigurable acceleration array matrix in one embodiment;
[0046] Figure 2 A schematic diagram of a process of calling a coarse-grained reconfigurable acceleration array matrix in one embodiment;
[0047] Figure 3 is a schematic diagram of a target feature matrix in one embodiment;
[0048] Figure 4 is a schematic diagram of a target weight matrix in one embodiment;
[0049] Figure 5 is a schematic diagram of a coarse-grained reconfigurable acceleration array matrix in one embodiment;
[0050] Figure 6 It is a flowchart of a method for calling a coarse-grained reconfigurable acceleration array matrix in another embodiment;
[0051] Figure 7 It is a flowchart of a method for calling a coarse-grained reconfigurable acceleration array matrix in another embodiment;
[0052] Figure 8 A schematic diagram of calling a coarse-grained reconfigurable acceleration array matrix in one embodiment;
[0053] Fig. 9 It is a flowchart of a method for calling a coarse-grained reconfigurable acceleration array matrix in another embodiment;
[0054] Fig.10 is a schematic diagram of a target feature matrix after processing in one embodiment;
[0055] Fig.11 It is a flowchart of a method for calling a coarse-grained reconfigurable acceleration array matrix in another embodiment;
[0056] Fig.12 A schematic diagram of calling a coarse-grained reconfigurable acceleration array matrix in another embodiment;
[0057] Fig.13 It is a flowchart of a method for calling a coarse-grained reconfigurable acceleration array matrix in another embodiment;
[0058] Fig.14 A schematic diagram of calling each unit of a coarse-grained reconfigurable acceleration array matrix in one embodiment;
[0059] Fig.15 It is a structural block diagram of a calling device of a coarse-grained reconfigurable acceleration array matrix in one embodiment;
[0060] FIG. 16 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION
[0061] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0062] The calling method of the acceleration array matrix provided in the embodiment of the present application can be applied to the application environment shown in FIG. 1. The terminal 102 communicates with the server 104 through the network. The data storage system can store the data that the server 104 needs to process. The data storage system can be integrated on the server 104, or it can be placed on the cloud or other network servers. The server 104 obtains the target input matrix and the target call requirement from the terminal 102, and then calls the acceleration array matrix according to the target call requirement to determine the call result corresponding to the target input matrix. The terminal 102 can be, but is not limited to, various personal computers, laptops, smart phones, tablet computers, Internet of Things devices and portable wearable devices. The Internet of Things devices can be smart speakers, smart TVs, smart air conditioners, smart car devices, projection devices, etc. The portable wearable device can be a smart watch, a smart bracelet, a head-mounted device, etc. The head-mounted device can be a virtual reality (VR) device, an augmented reality (AR) device, smart glasses, etc. The server 104 can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides cloud computing services.
[0063] In one embodiment, Figure 2 As shown, a method for calling an acceleration array matrix is provided, and the method is applied to the server in FIG. 1 as an example for explanation, including:
[0064] S201, obtaining a target input matrix and a target call requirement; the target input matrix includes a target feature matrix and a target weight matrix.
[0065] The target call requirement may include a fixed weight call mapping requirement or a unit combination mapping requirement. Both the target feature matrix and the target weight matrix may be square matrices, such as Figure 3 As shown, the target feature matrix can be expressed as matrix A, which is a square matrix with 6 rows and columns; Figure 4 As shown, the target weight matrix can be expressed as a matrix B, which is a square matrix with 3 rows and 3 columns.
[0066] In an embodiment of the present application, the server can receive the target input matrix and target call requirement sent by the terminal; or, the server can determine the target input matrix and target call requirement based on the information input by the user; or, the server can receive the target input matrix sent by the terminal or determine the target input matrix based on the information input by the user, and use any one of the preset call requirements as the target call requirement, wherein the preset call requirement may include a fixed weight call mapping requirement and a unit combination mapping requirement.
[0067] S202, determining a target calling strategy according to a target calling requirement; the target calling strategy is a fixed weight calling mapping strategy or a unit combination mapping strategy.
[0068] In the embodiment of the present application, a correspondence between the call requirement and the call strategy is pre-established, and a preset strategy library is stored in the server, so that the target call strategy is determined from the preset strategy library according to the target call requirement and the correspondence.
[0069] Exemplarily, if the target call requirement is a fixed weight call mapping requirement or a unit combination mapping requirement, then when the target call requirement is a fixed weight call mapping requirement, the target call strategy is determined to be a fixed weight call mapping strategy; when the target call requirement is a unit combination mapping requirement, the target call strategy is determined to be a unit combination mapping strategy.
[0070] S203, calling the acceleration array matrix according to the target calling strategy and the target input matrix, and obtaining a calling result corresponding to the target input matrix.
[0071] In the embodiment of the present application, the acceleration array matrix is a matrix based on a coarse-grained reconfigurable processor. The coarse-grained reconfigurable processor is a processor with flexibility and programmability, and its hardware structure can be dynamically reconfigured according to application requirements. Figure 5 As shown, the acceleration array matrix includes a memory access unit and a processing unit. The shaded squares in the figure represent the processing units, and the squares without shades represent the memory access units. According to the target calling strategy, the memory access unit is called to read the target input matrix, and the read data is transmitted to the processing unit, so that the processing unit is called to perform multiplication processing on the read data to obtain the calling result corresponding to the target input matrix.
[0072] Optionally, one memory access unit can be selected from multiple memory access units as the target memory access unit, and two can be selected from multiple processing units as the first processing unit and the second processing unit. Further, the target memory access unit is called to read each element in the target input matrix in sequence, and each element is transferred to the first processing unit. The first processing unit performs multiplication on each element to obtain multiple product values, and then the second processing unit is called to perform addition on the multiple product values to obtain a calling result corresponding to the target input matrix.
[0073] In the above-mentioned coarse-grained reconfigurable acceleration array matrix calling method, the target input matrix and the target calling requirement are obtained; the target input matrix includes the target feature matrix and the target weight matrix; the target calling strategy is determined according to the target calling requirement; the target calling strategy is a fixed weight calling mapping strategy or a unit combination mapping strategy; the acceleration array matrix is called according to the target calling strategy and the target input matrix to obtain the calling result corresponding to the target input matrix. The target input matrix is subjected to matrix multiplication data processing under different calling requirements, thereby obtaining the calling result corresponding to the target input matrix, expanding the application scope of matrix multiplication data processing, and the acceleration array matrix is called according to the target calling requirement, making the calling of the acceleration array matrix more flexible and accurate.
[0074] In one embodiment, an implementation of the above S203 is provided, where the target call strategy is a fixed weight call mapping strategy, such as Figure 6 As shown, the above “calling the acceleration array matrix according to the target calling strategy and the target input matrix to obtain the calling result corresponding to the target input matrix” includes:
[0075] S301, establishing an association relationship between a target weight matrix and an acceleration array matrix, and storing the target weight matrix in the acceleration array matrix.
[0076] In an embodiment of the present application, each weight element in the target weight matrix is associated with each storage location in the acceleration array matrix, so that each weight element is stored in a corresponding storage location in the acceleration array matrix. Optionally, a one-to-one association relationship can be established between each weight element in the target weight matrix and each storage location in the acceleration array matrix, that is, each storage location can store one weight element; or, each storage location can correspond to multiple weight elements, that is, each storage location can store multiple weight elements.
[0077] S302, calling the acceleration array matrix to read the target feature matrix, performing multiplication and addition operations with the target weight matrix in the acceleration array matrix, and obtaining a calling result corresponding to the target input matrix.
[0078] In an embodiment of the present application, the acceleration array matrix is called to read each element in the target feature matrix, and each read element is multiplied with the weight element in turn to obtain multiple multiplication values. Further, the acceleration array matrix is called to add the multiple multiplication values to obtain the call result corresponding to the target input matrix. Optionally, if the number of elements in the target feature matrix is greater than the number of elements in the target weight matrix. The acceleration array matrix is called multiple times to read the target feature matrix, and multiplication and addition operations are performed with the target weight matrix in the acceleration array matrix.
[0079] In the above application embodiment, the acceleration array matrix is called to read the target weight matrix, and the target weight matrix is fixed in the acceleration array matrix. In the subsequent processing process, only the target feature matrix needs to be read, which improves the reading efficiency of the acceleration array matrix and thus improves the data processing efficiency of the acceleration array matrix.
[0080] In one embodiment, an implementation of the above S301 is provided, such as Figure 7 As shown, the above “establishing an association relationship between the target weight matrix and the acceleration array matrix, and storing the target weight matrix in the acceleration array matrix” includes:
[0081] S401, a one-to-one correspondence is made between the memory access units in the acceleration array matrix and the weight elements in the target weight matrix according to a preset order, so as to obtain a first correspondence between the memory access units and the weight elements.
[0082] In an embodiment of the present application, each element in the target weight matrix is sorted in the order of rows and columns, and a first correspondence between each memory access unit and each weight element is obtained according to the sorting result of each weight element and the order of the memory access unit.
[0083] Optional, such as Figure 4 As shown, the weight elements can be arranged in order of rows and columns as B11, B12, B13, B21, B22, B23, B31, B32, B33. Further, as Figure 8 As shown, the memory access units in the acceleration array matrix are matched one by one with each weight element in the target weight matrix in a preset order. Figure 8 In the figure, LD is the called memory access unit. From top to bottom and from left to right, they are memory access unit 1, memory access unit 2, memory access unit 3, memory access unit 4, memory access unit 5, memory access unit 6, memory access unit 7, memory access unit 8, and memory access unit 9. B11 corresponds to memory access unit 1, B12 corresponds to memory access unit 2, B13 corresponds to memory access unit 3, B21 corresponds to memory access unit 4, B22 corresponds to memory access unit 5, B23 corresponds to memory access unit 6, B31 corresponds to memory access unit 7, B32 corresponds to memory access unit 8, and B33 corresponds to memory access unit 9.
[0084] S402, determining a second corresponding relationship between each processing unit and each weight element according to the positional relationship between each memory access unit and each processing unit in the acceleration array matrix, and the first corresponding relationship.
[0085] In the embodiment of the present application, for each memory access unit, the processing unit closest to the memory access unit is determined as the processing unit corresponding to the memory access unit, and further, according to the first corresponding relationship of the memory access unit, the second corresponding relationship between each processing unit and each weight element is determined. Exemplarily, if the first corresponding relationship includes that B11 corresponds to memory access unit 1, and memory access unit 1 corresponds to processing unit 1, then the second corresponding relationship of B11 is that B11 corresponds to processing unit 1.
[0086] S403: Store each weight element in a corresponding processing unit according to the second corresponding relationship.
[0087] In an embodiment of the present application, each memory access unit transmits the weight element to the corresponding processing unit, and the processing unit performs a storage operation on each weight element, that is, fixes each weight element in the acceleration array matrix.
[0088] For example, Figure 8 As shown, B11 is stored in processing unit 1, B12 is stored in processing unit 2, B13 is stored in processing unit 3, B21 is stored in processing unit 4, B22 is stored in processing unit 5, B23 is stored in processing unit 6, B31 is stored in processing unit 7, B32 is stored in processing unit 8, and B33 is stored in processing unit 9.
[0089] In the above-mentioned application embodiment, a first correspondence between the memory access unit and the weight element, and a second correspondence between the processing unit and the weight element are established in sequence, so that the weight elements are fixedly stored in the acceleration array matrix, reducing the number of times the weight matrix is read, and improving the calling efficiency of the acceleration array matrix.
[0090] In one embodiment, an implementation of the above S302 is provided, such as Fig. 9 As shown, the above “calling the acceleration array matrix to read the target feature matrix, performing multiplication and addition operations with the target weight matrix in the acceleration array matrix, and obtaining the calling result corresponding to the target input matrix” includes:
[0091] S501, for each processing cycle, calling the memory access unit in the acceleration array matrix to read the data of the target number of rows in the target feature matrix.
[0092] In the embodiment of the present application, the target feature matrix can be processed by img2col, and the processed target feature matrix is as follows: Fig.10As shown, the number of matrix elements included in each row of the processed target feature matrix is the same as the total number of weight elements in the target weight matrix. Further, the data of the target number of rows of access units in the acceleration array matrix is called.
[0093] For example, Figure 8 As shown, in the first processing cycle, the memory access unit reads the data 0, 0, 0, 0, A11, A12, 0, A21, A22 of the first row of the processed target feature matrix; in the second processing cycle, the memory access unit reads the data 0, 0, 0, A11, A12, A13, A21, A22, A23 of the second row of the processed target feature matrix.
[0094] S502, calling the processing unit corresponding to each memory access unit, performing multiplication and addition operations on the data of each target row number and the weight element, and obtaining the calling result corresponding to the target input matrix.
[0095] In the embodiments of the present application, Figure 8 As shown, in each processing cycle, the memory access unit transfers the read data to the corresponding processing unit, which performs multiplication and addition processing and then transfers the processing result to the next processing unit, that is, each row of the target feature matrix is multiplied and added with the weight elements fixed in the processing unit at a specified timing, and the output matrix result is generated after the first row of the target feature matrix and the first column of the target weight data are multiplied and added.
[0096] In the above application embodiment, the memory access unit and the processing unit in the coarse-grained reconfigurable acceleration array matrix are called to perform convolution processing on the target feature matrix and the target weight matrix, thereby improving the application scope of the matrix multiplication processing.
[0097] In one embodiment, an implementation of the above S203 is provided, where the target calling strategy is a unit combination mapping strategy, such as Fig.11 As shown, the above “calling the acceleration array matrix according to the target calling strategy and the target input matrix to obtain the calling result corresponding to the target input matrix” includes:
[0098] S601, dividing the acceleration array matrix into a plurality of unit groups; each unit group includes a memory access unit, a processing unit and a routing unit.
[0099] In the embodiments of the present application, Fig.12 As shown, each unit group includes 2 memory access units, 2 processing units and a routing unit, wherein one memory access unit is used to read the target feature matrix, the other memory access unit is used to read the target weight matrix, ADD is a processing unit for addition processing, MULL is another processing unit for multiplication processing, and the routing unit is used to establish a routing relationship between each unit group.
[0100] For example, in Fig.12 In the acceleration array matrix shown, a maximum of 16 unit groups can be divided, that is, the processing of a maximum of 6 output elements can be supported simultaneously.
[0101] S602: For each cell group, obtain the processing data of the previous cell group.
[0102] In the embodiment of the present application, each unit group is connected in sequence according to a preset order, and each unit group obtains the processing data of the previous unit group. The first unit group does not need to obtain the processing data of the previous unit group.
[0103] S603, calling the memory access unit in the cell group to read the data in the target feature matrix and the weight elements of the target weight matrix respectively, and calling the processing unit in the cell group to process the data in the target feature matrix, the weight elements of the target weight matrix and the processed data of the previous cell group to obtain processed data.
[0104] In an embodiment of the present application, a memory access unit in a cell group is called to read the data in a target feature matrix and the weight elements of a target weight matrix. The memory access unit transmits the read data to a processing unit. The processing unit obtains initial processing data based on the data in the target feature matrix and the weight elements of the target weight matrix, and then obtains processing data based on the initial processing data and the processing data of a previous cell group.
[0105] S604, calling the routing unit in the unit group to route the processed data to the next unit group for accumulation, and obtaining the calling result corresponding to the target input matrix.
[0106] In an embodiment of the present application, the processing unit transmits the processed data to the routing unit, which transmits the processed data to the next unit group for accumulation until all data read in this cycle is processed to obtain the call result corresponding to the target input matrix.
[0107] In the above-mentioned application embodiment, the coarse-grained acceleration array matrix is divided into multiple unit groups, and multiple units work together to perform convolution processing on the target feature matrix and the target weight matrix, which improves the processing efficiency, and makes the step-by-step calling more orderly, thereby improving the accuracy of processing the target feature matrix and the target weight matrix.
[0108] In one embodiment, an implementation of the above S603 is provided, where the processing units in the unit group include an addition unit and a multiplication unit, such as Fig.13 As shown, the above-mentioned “calling the processing unit in the unit group to process the data in the target feature matrix, the weight elements of the target weight matrix and the processed data of the previous unit group to obtain processed data” includes:
[0109] S701, calling the multiplication unit to perform multiplication processing on the data in the target feature matrix and the weight elements of the target weight matrix to obtain initial processing data.
[0110] In the embodiments of the present application, Fig.14 As shown, the multiplication unit obtains the data in the target feature matrix and the weight element of the target weight matrix read by the two memory access units, and further multiplies the data and the weight element to obtain the initial processing data. For example, when the data in the target feature matrix is 5 and the weight element is 2, the initial processing data is 10.
[0111] S702, calling the adding unit to perform addition processing on the initial processing data and the processing data of the previous unit group to obtain processing data.
[0112] In the embodiments of the present application, Fig.14 As shown, the multiplication unit transmits the initial processing data to the addition unit, and the addition unit performs addition processing on the initial processing data and the processing data of the previous unit group to obtain the processing data. For example, when the initial processing data is 10 and the processing data of the previous unit group is 20, the processing data is 30.
[0113] In the above application embodiment, the processing unit is configured with different functions, divided into an addition unit and a multiplication unit, so that different processing units are called to perform different processing operations, thereby improving the accuracy and efficiency of data processing.
[0114] In one embodiment, a complete method for calling a coarse-grained reconfigurable acceleration array matrix is provided, including:
[0115] S1, obtain the target input matrix and target call requirements; the target input matrix includes the target feature matrix and the target weight matrix.
[0116] S2, determining the target calling strategy according to the target calling requirement; the target calling strategy is a fixed weight calling mapping strategy or a unit combination mapping strategy.
[0117] S3, calling the acceleration array matrix according to the target calling strategy and the target input matrix to obtain the calling result corresponding to the target input matrix, specifically S4-S8, or S9-S14.
[0118] S4, making one-to-one correspondence between the memory access units in the acceleration array matrix and the weight elements in the target weight matrix according to a preset order, so as to obtain a first correspondence between the memory access units and the weight elements.
[0119] S5, determining a second corresponding relationship between each processing unit and each weight element according to the positional relationship between each memory access unit and each processing unit in the acceleration array matrix, and the first corresponding relationship.
[0120] S6. Store each weight element in a corresponding processing unit according to the second corresponding relationship.
[0121] S7, for each processing cycle, calling the memory access unit in the acceleration array matrix to read the data of the target number of rows in the target feature matrix.
[0122] S8, calling the processing unit corresponding to each memory access unit, performing multiplication and addition operations on the data of each target row number and the weight element, and obtaining the calling result corresponding to the target input matrix.
[0123] S9, dividing the acceleration array matrix into a plurality of unit groups; each unit group includes a memory access unit, a processing unit and a routing unit.
[0124] S10, for each cell group, obtaining the processing data of the previous cell group of the cell group.
[0125] S11, calling the memory access units in the unit group to read the data in the target feature matrix and the weight elements of the target weight matrix respectively.
[0126] S12, calling the multiplication unit to perform multiplication processing on the data in the target feature matrix and the weight elements of the target weight matrix to obtain initial processing data.
[0127] S13, calling the adding unit to perform addition processing on the initial processing data and the processing data of the previous unit group to obtain processing data.
[0128] S14, the routing unit in the calling unit group routes the processed data to the next unit group for accumulation, and obtains the calling result corresponding to the target input matrix.
[0129] In the above-mentioned coarse-grained reconfigurable acceleration array matrix calling method, the target input matrix and the target calling requirement are obtained; the target input matrix includes the target feature matrix and the target weight matrix; the target calling strategy is determined according to the target calling requirement; the target calling strategy is a fixed weight calling mapping strategy or a unit combination mapping strategy; the acceleration array matrix is called according to the target calling strategy and the target input matrix to obtain the calling result corresponding to the target input matrix. The target input matrix is subjected to matrix multiplication data processing under different calling requirements, thereby obtaining the calling result corresponding to the target input matrix, expanding the application scope of matrix multiplication data processing, and the acceleration array matrix is called according to the target calling requirement, making the calling of the acceleration array matrix more flexible and accurate.
[0130] It should be understood that, although the various steps in the flowcharts involved in the above-mentioned embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps does not have a strict order restriction, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above-mentioned embodiments can include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.
[0131] Based on the same inventive concept, the embodiment of the present application also provides a coarse-grained reconfigurable acceleration array matrix calling device for implementing the above-mentioned coarse-grained reconfigurable acceleration array matrix calling method. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme recorded in the above-mentioned method, so the specific limitations in the embodiments of one or more coarse-grained reconfigurable acceleration array matrix calling devices provided below can refer to the limitations of the coarse-grained reconfigurable acceleration array matrix calling method in the above text, and will not be repeated here.
[0132] In one embodiment, Fig.15 As shown, a device for calling a coarse-grained reconfigurable acceleration array matrix is provided, comprising: an acquisition module 10, a determination module 11 and a calling module 12, wherein:
[0133] The acquisition module 10 is used to acquire a target input matrix and a target call requirement; the target input matrix includes a target feature matrix and a target weight matrix.
[0134] The determination module 11 is used to determine the target calling strategy according to the target calling requirement; the target calling strategy is a fixed weight calling mapping strategy or a unit combination mapping strategy.
[0135] The calling module 12 is used to call the acceleration array matrix according to the target calling strategy and the target input matrix to obtain the calling result corresponding to the target input matrix.
[0136] In one embodiment, the calling module 12 includes: an establishing unit and a first calling unit, wherein:
[0137] An establishing unit is used to establish an association relationship between a target weight matrix and an acceleration array matrix, and store the target weight matrix in the acceleration array matrix;
[0138] The first calling unit is used to call the acceleration array matrix to read the target feature matrix, perform multiplication and addition operations on the target weight matrix in the acceleration array matrix, and obtain a calling result corresponding to the target input matrix.
[0139] In one embodiment, the above-mentioned establishment unit is specifically used to make a one-to-one correspondence between the memory access units in the acceleration array matrix and the weight elements in the target weight matrix in a preset order to obtain a first correspondence between each memory access unit and each weight element; according to the positional relationship between each memory access unit and each processing unit in the acceleration array matrix, and the first correspondence, determine the second correspondence between each processing unit and each weight element; according to the second correspondence, store each weight element in the corresponding processing unit.
[0140] In one embodiment, the above-mentioned first calling unit is specifically used to call the memory access unit in the acceleration array matrix to read the data of the target number of rows in the target feature matrix for each processing cycle; call the processing unit corresponding to each memory access unit to perform multiplication and addition operations on the data of each target number of rows and the weight elements to obtain the calling result corresponding to the target input matrix.
[0141] In one embodiment, the calling module 12 includes: a division unit, an acquisition unit, a second calling unit and a third calling unit, wherein:
[0142] The division unit is used to divide the acceleration array matrix into a plurality of unit groups; each unit group includes a memory access unit, a processing unit and a routing unit.
[0143] The acquisition unit is used to acquire, for each cell group, the processing data of the previous cell group.
[0144] The second calling unit is used to call the memory access unit in the cell group to read the data in the target feature matrix and the weight elements of the target weight matrix respectively, and call the processing unit in the cell group to process the data in the target feature matrix, the weight elements of the target weight matrix and the processed data of the previous cell group to obtain processed data.
[0145] The third calling unit is used to call the routing unit in the unit group to route the processed data to the next unit group for accumulation, so as to obtain the calling result corresponding to the target input matrix.
[0146] In one embodiment, the second calling unit is used to call the multiplication unit to perform multiplication processing on the data in the target feature matrix and the weight elements of the target weight matrix to obtain initial processed data; and call the addition unit to perform addition processing on the initial processed data and the processed data of the previous unit group to obtain processed data.
[0147] Each module in the above-mentioned coarse-grained reconfigurable acceleration array matrix calling device can be implemented in whole or in part by software, hardware, or a combination thereof. Each of the above-mentioned modules can be embedded in or independent of a processor in a computer device in the form of hardware, or can be stored in a memory in a computer device in the form of software, so that the processor can call and execute the operations corresponding to each of the above modules.
[0148] In an exemplary embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be shown in FIG16. The computer device includes a processor, a memory, an input / output interface (Input / Output, referred to as I / O) and a communication interface. The processor, the memory and the input / output interface are connected through a system bus, and the communication interface is connected to the system bus through the input / output interface. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store the call data of the coarse-grained reconfigurable acceleration array matrix. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a method for calling a coarse-grained reconfigurable acceleration array matrix is implemented.
[0149] Those skilled in the art will understand that the structure shown in FIG. 16 is merely a block diagram of a partial structure related to the scheme of the present application, and does not constitute a limitation on the computer device to which the scheme of the present application is applied. The specific computer device may include more or fewer components than shown in the figure, or combine certain components, or have a different arrangement of components.
[0150] In one embodiment, a computer device is provided, including a memory and a processor, wherein a computer program is stored in the memory, and when the processor executes the computer program, the following steps are implemented:
[0151] Obtain the target input matrix and target call requirements; the target input matrix includes the target feature matrix and the target weight matrix;
[0152] Determine the target calling strategy according to the target calling requirement; the target calling strategy is a fixed weight calling mapping strategy or a unit combination mapping strategy;
[0153] The acceleration array matrix is called according to the target calling strategy and the target input matrix to obtain the calling result corresponding to the target input matrix.
[0154] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:
[0155] Establish an association relationship between the target weight matrix and the acceleration array matrix, and store the target weight matrix in the acceleration array matrix;
[0156] Call the acceleration array matrix to read the target feature matrix, perform multiplication and addition operations with the target weight matrix in the acceleration array matrix, and obtain the call result corresponding to the target input matrix.
[0157] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:
[0158] The memory access units in the acceleration array matrix are matched one by one with each weight element in the target weight matrix in a preset order to obtain a first corresponding relationship between each memory access unit and each weight element;
[0159] Determine a second corresponding relationship between each processing unit and each weight element according to a positional relationship between each memory access unit and each processing unit in the acceleration array matrix, and the first corresponding relationship;
[0160] According to the second corresponding relationship, each weight element is stored in a corresponding processing unit.
[0161] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:
[0162] For each processing cycle, the memory access unit in the acceleration array matrix is called to read the data of the target number of rows in the target feature matrix;
[0163] The processing unit corresponding to each memory access unit is called to perform multiplication and addition operations on the data of each target row number and the weight element to obtain the calling result corresponding to the target input matrix.
[0164] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:
[0165] Dividing the acceleration array matrix into a plurality of unit groups; each unit group includes a memory access unit, a processing unit and a routing unit;
[0166] For each unit group, obtain the processing data of the previous unit group of the unit group;
[0167] The memory access unit in the cell group is called to read the data in the target feature matrix and the weight elements of the target weight matrix respectively, and the processing unit in the cell group is called to process the data in the target feature matrix, the weight elements of the target weight matrix and the processed data of the previous cell group to obtain the processed data;
[0168] The routing unit in the calling unit group routes the processed data to the next unit group for accumulation to obtain the calling result corresponding to the target input matrix.
[0169] In one embodiment, when the processor executes the computer program, the following steps are also implemented:
[0170] Call the multiplication unit to perform multiplication processing on the data in the target feature matrix and the weight elements of the target weight matrix to obtain initial processing data;
[0171] The adding unit is called to perform addition processing on the initial processing data and the processing data of the previous unit group to obtain the processing data.
[0172] In one embodiment, a computer readable storage medium is provided, on which a computer program is stored, and when the computer program is executed by a processor, the following steps are implemented:
[0173] Obtain the target input matrix and target call requirements; the target input matrix includes the target feature matrix and the target weight matrix;
[0174] Determine the target calling strategy according to the target calling requirement; the target calling strategy is a fixed weight calling mapping strategy or a unit combination mapping strategy;
[0175] The acceleration array matrix is called according to the target calling strategy and the target input matrix to obtain the calling result corresponding to the target input matrix.
[0176] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0177] Establish an association relationship between the target weight matrix and the acceleration array matrix, and store the target weight matrix in the acceleration array matrix;
[0178] Call the acceleration array matrix to read the target feature matrix, perform multiplication and addition operations with the target weight matrix in the acceleration array matrix, and obtain the call result corresponding to the target input matrix.
[0179] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0180] The memory access units in the acceleration array matrix are matched one by one with each weight element in the target weight matrix in a preset order to obtain a first correspondence between each memory access unit and each weight element;
[0181] Determine a second corresponding relationship between each processing unit and each weight element according to a positional relationship between each memory access unit and each processing unit in the acceleration array matrix, and the first corresponding relationship;
[0182] According to the second corresponding relationship, each weight element is stored in a corresponding processing unit.
[0183] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0184] For each processing cycle, the memory access unit in the acceleration array matrix is called to read the data of the target number of rows in the target feature matrix;
[0185] The processing unit corresponding to each memory access unit is called to perform multiplication and addition operations on the data of each target row number and the weight element to obtain the calling result corresponding to the target input matrix.
[0186] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0187] Dividing the acceleration array matrix into a plurality of unit groups; each unit group includes a memory access unit, a processing unit and a routing unit;
[0188] For each unit group, obtain the processing data of the previous unit group of the unit group;
[0189] The memory access unit in the cell group is called to read the data in the target feature matrix and the weight elements of the target weight matrix respectively, and the processing unit in the cell group is called to process the data in the target feature matrix, the weight elements of the target weight matrix and the processed data of the previous cell group to obtain the processed data;
[0190] The routing unit in the calling unit group routes the processed data to the next unit group for accumulation to obtain the calling result corresponding to the target input matrix.
[0191] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0192] Call the multiplication unit to perform multiplication processing on the data in the target feature matrix and the weight elements of the target weight matrix to obtain initial processing data;
[0193] The adding unit is called to perform addition processing on the initial processing data and the processing data of the previous unit group to obtain the processing data.
[0194] In one embodiment, a computer program product is provided, comprising a computer program, which, when executed by a processor, implements the following steps:
[0195] Obtain the target input matrix and target call requirements; the target input matrix includes the target feature matrix and the target weight matrix;
[0196] Determine the target calling strategy according to the target calling requirement; the target calling strategy is a fixed weight calling mapping strategy or a unit combination mapping strategy;
[0197] The acceleration array matrix is called according to the target calling strategy and the target input matrix to obtain the calling result corresponding to the target input matrix.
[0198] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0199] Establish an association relationship between the target weight matrix and the acceleration array matrix, and store the target weight matrix in the acceleration array matrix;
[0200] Call the acceleration array matrix to read the target feature matrix, perform multiplication and addition operations with the target weight matrix in the acceleration array matrix, and obtain the call result corresponding to the target input matrix.
[0201] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0202] The memory access units in the acceleration array matrix are matched one by one with each weight element in the target weight matrix in a preset order to obtain a first corresponding relationship between each memory access unit and each weight element;
[0203] Determine a second corresponding relationship between each processing unit and each weight element according to a positional relationship between each memory access unit and each processing unit in the acceleration array matrix, and the first corresponding relationship;
[0204] According to the second corresponding relationship, each weight element is stored in a corresponding processing unit.
[0205] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0206] For each processing cycle, the memory access unit in the acceleration array matrix is called to read the data of the target number of rows in the target feature matrix;
[0207] The processing unit corresponding to each memory access unit is called to perform multiplication and addition operations on the data of each target row number and the weight element to obtain the calling result corresponding to the target input matrix.
[0208] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0209] Dividing the acceleration array matrix into a plurality of unit groups; each unit group includes a memory access unit, a processing unit and a routing unit;
[0210] For each unit group, obtain the processing data of the previous unit group of the unit group;
[0211] The memory access unit in the cell group is called to read the data in the target feature matrix and the weight elements of the target weight matrix respectively, and the processing unit in the cell group is called to process the data in the target feature matrix, the weight elements of the target weight matrix and the processed data of the previous cell group to obtain the processed data;
[0212] The routing unit in the calling unit group routes the processed data to the next unit group for accumulation to obtain the calling result corresponding to the target input matrix.
[0213] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0214] Call the multiplication unit to perform multiplication processing on the data in the target feature matrix and the weight elements of the target weight matrix to obtain initial processing data;
[0215] The adding unit is called to perform addition processing on the initial processing data and the processing data of the previous unit group to obtain the processing data.
[0216] A person of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment method can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in the present application can include at least one of non-volatile memory and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, an artificial intelligence (AI) processor, etc., but are not limited to this.
[0217] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this application.
[0218] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.
Claims
1. A method for calling a coarse-grained reconfigurable acceleration array matrix, characterized in that: The method comprises: Obtaining a target input matrix and a target call requirement; the target input matrix includes a target feature matrix and a target weight matrix; Determine a target calling strategy according to the target calling requirement; the target calling strategy is a fixed weight calling mapping strategy or a unit combination mapping strategy; The acceleration array matrix is called according to the target calling strategy and the target input matrix to obtain a calling result corresponding to the target input matrix.
2. The method according to claim 1, characterized in that: The target calling strategy is the fixed weight calling mapping strategy, and calling the acceleration array matrix according to the target calling strategy and the target input matrix to obtain a calling result corresponding to the target input matrix includes: Establishing an association relationship between the target weight matrix and the acceleration array matrix, and storing the target weight matrix in the acceleration array matrix; The acceleration array matrix is called to read the target feature matrix, and multiplication and addition operations are performed on the target weight matrix in the acceleration array matrix to obtain a call result corresponding to the target input matrix.
3. The method according to claim 2, characterized in that The step of establishing an association relationship between the target weight matrix and the acceleration array matrix, and storing the target weight matrix in the acceleration array matrix, comprises: The memory access units in the acceleration array matrix are matched one by one with the weight elements in the target weight matrix in a preset order to obtain a first corresponding relationship between the memory access units and the weight elements; Determine a second corresponding relationship between each of the processing units and each of the weight elements according to a positional relationship between each of the memory access units and each of the processing units in the acceleration array matrix, and the first corresponding relationship; According to the second corresponding relationship, each of the weight elements is stored in a corresponding processing unit.
4. The method according to claim 2 or 3, characterized in that: The calling of the acceleration array matrix to read the target feature matrix and perform multiplication and addition operations with the target weight matrix in the acceleration array matrix to obtain a calling result corresponding to the target input matrix includes: For each processing cycle, calling the memory access unit in the acceleration array matrix to read the data of the target number of rows in the target feature matrix; The processing unit corresponding to each of the memory access units is called to perform multiplication and addition operations on the data of each of the target rows and the weight elements to obtain a calling result corresponding to the target input matrix.
5. The method according to claim 1, characterized in that The target calling strategy is the unit combination mapping strategy, and calling the acceleration array matrix according to the target calling strategy and the target input matrix to obtain a calling result corresponding to the target input matrix includes: Dividing the acceleration array matrix into a plurality of unit groups; each of the unit groups comprises a memory access unit, a processing unit and a routing unit; For each unit group, obtaining processing data of a previous unit group of the unit group; Calling the memory access unit in the cell group to read the data in the target feature matrix and the weight elements of the target weight matrix respectively, and calling the processing unit in the cell group to process the data in the target feature matrix, the weight elements of the target weight matrix and the processed data of the previous cell group to obtain processed data; The routing unit in the unit group is called to route the processed data to the next unit group for accumulation, so as to obtain a calling result corresponding to the target input matrix.
6. The method according to claim 5, characterized in that The processing unit in the unit group includes an addition unit and a multiplication unit, and the calling of the processing unit in the unit group processes the data in the target feature matrix, the weight elements of the target weight matrix and the processed data of the previous unit group to obtain the processed data, including: Calling the multiplication unit to perform multiplication processing on the data in the target feature matrix and the weight elements of the target weight matrix to obtain initial processing data; The adding unit is called to perform addition processing on the initial processing data and the processing data of the previous unit group to obtain processing data.
7. A device for calling a coarse-grained reconfigurable acceleration array matrix, characterized in that: The device comprises: An acquisition module is used to acquire a target input matrix and a target call requirement; the target input matrix includes a target feature matrix and a target weight matrix; A determination module, used to determine a target call strategy according to the target call requirement; the target call strategy is a fixed weight call mapping strategy or a unit combination mapping strategy; A calling module is used to call the acceleration array matrix according to the target calling strategy and the target input matrix to obtain a calling result corresponding to the target input matrix.
8. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 6 are implemented.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.
10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.