A target detection method, apparatus, device and medium
By using a post-processing synthesis operator in object detection, multiple post-processing functions are integrated, solving the problem of low object detection efficiency in existing technologies and achieving a more efficient processing speed.
Patent Information
- Application Number
- CN202511767548.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-27
- Publication Date
- 2026-03-20
- Estimated Expiration
- 2045-11-27
AI Technical Summary
The low efficiency of target detection in existing technologies is mainly due to the need to call multiple independent operators in post-processing operations, which results in a large time overhead for GPU kernel startup.
A post-processing synthesis operator is adopted, which integrates data transposition, maximum value reduction, threshold filtering, data concatenation, score collection and format conversion functions, reducing the number of GPU kernel startups and processing multiple computation operators into a single operator.
It improves the efficiency of object detection, reduces the GPU kernel startup time, and increases processing speed.
Smart Images

Figure CN121214182B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of image processing, and particularly relates to a target detection method and device, equipment and a medium. BACKGROUND
[0002] In the related art, after a feature tensor of an image is extracted based on a pre-processing operation, a post-processing operation is generally performed based on the feature tensor to obtain a detection result. However, in the related art, in order to perform the post-processing operation, a plurality of independent operators need to be called. Each time an operator is called, a GPU kernel function needs to be called to start a GPU kernel, and each time the GPU kernel is started, a fixed time overhead is required, which in turn leads to low target detection efficiency.
[0003] Therefore, how to improve the efficiency of target detection has become a problem to be solved. SUMMARY
[0004] Embodiments of the present application provide a target detection method, device, equipment and medium to solve the problem of low target detection efficiency in the prior art.
[0005] The embodiments of the present application provide a target detection method, which comprises:
[0006] If the graphics processing unit (GPU) receives an instruction to perform post-processing, a target feature tensor is obtained, wherein the target feature tensor is obtained after pre-processing of a to-be-processed image;
[0007] A post-processing comprehensive operator is called to perform corresponding processing operations on the target feature tensor to determine a target detection result of the to-be-processed image, wherein the post-processing comprehensive operator has data transposition, maximum reduction, threshold filtering, data splicing, score collection and format conversion functions.
[0008] Further, the target feature tensor is obtained by:
[0009] For each thread block in the GPU, first position information configured for the thread block is obtained, wherein the first position information is information of a position of a sub-feature tensor required to be processed by the thread block in the target feature tensor;
[0010] A sub-feature tensor corresponding to the first position information in the target feature tensor is determined.
[0011] The post-processing comprehensive operator is called to perform corresponding processing operations on the target feature tensor to determine the target detection result of the to-be-processed image, comprising:
[0012] The thread block calls the post-processing comprehensive operator to perform corresponding processing operations on the sub-feature tensor to determine a detection result corresponding to the sub-feature tensor, and the detection result determined by each thread block constitutes the target detection result.
[0013] Further, the thread block calls the post-processing comprehensive operator to perform corresponding processing operations on the sub-feature tensor to determine a detection result corresponding to the sub-feature tensor, and the detection result determined by each thread block constitutes the target detection result.
[0014] If the current code segment to be executed is a code segment corresponding to the first function in the post-processing comprehensive operator, the sub-feature tensor is obtained from the global memory, and the sub-feature tensor is processed based on the code segment to obtain an intermediate processing result, and the intermediate processing result is stored in the shared memory.
[0015] If the current code segment to be executed is a code segment corresponding to a function other than the first and last functions in the post-processing comprehensive operator, the target data required by the code segment is obtained from the shared memory, and the target data is processed based on the code segment to obtain an intermediate processing result, and the intermediate processing result is stored in the shared memory.
[0016] If the current code segment to be executed is a code segment corresponding to the last function in the post-processing comprehensive operator, the target data required by the code segment is obtained from the shared memory, and the target data is processed based on the code segment, and the processing result obtained is taken as the detection result corresponding to the sub-feature tensor.
[0017] Further, the threshold screening includes local threshold screening and global threshold screening.
[0018] If the target function implemented by the current code segment to be executed is local threshold screening, the processing of the target data based on the code segment to obtain an intermediate processing result includes:
[0019] Performing screening processing on the target data based on the code segment corresponding to the local threshold screening to obtain an intermediate processing result.
[0020] After storing the intermediate processing result in the shared memory, the method further includes:
[0021] Migrating the intermediate processing result stored in the shared memory to the global memory.
[0022] Further, if the target function implemented by the current code segment to be executed is global threshold screening, the processing of the target data based on the code segment to obtain an intermediate processing result includes:
[0023] The method further comprises:
[0024] According to a pre-configured relationship between a global threshold screening round and second position information, second position information corresponding to a currently executed global threshold screening round is determined, wherein the second position information is information of a position where target data to be processed by the thread block when implementing a global threshold screening function is stored.
[0025] According to the second position information, target data is obtained from the global memory.
[0026] Based on a code segment corresponding to the global threshold screening, the target data is screened to obtain an intermediate processing result.
[0027] If the currently executed global threshold screening round is not the last round, after the intermediate processing result is stored in the shared memory, the method further comprises:
[0028] The intermediate processing result stored in the shared memory is migrated to the global memory.
[0029] Further, if a target function implemented by a current code segment to be executed is a next function of the global threshold screening, the target data required by the code segment is obtained from the shared memory, comprising:
[0030] Third position information configured for the thread block is obtained, wherein the third position information is information of a position of target data to be processed by the thread block in the intermediate processing result.
[0031] Target data corresponding to the third position information in the intermediate processing result is determined.
[0032] Further, the threshold screening function is implemented based on a double sorting algorithm.
[0033] Embodiments of the present application also provide a target detection device, the device comprising:
[0034] An acquisition module is configured to acquire a target feature tensor if the GPU receives an instruction to perform post-processing, wherein the target feature tensor is obtained after pre-processing of an image to be processed.
[0035] A detection module is configured to call a post-processing comprehensive operator to perform a corresponding processing operation on the target feature tensor to determine a target detection result of the image to be processed, wherein the post-processing comprehensive operator has data transposition, maximum reduction, threshold screening, data splicing, score collection and format conversion functions.
[0036] Further, the acquisition module is specifically configured to acquire, for each thread block in the GPU, first position information configured for the thread block, wherein the first position information is information of a position of a sub-feature tensor required to be processed by the thread block in the target feature tensor; and determine the sub-feature tensor corresponding to the first position information in the target feature tensor.
[0037] The detection module is specifically configured to determine a detection result corresponding to the sub-feature tensor by calling the post-processing comprehensive operator to perform each processing operation on the sub-feature tensor by the thread block, and the detection result determined by each thread block constitutes the target detection result.
[0038] Further, the detection module is specifically configured to, if the current code segment to be executed is a code segment corresponding to a first function in the post-processing comprehensive operator, acquire the sub-feature tensor from the global memory, process the sub-feature tensor based on the code segment, obtain an intermediate processing result, and store the intermediate processing result in the shared memory.
[0039] If the current code segment to be executed is a code segment corresponding to a function other than the first and last functions in the post-processing comprehensive operator, the detection module is specifically configured to acquire target data required by the code segment from the shared memory, process the target data based on the code segment, obtain an intermediate processing result, and store the intermediate processing result in the shared memory.
[0040] If the current code segment to be executed is a code segment corresponding to a last function in the post-processing comprehensive operator, the detection module is specifically configured to acquire target data required by the code segment from the shared memory, process the target data based on the code segment, and obtain a processing result as the detection result corresponding to the sub-feature tensor.
[0041] Further, the threshold screening includes local threshold screening and global threshold screening; and the detection module is specifically configured to perform screening processing on the target data based on a code segment corresponding to the local threshold screening, and obtain an intermediate processing result.
[0042] The detection module is further configured to migrate the intermediate processing result stored in the shared memory to the global memory.
[0043] Further, if a target function implemented by the current code segment to be executed is global threshold screening, the detection module is specifically configured to perform global threshold screening processing of a set number of rounds based on a code segment corresponding to the global threshold screening, and a process of each global threshold screening processing includes:
[0044] Based on the pre-configured pairing relationship between global threshold filtering rounds and second position information, the second position information corresponding to the currently executed global threshold filtering round is determined, wherein the second position information is the information of the location where the target data to be processed by the thread block is stored when implementing the global threshold filtering function; the target data is obtained from the global memory according to the second position information; the target data is filtered based on the code segment corresponding to the global threshold filtering to obtain intermediate processing results; if the currently executed global threshold filtering round is not the last round, after storing the intermediate processing results in the shared memory, the method further includes: migrating the intermediate processing results stored in the shared memory to the global memory.
[0045] Furthermore, if the target function implemented by the currently executed code segment is the next function of the global threshold filtering, the detection module is specifically used to obtain the third position information configured for the thread block, wherein the third position information is the information of the position of the target data to be processed by the thread block in the intermediate processing result; and to determine the target data corresponding to the third position information in the intermediate processing result.
[0046] Furthermore, the threshold filtering function is implemented based on the bitonic sorting algorithm.
[0047] This application also provides an electronic device, which includes a processor for executing a computer program stored in a memory to implement the steps of any of the target detection methods described above.
[0048] This application also provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the steps of any of the target detection methods described above.
[0049] This application also provides a computer program product, which includes computer program code that, when run on a computer, causes the computer to perform the steps of any of the target detection methods described above.
[0050] In the embodiment of the present application, in the target detection process, if the graphics processing unit GPU receives an instruction to perform post-processing, the target feature tensor obtained after pre-processing of the to-be-processed image is acquired, and each processing operation of the target feature tensor is performed by calling a post-processing comprehensive operator, so as to obtain the target detection result of the to-be-processed image. The post-processing comprehensive operator has the functions of data transposition, maximum reduction, threshold filtering, data splicing, score collection and format conversion. Since all the functions of the post-processing stage are included in one post-processing comprehensive operator, the GPU only needs to call the post-processing comprehensive operator once in the post-processing stage to obtain the target detection result, without the need to call multiple operators, which greatly reduces the time of starting the GPU kernel, thereby improving the efficiency of target detection. BRIEF DESCRIPTION OF DRAWINGS
[0051] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed in the embodiment description will be briefly introduced. Obviously, the drawings in the following description are only some embodiments of the present application, and other drawings can be obtained by those skilled in the art without creative labor.
[0052] Figure 1 A flowchart of the post-processing process of the YOLO-v10 target detection model in the related art is shown.
[0053] Figure 2 A target detection process diagram provided by the embodiment of the present application is shown.
[0054] Figure 3 Another target detection process diagram provided by the embodiment of the present application is shown.
[0055] Figure 4 A target detection device structure diagram provided by the embodiment of the present application is shown.
[0056] Figure 5 An electronic device structure diagram provided by the embodiment of the present application is shown. DETAILED DESCRIPTION
[0057] In order to make the purpose and implementation of the present application more clear, the exemplary embodiments of the present application will be described clearly and completely in conjunction with the drawings in the exemplary embodiments of the present application. Obviously, the described exemplary embodiments are only some embodiments of the present application, not all embodiments.
[0058] It should be noted that the brief description of the terms in the present application is only for the convenience of understanding the subsequently described embodiments, and is not intended to limit the embodiments of the present application. Unless otherwise specified, these terms should be understood according to their ordinary and general meanings.
[0059] The terms "first", "second", "third", etc. in the specification and claims of this application and in the above figures are used for distinguishing between like or similar objects or entities and do not necessarily imply a specific order or sequence unless otherwise specified. It is to be understood that the terms so used are interchangeable under appropriate circumstances.
[0060] The terms "comprises", "comprising", "includes", "including", "has", "having", "contains", "containing", or any other variation thereof, are intended to cover a non-exclusive inclusion, for example, a product or device that comprises a list of components is not necessarily limited to only those components but can include other components not expressly listed or inherent to such product or device.
[0061] The term "module" refers to any known or later developed hardware, software, firmware, artificial intelligence, fuzzy logic, or combination of hardware and / or software codes that can perform the function related to the element that it is associated with.
[0062] Figure 1 A flowchart of a post-processing process for a YOLO-v10 target detection model in the related art is shown in FIG. 1, which shows that the post-processing process of the current YOLO series target detection model usually includes a plurality of independent image processing operator operations, mainly including the following functions. Figure 1 Data transpose: Transpose the output results of the model to facilitate subsequent processing.
[0063] Data split: Split the data after the transpose processing according to the set strategy.
[0064] ReduceMax: Find the maximum confidence in all classes at each spatial position from all candidate detection boxes output by YOLO-v10.
[0065] Top-K: Select the top K detection results with the highest confidence from a large number of candidate boxes.
[0066] Unsqueeze: Adjust the tensor shape to meet the model input or operation requirements.
[0067] Concat: Concatenate different levels of feature maps (such as low resolution high semantic and high resolution low semantic) in the channel dimension to enhance the model's perception of target details and global information.
[0068] GatherElements: Collect feature responses from local or global ranges to enhance context awareness.
[0069]
[0070] Format conversion output: convert the detection result into the format required by the final output.
[0071] As shown in Figure 1 The flow starting point Concat_5_output_0 outputs a dimension of 1x84x8400, representing the input feature map, i.e., the feature tensor. Then, the feature tensor output by the previous node is transposed to adjust the data format to adapt to subsequent processing. Next, Split splits the transposed data according to the specified strategy. The 1x8400x84 feature tensor is split into a 1x8400x4 feature tensor and a 1x8400x80 feature tensor. The 1x8400x80 feature tensor is reduced to a 1x8400 feature tensor by taking the maximum value, and then the Top-K operation is performed on the 1x8400 feature tensor to obtain a 1x300 feature tensor. Next, the data is unsqueezed to increase the dimension, and the output dimension is 1x300x1, which increases the dimension for subsequent processing. Then, the data is Tile operated (repeatedly copied), and the output dimension is 1x300x4 and 1x300x80, and the features are repeated to enhance the detection capability. The 1x8400x4 feature tensor after splitting and the 1x300x4 feature tensor obtained by Tile operation are subjected to gatherElements operation, and a 1x300x4 feature tensor is extracted.
[0072] Meanwhile, the 1x8400x80 feature tensor after splitting and the 1x300x80 feature tensor obtained by Tile operation are subjected to gatherElements operation, and a 1x300x80 feature tensor is extracted. Next, the 1x300x80 feature tensor is subjected to Flatten operation (flattening) to obtain a 1x2400 feature tensor. The 1x2400 feature tensor is subjected to Top-K operation to obtain a 1x300 feature tensor. Next, the feature tensor is subjected to normalization processing or scaling, dimension increasing, data type conversion, etc. Then, the feature tensors of each branch are spliced to obtain a 1x300x6 feature tensor, which is the feature tensor of the target detection result and output output.
[0073] In related technologies, these operators are usually executed as independent GPU kernel functions, and each operator requires separate memory read-write operations and kernel launch overhead. It should be noted that the implementation of the above functions in the post-processing stage of the target detection model in related technologies has been described in detail, and the process will not be described in the embodiments of the present application.
[0074] Based on this, the embodiment of the application provides a target detection method, device, equipment and medium. In the method, if the graphics processing unit (GPU) receives an instruction for post-processing, a target feature tensor is acquired, the target feature tensor is obtained after pre-processing of a to-be-processed image; each processing operation corresponding to the target feature tensor is performed by calling a post-processing comprehensive operator, and a target detection result of the to-be-processed image is determined, wherein the post-processing comprehensive operator has data transposition, maximum reduction, threshold screening, data splicing, score collection and format conversion functions.
[0075] The target detection method provided by the embodiment of the application can be applied to a real-time image target detection scene, and in particular, in the fields of industrial detection, automatic driving, intelligent monitoring and the like requiring high-performance GPU acceleration, the inference performance of a target detection model is significantly improved through operator fusion technology.
[0076] Embodiment 1
[0077] Figure 2 A target detection process schematic diagram is provided in the embodiment of the application, and the process includes the following steps.
[0078] S201: If a graphics processing unit (GPU) receives an instruction for post-processing, a target feature tensor is acquired, the target feature tensor is obtained after pre-processing of a to-be-processed image.
[0079] The target detection method provided by the embodiment of the application is applied to an electronic device, which can be a personal computer (PC), a server or the like, and in particular, can be applied to a GPU of the electronic device.
[0080] In the embodiment of the application, the GPU can receive an instruction for post-processing in real time. The instruction can be triggered by the GPU after performing a pre-processing operation of target detection, or can be sent by a central processing unit (CPU) of the electronic device to the GPU after performing the pre-processing operation of target detection.
[0081] In the embodiment of the application, the pre-processing operation of the target detection can be implemented by a pre-processing module based on a YOLO (You Only Look Once) algorithm. The YOLO algorithm is a series of target detection algorithms. In the embodiment of the application, a YOLO-v10 target detection model is taken as an example for description.
[0082] After receiving the instruction, the target feature tensor can be obtained from a storage address carried in the instruction. Of course, the storage address can also be pre-configured and does not need to be carried in the instruction. When the instruction is received, the target feature tensor can be directly obtained from the pre-configured storage address.
[0083] In the embodiment of the present application, the target feature tensor is obtained after pre-processing of the to-be-processed image. The related techniques of how the target detection model pre-processes the received to-be-processed image have been described in detail, and the process will not be repeated here.
[0084] S202: calling the post-processing comprehensive operator to perform corresponding processing operations on the target feature tensor to determine the target detection result of the to-be-processed image, wherein the post-processing comprehensive operator has data transposition, maximum reduction, threshold screening, data splicing, score collection and format conversion functions.
[0085] In order to reduce the number of times of calling the kernel function of the GPU in the post-processing process, in the embodiment of the present application, all functions of the post-processing operation are integrated in a post-processing comprehensive operator. Specifically, the post-processing comprehensive operator can have data transposition, maximum reduction, threshold screening, data splicing, score collection and format conversion functions. It should be noted that a person skilled in the art can configure other functions for the post-processing comprehensive operator according to needs. For example, all functions in the post-processing process of the YOLO-v10 target detection model can be integrated in the post-processing comprehensive operator.
[0086] In the embodiment of the present application, a plurality of calculation operators are combined into a single operator, aiming to reduce the storage and transmission overhead of intermediate data.
[0087] The GPU can call the post-processing comprehensive operator to perform corresponding processing operations on the target feature tensor to determine the target detection result of the to-be-processed image in the post-processing process.
[0088] In the embodiment of the present application, based on the data flow graph analysis theory, a plurality of operators in the post-processing process in the related technology are systematically fused. By analyzing the data dependency relationship and the calculation characteristics between the operators, the operators with the same data access mode and calculation characteristics are combined into a single fusion operator, so as to eliminate the storage and read-write overhead of intermediate data.
[0089] In the embodiment of the present application, in the target detection process, if the GPU receives an instruction to perform post-processing, a target feature tensor obtained after pre-processing of the to-be-processed image is acquired, and a post-processing comprehensive operator is called to perform corresponding processing operations on the target feature tensor, so as to obtain the target detection result of the to-be-processed image. The post-processing comprehensive operator has the functions of data transposition, maximum reduction, threshold filtering, data splicing, score collection and format conversion. Since all the functions in the post-processing stage are included in one post-processing comprehensive operator, the GPU only needs to call the post-processing comprehensive operator once in the post-processing stage to obtain the target detection result, without the need to call multiple operators, which greatly reduces the time of starting the GPU kernel, thereby improving the efficiency of target detection.
[0090] Embodiment 2
[0091] In order to further improve the efficiency of target detection, on the basis of the above-mentioned embodiments, in the embodiment of the present application, the target feature tensor is acquired, including:
[0092] For each thread block in the GPU, first position information configured for the thread block is acquired, wherein the first position information is the position information of a sub-feature tensor required to be processed by the thread block in the target feature tensor;
[0093] The sub-feature tensor corresponding to the first position information in the target feature tensor is determined.
[0094] The post-processing comprehensive operator is called to perform corresponding processing operations on the target feature tensor to determine the target detection result of the to-be-processed image, including:
[0095] The thread block calls the post-processing comprehensive operator to perform corresponding processing operations on the sub-feature tensor to determine the detection result corresponding to the sub-feature tensor, and the detection results determined by each thread block constitute the target detection result.
[0096] In order to reasonably utilize the performance of the GPU, in the embodiment of the present application, when the target feature tensor is acquired, each thread block (Block) of the GPU can be called to synchronously perform the same processing operation to process different data sources. The thread block is a scheduling unit of parallel execution of the GPU, contains multiple thread bundles (Warp), and can access the shared memory. The thread bundle is a basic scheduling unit of execution of the GPU, usually contains 32 threads, and is executed in the SIMT (Single Instruction Multiple Thread) mode.
[0097] Since the configuration of the GPU is generally unchanged, in the embodiments of the present application, the first position information can be configured in advance for each thread block in the GPU. The first position information is the information of the position of the sub-feature tensor corresponding to the thread block in the target feature tensor.
[0098] In the embodiments of the present application, when the target feature tensor is obtained, the first position information configured for each thread block in the GPU can be obtained for the thread block. And the sub-feature tensor corresponding to the first position information in the target feature tensor is determined.
[0099] Specifically, assuming that the first position information configured for the thread block 1 is: the 0-128 bytes in the target feature tensor. Then, the feature tensor corresponding to the 0-128 bytes in the target feature tensor can be determined as the sub-feature tensor that needs to be processed by the thread block 1.
[0100] In the embodiments of the present application, when the target feature tensor is obtained, the first position information configured for each thread block in the GPU can be obtained for the thread block. And the sub-feature tensor corresponding to the first position information in the target feature tensor is determined.
[0101] That is to say, each thread block of the GPU respectively obtains a sub-feature tensor at a set position in the target feature tensor, and processes the sub-feature tensor obtained by each thread block based on the same post-processing comprehensive algorithm to obtain the detection result corresponding to the sub-feature tensor.
[0102] After the detection result corresponding to each thread block is determined, the detection result of each thread block constitutes the target detection result.
[0103] In the embodiments of the present application, according to the hardware characteristics of the GPU, the input data is divided into a plurality of independent data blocks, and each thread block is responsible for processing a data block. The thread blocks are completely parallel, have no data dependency, and maximize the parallel computing capability of the GPU.
[0104] In order to further improve the efficiency of target detection, on the basis of the above embodiments, in the embodiments of the present application, the thread block calling the post-processing comprehensive algorithm to perform corresponding processing operations on the sub-feature tensor to determine the detection result corresponding to the sub-feature tensor comprises:
[0105] If the current code segment to be executed is the code segment corresponding to the first function in the post-processing comprehensive algorithm, the sub-feature tensor is obtained from the global memory, and the sub-feature tensor is processed based on the code segment to obtain an intermediate processing result, and the intermediate processing result is stored in the shared memory.
[0106] If the current code segment to be executed is a code segment corresponding to a non-first / last function in the post-processing comprehensive operator, target data required by the code segment is obtained from the shared memory, and the target data is processed based on the code segment to obtain an intermediate processing result, and the intermediate processing result is stored to the shared memory.
[0107] If the current code segment to be executed is a code segment corresponding to a last function in the post-processing comprehensive operator, target data required by the code segment is obtained from the shared memory, and the target data is processed based on the code segment, and a processing result obtained is taken as a detection result corresponding to the sub-feature tensor.
[0108] In the related art, frequent intermediate data storage and transmission between operators lead to a large number of GPU memory read / write operations, and the memory bandwidth utilization is low, which can occupy about 40-60% of the overall processing time. In order to further improve the efficiency of target detection, in the embodiments of the present application, the high-bandwidth characteristics of the shared memory can be used to store frequently accessed intermediate data in the shared memory, thereby reducing the access times to the global memory. The shared memory is a high-speed memory in the GPU, which can be accessed by all threads in the same thread block.
[0109] In the embodiments of the present application, when each processing operation of the post-processing comprehensive operator is performed on the sub-feature tensor, it can be determined from where to obtain the data required for processing and where to store the output data obtained by running, according to whether the current executed code segment is a code segment corresponding to a first / last function.
[0110] In the embodiments of the present application, if the current executed code segment is a code segment corresponding to a first function in the post-processing comprehensive operator, the sub-feature tensor can be obtained from the global memory, and the sub-feature tensor is processed based on the code segment to obtain an intermediate processing result. Since the intermediate processing result needs to be further processed by other code segments, in the embodiments of the present application, the intermediate processing result can be stored in the shared memory.
[0111] In the embodiments of the present application, if the current code segment to be executed is a code segment corresponding to a non-first / last function in the post-processing comprehensive operator, target data required by the code segment is obtained from the shared memory, and the target data is processed based on the code segment to obtain an intermediate processing result. That is, the target data required is obtained from the shared memory when the code segment implementing the intermediate function in the post-processing comprehensive operator is run. Since the code segment corresponding to the non-first / last function will be followed by the code segment corresponding to the last function, in the embodiments of the present application, the intermediate processing result can be stored in the shared memory.
[0112] In the embodiments of the present application, if the code segment to be executed is the code segment corresponding to the last function in the post-processing comprehensive operator, the target data required by the code segment can be obtained from the shared memory, and the target data is processed based on the code segment. Since the last function is the last function in the post-processing comprehensive operator, the processing result obtained by processing can be used as the detection result corresponding to the sub-feature tensor.
[0113] In order to further improve the efficiency of target detection, on the basis of the above embodiments, in the embodiments of the present application, the threshold screening includes local threshold screening and global threshold screening.
[0114] If the target function implemented by the current code segment to be executed is local threshold screening, the processing of the target data based on the code segment to obtain the intermediate processing result includes:
[0115] The target data is screened and processed based on the code segment corresponding to the local threshold screening to obtain the intermediate processing result.
[0116] After storing the intermediate processing result in the shared memory, the method further includes:
[0117] The intermediate processing result stored in the shared memory is migrated to the global memory.
[0118] Since each thread block processes based on its own data when implementing the threshold screening function. In order to ensure the accuracy of target detection, after each thread block obtains the screening result, the screening results of all thread blocks should be integrated to determine the final threshold screening result. Therefore, in the embodiments of the present application, the threshold screening function can include local threshold screening and global threshold screening.
[0119] If the target function implemented by the current code segment to be executed is local screening function, when the target data is processed based on the code segment, the target data can be screened and processed based on the code segment corresponding to the local threshold screening to obtain the intermediate processing result.
[0120] Since the final threshold screening result needs to be determined by other thread blocks based on the screening results of each thread block, in the embodiments of the present application, the intermediate processing result stored in the shared memory can be migrated to the global memory to facilitate other thread blocks to obtain.
[0121] In order to further improve the efficiency of target detection, on the basis of the above embodiments, in the embodiments of the present application, if the target function implemented by the current code segment to be executed is global threshold screening, the processing of the target data based on the code segment to obtain the intermediate processing result includes:
[0122] performing a global threshold screening process of a set number of rounds based on the corresponding code segment of the global threshold screening, and a process of one round of the global threshold screening screening process comprises:
[0123] determining second position information corresponding to a currently performed global threshold screening round according to a pre-configured pair relationship between a global threshold screening round and the second position information, wherein the second position information is information of a position where target data needed to be processed by the thread block when implementing a global threshold screening function is stored;
[0124] obtaining the target data in the global memory according to the second position information;
[0125] performing a screening process on the target data based on the corresponding code segment of the global threshold screening, to obtain an intermediate processing result;
[0126] if the currently performed global threshold screening round is not the last round, after storing the intermediate processing result in the shared memory, the method further comprises:
[0127] migrating the intermediate processing result stored in the shared memory to the global memory.
[0128] In the embodiments of the present application, if a target function implemented by a current code segment to be executed is global threshold screening, a global threshold screening process of a set number of rounds can be performed based on the corresponding code segment of the global threshold screening when processing target data based on the code segment to obtain an intermediate processing result. The set number of rounds is determined according to the number of thread blocks included in a GPU, and the number of thread blocks included in the GPU can be pre-analyzed to determine how many global threshold screening processes of the set number of rounds are needed to be performed by the thread blocks, so that the final intermediate result is obtained by comprehensively processing the intermediate processing results of all thread blocks.
[0129] For example, in the process of global threshold screening, thread block 1 and thread block 2 perform global threshold screening to obtain R0, at the same time, thread block 3 and thread block 4 perform global threshold screening to obtain R1, thread block 5 and thread block 6 perform global threshold screening to obtain R2, thread block 7 and thread block 8 perform global threshold screening to obtain R3, and so on. Here, each thread block performs global threshold screening at the same time. Then, thread block 1, thread block 2, thread block 3 and thread block 4 perform global threshold screening according to R0 and R1 at the same time to obtain T0. At the same time, thread block 5, thread block 6, thread block 7 and thread block 8 perform global threshold screening according to R2 and R3 at the same time to obtain T1, and so on. Then, the above process is iterated until all thread blocks process the same data to obtain a comprehensive result. The number of iteration loops is the set number of rounds.
[0130] In the embodiments of the present application, the process of each global threshold screening processing can be consistent, but the data sources processed are different. In the embodiments of the present application, a correspondence relationship between different global threshold screening rounds and second position information can be preconfigured. That is, the preconfigured information of the position where the target data needed to be processed by each thread block when implementing the global threshold screening function is stored when different rounds are executed. Exemplarily, the second position information can be the information of the position where the intermediate processing result of one or more thread blocks is stored in the global memory.
[0131] In the embodiments of the present application, when the thread block performs each global threshold screening processing, the second position information corresponding to the currently executed global threshold screening round can be determined according to the preconfigured correspondence relationship between the global threshold screening round and the second position information.
[0132] Since the intermediate processing result is stored in the global memory when each thread block implements the local threshold screening function, in the embodiments of the present application, after the second position information is obtained, the target data can be obtained in the global memory according to the second position information. After the target data is obtained, the target data can be processed based on the code segment corresponding to the global threshold screening, to obtain the intermediate processing result.
[0133] In the embodiments of the present application, if the currently executed global threshold screening round is not the last round, in order to enable each thread block to obtain the target data needed to be processed subsequently, in the embodiments of the present application, after the intermediate processing result is stored in the shared memory, the intermediate processing result stored in the shared memory can be migrated to the global memory.
[0134] Exemplarily, the thread block 1 and the thread block 2 respectively calculate the Top-K result in the internal thereof, and then store the Top-K result to the global memory. It is assumed that the storage positions are H1 and H2 respectively. At this time, the thread block 1 obtains the data stored by the thread block 2 from H2 as the target data. Meanwhile, the thread block 2 obtains the data stored by the thread block 2 from H1 as the target data. Subsequently, all the thread blocks simultaneously process the intermediate processing result and the obtained target data based on the code segment corresponding to the global threshold screening, to obtain the intermediate processing result.
[0135] In order to further improve the efficiency of target detection, on the basis of the above embodiments, in the embodiments of the present application, if the target function implemented by the currently executed code segment is the next function of the global threshold screening, the target data needed by the code segment from the shared memory includes:
[0136] obtaining third position information configured for the thread block, wherein the third position information is the information of the position of the target data needed to be processed by the thread block in the intermediate processing result.
[0137] determining target data corresponding to the third position information in the intermediate processing result.
[0138] After each thread block executes the global threshold screening function, the intermediate processing data obtained by each thread block is consistent. If each thread block continues to process the same data based on the same algorithm after executing the global threshold screening function, resource waste will be caused. Therefore, in the embodiment of the present application, different target data can be obtained from different positions in the determined intermediate processing data before executing the next function of the global threshold screening. That is, after executing the global threshold screening function, the intermediate processing data is distributed to different thread blocks, and different target data is processed by each thread block based on the same code segment.
[0139] In the embodiment of the present application, if the target function implemented by the current code segment to be executed is the next function of the global threshold screening, when obtaining the target data required by the code segment from the shared memory, the third position information configured for the thread block can be obtained. The third position information is the information of the position of the target data required by the thread block in the intermediate processing result. Exemplarily, the third position information can be the 0-128 bytes, the 129-256 bytes in the intermediate processing result, or the information of the position of the intermediate processing result of thread block 1, the information of the position of the intermediate processing result of thread block 3.
[0140] After obtaining the third position information, the target data corresponding to the third position information in the intermediate processing result can be determined.
[0141] In the embodiment of the present application, a block processing strategy is adopted to divide large-scale data into data blocks suitable for the capacity of the shared memory. Each thread block processes a data block, and all intermediate calculations are completed in the shared memory, thereby significantly reducing the number of global memory access times.
[0142] In the embodiment of the present application, the shared memory can be initialized as negative infinity, so as to ensure that any real score will be larger.
[0143] In the parallel processing stage, each thread block is responsible for processing a specific spatial position, and multiple thread blocks are processed in parallel.
[0144] The thread block is a parallel task unit written by the developer and is finally executed by the computing resource in the compute unit (CU). In the execution process, first, CU internal sorting is performed: TopK is selected in each CU, and the result can be stored in the shared memory or the global memory; then, cross-CU sorting is performed: the final TopK is selected from the results of all CUs.
[0145] In the embodiments of the present application, the __sync_block_cluster_threads() function can be used to ensure synchronization of all CUs. The __sync_block_cluster_threads() is a thread block cluster synchronization function, which is used to coordinate shared memory access and communication among multiple thread blocks.
[0146] In the embodiments of the present application, through memory access mode optimization, the memory access within the thread bundle is ensured to have continuity, and the memory merging efficiency is improved.
[0147] In the embodiments of the present application, a multi-level parallelization strategy is adopted: data sharding parallel processing is implemented at the thread block level, cooperative computing is implemented at the thread bundle level, and fine-grained operations are implemented at the single thread level. Through this hierarchical parallel model, the utilization rate of GPU hardware resources is maximized.
[0148] In the embodiments of the present application, the memory access mode is also optimized. Through the designed data layout and access mode, the continuity of memory access within the thread bundle is ensured, the memory merging efficiency is improved, and the problem of memory bank conflict is avoided, the shared memory bandwidth utilization rate is maximized. At the same time, the vectorized loading instruction is used to improve the data amount of single memory transmission. Inside the thread block, the thread bundle level cooperative computing strategy is adopted. Through the carefully designed thread bundle synchronization mechanism, the data consistency and the correctness of the calculation are ensured, and the utilization rate of the computing resources is maximized.
[0149] Embodiment 3:
[0150] In order to further improve the efficiency of target detection, on the basis of the above embodiments, in the embodiments of the present application, the threshold screening function is realized based on a double tuning sorting algorithm.
[0151] The sorting algorithm used by the traditional Top-K selection operator has limited parallelization degree on the GPU, and cannot fully utilize the large-scale parallel computing capability of the GPU. Since the Bitonic sorting algorithm has natural parallel characteristics, it is very suitable for the large-scale parallel computing architecture of the GPU. Therefore, in the embodiments of the present application, the Bitonic sorting algorithm can be used to realize the threshold screening function. That is, the Bitonic sorting algorithm is used as the core algorithm of the Top-K selection. The Bitonic sorting algorithm can complete sorting within the time complexity of O (N log N) through constructing a Bitonic sequence and performing recursive sorting, and has good GPU parallelization efficiency.
[0152] Embodiment 4:
[0153] The target detection process will be described below, Figure 3 Figure 3 This is a schematic diagram of another target detection process provided in an embodiment of this application, as shown below. Figure 3 As shown, during object detection, the raw feature map data output by the YOLO model is acquired. The GPU calls the post-processing synthesis operator to process the feature map data and obtain the final detection result. This final detection result may include bounding box coordinates, confidence scores, and category information. In this embodiment, the post-processing synthesis operator yolov10PostProcessBackend() can be called only once. This post-processing synthesis operator is a single GPU kernel function. The post-processing synthesis operator includes: code segments corresponding to the maximum value reduction and Top-K selection operators, which can be represented as reduceMaxTopKFusedKernel; code segments corresponding to the maximum value reduction and Top-K selection operators, which can be represented as gatherScoreTopKFusedKernel; code segments corresponding to the score collection and data concatenation operators, which can be represented as gatherBoxConcatFusedKernel; and code segments corresponding to the data transpose and type conversion operators, which can be represented as transposeAndTransDataTypeFusedKernel.
[0154] In this embodiment of the application, the intermediate result data of each code segment is stored in shared memory by utilizing the characteristics of high-speed data caching in shared memory.
[0155] This application implements a high-performance operator fusion method for image object detection, particularly suitable for the post-processing stage of real-time object detection models such as YOLO-v10. This method, through an innovative operator fusion architecture, merges multiple traditionally separately executed GPU operators (including ReduceMax, TopK selection, Gather, Transpose, etc.) into a single kernel function, significantly reducing GPU memory read / write operations and kernel startup overhead. Core technologies include: an efficient parallel TopK selection algorithm based on a Bitonic sorting network, a multi-stage data reuse strategy, and cross-operator memory access optimization. Specifically, through operator fusion, the kernel startup overhead is reduced from 10+ times to 1 time; by utilizing operator fusion and shared memory, the number of GPU memory accesses is reduced, improving memory bandwidth utilization efficiency; based on the Bitonic sorting strategy and in conjunction with the GPU's Single Instruction Multiple Threads (SIMT) hardware architecture, an efficient Top-K algorithm is implemented, further accelerating operator performance.
[0156] Example 4:
[0157] Based on the same inventive concept, embodiments of this application provide a target detection device.Figure 4 A target detection device structure schematic diagram is provided for an embodiment of the present application. The device comprises:
[0158] An acquisition module 401 is configured to acquire a target feature tensor if the GPU receives an instruction to perform post-processing, wherein the target feature tensor is obtained after pre-processing of a to-be-processed image.
[0159] A detection module 402 is configured to call a post-processing comprehensive operator to perform corresponding processing operations on the target feature tensor, and determine a target detection result of the to-be-processed image, wherein the post-processing comprehensive operator has data transposition, maximum reduction, threshold screening, data splicing, score collection, and format conversion functions.
[0160] In a possible implementation, the acquisition module 401 is specifically configured to acquire, for each thread block in the GPU, first position information configured for the thread block, wherein the first position information is information about a position of a sub-feature tensor required to be processed by the thread block in the target feature tensor; and determine the sub-feature tensor corresponding to the first position information in the target feature tensor.
[0161] The detection module 402 is specifically configured to call the post-processing comprehensive operator to perform corresponding processing operations on the sub-feature tensor, determine a detection result corresponding to the sub-feature tensor, and determine the detection result of each thread block to constitute the target detection result.
[0162] In a possible implementation, the detection module 402 is specifically configured to, if a code segment to be currently executed is a code segment corresponding to a first function in the post-processing comprehensive operator, acquire the sub-feature tensor from a global memory, process the sub-feature tensor based on the code segment to obtain an intermediate processing result, and store the intermediate processing result in a shared memory.
[0163] If a code segment to be currently executed is a code segment corresponding to a function other than the first and last functions in the post-processing comprehensive operator, acquire target data required by the code segment from the shared memory, process the target data based on the code segment to obtain an intermediate processing result, and store the intermediate processing result in the shared memory.
[0164] If a code segment to be currently executed is a code segment corresponding to a last function in the post-processing comprehensive operator, acquire target data required by the code segment from the shared memory, process the target data based on the code segment, and take a processing result obtained by the processing as a detection result corresponding to the sub-feature tensor.
[0165] In a possible implementation, the threshold screening includes local threshold screening and global threshold screening; the detection module 402 is specifically configured to perform screening processing on the target data based on a code segment corresponding to the local threshold screening, to obtain an intermediate processing result.
[0166] The detection module 402 is further configured to migrate the intermediate processing result stored in the shared memory to the global memory.
[0167] In a possible implementation, if a target function implemented by a code segment to be currently executed is global threshold screening, the detection module 402 is specifically configured to perform global threshold screening processing of a set of rounds based on a code segment corresponding to the global threshold screening, and a process of each round of global threshold screening processing includes:
[0168] According to a preconfigured correspondence between a global threshold screening round and second position information, second position information corresponding to a currently executed global threshold screening round is determined, where the second position information is information of a position where target data to be processed by the thread block when implementing the global threshold screening function is stored; target data is acquired in the global memory according to the second position information; the target data is screened based on a code segment corresponding to the global threshold screening, to obtain an intermediate processing result; if the currently executed global threshold screening round is not the last round, after the intermediate processing result is stored in the shared memory, the method further includes migrating the intermediate processing result stored in the shared memory to the global memory.
[0169] In a possible implementation, if a target function implemented by a code segment to be currently executed is a next function of the global threshold screening, the detection module 402 is specifically configured to acquire third position information configured for the thread block, where the third position information is information of a position of target data to be processed by the thread block in the intermediate processing result; and target data corresponding to the third position information in the intermediate processing result is determined.
[0170] In a possible implementation, the threshold screening function is implemented based on a double sorting algorithm.
[0171] Embodiment 5
[0172] Based on the same inventive concept, the embodiment of the present application provides an electronic device, which can implement the steps of the target detection method discussed above, Figure 5 A structural schematic diagram of an electronic device provided by the embodiment of the present application is as follows, Figure 5As shown, it comprises a processor 501, a communication interface 502, a memory 503 and a communication bus 504, wherein the processor 501, the communication interface 502 and the memory 503 complete mutual communication through the communication bus 504;
[0173] The memory 503 stores a computer program, which, when executed by the processor 501, causes the processor 501 to perform the following steps:
[0174] The GPU acquires a target feature tensor if it receives an instruction to perform post-processing, wherein the target feature tensor is obtained after pre-processing of the image to be processed;
[0175] The post-processing comprehensive operator is called to perform corresponding processing operations on the target feature tensor, and a target detection result of the image to be processed is determined, wherein the post-processing comprehensive operator has data transposition, maximum reduction, threshold filtering, data splicing, score collection and format conversion functions.
[0176] In a possible implementation, the target feature tensor is acquired by:
[0177] For each thread block in the GPU, first position information configured for the thread block is acquired, wherein the first position information is information of a position of a sub-feature tensor required to be processed by the thread block in the target feature tensor;
[0178] The sub-feature tensor corresponding to the first position information in the target feature tensor is determined.
[0179] The post-processing comprehensive operator is called to perform corresponding processing operations on the target feature tensor, and a target detection result of the image to be processed is determined, comprising:
[0180] The thread block calls the post-processing comprehensive operator to perform corresponding processing operations on the sub-feature tensor, and determines a detection result corresponding to the sub-feature tensor, and the detection results determined by each thread block constitute the target detection result.
[0181] In a possible implementation, the thread block calls the post-processing comprehensive operator to perform corresponding processing operations on the sub-feature tensor, and determines a detection result corresponding to the sub-feature tensor, comprising:
[0182] If the code segment to be executed currently is a code segment corresponding to a first function in the post-processing comprehensive operator, the sub-feature tensor is acquired from the global memory, and the sub-feature tensor is processed based on the code segment to obtain an intermediate processing result, and the intermediate processing result is stored in the shared memory;
[0183] If the current code segment to be executed is a code segment corresponding to a non-first or non-last function in the post-processing comprehensive operator, target data required by the code segment is obtained from the shared memory, and the target data is processed based on the code segment to obtain an intermediate processing result, and the intermediate processing result is stored in the shared memory.
[0184] If the current code segment to be executed is a code segment corresponding to a last function in the post-processing comprehensive operator, target data required by the code segment is obtained from the shared memory, and the target data is processed based on the code segment, and a processing result obtained is taken as a detection result corresponding to the sub-feature tensor.
[0185] In a possible implementation, the threshold screening includes local threshold screening and global threshold screening.
[0186] If a target function implemented by the current code segment to be executed is local threshold screening, the processing of the target data based on the code segment to obtain an intermediate processing result includes:
[0187] Performing screening processing on the target data based on a code segment corresponding to the local threshold screening to obtain an intermediate processing result.
[0188] After the intermediate processing result is stored in the shared memory, the method further includes:
[0189] Migrating the intermediate processing result stored in the shared memory to the global memory.
[0190] In a possible implementation, if a target function implemented by the current code segment to be executed is global threshold screening, the processing of the target data based on the code segment to obtain an intermediate processing result includes:
[0191] Performing a global threshold screening processing of a set number of rounds based on a code segment corresponding to the global threshold screening, and a process of each global threshold screening processing includes:
[0192] Determining second position information corresponding to a currently executed global threshold screening round according to a preconfigured correspondence between a global threshold screening round and the second position information, wherein the second position information is information of a position where target data required by the thread block when implementing the global threshold screening function is stored.
[0193] Obtaining the target data from the global memory according to the second position information.
[0194] Performing screening processing on the target data based on the code segment corresponding to the global threshold screening to obtain an intermediate processing result.
[0195] If the current global threshold filtering round is not the last round, after storing the intermediate processing result in the shared memory, the method further includes:
[0196] The intermediate processing result stored in the shared memory is migrated to the global memory.
[0197] In one possible implementation, if the target function implemented by the currently executed code segment is the next function of the global threshold filtering, the step of obtaining the target data required by the code segment from the shared memory includes:
[0198] Obtain the third position information configured for the thread block, wherein the third position information is the position information of the target data to be processed by the thread block in the intermediate processing result;
[0199] Determine the target data corresponding to the third location information in the intermediate processing result.
[0200] In one possible implementation, the threshold filtering function is based on a bitonic sorting algorithm.
[0201] Since the principle of the above-mentioned electronic device in solving the problem is similar to that of the target detection method, the implementation of the above-mentioned electronic device can be found in the embodiments of the method, and repeated parts will not be described again.
[0202] The communication bus mentioned in the aforementioned electronic device can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. This communication bus can be divided into address bus, data bus, control bus, etc. For ease of illustration, only one thick line is used in the figure, but this does not indicate that there is only one bus or one type of bus. Communication interface 502 is used for communication between the aforementioned electronic device and other devices. The memory can include random access memory (RAM) or non-volatile memory (NVM), such as at least one disk storage device. Optionally, the memory can also be at least one storage device located remotely from the aforementioned processor.
[0203] The processor can be a general processor, including a central processing unit, a network processor (NP), etc.; can also be a digital signal processor (DSP), an application specific integrated circuit, a field programmable gate array or other programmable logic device, a discrete gate or transistor logic, a discrete hardware component, etc.
[0204] Embodiment 6:
[0205] Based on the same inventive concept, the embodiment of the present application further provides a computer readable storage medium, which stores a computer program executable by a processor, and when the program is run on the processor, the processor executes the following steps:
[0206] The graphics processing unit (GPU) receives an instruction to perform post-processing, and obtains a target feature tensor, which is obtained after pre-processing of the image to be processed;
[0207] The post-processing comprehensive operator is called to perform corresponding processing operations on the target feature tensor, and a target detection result of the image to be processed is determined, wherein the post-processing comprehensive operator has data transposition, maximum reduction, threshold filtering, data splicing, score collection and format conversion functions.
[0208] In a possible implementation, the obtaining of the target feature tensor comprises:
[0209] For each thread block in the GPU, first position information configured for the thread block is obtained, wherein the first position information is information of a position of a sub-feature tensor required to be processed by the thread block in the target feature tensor;
[0210] The sub-feature tensor corresponding to the first position information in the target feature tensor is determined.
[0211] The post-processing comprehensive operator is called to perform corresponding processing operations on the target feature tensor, and a target detection result of the image to be processed is determined, wherein the post-processing comprehensive operator has data transposition, maximum reduction, threshold filtering, data splicing, score collection and format conversion functions.
[0212] The thread block calls the post-processing comprehensive operator to perform corresponding processing operations on the sub-feature tensor, and a detection result corresponding to the sub-feature tensor is determined, and the detection results determined by each thread block constitute the target detection result.
[0213] In a possible implementation, the calling of the post-processing comprehensive operator to perform corresponding processing operations on the sub-feature tensor to determine the detection result corresponding to the sub-feature tensor comprises:
[0214] If the current code segment to be executed is the code segment corresponding to the first function in the post-processing comprehensive operator, the sub-feature tensor is obtained from the global memory, and the sub-feature tensor is processed based on the code segment to obtain an intermediate processing result, and the intermediate processing result is stored in the shared memory.
[0215] If the current code segment to be executed is the code segment corresponding to the non-first and non-last function in the post-processing comprehensive operator, the target data required by the code segment is obtained from the shared memory, and the target data is processed based on the code segment to obtain an intermediate processing result, and the intermediate processing result is stored in the shared memory.
[0216] If the current code segment to be executed is the code segment corresponding to the last function in the post-processing comprehensive operator, the target data required by the code segment is obtained from the shared memory, and the target data is processed based on the code segment, and the obtained processing result is taken as the detection result corresponding to the sub-feature tensor.
[0217] In a possible implementation, the threshold screening includes local threshold screening and global threshold screening.
[0218] If the target function implemented by the current code segment to be executed is local threshold screening, the processing of the target data based on the code segment to obtain an intermediate processing result includes:
[0219] Performing screening processing on the target data based on the code segment corresponding to the local threshold screening to obtain an intermediate processing result;
[0220] After storing the intermediate processing result in the shared memory, the method further includes:
[0221] Migrating the intermediate processing result stored in the shared memory to the global memory.
[0222] In a possible implementation, if the target function implemented by the current code segment to be executed is global threshold screening, the processing of the target data based on the code segment to obtain an intermediate processing result includes:
[0223] Performing a global threshold screening processing of a set number of rounds based on the code segment corresponding to the global threshold screening, and the process of each global threshold screening processing includes:
[0224] Determining the second position information corresponding to the currently executed global threshold screening round according to a preconfigured relationship between the global threshold screening round and the second position information, wherein the second position information is the information of the position where the target data processed by the thread block when implementing the global threshold screening function is stored.
[0225] acquire target data in the global memory according to the second position information;
[0226] perform filtering processing on the target data according to the corresponding code segment based on the global threshold filtering, to obtain an intermediate processing result;
[0227] If the current executed global threshold filtering round is not the last round, after the intermediate processing result is stored in the shared memory, the method further includes:
[0228] migrate the intermediate processing result stored in the shared memory to the global memory.
[0229] In a possible implementation, if a target function implemented by a code segment to be executed currently is a next function of the global threshold filtering, the target data required by the code segment for acquiring from the shared memory includes:
[0230] acquire third position information configured for the thread block, where the third position information is information about a position of target data required by the thread block in the intermediate processing result;
[0231] determine the target data corresponding to the third position information in the intermediate processing result.
[0232] In a possible implementation, the threshold filtering function is implemented based on a double sorting algorithm.
[0233] Since the principle of the above computer readable storage medium for solving the problem is similar to that of the target detection method, the implementation of the above computer readable storage medium can refer to the implementation of the method, and the repeated parts will not be described herein.
[0234] Embodiment 7
[0235] Based on the same inventive concept, the embodiments of the present application further provide a computer program product, which includes computer program code. When the computer program code runs on a computer, the computer program code causes the computer to perform any of the target detection methods discussed above. Since the principle of the above computer program product for solving the problem is similar to that of the target detection method, the implementation of the above computer program product can refer to the implementation of the method, and the repeated parts will not be described herein.
[0236] Those skilled in the art will appreciate that embodiments of the application can be devised for a method, a system, or a computer program product. Accordingly, the present application can be embodied in the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present application can take the form of a computer program product on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROMs, optical storage devices, and the like) embodying computer readable program code.
[0237] The present application is described in reference to the flow diagrams and / or block diagrams of the methods, apparatus (systems) and computer program products according to this application. It will be understood that each block of the flow diagrams and / or block diagrams, and combinations of blocks in the flow diagrams and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flow diagrams and / or block diagrams block or blocks. Figure 1 one or more functions specified in the flow diagram and / or block diagram block or blocks. Figure 1 one or more functions specified in the flow diagram and / or block diagram block or blocks.
[0238] These computer program instructions can also be stored in a computer- readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instructions which implement the flow diagram and / or block diagram block or blocks. Figure 1 one or more functions specified in the flow diagram and / or block diagram block or blocks. Figure 1 one or more functions specified in the flow diagram and / or block diagram block or blocks.
[0239] These computer program instructions can also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the flow diagram and / or block diagram block or blocks. Figure 1 one or more functions specified in the flow diagram and / or block diagram block or blocks. Figure 1 one or more functions specified in the flow diagram and / or block diagram block or blocks.
[0240] Obviously, numerous modifications and variations of the present application are possible in light of the above teachings. It is therefore to be understood that within the scope of the application, the application can be practiced otherwise than as specifically described. Since modifications and variations of the application can be made without departing from its spirit and scope, it is intended that all such modifications and variations come within the scope of the claims of the application and their equivalents.
Claims
1. A target detection method, characterized in that, The method includes: If the graphics processing unit (GPU) receives an instruction to perform post-processing; For each thread block in the GPU, first position information configured for that thread block is obtained, wherein the first position information is the position information of the sub-feature tensor to be processed by that thread block in the target feature tensor, wherein the target feature tensor is obtained after preprocessing the image to be processed; Determine the sub-feature tensor corresponding to the first position information in the target feature tensor; The thread block calls the post-processing synthesis operator to perform each corresponding processing operation on the sub-feature tensor, and determines the detection result corresponding to the sub-feature tensor. The detection result determined by each thread block constitutes the target detection result. The post-processing synthesis operator has the functions of data transposition, maximum value reduction, threshold filtering, data concatenation, score collection and format conversion.
2. The method according to claim 1, characterized in that, The thread block calls the post-processing synthesis operator to perform each corresponding processing operation on the sub-feature tensor to determine the detection result corresponding to the sub-feature tensor, including: If the code segment to be executed is the code segment corresponding to the first function in the post-processing synthesis operator, the sub-feature tensor is obtained from the global memory, and the sub-feature tensor is processed based on the code segment to obtain the intermediate processing result, and the intermediate processing result is stored in the shared memory; If the code segment to be executed is a code segment that is not the first or last function in the post-processing synthesis operator, the target data required by the code segment is obtained from the shared memory, and the target data is processed based on the code segment to obtain intermediate processing results, and the intermediate processing results are stored in the shared memory. If the code segment to be executed is the code segment corresponding to the last function in the post-processing synthesis operator, the target data required by the code segment is obtained from the shared memory, and the target data is processed based on the code segment. The processing result is used as the detection result corresponding to the sub-feature tensor.
3. The method according to claim 2, characterized in that, The threshold filtering includes local threshold filtering and global threshold filtering; If the target function implemented by the currently executed code segment is local threshold filtering, the step of processing the target data based on the code segment to obtain intermediate processing results includes: The target data is filtered based on the code segment corresponding to the local threshold filtering to obtain intermediate processing results; After storing the intermediate processing result in the shared memory, the method further includes: The intermediate processing result stored in the shared memory is migrated to the global memory.
4. The method according to claim 3, characterized in that, If the target function implemented by the code segment to be executed is global threshold filtering, the step of processing the target data based on the code segment to obtain intermediate processing results includes: Based on the code segment corresponding to the global threshold filtering, a set number of rounds of global threshold filtering are executed. The process of any one round of global threshold filtering includes: Based on the pre-configured pairing relationship between the global threshold filtering rounds and the second position information, the second position information corresponding to the currently executed global threshold filtering round is determined, wherein the second position information is the information of the location where the target data to be processed by the thread block is stored when implementing the global threshold filtering function; The target data is obtained from the global memory based on the second location information; The target data is filtered based on the code segment corresponding to the global threshold filtering to obtain intermediate processing results; If the current global threshold filtering round is not the last round, after storing the intermediate processing result in the shared memory, the method further includes: The intermediate processing result stored in the shared memory is migrated to the global memory.
5. The method according to claim 4, characterized in that, If the target function implemented by the currently executed code segment is the next function of the global threshold filtering, the step of obtaining the target data required by the code segment from the shared memory includes: Obtain the third position information configured for the thread block, wherein the third position information is the position information of the target data to be processed by the thread block in the intermediate processing result; Determine the target data corresponding to the third location information in the intermediate processing result.
6. The method according to claim 1, characterized in that, The threshold filtering function is implemented based on the bitonic sorting algorithm.
7. A target detection device, characterized in that, The device includes: The acquisition module is configured to, when a graphics processing unit (GPU) receives a post-processing instruction, acquire first position information configured for each thread block in the GPU, wherein the first position information is the position information of the sub-feature tensor to be processed by the thread block in the target feature tensor, wherein the target feature tensor is obtained after pre-processing the image to be processed; and determine the sub-feature tensor corresponding to the first position information in the target feature tensor. The detection module is used by the thread block to call the post-processing synthesis operator to perform each corresponding processing operation on the sub-feature tensor, and determine the detection result corresponding to the sub-feature tensor. The detection result determined by each thread block constitutes the target detection result. The post-processing synthesis operator has the functions of data transpose, maximum value reduction, threshold filtering, data concatenation, score collection and format conversion.
8. An electronic device, characterized in that, The electronic device includes a processor that executes a computer program stored in a memory to implement the steps of the target detection method as described in any one of claims 1-6.
9. A computer-readable storage medium, characterized in that, It stores a computer program that, when executed by a processor, implements the steps of the target detection method as described in any one of claims 1-6.
Citation Information
Patent Citations
Calculation device for performing target detection and calculation method for target detection
CN114330539A