Method, computing device, computing system and storage medium for convolution operation

By transforming the weight matrix and input matrix in the convolution operation, the number of channels matches the minimum granularity of the hardware accelerator, the problem of waste of computing power caused by channel mismatch is solved and the efficiency of convolution operation is improved.

CN114036457BActive Publication Date: 2025-03-21SHANGHAI BIREN TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111345826.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-11-15
Publication Date
2025-03-21
Estimated Expiration
2041-11-15

AI Technical Summary

Technical Problem

In convolutional operations, the minimum channel granularity of a particular hardware accelerator does not match the number of channels in the input matrix or weight matrix, resulting in wasted computing power and inefficient computing efficiency.

Method used

By dividing the weight matrix and the input matrix into blocks of the same size and performing the transformation operation iteratively, adjusting the number of columns or row blocks of the weight matrix to align to the smallest even number N, and then stacking them on the channel dimension to generate a transformed matrix suitable for the convolution operation of the matrix computing device.

Benefits of technology

By increasing the number of channels of the matrix, it can better match the minimum channel granularity of the hardware accelerator, reduce computing power waste, improve the efficiency of convolutional operations, and even achieve several times acceleration effects in some cases.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114036457B_ABST
    Figure CN114036457B_ABST
Patent Text Reader

Abstract

The present disclosure provides a method, device and storage medium for convolution operation, and relates to the field of computing. The specific scheme is: obtain a weight matrix and an input matrix, and the weight matrix and the input matrix are divided into blocks of the same size; iterate once or multiple times to perform the following transformation operation to perform a convolution operation via a matrix computing device: align the number of blocks included in the weight matrix on the column or row to the minimum even number N greater than or equal to the number to generate an aligned weight matrix; stack the first half and the second half of the aligned weight matrix divided in half by column or row on the channel dimension of the input matrix to generate a transformed weight matrix; and stack the data after removing the last N / 2 columns or rows of blocks in the input matrix and the data after removing the first N / 2 columns or rows of blocks in the input matrix on the channel dimension to generate a transformed input matrix. Thus, the efficiency of the matrix computing device in performing convolution operations can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of computing, and more particularly to a method, a computing device, a computing system, and a computer-readable storage medium for convolution operations. Background Art

[0002] When using a specific hardware accelerator for convolution operations, there is a minimum granularity requirement for the number of input channels of the weight matrix or the number of channels of the input matrix. For example, if the number of input channels of the weight matrix and the channel data of the input matrix are 8, but the minimum channel granularity of the convolution operation of the specific hardware accelerator is 16, then the specific hardware accelerator will still perform the operation according to channel 16 when actually performing the convolution operation, which is equivalent to wasting half of the computing power and the computing efficiency is not high. Summary of the invention

[0003] The present disclosure provides a method, a computing device, a computing system, and a computer-readable storage medium for convolution operations.

[0004] According to a first aspect of the present disclosure, a method for convolution operation is provided, comprising: obtaining a weight matrix and an input matrix for convolution operation, the weight matrix and the input matrix being divided into blocks of the same size; iteratively performing the following transformation operations once or multiple times to generate a transformed weight matrix and a transformed input matrix for performing the convolution operation via a matrix computing device: aligning the number of blocks included in the weight matrix on columns or rows to a minimum even number N greater than or equal to the number to generate an aligned weight matrix; stacking the first half and the second half of the aligned weight matrix divided in half on columns or rows on the channel dimension of the input matrix to generate a transformed weight matrix; and stacking the data after removing the last N / 2 columns or rows of blocks in the input matrix and the data after removing the first N / 2 columns or rows of blocks in the input matrix on the channel dimension to generate a transformed input matrix.

[0005] According to a second aspect of the present disclosure, a computing device is provided, comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the method according to the first aspect.

[0006] According to a third aspect of the present disclosure, a computing system is provided, comprising: a computing device according to the second aspect of the present disclosure; and a matrix computing device, which is communicatively connected to the computing device and configured to perform a convolution operation based on a transformed weight matrix and a transformed input matrix to generate a convolution operation result.

[0007] According to a fourth aspect of the present disclosure, a non-transitory computer-readable storage medium storing computer instructions is provided, wherein the computer instructions are used to cause the computer to execute the method according to the first aspect.

[0008] According to the solution disclosed in the present invention, the efficiency of convolution operations performed by a matrix computing device can be improved.

[0009] It should be understood that the content described in this section is not intended to identify the key or important features of the embodiments of the present disclosure, nor is it intended to limit the scope of the present disclosure. Other features of the present disclosure will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS

[0010] The accompanying drawings are used to better understand the present solution and do not constitute a limitation of the present disclosure.

[0011] Figure 1 is a schematic diagram of a computing system 100 according to an embodiment of the present disclosure.

[0012] Figure 2 is a schematic diagram of a method 200 for convolution operation according to an embodiment of the present disclosure.

[0013] Figure 3 3 is a schematic diagram of a transformation process 300 of a weight matrix and an input matrix according to an embodiment of the present disclosure.

[0014] Figure 4 4 is a schematic diagram of a transformation process 400 of a weight matrix and an input matrix according to an embodiment of the present disclosure.

[0015] Figure 5 is a schematic block diagram of a method 500 for determining the number of iterations according to an embodiment of the present disclosure. DETAILED DESCRIPTION

[0016] The following is a description of exemplary embodiments of the present disclosure in conjunction with the accompanying drawings, including various details of the embodiments of the present disclosure to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present disclosure. Similarly, for the sake of clarity and conciseness, descriptions of well-known functions and structures are omitted in the following description.

[0017] As described above, when the minimum granularity of a specific hardware accelerator for convolution operations does not match the number of channels of the input matrix or the number of input channels of the weight matrix, computing power will be wasted and computing efficiency will be reduced.

[0018] In order to at least partially solve one or more of the above problems and other potential problems, an example embodiment of the present disclosure proposes a scheme for convolution operation. In this scheme, a computing device obtains a weight matrix and an input matrix for convolution operation, and the weight matrix and the input matrix are divided into blocks of the same size. Subsequently, the computing device iterates once or multiple times to perform the following transformation operations to generate a transformed weight matrix and a transformed input matrix for performing a convolution operation via a matrix computing device: aligning the number of blocks included in the weight matrix on columns or rows to a minimum even number N greater than or equal to the number to generate an aligned weight matrix; stacking the first half and the second half of the aligned weight matrix divided in half by columns or rows on the channel dimension of the input matrix to generate a transformed weight matrix; and stacking the data after removing the last N / 2 columns or rows of blocks in the input matrix and the data after removing the first N / 2 columns or rows of blocks in the input matrix on the channel dimension to generate a transformed input matrix. According to an embodiment of the present disclosure, by transforming the input matrix and the weight matrix so that the number of their channels is increased, it is possible to better match the minimum channel granularity of the matrix computing device, reduce the computing power waste of the matrix computing unit, and thus improve the efficiency of the convolution operation of the matrix computing device.

[0019] Hereinafter, specific embodiments of the present disclosure will be described in more detail with reference to the accompanying drawings.

[0020] Figure 1 FIG. 1 is a schematic diagram showing an example of a computing system 100 according to an embodiment of the present disclosure. Figure 1 As shown, the computing system 100 includes a computing device 110 and a matrix computing apparatus 120. The computing device 110 and the matrix computing apparatus 120 may be communicatively connected via a communication channel 130.

[0021] Regarding the computing system 100 , it includes, for example, but is not limited to, smartphones, personal computers, tablet computers, laptop computers, desktop computers, personal digital assistants, wearable devices, servers, in-vehicle electronic devices, edge computing devices, etc.

[0022] Regarding the computing device 110, it may include: at least one processor 111; and a memory 112 that is communicatively connected to the at least one processor 111. The memory 112 may store instructions that can be executed by the at least one processor 111. The instructions are executed by the at least one processor 111 to enable the at least one processor 111 to perform related functions. The processor 111 includes, but is not limited to: a scalar processor, a SIMD (Single Instruction Multiple Data) processor, a SIMT (Single Instruction Multiple Threads) processor, and a vector processor.

[0023] The matrix computing device 120 may include, but is not limited to, a graphics processing unit (GPU), a field programmable gate array (FPGA), an application specific integrated circuit (ASIC), and the like.

[0024] The communication channel 130 includes, for example, but is not limited to, a bus, an on-chip network, etc.

[0025] The computing device 110 can be used to obtain a weight matrix and an input matrix for a convolution operation, where the weight matrix and the input matrix are divided into blocks of the same size; iterate once or multiple times to perform the following transformation operations to generate a transformed weight matrix and a transformed input matrix for performing a convolution operation via the matrix computing device 120: align the number of blocks included in the weight matrix on columns or rows to a minimum even number N greater than or equal to the number to generate an aligned weight matrix; stack the first half and the second half of the aligned weight matrix divided in half on columns or rows on the channel dimension of the input matrix to generate a transformed weight matrix; and stack the data after removing the last N / 2 columns or rows of blocks in the input matrix and the data after removing the first N / 2 columns or rows of blocks in the input matrix on the channel dimension to generate a transformed input matrix.

[0026] In addition, the matrix calculation device 120 can be used to perform a convolution operation based on the transformed weight matrix and the transformed input matrix to generate a convolution operation result.

[0027] Therefore, by transforming the input matrix and the weight matrix so that the number of their channels increases, it is possible to better match the minimum channel granularity of the matrix computing device, reduce the computing power waste of the matrix computing unit, and thus improve the efficiency of the convolution operation of the matrix computing device.

[0028] Figure 2 2 shows a flow chart of a method 200 for convolution operation according to an embodiment of the present disclosure. For example, the method 200 may be performed as follows: Figure 1The method 200 is executed by the computing device 110 shown. It should be understood that the method 200 may also include additional blocks not shown and / or may omit the blocks shown, and the scope of the present disclosure is not limited in this respect.

[0029] At block 202 , the computing device 110 obtains a weight matrix and an input matrix for a convolution operation, the weight matrix and the input matrix being divided into blocks of the same size.

[0030] It should be understood that the weight matrix and the input matrix can be two-dimensional matrices or multi-dimensional matrices. A block can include one or more matrix elements.

[0031] The scheme disclosed in the present invention can be applied to any field that requires convolution operation, such as computer vision, speech recognition, natural language processing, etc. For computer vision, the input data may include images or videos. When performing convolution operation, the input data will be transformed into an n-dimensional input matrix (generally four-dimensional, such as (n, c, h, w), etc.). The input of natural language processing can be a paragraph of text or a word or a character, etc. Regardless of the field, the input data will be transformed into n-dimensional matrix data before performing convolution operation.

[0032] Figure 3 FIG. 3 is a schematic diagram of a transformation process 300 of a weight matrix and an input matrix according to an embodiment of the present disclosure. Figure 3 As shown, the weight matrix 310 is divided into 16 blocks, with a total of 4 rows and 4 columns, and the input matrix 320 is divided into 36 blocks, with a total of 6 rows and 6 columns, wherein the sizes of the blocks are the same.

[0033] Figure 4 FIG. 4 is a schematic diagram showing a transformation process 400 of a weight matrix and an input matrix according to an embodiment of the present disclosure. Figure 4 As shown, the weight matrix 410 is divided into 12 blocks, with a total of 4 rows and 3 columns, and the input matrix 440 is divided into 30 blocks, with a total of 6 rows and 5 columns, wherein the sizes of the blocks are the same.

[0034] Subsequently, the computing device 110 may iteratively perform the following transformation operations 204 - 208 one or more times to generate a transformed weight matrix and a transformed input matrix for performing a convolution operation via the matrix computing device 120 .

[0035] It should be understood that the previous iteration and the subsequent iteration in the multiple iterations can be both for rows, both for columns, for rows and columns respectively, or for columns and rows respectively. For example, the first iteration is performed for the rows of the weight matrix and the input matrix, and the second iteration is performed for the columns of the weight matrix and the input matrix, or vice versa. For another example, the first iteration is performed for the rows of the weight matrix and the input matrix, and the second iteration is performed for the rows of the weight matrix and the input matrix. For another example, the first iteration is performed for the columns of the weight matrix and the input matrix, and the second iteration is performed for the columns of the weight matrix and the input matrix. The scope of the present disclosure is not limited here.

[0036] In some embodiments, before performing the transformation operation iteratively one or more times, the computing device 110 may determine whether the number of channels of the input matrix is ​​the same as the minimum channel granularity of the matrix computing device 120 for the convolution operation. If the computing device 110 determines that the number of channels of the input matrix is ​​different from the minimum channel granularity of the matrix computing device 120 for the convolution operation, the transformation operation 204-208 is performed iteratively one or more times. Therefore, it is first determined whether the number of channels is different from the minimum channel granularity, and then the transformation is performed, so as to further improve the efficiency of the convolution operation.

[0037] In some embodiments, the computing device 110 may determine the number of iterations based on the weight matrix, the input matrix, and the width, height, and minimum channel granularity of the matrix computing unit for the convolution operation. Subsequently, the computing device 110 may iteratively perform the transformation operations 204-208 based on the determined number of iterations.

[0038] In this way, the number of iterations can be matched with the channel data of the input matrix and the minimum number of channel particles, thereby maximizing the efficiency of the convolution operation of the matrix calculation unit.

[0039] At block 204 , the computing device 110 aligns the number of blocks included in the weight matrix 310 on a column or a row to a minimum even number N greater than or equal to the number to generate an aligned weight matrix.

[0040] like Figure 3 As shown, the number of blocks included in the column of the weight matrix 310 is 4, and the smallest even number N greater than or equal to 4 is 4, so the aligned weight matrix is ​​the weight matrix 310 itself.

[0041] like Figure 4 As shown, the number of blocks included in the weight matrix 410 in the column is 3, and the smallest even number N greater than or equal to 3 is 4, then the blocks in the rightmost column of the weight matrix 310 can be padded to obtain 4 columns of blocks, for example, they can be padded with 0. After padding, the aligned weight matrix 420 is obtained.

[0042] At block 206 , the computing device 110 stacks the first half and the second half of the aligned weight matrix divided in half by columns or rows on the channel dimension of the input matrix to generate a transformed weight matrix.

[0043] like Figure 3 As shown, the aligned weight matrix 310 is divided into half according to the columns to obtain the first half 311 and the second half 312. The first half 311 and the second half 312 are stacked on the channel dimension of the input matrix 320 to generate a transformed weight matrix 330. The stacking is, for example, stacking the first half 311 on the second half 312.

[0044] like Figure 4 As shown, the aligned weight matrix 420 is divided into two halves according to columns to obtain a first half 421 and a second half 422. The first half 421 and the second half 422 are stacked on the channel dimension of the input matrix 440 to generate a transformed weight matrix 430. The stacking is, for example, stacking the first half 421 on the second half 422.

[0045] At box 208, the computing device 110 stacks the data after removing the last N / 2 columns or rows of the block in the input matrix and the data after removing the first N / 2 columns or rows of the block in the channel dimension to generate a transformed input matrix.

[0046] like Figure 3 As shown, after removing the blocks of the first 2 (4 / 2=2) columns from the input matrix 320, data 322 is obtained, and after removing the blocks of the last 2 columns from the input matrix 320, data 321 is obtained. Data 321 and data 322 are stacked in the channel dimension to obtain a transformed input matrix 340. Stacking is, for example, stacking data 321 on data 322.

[0047] like Figure 4 As shown, after removing the blocks of the first 2 (4 / 2=2) columns from the input matrix 440, data 442 is obtained, and after removing the blocks of the last 2 columns from the input matrix 440, data 441 is obtained. Data 441 and data 442 are stacked in the channel dimension to obtain a transformed input matrix 450. Stacking is, for example, stacking data 441 on data 442.

[0048] It should be understood that although Figure 3 and Figure 4 The process of transforming the columns of the input matrix and the weight matrix is ​​shown, but this is just an example. The rows of the input matrix and the weight matrix can also be transformed. The process is similar and will not be repeated here.

[0049] Therefore, by transforming the input matrix and the weight matrix so that the number of channels increases, it can better match the minimum channel granularity of the matrix computing device, reduce the waste of computing power of the matrix computing unit, and thus improve the efficiency of the convolution operation of the matrix computing device. In the case where the number of channels of the input matrix is ​​less than the minimum channel granularity of the matrix computing device for the convolution operation, it can even achieve several times the acceleration effect.

[0050] After generating the transformed weight matrix and the transformed input matrix, a convolution operation may be performed based on the transformed weight matrix and the transformed input matrix via the matrix calculation device 120 to generate a convolution operation result.

[0051] Figure 5 FIG. 5 is a flowchart of a method 500 for determining the number of iterations according to an embodiment of the present disclosure. For example, the method 500 may be performed as follows: Figure 1 The method 500 is executed by the computing device 110 shown. It should be understood that the method 500 may also include additional blocks not shown and / or may omit the blocks shown, and the scope of the present disclosure is not limited in this respect.

[0052] At block 502 , the computing device 110 determines a maximum number of transformable times of a weight matrix.

[0053] The maximum number of transformations of the weight matrix is, for example, the number of transformations required when the weight matrix is ​​transformed to a width and a height of 1. For example, for an 8x8x1 weight matrix, the maximum number of transformations is 6, that is, a 1x1x64 weight matrix can be obtained through 6 transformations. It should be understood that the transformation here refers to the transformation operation on the weight matrix described above.

[0054] For each number of transformations in a plurality of transformations that is less than or equal to the maximum number of transformations, box 504 and box 506 are executed. In some embodiments, the plurality of transformations does not include zero transformations. Taking the above 6 maximum transformations as an example, the plurality of transformations may include 1, 2, 3, 4, 5, and 6. In other embodiments, the plurality of transformations includes zero transformations. Taking the above 6 maximum transformations as an example, the plurality of transformations may include 0, 1, 2, 3, 4, 5, and 6, where 0 means no transformation. Thus, it is possible to achieve the minimum waste of computing power and the highest computing efficiency when performing convolution operations at the matrix computing device without performing transformations.

[0055] At block 504 , computing device 110 determines the width, height, and number of channels of the input matrix after the number of transformations.

[0056] It should be understood that, for the case where the number of transformations is 0, the width, height and number of channels of the input matrix after the number of transformations are equivalent to the width, height and number of channels of the input matrix.

[0057] At block 506 , the computing device 110 determines the number of convolution operations based on the width, height, and minimum channel granularity of the matrix computing device for the convolution operation and the width, height, and number of channels of the input matrix after the number of transformations.

[0058] For example, the width, height and minimum channel granularity of the matrix calculation device for the convolution operation can be multiplied to obtain a first result. For example, the width, height and minimum channel granularity of the matrix calculation device for the convolution operation are 50, 50 and 16 respectively, then the first result is 50x50x16. The width, height and number of channels of the input matrix after the number of transformations are multiplied to obtain a second result. For example, the width, height and number of channels of the input matrix after the number of transformations are 100, 100 and 48 respectively, then the second result is 100x100x48. The second result is divided by the first result and rounded up to obtain the number of convolution operations. For example, the second result 100x100x48 is divided by 50x50x16=12, that is, the matrix calculation device needs to perform 12 convolution operations.

[0059] For example, the width of the input matrix after the number of transformations can be divided by the width of the matrix calculation device for the convolution operation and then rounded up to obtain a first value. For example, the width of the input matrix after the number of transformations is 99, and the width of the matrix calculation device for the convolution operation is 50, then the first value is ceil(99 / 50)=2, where ceil means rounding up. The height of the input matrix after the number of transformations can be divided by the height of the matrix calculation device for the convolution operation and then rounded up to obtain a second value. For example, the height of the input matrix after the number of transformations is 100, and the height of the matrix calculation device for the convolution operation is 50, then the second value is ceil(100 / 50)=2. The number of channels of the input matrix after the number of transformations can be divided by the minimum channel granularity of the matrix calculation device for the convolution operation and then rounded up to obtain a third value. For example, the number of channels of the input matrix after the number of transformations is 48, and the minimum granularity of the matrix calculation device for the convolution operation is 16, then the third value is ceil(48 / 16)=3. By multiplying the first value, the second value, and the third value, the number of convolution operations can be obtained as 12.

[0060] At block 508 , the computing device 110 determines a transform number with the smallest number of convolution operations from among the plurality of transform numbers as the number of iterations.

[0061] It should be understood that if it is determined that the number of convolution operations is the smallest when the number of transformations is 0, the number of iterations is 0, that is, no transformation is performed.

[0062] Thus, the determined number of iterations minimizes the waste of computing power and maximizes the computing efficiency when the input matrix and the weight matrix are convolved at the matrix computing device without or after transformation. In the case where the number of channels of the input matrix is ​​less than the minimum channel granularity of the matrix computing device for the convolution operation, even several times of acceleration can be achieved.

[0063] In the technical solution disclosed herein, the acquisition, storage and application of user personal information involved are in compliance with the provisions of relevant laws and regulations and do not violate public order and good morals.

[0064] According to an embodiment of the present disclosure, the present disclosure also provides a computing device, a readable storage medium, and a computer program product.

[0065] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.

[0066] The program code for implementing the method of the present disclosure may be written in any combination of one or more programming languages. These program codes may be provided to a processor or controller of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that the program code, when executed by the processor or controller, enables the functions / operations specified in the flow chart and / or block diagram to be implemented. The program code may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.

[0067] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

[0068] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the computer. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).

[0069] The systems and techniques described herein may be implemented in a computing system that includes back-end components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes front-end components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such back-end components, middleware components, or front-end components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), and the Internet.

[0070] A computer system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The relationship of client and server is generated by computer programs running on respective computers and having a client-server relationship with each other. The server may be a cloud server, a server of a distributed system, or a server combined with a blockchain.

[0071] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps recorded in this disclosure can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solutions disclosed in this disclosure can be achieved, and this document does not limit this.

[0072] The above specific implementations do not constitute a limitation on the protection scope of the present disclosure. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present disclosure shall be included in the protection scope of the present disclosure.

Claims

1. A method for convolution operation of a matrix computing device, comprising: Obtaining a weight matrix and an input matrix for a convolution operation, wherein the weight matrix and the input matrix are divided into blocks of the same size; Iteratively performing the following transformation operation one or more times to generate a transformed weight matrix and a transformed input matrix whose number of channels matches the minimum channel granularity of the matrix calculation device, for performing a convolution operation via the matrix calculation device: Aligning the number of the blocks included in the weight matrix in columns or rows to a minimum even number N greater than or equal to the number to generate an aligned weight matrix; Stacking the first half and the second half of the aligned weight matrix divided in half by columns or rows on the channel dimension of the input matrix to generate a transformed weight matrix; as well as The data after removing the last N / 2 columns or rows of the block in the input matrix and the data after removing the first N / 2 columns or rows of the block in the input matrix are stacked in the channel dimension to generate a transformed input matrix.

2. The method according to claim 1, wherein iterating one or more times to perform the transformation operation comprises: Determining whether the number of channels of the input matrix is ​​the same as the minimum channel granularity of the matrix calculation device for the convolution operation; as well as If it is determined that the number of channels of the input matrix is ​​different from the minimum channel granularity of the matrix calculation device for the convolution operation, the transformation operation is performed iteratively one or more times.

3. The method according to claim 2, wherein iterating one or more times to perform the transformation operation comprises: Determining the number of iterations based on the weight matrix, the input matrix, and the width, height, and minimum channel granularity of the convolution operation of the matrix calculation unit; as well as Based on the determined number of iterations, the transform operation is iteratively performed.

4. The method of claim 3, wherein determining the number of iterations comprises: Determining the maximum number of times the weight matrix can be transformed; For each of a plurality of transformation times that are less than or equal to the maximum possible transformation times: Determining the width, height and number of channels of the input matrix after the number of transformations; and Determining the number of convolution operations based on the width, height and minimum channel granularity of the matrix computing device for the convolution operation and the width, height and number of channels of the input matrix after the number of transformations; as well as The number of transformations with the smallest number of convolution operations is determined from the multiple numbers of transformations as the number of iterations. The method of claim 4 , wherein the plurality of transform orders include zero transforms, or the plurality of transform orders do not include zero transforms.

6. The method according to claim 1, further comprising: A convolution operation is performed via the matrix calculation device based on the transformed weight matrix and the transformed input matrix to generate a convolution operation result. 7 . The method according to claim 1 , wherein the preceding iteration and the succeeding iteration in the plurality of iterations are both for rows, both for columns, for rows and columns respectively, or for columns and rows respectively. The method of claim 1 , wherein the block comprises one or more matrix elements.

9. A computing device comprising: at least one processor; as well as a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method according to any one of claims 1 to 8.

10. A computing system comprising: The computing device according to claim 9; as well as The matrix calculation device is communicatively connected to the computing device and is configured to perform a convolution operation based on the transformed weight matrix and the transformed input matrix to generate a convolution operation result.

11. A non-transitory computer-readable storage medium storing computer instructions, wherein: The computer instructions are used to cause the computer to execute the method according to any one of claims 1-8.

Citation Information

Patent Citations

  • Hardware accelerator architecture for processing very-sparse and hyper-sparse matrix data

    CN108268422A

  • Convolutional neural network acceleration engine, convolutional neural network acceleration system and method

    CN111178519A