A convolution processing method, device, equipment and medium for feature map
By combining and convolving multiple feature maps in the feature pyramid in the neural network processor, the problem of insufficient processing speed and real-time performance of convolutional neural networks in IoT applications is solved, and processing efficiency and resource utilization are improved. Rate.
Patent Information
- Application Number
- CN202210042329.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-01-14
- Publication Date
- 2024-09-06
- Estimated Expiration
- 2042-01-14
AI Technical Summary
Existing convolutional neural networks suffer from insufficient processing speed and real-time performance in IoT applications, especially when performing deep learning model inference on edge devices, resulting in low processing efficiency and low utilization of hardware resources.
The neural network processor combines multiple feature maps in the feature pyramid to form a combined feature map, and uses multiple arithmetic logic units that can run in parallel to perform convolution operations to improve processing efficiency and resource utilization.
It improves the utilization of the arithmetic logic unit in the neural network processor, reduces the number of convolution kernel calls, reduces resource occupation, and significantly improves the efficiency of convolution processing of feature maps.
Smart Images

Figure CN114429207B
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a method, device, equipment and medium for convolution processing of feature maps. Background Art
[0002] Convolutional neural networks are currently widely used in target detection, image enhancement, and super-resolution-related image tasks. With the development of IoT technology, more and more deep learning models need to be inferred on edge devices, and the requirements for task processing speed are also getting higher and higher. For example, IoT applications represented by computer vision have high requirements for reasoning speed and real-time performance.
[0003] Therefore, how to improve the processing speed of tasks based on convolutional neural networks is a technical problem that needs to be solved urgently. Summary of the invention
[0004] The embodiments of this specification provide a method, device, equipment and medium for convolution processing of feature maps to increase the speed of convolution processing of feature maps.
[0005] To solve the above technical problems, the embodiments of this specification are implemented as follows:
[0006] An embodiment of the present specification provides a convolution processing method for a feature map, the method relates to a neural network processor, the neural network processor includes a plurality of arithmetic logic units that can run in parallel; the number of convolution calculation vectors that can be supported by the plurality of arithmetic logic units that can run in parallel in one operation process is a preset number, and the method includes:
[0007] Acquire a feature pyramid of the target object; the feature pyramid includes a plurality of feature graphs; the number of first convolution calculation vectors included in at least one feature graph of the plurality of feature graphs is less than the preset number;
[0008] Combining the multiple feature maps to obtain a combined feature map; the number of second convolution calculation vectors included in the combined feature map is greater than the number of the first convolution calculation vectors;
[0009] The neural network processor is used to perform a convolution operation on the combined feature map.
[0010] An embodiment of the present specification provides a convolution processing device for a feature map, the device relates to a neural network processor, the neural network processor includes a plurality of arithmetic logic units that can run in parallel; the number of convolution calculation vectors that can be supported by the plurality of arithmetic logic units that can run in parallel in one operation process is a preset number, and the device includes:
[0011] A feature graph acquisition module, used to acquire a feature pyramid of a target object; the feature pyramid includes a plurality of feature graphs; at least one feature graph among the plurality of feature graphs includes a first convolution calculation vector quantity that is less than the preset quantity;
[0012] A combining module, used for combining the multiple feature maps to obtain a combined feature map; the number of second convolution calculation vectors included in the combined feature map is greater than the number of the first convolution calculation vectors;
[0013] A convolution module is used to perform a convolution operation on the combined feature map using the neural network processor.
[0014] An embodiment of the present specification provides a convolution processing device for a feature map, the device relates to a neural network processor, the neural network processor includes a plurality of arithmetic logic units that can run in parallel; the number of convolution calculation vectors that can be supported by the plurality of arithmetic logic units that can run in parallel in one operation process is a preset number, and the device includes:
[0015] at least one processor; and,
[0016] a memory communicatively connected to the at least one processor; wherein,
[0017] The memory stores instructions executable by the at least one processor, the instructions being executed by the at least one processor to enable the at least one processor to:
[0018] Acquire a feature pyramid of the target object; the feature pyramid includes a plurality of feature graphs; the number of first convolution calculation vectors included in at least one feature graph of the plurality of feature graphs is less than the preset number;
[0019] Combining the multiple feature maps to obtain a combined feature map; the number of second convolution calculation vectors included in the combined feature map is greater than the number of the first convolution calculation vectors;
[0020] The neural network processor is used to perform a convolution operation on the combined feature map.
[0021] An embodiment of the present specification provides a computer-readable medium on which computer-readable instructions are stored. The computer-readable instructions can be executed by a processor to implement a convolution processing method for a feature map.
[0022] An embodiment of this specification can achieve the following beneficial effects:
[0023] In the embodiments of the present specification, a neural network processor can be used to process convolution operations on feature maps, wherein multiple feature maps included in a feature pyramid of a target object can be combined, and a neural network processor can be used to perform convolution operations on the combined feature maps. The number of convolution calculation vectors included in the combined feature maps is greater than the number of convolution calculation vectors included in independent feature maps, so that multiple arithmetic logic units that can run in parallel in the neural network processor can process more convolution calculation vectors in one operation, thereby improving the utilization rate of the arithmetic logic units in the neural network processor, and further improving the convolution processing efficiency of the feature maps of the target object.
[0024] Furthermore, in the embodiments of the present specification, convolution operations can be performed on the combined feature maps without having to perform convolution operations on each feature map in the feature pyramid separately, thereby reducing the number of times the convolution kernel is called, thereby improving the convolution processing efficiency of the feature map of the target object, and reducing the resource occupation of the neural network processor by calling the convolution kernel, thereby improving the utilization rate of the neural network processor. BRIEF DESCRIPTION OF THE DRAWINGS
[0025] In order to more clearly illustrate the embodiments of this specification or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in this application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0026] Figure 1 A schematic diagram of an application scenario of a convolution processing method for a feature map provided in an embodiment of this specification;
[0027] Figure 2 A flowchart of a convolution processing method for a feature map provided in an embodiment of this specification;
[0028] Figure 3 A schematic diagram of a feature map filling provided in an embodiment of this specification;
[0029] Figure 4 A schematic diagram of performing block processing on a feature map provided in an embodiment of this specification;
[0030] Figure 5 A schematic diagram of a combined characteristic graph provided in an embodiment of this specification;
[0031] Figure 6 A schematic diagram of reorganizing a convolution result provided in an embodiment of this specification;
[0032] Figure 7A swim lane diagram for convolution processing of a feature map provided in an embodiment of this specification;
[0033] Figure 8 A schematic diagram of the structure of a convolution processing device for a feature map provided in an embodiment of this specification;
[0034] Fig. 9 A schematic diagram of the structure of a convolution processing device for a feature map provided in an embodiment of this specification. DETAILED DESCRIPTION
[0035] In order to make the purpose, technical solutions and advantages of one or more embodiments of this specification clearer, the technical solutions of one or more embodiments of this specification will be clearly and completely described below in combination with the specific embodiments of this specification and the corresponding drawings. Obviously, the described embodiments are only part of the embodiments of this specification, not all of the embodiments. Based on the embodiments in this description, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of one or more embodiments of this specification.
[0036] The technical solutions provided by the embodiments of this specification are described in detail below in conjunction with the accompanying drawings.
[0037] Convolutional neural networks remain invariant to object translation, but cannot handle scale changes of objects. Feature pyramids, as a classic subgraph of deep learning networks, can obtain feature expressions of input images at different sizes and achieve scale invariance of the network. They are currently widely used in target detection, image enhancement, and super-resolution related image tasks.
[0038] In the prior art, for a network subgraph such as a feature pyramid, convolution operations are usually performed on the feature maps in each layer of the feature pyramid respectively. After one layer of feature maps is processed, another layer of feature maps is processed. As the number of layers of the pyramid increases, the number of times the convolution is called increases significantly linearly, which requires more hardware resources, and it is necessary to wait for the processing of one layer of feature maps to be completed before processing another feature map, resulting in low overall processing efficiency.
[0039] In addition, the amount of convolution calculations corresponding to each layer of feature maps in the feature pyramid may not be very large, especially the amount of calculations corresponding to the feature maps close to the top layer are usually not large, but they also need to consume hardware processing resources separately, which makes the utilization rate of the hardware processor that processes the convolution operation low, and also affects the overall processing efficiency.
[0040] In order to solve the defects in the prior art, this solution provides the following embodiments:
[0041] Figure 1A schematic diagram of an application scenario of a convolution processing method for a feature map provided in an embodiment of this specification. Figure 1 As shown, the solution may include a server 1, a feature pyramid 2 of the target object, and a combined feature Figure 3 And a neural network processor 4. The server 1 can combine and process multiple feature maps contained in the feature pyramid 2 of the target object to obtain a combined feature map. Figure 3 , and then the neural network processor 4 is used to perform convolution operation on the combined feature map.
[0042] In actual applications, the neural network processor can be deployed in a server, the neural network processor can be deployed in the same device as the server, or the neural network processor can be deployed in a different device from the server. The specific location relationship is not limited here as long as it can meet actual needs.
[0043] Next, a convolution processing method for a feature map provided in an embodiment of the specification is specifically described with reference to the accompanying drawings:
[0044] Figure 2 A flowchart of a convolution processing method for a feature map provided in an embodiment of the present specification. From a program perspective, the execution subject of the process can be a program installed on an application server or an application client.
[0045] The method provided in the embodiments of this specification may involve a neural network processor, which may include multiple arithmetic logic units that can run in parallel; the number of convolution calculation vectors that can be supported by the multiple arithmetic logic units that can run in parallel during one operation is a preset number.
[0046] The neural network processor (NPU) adopts a data-driven parallel computing architecture and is good at processing massive multimedia data such as videos and images.
[0047] like Figure 2 As shown, the process may include the following steps:
[0048] Step 202: Acquire a feature pyramid of the target object; the feature pyramid includes multiple feature maps; at least one feature map among the multiple feature maps includes a first convolution calculation vector quantity that is less than the preset quantity.
[0049] Feature pyramid is a basic component in the recognition system for detecting objects of different scales. It is a subgraph in deep learning networks, such as Faster R-CNN, RetinaNet, Mask-RCNN, etc.
[0050] In the embodiments of this specification, the target object may be an object in image format, and may be an image to be recognized in computer vision. A feature pyramid may include multiple feature maps, and each layer of the pyramid may be regarded as a feature map.
[0051] Step 204: Combine the multiple feature maps to obtain a combined feature map; the number of second convolution calculation vectors included in the combined feature map is greater than the number of the first convolution calculation vectors.
[0052] In the embodiments of this specification, the combined feature map can be used as a feature map, and the combined feature map can include image symbols of each feature map in the feature pyramid. The number of convolution calculation vectors can be the number of vectors included in the process of performing convolution operation on the feature map, and the number is positively correlated with the pixel points included in the feature map for convolution calculation.
[0053] Step 206: Use the neural network processor to perform a convolution operation on the combined feature map.
[0054] In the embodiments of this specification, the combined feature map can be used as a feature map and processed using a neural network processor.
[0055] In the embodiments of the present specification, a neural network processor can be used to process the convolution operation of a feature map, wherein multiple feature maps contained in a feature pyramid of a target object can be combined, and the combined feature map is used as a feature map to perform convolution operation using a neural network processor. The number of convolution calculation vectors contained in the combined feature map can be greater than the number of convolution calculation vectors contained in an independent feature map in the feature pyramid, so that multiple arithmetic logic units that can run in parallel in the neural network processor can process more convolution calculation vectors in one operation process, which can improve the utilization rate of the arithmetic logic units in the neural network processor, and further improve the convolution processing efficiency of the feature map of the target object.
[0056] Furthermore, in the embodiments of the present specification, convolution operations can be performed on the combined feature maps, without having to perform convolution operations on each feature map in the feature pyramid, thereby reducing the number of times the convolution kernel is called, that is, the number of times the convolution kernel is called can be reduced, and the time for multiple acquisitions of the convolution kernel can be reduced, thereby improving the convolution processing efficiency of the feature map of the target object, reducing the resource occupation of the neural network processor by calling the convolution kernel, and improving the utilization rate of the neural network processor.
[0057] It should be understood that the order of some steps in the methods described in one or more embodiments of this specification can be interchanged according to actual needs, or some steps can be omitted or deleted.
[0058] based on Figure 2 The method, the examples of this specification also provide some specific implementation plans of the method, which are described below.
[0059] The combined feature graph in the embodiments of this specification may have a corresponding combined feature graph identifier; the combined feature graph identifier is used to indicate that the combined feature graph is operated as a whole.
[0060] In practical applications, the combined feature map can be obtained according to the combined feature identifier, and the combined feature map can be used as a whole to perform convolution operations using a neural network processor.
[0061] In practical applications, a neural network processor may include multiple arithmetic logic units, each of which can process a certain number of arithmetic operations. Convolution operations usually include multiplication, addition and other operations, and the arithmetic logic unit can be used to process various operations in the convolution operation.
[0062] In the embodiments of the present specification, the neural network processor may include multiple arithmetic logic units that can run in parallel, and the convolution calculation vectors included in the combined feature map can be sent to multiple arithmetic logic units for calculation according to the required amount of calculation, making full use of the arithmetic logic units that can run in parallel. Specifically, the neural network processor is used in the embodiments of the present specification to perform convolution operation on the combined feature map, which specifically includes:
[0063] Sending the convolution calculation vectors of the second convolution calculation vector quantity contained in the combined feature graph to a first number of arithmetic logic units in the neural network processor; the first number is greater than the second number; the second number is the number of arithmetic logic units that the convolution calculation vectors of the first number of convolution calculation vectors need to occupy;
[0064] The first number of arithmetic logic units is used to perform a convolution operation on the combined feature map.
[0065] In the prior art, a convolution operation is usually performed on each feature map in the feature pyramid. Since the number of convolution calculation vectors contained in a single feature map may be small, only a small number of arithmetic logic units can be used in one convolution operation, and other unused arithmetic logic units can only be idle, which is not a high utilization rate for the neural network processor. The second number in the embodiment of this specification can be understood as the number of arithmetic logic units that need to be occupied when the feature maps in the feature pyramid are independently processed in the existing manner.
[0066] Assuming that the neural network processor contains 128 arithmetic logic units and the feature pyramid is a 5-layer feature pyramid, it can be considered that the feature pyramid contains 5 feature maps, and the number of pixels contained in the feature maps from top to bottom are 4, 8, 16, 32, and 64 respectively. For ease of understanding, it is assumed here that the number of convolution calculation vectors contained in the feature maps from top to bottom is 4, 8, 16, 32, and 64, and each arithmetic logic unit can process a convolution calculation vector in one operation.
[0067] According to the existing method, convolution operations need to be performed for each feature map separately, and the neural network processor needs to perform 5 convolution operations. For the first layer (top layer) feature map, 4 arithmetic logic units in the neural network processor are used, and the utilization rate is 0.03125; similarly, it can be concluded that the utilization rates of other feature maps for the neural network processor are 0.0625, 0.125, 0.25, and 0.5 respectively. It can also be understood that 640 (i.e. 128*5) arithmetic logic units are used to process 124 (i.e. 4+8+16+32+64) convolution calculation vectors, and the comprehensive utilization rate of the feature pyramid for the neural network processor is 0.19375.
[0068] According to the method provided in the embodiments of this specification, five feature maps are combined into an overall feature map, and a neural network processor is used to perform convolution operations on the combined overall feature map. The number of convolution calculation vectors contained in the combined feature map can be 124 (i.e., 4+8+16+32+64). Then, the 124 arithmetic logic units in the neural network processor can be used for operations. At this time, the utilization rate of the neural network processor is 0.96875, which is significantly higher than the utilization rate of the neural network processor in the prior art.
[0069] Moreover, in the above-mentioned embodiment, according to the method of the prior art, the neural network processor needs to perform five operation processes in the entire feature pyramid operation process. Assuming that the time required for one operation process of the neural network processor is t, the required operation time is 5t; according to the method in the embodiment of this specification, multiple feature maps are budgeted as a whole feature map, and the neural network processor only needs to perform one operation process, that is, the required operation time is t, which is less than 5t required in the prior art. Therefore, the method in this specification can also reduce the time for the convolution operation of the feature pyramid.
[0070] In addition, according to the existing method, it is necessary to obtain a convolution kernel for each feature map, that is, it needs to be obtained 5 times. The method provided in the embodiment of this specification can complete the operation by obtaining the convolution kernel once, which can also reduce the time for obtaining the convolution kernel, and further reduce the time for feature pyramid convolution operation, thereby improving operation efficiency.
[0071] It can be understood that the above embodiments are only examples for more clearly explaining the methods provided in the embodiments of this specification, and the numerical values therein are only for illustration and may not have actual meaning. In practical applications, the number of arithmetic logic units included in the neural network processor and the number of convolution calculation vectors that the arithmetic logic unit can support in one operation can be determined according to actual conditions, and no specific limitation is made here.
[0072] In practical applications, the arithmetic logic unit in the neural network processor can also process a certain number of convolution calculation vectors in one operation process. In the embodiment of this specification, the convolution calculation vector can also be sent to the arithmetic logic unit. Specifically, the above-mentioned use of the neural network processor to perform a convolution operation on the combined feature map specifically includes:
[0073] Sending a third number of convolution calculation vectors in the convolution calculation vectors of the second number of convolution calculation vectors contained in the combined feature graph to an arithmetic logic unit in the neural network processor;
[0074] The arithmetic logic unit is used to perform operations on the third number of convolution calculation vectors; the third number is greater than the fourth number; the fourth number is the number of convolution calculation vectors in the convolution calculation vectors of the first number of convolution calculation vectors that need to be sent to the arithmetic logic unit.
[0075] In the embodiments of this specification, the combined feature map may include more convolution calculation vectors, and more convolution calculation vectors may be sent to the arithmetic logic unit, thereby improving the utilization rate of the arithmetic logic unit.
[0076] In practical applications, in order to avoid losing features in edge pixels in a feature map, the feature map may be padded before performing a convolution operation. In the embodiment of this specification, the feature map may be padded and the padded feature map may be processed. Specifically, before combining the multiple feature maps in the embodiment of this specification, the following steps may also be included:
[0077] Performing pixel filling on each feature map in the multiple feature maps to obtain a filled feature map;
[0078] The combining of the multiple feature maps may specifically include:
[0079] Combine the padded feature maps.
[0080] The performing pixel filling on each feature map in the multiple feature maps may specifically include:
[0081] Determine the side length of the target convolution kernel;
[0082] Determine the side length of the padded image based on the side length of the target convolution kernel;
[0083] Each side of each feature map is filled according to the side length of the filling image.
[0084] Figure 3 A schematic diagram of a feature map filling provided in an embodiment of this specification. Figure 3 As shown, feature map 302 is a feature map included in the feature pyramid, and the filling image B can be used to fill each edge in feature map A. The size of the filling image 304 can be set according to the size of the convolution kernel.
[0085] In the embodiments of this specification, it is assumed that the side length of the convolution kernel is K, and K is an odd number; the side length P of the padded image can be (K-1) / 2. For example, if the side length of the convolution kernel is 3 pixels, the side length of the padded image can be 1, and a row of padded images with a side length of 1 pixel is added to each side of each feature map to obtain a padded feature map.
[0086] As an implementation manner, the combination of the filled feature maps described in the embodiments of this specification may specifically include:
[0087] Divide each filled feature map into blocks according to a preset block rule to obtain feature blocks corresponding to each filled feature map;
[0088] The feature blocks are combined according to a preset combination rule to obtain the combined feature map.
[0089] In the embodiments of this specification, the feature graph in the feature pyramid may be divided into blocks and then combined to obtain a combined feature graph that can be used as a whole to perform a convolution operation.
[0090] The method of dividing each filled feature map into blocks according to a preset block rule in the embodiments of this specification may specifically include:
[0091] The padded feature map with the smallest pixel among the padded feature maps is used as the block reference feature map;
[0092] According to the side length of the block reference feature map, each filled feature map is divided into blocks with the side length of the feature map with the smallest pixel among the multiple feature maps as a step length.
[0093] Assuming that the side length of the feature map with the smallest pixel among multiple feature maps is S, the feature map obtained after filling it can be used as the block reference feature map, and the side length of the block reference feature map is B, where B=S+2*P, and P is the side length of the filled image.
[0094] Figure 4This is a schematic diagram of a block processing of a feature map provided in an embodiment of this specification. Figure 4 As shown, feature map 402 is a feature map included in the feature pyramid. Feature map 406 is obtained by filling feature map 402 with an image with a side length P. Feature map 406 is divided into blocks according to the minimum side length B of the filled feature map and the minimum side length S of the feature map. Feature map 406 can be divided into multiple feature blocks 408, wherein the sizes of the obtained feature blocks are the same.
[0095] like Figure 4 As shown, assuming that the side length m of the feature map 402 is 8, the side length P of the padded image is 1, the side length n of the feature map 406 obtained after padding is 10, n=m+2*P. The side length B of the smallest padded feature map among the padded feature maps in the feature pyramid is 6, and the side length S of the smallest feature map is 4. For the feature map 406 obtained after padding, 4 feature blocks with a side length of 6 can be obtained.
[0096] In practical applications, the neural network completes the backbone network inference for the target image and outputs the feature pyramid. The feature map contained in the feature pyramid is represented as F i , the minimum feature map side length is recorded as S, then the feature map F contained in the feature pyramid i The side length can be S*2^i.
[0097] In the embodiment of this specification, it is assumed that the convolution kernel size is K, and the padded image becomes P = (K-1) / 2. The top, bottom, left, and right of each feature map are padded with a size of P 0, and the padded feature map F' can be obtained. i , the side length of the padded feature map is S*2^i+2*P. Each feature map F'i can be divided into blocks with a step size of S according to the block reference feature map with a side length of B=S+2*P.
[0098] As an implementation manner, in the embodiments of this specification, the feature blocks may be combined according to a preset combination rule to obtain the combined feature map, which may specifically include:
[0099] Each feature block is combined in a stacked manner to obtain a combined feature map.
[0100] Among them, the side length of the combined feature map can be the side length of the block reference feature map.
[0101] Figure 5 Schematic diagram of a combined characteristic graph provided in the embodiments of this specification. Figure 5As shown, assuming that the filled feature map 502 is divided into four feature blocks of the same size, the first feature block 504, the second feature block 506, the third feature block 508 and the fourth feature block 510, each feature block can be stacked to combine the feature map. The arrows can represent the position of the feature blocks in the feature map and the position of the combined feature blocks.
[0102] In the embodiments of this specification, Figure 5 The method shown divides each feature map into multiple feature blocks of the same size, and combines each feature block in a stacked manner to form a combined feature map.
[0103] In practical applications, each feature block can be numbered and stacked in the order of the numbers. For example, each feature block contained in the feature map of each layer can be numbered from left to right and from top to bottom in the order from the top layer to the bottom layer of the feature pyramid, and each feature block can be stacked in the order of the numbers to obtain a combined feature map.
[0104] In the embodiment of this specification, a group convolution operation can be performed on the combined feature map, wherein, the above-mentioned use of the target neural network processor to perform a convolution operation on the combined feature map can specifically include:
[0105] Based on the convolution kernel, the target neural network processor is used to perform a group convolution operation on the combined feature map.
[0106] The convolution kernel in the embodiments of this specification may be the same as the convolution kernel in the prior art that performs convolution operations on the feature graphs in the feature pyramid respectively, and group convolution is used to perform convolution operations.
[0107] In practical applications, the input feature map in a convolution operation can usually be a multi-dimensional matrix of N*Ci*H*W; where N represents the number of images in the feature map, which can also be understood as the number of images that the neural network can process at one time, N≥1; Ci represents the number of input feature map channels; H represents the length of the feature map, and W represents the width of the feature map; the convolution kernel can be Co*Ci*K*K, where Co represents the output feature map channel, K represents the convolution kernel size, and the corresponding output feature map can be expressed as N*Co*H*W.
[0108] In the embodiment of the present specification, the combined feature map as the input feature map of the convolution operation can be expressed as N*(Ci*M)*B*B, wherein N can represent the number of images contained in the feature block, and M can represent the total number of feature blocks divided into blocks; Ci*M can represent the number of channels of the input combined feature map; B can represent the side length of the feature block; the output feature map corresponding to the combined feature map can be expressed as N*(Co*M)*B*B.
[0109] In the examples of this specification, the grouped convolution method can be used to perform convolution operations on the combined feature maps, which can fully utilize the computing power of the neural network processor and improve the efficiency of the convolution operation.
[0110] As another implementation method, in the embodiments of this specification, each feature block can also be combined in a splicing manner to obtain a combined feature map. Among them, the number of pictures contained in each feature block can be used as the number of pictures of the input feature map of the convolution operation, and the combined feature map as the input feature map of the convolution operation can be expressed as (N*M)*Ci*B*B, where N*M can be the number of pictures contained in the feature map input of the convolution operation, and N*M pictures can be processed in one convolution operation; the output feature map corresponding to the combined feature map can be expressed as (N*M)*Co*B*B.
[0111] The number of channels of the convolution operation corresponding to the combined feature map obtained by the splicing method can remain unchanged, and the convolution operation can be performed on the combined feature map in the ordinary convolution method.
[0112] To facilitate the subsequent use of the convolution result obtained after the convolution, the positional relationship of each feature block in the feature map can also be marked in the embodiment of this specification, and the obtained convolution result can also be mapped to the convolution result corresponding to each feature map by using the positional relationship. Specifically, the method in the embodiment of this specification can also include:
[0113] Mark each feature block;
[0114] Based on the block mark of each feature block, a position index is generated; the position index is used to indicate the position of each feature block in each feature map.
[0115] In the embodiments of this specification, the convolution operation is performed on the combined feature map, which is equivalent to performing a convolution operation on each feature block, and the convolution result obtained can be the convolution calculation result of each feature block. Among them, the convolution result obtained by performing a convolution operation on the combined feature map can include multiple convolution sub-results; each feature block corresponds to each convolution sub-result.
[0116] In the embodiment of this specification, the convolution result corresponding to each feature map can be obtained according to the preset position index representing the position information of the feature block in the feature map. Specifically, the method in the embodiment of this specification can also include:
[0117] Based on the position index, each convolution sub-result is reorganized to obtain a plurality of convolution feature maps; the convolution feature maps correspond to the feature maps in the feature pyramid.
[0118] Figure 6A schematic diagram of reorganizing the convolution result provided in the embodiment of this specification. Figure 6 As shown, assuming that the convolution result obtained by performing a convolution operation on the combined feature map includes a first convolution sub-result 602, a second convolution sub-result 604, a third convolution sub-result 606, and a fourth convolution sub-result 608, the four convolution sub-results are the results of convolution of the feature blocks included in the feature map X in the feature pyramid, and the respective convolution sub-results can be reorganized into a convolution result 610 corresponding to the feature map X according to a preset position index. The straight line with an arrow can represent the position correspondence of the convolution sub-results in the reorganized convolution result 610.
[0119] In the embodiments of the present specification, the convolution sub-results corresponding to each feature block can be mapped back to the convolution results corresponding to the original feature map according to the positional correspondence between the feature blocks and the feature map, so that the convolution results corresponding to each feature map can be obtained, so that the convolution results corresponding to each feature map can be used for subsequent operations. For example, the convolution results corresponding to each feature map can be input into the input layer in an existing manner to perform image recognition, etc.
[0120] In the embodiments of this specification, the convolution calculation results corresponding to each feature map can also be obtained, so that the neural network model can perform image recognition and analysis in a universal manner, etc., which can improve the wide application of the method.
[0121] Taking into account the computing power of the neural network processor, in the embodiment of this specification, the number of convolution calculation vectors contained in the combined feature map can also be grouped according to the number of vectors that the neural network processor can process, and a preset number of convolution calculation vectors are sent to the neural network processor so that the neural network processor can perform parallel calculations. Specifically, the method in the embodiment of this specification can also include:
[0122] Determine the preset number of processing vectors of the neural network processor; the preset number of processing vectors may be the number of convolution calculation vectors that can be supported by the neural network processor during one operation;
[0123] Determining the number of convolution calculation vectors to be calculated contained in the combined feature map;
[0124] According to the preset number of processing vectors, grouping the convolution calculation vectors to be calculated of the number of convolution calculation vectors to be calculated;
[0125] The using the neural network processor to perform a convolution operation on the combined feature map specifically includes:
[0126] Sending the grouped convolution calculation vectors to be calculated to the neural network processor;
[0127] A neural network processor is used to perform convolution operation on the grouped convolution calculation vectors to be calculated.
[0128] In practical applications, the feature pyramid can be used as the input of a small network in a neural network calculation, and a convolution operation is performed in the small network. For example, in a deep learning network that includes a feature pyramid, a small FCN (Fully Convolutional Networks) network is usually used to take the pyramid layer as input. In the prior art, it is necessary to set up a small network for each layer of the pyramid, that is, it is necessary to build multiple small networks, which requires a large model volume. In the embodiments of this specification, a small network can be used to complete the convolution operation of the combined feature map, without the need to build multiple small networks, and the model volume can also be reduced.
[0129] The embodiments of this specification can effectively reduce the time for convolution calculations on feature graphs included in the feature pyramid. In actual applications, by comparing the running time of the classic feature pyramid subgraph on a neural network processor with the same computing power, it is also possible to observe whether a third party has adopted a method similar to the method provided in the embodiments of this specification to assess whether the third party is likely to have plagiarized. For example, if the time taken to calculate the same feature pyramid graph using a method adopted by a third party is slightly different from that taken using the method in the embodiments of this specification, for example, within 20%, it can be determined that the third party is at risk of plagiarism.
[0130] To more clearly illustrate the convolution processing method for the feature map provided in the example of this specification, Figure 7 A lane diagram for convolution processing of a feature map provided in an embodiment of this specification, such as Figure 7 The scheme may include a feature map acquisition stage, a block combination stage, a convolution processing stage, and a result reorganization stage, specifically:
[0131] Step 702: Acquire a feature pyramid of the target object; the feature pyramid includes multiple feature maps; at least one feature map among the multiple feature maps includes a first convolution calculation vector quantity that is less than the preset quantity.
[0132] Step 704: performing pixel filling on each feature map in the plurality of feature maps to obtain a filled feature map.
[0133] Step 706: Divide each filled feature map into blocks according to a preset block rule to obtain a feature block corresponding to each filled feature map.
[0134] Step 708: Combine the feature blocks according to a preset combination rule to obtain the combined feature map.
[0135] Step 710: Use the neural network processor to perform a convolution operation on the combined feature map.
[0136] Step 712: Based on the position index, reorganize each convolution sub-result to obtain a plurality of convolution feature maps; the convolution feature maps correspond to the feature maps in the feature pyramid.
[0137] Based on the same idea, the embodiments of this specification also provide a device corresponding to the above method. Figure 8 The following is a schematic diagram of a convolution processing device for a feature map provided in an embodiment of the present specification. Figure 8 As shown, the device relates to a neural network processor, the neural network processor includes a plurality of arithmetic logic units that can run in parallel; the number of convolution calculation vectors that can be supported by the plurality of arithmetic logic units that can run in parallel in one operation process is a preset number, and the device may include:
[0138] A feature graph acquisition module 802 is used to acquire a feature pyramid of a target object; the feature pyramid includes a plurality of feature graphs; at least one feature graph among the plurality of feature graphs includes a first convolution calculation vector quantity that is less than the preset quantity;
[0139] A combining module 804 is used to combine the multiple feature maps to obtain a combined feature map; the number of second convolution calculation vectors included in the combined feature map is greater than the number of first convolution calculation vectors;
[0140] The convolution module 806 is used to use the neural network processor to perform a convolution operation on the combined feature map.
[0141] Based on the same idea, the embodiments of this specification also provide a device corresponding to the above method.
[0142] Fig. 9 A schematic diagram of a convolution processing device for a feature map provided in an embodiment of the present specification. The device relates to a neural network processor, which includes a plurality of arithmetic logic units that can run in parallel; the number of convolution calculation vectors that can be supported by the plurality of arithmetic logic units that can run in parallel in one operation process is a preset number, such as Fig. 9 As shown, the device 900 may include:
[0143] at least one processor 910; and,
[0144] A memory 930 in communication with the at least one processor; wherein,
[0145] The memory 930 stores instructions 920 that can be executed by the at least one processor 910. The instructions are executed by the at least one processor 910 to enable the at least one processor 910 to:
[0146] Acquire a feature pyramid of the target object; the feature pyramid includes a plurality of feature graphs; the number of first convolution calculation vectors included in at least one feature graph of the plurality of feature graphs is less than the preset number;
[0147] Combining the multiple feature maps to obtain a combined feature map; the number of second convolution calculation vectors included in the combined feature map is greater than the number of the first convolution calculation vectors;
[0148] The neural network processor is used to perform a convolution operation on the combined feature map.
[0149] Based on the same idea, the embodiment of this specification also provides a computer-readable medium corresponding to the above method. The computer-readable medium stores computer-readable instructions, and the computer-readable instructions can be executed by a processor to implement the above convolution processing method for the feature map.
[0150] Each embodiment in this specification is described in a progressive manner. The same or similar parts between the embodiments can be referred to each other. Each embodiment focuses on the differences from other embodiments. Fig. 9 As for the device shown, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0151] In the 1990s, improvements to a technology could be clearly distinguished as hardware improvements (for example, improvements to the circuit structure of diodes, transistors, switches, etc.) or software improvements (improvements to the method flow). However, with the development of technology, many improvements to the method flow today can be regarded as direct improvements to the hardware circuit structure. Designers almost always obtain the corresponding hardware circuit structure by programming the improved method flow into the hardware circuit. Therefore, it cannot be said that an improvement in a method flow cannot be implemented using a hardware entity module. For example, a programmable logic device (PLD) (such as a field programmable gate array (FPGA)) is such an integrated circuit whose logical function is determined by the user's programming of the device. Designers can "integrate" a digital system on a PLD by programming it themselves, without having to ask a chip manufacturer to design and produce a dedicated integrated circuit chip. Moreover, nowadays, instead of manually making integrated circuit chips, this kind of programming is mostly implemented by "logic compiler" software, which is similar to the software compiler used when developing and writing programs, and the original code before compilation must also be written in a specific programming language, which is called hardware description language (HDL). There is not only one HDL, but many kinds, such as ABEL (Advanced Boolean Expression Language), AHDL (Altera Hardware Description Language), Confluence, CUPL (Cornell University Programming Language), HDCal, JHDL (Java Hardware Description Language), Lava, Lola, MyHDL, PALASM, RHDL (Ruby Hardware Description Language), etc. The most commonly used ones are VHDL (Very-High-Speed Integrated Circuit Hardware Description Language) and Verilog. Those skilled in the art should also know that it is only necessary to program the method flow slightly in the above-mentioned hardware description languages and program it into the integrated circuit, and then it is easy to obtain the hardware circuit that implements the logic method flow.
[0152] The controller can be implemented in any appropriate manner, for example, the controller can take the form of a microprocessor or processor and a computer-readable medium storing a computer-readable program code (such as software or firmware) that can be executed by the (micro)processor, a logic gate, a switch, an application-specific integrated circuit (ASIC), a programmable logic controller, and an embedded microcontroller. Examples of controllers include, but are not limited to, the following microcontrollers: ARC625D, AtmelAT91SAM, Microchip PIC18F26K20, and Silicone Labs C8051F320. The memory controller can also be implemented as part of the control logic of the memory. Those skilled in the art also know that in addition to implementing the controller in a purely computer-readable program code manner, the controller can be implemented in the form of a logic gate, a switch, an application-specific integrated circuit, a programmable logic controller, and an embedded microcontroller by logically programming the method steps. Therefore, this controller can be considered as a hardware component, and the devices included therein for implementing various functions can also be regarded as structures within the hardware component. Or even, the devices for implementing various functions can be regarded as both software modules for implementing the method and structures within the hardware component.
[0153] The systems, devices, modules or units described in the above embodiments may be implemented by computer chips or entities, or by products with certain functions. A typical implementation device is a computer. Specifically, the computer may be, for example, a personal computer, a laptop computer, a cellular phone, a camera phone, a smart phone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or a combination of any of these devices.
[0154] For the convenience of description, the above device is described in various units according to their functions. Of course, when implementing the present application, the functions of each unit can be implemented in the same or multiple software and / or hardware.
[0155] Those skilled in the art will appreciate that embodiments of the present invention may be provided as methods, systems, or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0156] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0157] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0158] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0159] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0160] The memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.
[0161] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.
[0162] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.
[0163] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that contain computer-usable program code.
[0164] The present application may be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types. The present application may also be practiced in distributed computing environments where tasks are performed by remote processing devices connected through a communication network. In a distributed computing environment, program modules may be located in local and remote computer storage media, including storage devices.
[0165] The above is only an embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included in the scope of the claims of the present application.
Claims
1. A convolution processing method for a feature map, the method involving a neural network processor, the neural network processor comprising a plurality of arithmetic logic units that can run in parallel; The number of convolution calculation vectors that can be supported by the multiple arithmetic logic units that can run in parallel in one operation process is a preset number, and the method includes: Acquire a feature pyramid of the target object; the feature pyramid includes a plurality of feature graphs; the number of first convolution calculation vectors included in at least one feature graph of the plurality of feature graphs is less than the preset number; Combining the multiple feature maps to obtain a combined feature map; the number of second convolution calculation vectors included in the combined feature map is greater than the number of the first convolution calculation vectors; The combined feature map is taken as a whole and a convolution operation is performed using the neural network processor.
2. According to the method of claim 1, the combined feature map has a corresponding combined feature map identifier; the combined feature map identifier is used to indicate that the combined feature map is operated as a whole.
3. The method according to claim 2, wherein the step of performing a convolution operation on the combined feature map as a whole using the neural network processor comprises: Sending the convolution calculation vectors of the second convolution calculation vector quantity contained in the combined feature graph to a first number of arithmetic logic units in the neural network processor; the first number is greater than the second number; the second number is the number of arithmetic logic units that the convolution calculation vectors of the first number of convolution calculation vectors need to occupy; The first number of arithmetic logic units is used to perform a convolution operation on the combined feature map.
4. The method according to claim 2, wherein the step of performing a convolution operation on the combined feature map as a whole using the neural network processor comprises: Sending a third number of convolution calculation vectors in the convolution calculation vectors of the second number of convolution calculation vectors contained in the combined feature graph to an arithmetic logic unit in the neural network processor; The arithmetic logic unit is used to perform operations on the third number of convolution calculation vectors; the third number is greater than the fourth number; the fourth number is the number of convolution calculation vectors in the convolution calculation vectors of the first number of convolution calculation vectors that need to be sent to the arithmetic logic unit.
5. The method according to claim 1, before combining the plurality of feature maps, further comprising: Performing pixel filling on each feature map in the multiple feature maps to obtain a filled feature map; The combining the multiple feature maps specifically includes: Combine the padded feature maps.
6. The method according to claim 5, wherein combining the filled feature maps comprises: Divide each filled feature map into blocks according to a preset block rule to obtain feature blocks corresponding to each filled feature map; The feature blocks are combined according to a preset combination rule to obtain the combined feature map.
7. The method according to claim 6, wherein the step of dividing each filled feature map into blocks according to a preset block rule comprises: The padded feature map with the smallest pixel among the padded feature maps is used as the block reference feature map; According to the side length of the block reference feature map, each filled feature map is divided into blocks with the side length of the feature map with the smallest pixel among the multiple feature maps as a step length.
8. The method according to claim 7, wherein the step of combining the feature blocks according to a preset combination rule to obtain the combined feature map comprises: Each feature block is combined in a stacked manner to obtain a combined feature map.
9. The method according to claim 6, wherein the step of performing a convolution operation on the combined feature map as a whole using the neural network processor comprises: Based on the convolution kernel, the neural network processor is used to perform group convolution operation on the combined feature map.
10. According to the method of claim 5, the step of performing pixel filling on each of the plurality of feature maps comprises: Determine the side length of the target convolution kernel; Determine the side length of the padded image based on the side length of the target convolution kernel; Each side of each feature map is filled according to the side length of the filling image.
11. The method according to claim 1, further comprising: Mark each feature block; Generate a position index based on the block mark of each feature block; The position index is used to indicate the position of each feature block in each feature map.
12. According to the method of claim 11, the convolution result obtained by performing a convolution operation on the combined feature map includes multiple convolution sub-results; each feature block corresponds to each convolution sub-result; The method further comprises: Based on the position index, each convolution sub-result is reorganized to obtain a plurality of convolution feature maps; the convolution feature maps correspond to the feature maps in the feature pyramid.
13. A convolution processing device for a feature map, the device being related to a neural network processor, the neural network processor comprising a plurality of arithmetic logic units that can run in parallel; The number of convolution calculation vectors that can be supported by the multiple arithmetic logic units that can run in parallel in one operation process is a preset number, and the device includes: A feature graph acquisition module, used to acquire a feature pyramid of a target object; the feature pyramid includes a plurality of feature graphs; at least one feature graph among the plurality of feature graphs includes a first convolution calculation vector quantity that is less than the preset quantity; A combining module, used for combining the multiple feature maps to obtain a combined feature map; the number of second convolution calculation vectors included in the combined feature map is greater than the number of the first convolution calculation vectors; A convolution module is used to perform a convolution operation on the combined feature map as a whole using the neural network processor.
14. A convolution processing device for a feature map, the device being related to a neural network processor, the neural network processor comprising a plurality of arithmetic logic units that can operate in parallel; The number of convolution calculation vectors that can be supported by the multiple arithmetic logic units that can run in parallel in one operation process is a preset number, and the device includes: 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, the instructions being executed by the at least one processor to enable the at least one processor to: Acquire a feature pyramid of the target object; the feature pyramid includes a plurality of feature graphs; the number of first convolution calculation vectors included in at least one feature graph of the plurality of feature graphs is less than the preset number; Combining the multiple feature maps to obtain a combined feature map; the number of second convolution calculation vectors included in the combined feature map is greater than the number of the first convolution calculation vectors; The combined feature map is taken as a whole and a convolution operation is performed using the neural network processor.
15. A computer-readable medium having computer-readable instructions stored thereon, wherein the computer-readable instructions can be executed by a processor to implement the convolution processing method for a feature map as described in any one of claims 1 to 12.
Citation Information
Patent Citations
Data mapping system and method for realizing parallel convolution calculation
CN108647777A
Image processing method and device
CN110473137A
Target detection method and system based on NAS network
CN112906814A
Pedestrian detection method combining head and overall information
CN112926500A
