Model processing method, device, computer equipment, storage medium and program product

By dynamically allocating the number of tensor computing cores to process training images in parallel, the problem of low processing efficiency of machine learning models is solved and faster training time is achieved.

CN117993443BActive Publication Date: 2024-08-30TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202410397189.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-04-03
Publication Date
2024-08-30
Estimated Expiration
2044-04-03

AI Technical Summary

Technical Problem

During the processing of the machine learning model, due to the large number of sample images in the same batch, the processing time is long and the overall processing efficiency is affected.

Method used

By determining the number of training images in the current batch, dynamically allocate the number of tensor computing cores, and process multiple training images in parallel to improve model training efficiency.

Benefits of technology

It effectively improves the processing efficiency of machine learning models, makes full use of GPU hardware resources, and shortens training time.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117993443B
    Figure CN117993443B
Patent Text Reader

Abstract

The present application relates to a model processing method, apparatus, computer equipment, storage medium and computer program product. The method comprises: determining a first number of a current batch of multiple training images input to a target model to be trained; determining a second number of tensor computing cores required to process the current batch of multiple training images according to the first number of the current batch of multiple training images; calling the second number of tensor computing cores to process the multiple training images in parallel to train the target model. The use of this method can improve the target model processing efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a model processing method, apparatus, computer equipment, storage medium and computer program product. Background Art

[0002] With the development of autonomous driving technology, machine learning models such as bevformer (Birds Eye View + transformer, autonomous driving perception algorithm) models play an important role in vehicle driving planning, vehicle behavior control and other operations.

[0003] At present, in the process of processing machine learning models, multiple batches of sample images are processed to carry out the training of machine learning models, and then the trained machine learning models can be applied to various practical tasks, such as assisted driving tasks or obstacle detection tasks.

[0004] However, in the process of processing multiple sample images of any batch, due to the large number of sample images in the same batch, the processing time is long, which affects the overall processing efficiency of the machine learning model. Summary of the invention

[0005] Based on this, it is necessary to provide a model processing method, device, computer equipment, computer-readable storage medium and computer program product that can improve the processing efficiency of machine learning models in response to the above-mentioned technical problems.

[0006] In a first aspect, the present application provides a model processing method. The method comprises:

[0007] Determining a first number of a current batch of multiple training images to be input to a target model to be trained;

[0008] Determining a second number of tensor computing cores required to process the current batch of training images based on the first number of the current batch of training images;

[0009] The second number of tensor computing cores are called to process the multiple training images in parallel to train the target model.

[0010] In a second aspect, the present application also provides a model processing device. The device comprises:

[0011] A determination module, configured to determine a first number of a current batch of multiple training images to be input to a target model to be trained;

[0012] The determination module is further used to determine a second number of tensor computing cores required to process the plurality of training images in the current batch according to the first number of the plurality of training images in the current batch;

[0013] A processing module is used to call the second number of tensor computing cores to process the multiple training images in parallel to train the target model.

[0014] In a third aspect, the present application further provides a computer device, wherein the computer device comprises a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the steps of the above-mentioned model processing method are implemented.

[0015] In a fourth aspect, the present application further provides a computer-readable storage medium having a computer program stored thereon, and the computer program implements the steps of the above-mentioned model processing method when executed by a processor.

[0016] In a fifth aspect, the present application also provides a computer program product, which includes a computer program, and when the computer program is executed by a processor, the steps of the above-mentioned model processing method are implemented.

[0017] The above-mentioned model processing method, apparatus, computer equipment, storage medium and computer program product determine the first number of the current batch of multiple training images input to the target model to be trained; and then the second number of tensor computing cores required to process the current batch of multiple training images can be determined based on the first number, so as to fully call the second number of tensor computing cores to process the multiple training images in parallel to train the target model. The second number of tensor computing cores required is determined by the first number of the current batch of multiple training images, so that the second number of tensor computing cores can be called to carry out parallel processing for multiple training images, which makes full use of the hardware resources of the GPU and can effectively improve the processing efficiency of the target model. BRIEF DESCRIPTION OF THE DRAWINGS

[0018] Figure 1 An application environment diagram of a model processing method in an embodiment;

[0019] Figure 2 A schematic diagram of a flow chart of a model processing method in one embodiment;

[0020] Figure 3 is a flowchart of a model processing method in one embodiment;

[0021] Figure 4 is a schematic diagram of the attention mechanism layer during the forward propagation process in one embodiment;

[0022] Figure 5 A schematic diagram of an attention mechanism layer during back propagation in one embodiment;

[0023] Figure 6 is a flowchart of a model processing method in another embodiment;

[0024] Figure 7 Schematic diagram of the feature extraction process of the convolution layer in traditional technology;

[0025] Figure 8 A schematic diagram of a feature extraction process of a convolutional layer during forward propagation in one embodiment;

[0026] Fig. 9 A schematic diagram of a convolutional layer expansion feature extraction process during back propagation in one embodiment;

[0027] Fig.10 is a structural block diagram of a model processing device in an embodiment;

[0028] Fig.11 FIG. 4 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION

[0029] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.

[0030] The model processing method provided in the embodiment of the present application can be applied to Figure 1 In the application environment shown. Among them, the terminal 102 communicates with the server 104 through the network. The data storage system can store the data that the server 104 needs to process. The data storage system can be integrated on the server 104, or it can be placed on the cloud or other network servers. The terminal 102 and the server 104 can be used alone to execute the model processing method in this application, and the terminal 102 and the server 104 can be used together to execute the model processing method in this application.

[0031] Taking the terminal 102 and the server 104 cooperating to execute the present application as an example, when the target model is processed, the terminal 102 can obtain multiple camera images of the vehicle's surrounding environment and transmit the multiple camera images to the server 104 as training images. The server 104 performs batch processing based on the obtained multiple training images to obtain multiple batches of training images, each batch including multiple training images. For any batch of multiple training images, they can be used as multiple training images of the current batch and input into the target model to be trained. Specifically, the server 104 can determine the first number of multiple training images of the current batch input into the target model to be trained; according to the first number of multiple training images of the current batch, determine the second number of tensor computing cores required to process the multiple training images of the current batch; call the second number of tensor computing cores to process the multiple training images in parallel to train the target model. Among them, each camera image can be an image of the vehicle's surrounding environment obtained by a multi-view camera set on the vehicle. The trained target model can be used in an autonomous driving scenario to complete related tasks, such as lane line detection, obstacle detection, etc.

[0032] Among them, the terminal 102 can be, but is not limited to, various desktop computers, laptops, smart phones, tablet computers, Internet of Things devices, portable wearable devices, intelligent voice interaction devices, smart home appliances, vehicle-mounted terminals, aircraft, etc. The Internet of Things devices can be smart speakers, smart TVs, smart air conditioners, smart vehicle-mounted devices, etc. Portable wearable devices can be smart watches, smart bracelets, head-mounted devices, etc. The server 104 can be implemented with an independent server or a server cluster consisting of multiple servers. The server can be implemented with an independent server or a server cluster consisting of multiple servers, and can also be a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms. The terminal and the server can be directly or indirectly connected via wired or wireless communication.

[0033] The embodiments of the present application can be applied to various scenarios, including but not limited to cloud technology, artificial intelligence, smart transportation, assisted driving, etc.

[0034] Artificial Intelligence (AI) is a theory, method, technology and application system that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results. In other words, artificial intelligence is a comprehensive technology in computer science that attempts to understand the essence of intelligence and produce a new intelligent machine that can respond in a similar way to human intelligence. Artificial intelligence is to study the design principles and implementation methods of various intelligent machines so that machines have the functions of perception, reasoning and decision-making.

[0035] Artificial intelligence technology is a comprehensive discipline that covers a wide range of fields, including both hardware-level and software-level technologies. The basic technologies of artificial intelligence generally include sensors, dedicated artificial intelligence chips, cloud computing, distributed storage, big data processing technology, operation / interaction systems, mechatronics and other technologies. Artificial intelligence software technology mainly includes computer vision technology, speech processing technology, natural language processing technology, and machine learning / deep learning.

[0036] At present, in the 3D (three-dimensional) perception task of autonomous driving, target models such as the bevformer model are the mainstream model frameworks. During the processing of the target model, various operators involved in the calculation will be called multiple times. Analysis of the source code shows that various operators are called cyclically along the input batch dimension. For example, for the DCN (Deformable Convolution Network) calculation in the target model, when the number of training images in the current batch is 24, the operator will be called 24 times in one DCN calculation, making the processing efficiency of the target model low. Existing data shows that backbone_fpn (feature extraction process) takes 49ms (milliseconds), while DCN takes about 13ms, accounting for a large proportion of the time.

[0037] Therefore, in order to solve the problem of high time consumption of DCN, the present application proposes a model processing method, which performs feature extraction on multiple training images in parallel by calling the second number of tensor computing cores required for multiple training images to improve the processing efficiency of the target model.

[0038] The following is a detailed introduction to the model processing method of this application:

[0039] In an exemplary embodiment, Figure 2 As shown, a model processing method is provided, which is applied to a GPU (Graphics Processing Unit) in a computer device (the computer device can be specifically Figure 1 The terminal 102 or server 104 in the example is used for explanation. Among them, when the GPU is in operation, when it comes to the training of the target model, the target model may call the calculation function, and execute the corresponding logic based on the called calculation function to complete the training of the target model. In the training process of the target model, a variety of different processing logics are involved. Accordingly, the calculation function may specifically include various operators such as modulated_deformable_col2im_gpu_kernel (matrix to image operator), modulated_deformable_col2im_coord_gpu_kernel (matrix to image operator), and modulated_deformable_im2col_gpu_kernel (image to matrix operator). The model processing method includes the following steps:

[0040] Step 202 , determining a first number of a current batch of multiple training images to be input to a target model to be trained.

[0041] The training images are sample images used for model training. The first number refers to the number of training images in the current batch.

[0042] The target model is a neural network model built based on an artificial intelligence algorithm, that is, a machine learning model. When constructing a target model, it can be constructed based on multiple types of algorithms such as supervised learning algorithms and unsupervised learning algorithms. The target model is a machine learning model related to specific business needs. For example, the target model in this application can specifically be an image processing model. In the field of intelligent driving, the target model of this application can be a target detection model. Among them, when constructing a target model based on a supervised learning algorithm, it can be constructed based on various target detection algorithms such as BEVFormer (BEV+transformer, autonomous driving perception algorithm), DETR (DEtection Transformer, end-to-end target detection network), Faster-RCNN (Faster Regionswith CNN features, fast target detection algorithm), YOLO (You Only Look Once, a target detection algorithm), etc.

[0043] Specifically, in the training phase of the target model, in any batch training process, the calculation function can determine the first number of the multiple training images of the current batch. The multiple training images of the current batch can be input to the target model by a computer device with image processing function such as a terminal device or a server. When the target model receives the training image, it can process the training image based on the calculation function by calling the calculation function.

[0044] In some embodiments, the first number of the current batch of multiple training images input to the target model may be pre-set, for example, usually determined in combination with hardware resources of the computer device such as video memory capacity, video memory bandwidth, core frequency, CUDA (Compute Unified Device Architecture) core number and floating point performance.

[0045] In some embodiments, the first number of the plurality of training images in the current batch is determined according to the video memory size of the graphics processor. The video memory size can determine the amount of data that the graphics processor can load and process, so determining the first number of training images in each batch by the video memory size can improve the performance of the GPU in the target model processing process.

[0046] In some embodiments, the target model may be a target detection model or other image processing models. The target detection model may be used in autonomous driving tasks, such as lane detection, obstacle detection, etc. Among them, the target model may be a network structure built based on BEVFormer. The target model may be composed of multiple network layers, and the network layer may include a convolution layer, an attention mechanism layer, a feedforward network layer, a task layer, etc. The convolution layer may be used to extract features of the training image input to the target model to obtain image features. The attention mechanism layer may be used to perform an attention mechanism on image features, for example: Spatial cross-attention, Tenporal self-attention, Global cross-attention, Deformable cross-attention, to obtain BEV (Birds Eye View) features. The task layer may perform prediction or classification based on the extracted BEV features to obtain the final prediction result.

[0047] In some embodiments, the convolution layer may be composed of network structures such as DCN (Deformable Convolution Network), transposed (de)convolution, dilated convolutions, etc. For example, the convolution layer may be composed of at least one DCN, and each DCN is implemented based on a convolution operator, thereby realizing feature extraction of image features through multiple DCNs.

[0048] In some embodiments, the training images may be images of N perspectives acquired by N image acquisition devices, where N is greater than or equal to 1. The image acquisition device may be a camera, and the N image acquisition devices may be deployed at different positions of the vehicle, with any image acquisition device corresponding to one perspective.

[0049] In other embodiments, the training images may also be directly obtained from a preset database, which is not limited in the embodiments of the present application.

[0050] In a specific application, before inputting the training images into the target model, the computer device can obtain multiple training images, and perform batch processing on each training image to obtain multiple batches of training images, each batch can include multiple training images; for any batch of multiple training images, the computer device can use the multiple training images of the targeted batch as the multiple training images of the current batch, and input them into the target model to be trained.

[0051] Step 204 : Determine a second number of tensor computing cores required to process the current batch of training images based on the first number of the current batch of training images.

[0052] Among them, the tensor core is a hardware unit in the GPU, which can be used for matrix and tensor operations in deep learning and machine learning tasks. When the calculation function processes the training image, the image processing can be carried out by calling the tensor core, that is, the hardware resources of the GPU.

[0053] The second number refers to the number of tensor computing cores required to process the first number of training images. The second number may be specifically related to the size of the training images, the first number of training images, and the like.

[0054] In some embodiments, the actual number of tensor computing cores on the GPU may be fixed, that is, determined by the performance of the GPU. The actual number of tensor computing cores may also be different for GPUs of different performances. Therefore, a suitable GPU may be adaptively selected for the first number of training images to be processed, which can avoid waste of resources on the one hand, and improve the processing efficiency of the target model on the other hand.

[0055] In some embodiments, the computing function may count a first number of multiple training images in the current batch, and determine a size of the training image, and based on the first number and the size of the training image, determine a second number of tensor computing cores required for the multiple training images in the current batch.

[0056] Step 206: Call a second number of tensor computing cores to process the multiple training images in parallel to train the target model.

[0057] Specifically, the calculation function can call the second number of tensor computing cores based on the determined second number of tensor computing cores required to implement parallel processing of multiple training images. In the process of processing each training image, the calculation function can call the tensor computing cores to carry out a series of transformations and calculations on the training image based on the tensor computing cores to train the target model.

[0058] In some embodiments, the computing function can expand the allocation based on calling the second number of tensor computing cores, and allocate a matching tensor computing core to each training image in the current batch to achieve parallel processing of multiple training images in the current batch.

[0059] In some embodiments, when the first number of training images in the current batch is large, the second number of required tensor computing cores may be large. If the actual number of tensor computing cores in the current GPU is less than the second number of required tensor computing cores, some training images can be processed in parallel first, and after the processing of some training images is completed, the remaining training images can be processed in parallel.

[0060] In one embodiment, Figure 3 As shown in the figure, it is a flowchart of the model processing method in a specific application:

[0061] The training image processed by the calculation function can be input to the target model by the terminal. The terminal can obtain multiple training images and divide the multiple training images into batches to obtain multiple batches of training images. The terminal can use any batch as the current batch and use the multiple training images of the current batch as input to the target model to be trained. The target model to be trained calls the calculation function and performs parallel processing on the multiple training images based on the calculation function to complete the training of the target model.

[0062] In the process of processing multiple training images by the calculation function, the multiple training images can be convolved in parallel in the convolution layer to extract the image features of each training image. In the convolution layer, the parallel processing process can be realized by calling the tensor calculation core matching the multiple training images. When it comes to extracting image features, the calculation function can be the im2col operator.

[0063] The image features of each training image obtained can be input into the attention mechanism layer, and bev conversion can be performed through the attention mechanism layer to obtain bev features. The obtained bev features can be transmitted to the task layer, where target detection is performed to obtain prediction results; the calculation function can be trained based on the prediction results and labels, and the target model is trained until the preset training stop condition is met to obtain the trained target model. In the process of training based on the prediction results and labels, the target loss can be calculated based on the prediction results and labels, and the gradient is returned according to the target loss to update the model parameters of the target model to be trained. Among them, the label can be the expected result corresponding to the training image that is pre-labeled.

[0064] In the above model processing method, the first number of the current batch of multiple training images input to the target model to be trained is determined; then, based on the first number, the second number of tensor computing cores required to process the current batch of multiple training images can be determined, so that the second number of tensor computing cores can be fully called to process the multiple training images in parallel to train the target model. By determining the second number of the required tensor computing cores based on the first number of the current batch of multiple training images, the second number of tensor computing cores can be called to carry out parallel processing on the multiple training images, which fully utilizes the hardware resources of the GPU and can effectively improve the processing efficiency of the target model.

[0065] In one embodiment, determining a second number of tensor computing cores required to process multiple training images in the current batch based on a first number of multiple training images in the current batch includes: determining the second number of tensor computing cores required to process multiple training images in the current batch based on image feature sizes of the training images and the first number of multiple training images in the current batch.

[0066] The image feature size can also be understood as the size of the image feature, including the size of the height dimension, width dimension, and channel dimension. For each training image, it can be composed of multiple elements. For any element in a single training image, the calculation function can process it based on the tensor calculation core by calling the tensor calculation core.

[0067] Specifically, the computing function can determine the first number and the image feature size, and perform calculations based on the first number and the image feature size. For example, the computing function can multiply the first number and the image feature size, and determine the second number of tensor computing cores required based on the product of the two.

[0068] In some embodiments, the computer function may directly determine the second quantity as the product of the first quantity and the image feature size.

[0069] For multiple training images of the current batch, the calculation function in the relevant scheme calls the tensor computing core required for one training image to process the training image, and then calls the tensor computing core required for another training image to process the training image, and so on, and so on, until all the training images of the current batch are processed. However, the present application is different from this method. The present application uses multiple tensor computing cores to process all training images in parallel. Obviously, this method in the present application can fully call the hardware resources of the GPU to realize batch processing of training images, which can greatly improve the model processing efficiency.

[0070] Exemplarily, when the current batch of multiple training images includes N1 images, N1 is not equal to 0. In the conventional technology, the calculation function determines that the number of tensor computing cores required for one training image among the N1 training images is N2. The calculation function can call N2 tensor computing cores to process one training image. After the processing is completed, the calculation function continues to call N2 tensor computing cores to process the next training image until the N1 training images are processed. In the present application, the calculation function can determine the number of tensor computing cores required to process N1 training images as N1*N2 at one time based on N1 training images, and call N1*N2 tensor computing cores to process N1 training images in parallel, thereby improving the model processing efficiency.

[0071] In the above embodiment, the computer function can first determine the first quantity and the image feature size, and then obtain the second quantity based on the first quantity and the image feature size, so as to increase the number of tensor computing cores for feature extraction of training images, realize parallel processing of multiple training images in the current batch, and improve the processing efficiency of the target model.

[0072] In one embodiment, a second number of tensor computing cores are called to process multiple training images in parallel to train a target model, including: calling a second number of tensor computing cores to perform forward processing on the multiple training images in parallel to obtain a prediction result of each training image; determining a target loss for each training image based on the prediction result and label of each training image; calling a second number of tensor computing cores to perform back propagation on the target losses of the multiple training images in parallel to update model parameters of the target model to be trained.

[0073] The prediction result is the result obtained by forward processing the calculation function on each training image. Model parameters are configuration variables inside the target model, for example, model parameters may include weights, biases, etc.

[0074] Specifically, the target model may include multiple network layers, and the calculation function may determine the gradient value of each network layer according to the target loss by back-propagation, and based on the determined gradient values ​​of each network layer, update the weights, biases, etc. of each network layer accordingly. Among them, the target loss may be determined based on the label and the prediction result. When the target loss does not meet the end condition of the model training, the target loss is back-propagated in the target model to update the model parameters, and then the target model is iteratively trained until the end condition of the model training is met, and the trained target model is obtained. Similarly, in the process of back-propagation, the calculation function still calls the second number of tensor computing cores to back-propagate the target losses of multiple training images in parallel.

[0075] In some embodiments, the model training end condition may be whether the target loss is less than a loss threshold. When the target loss is less than the loss threshold, the model training end condition is determined to be satisfied. The model training end condition may also be whether the number of iterations reaches an iteration threshold. When the number of iterations reaches the iteration threshold, the model training end condition is determined to be satisfied. For example, the iteration threshold may be set to 50 times. When the number of iterations reaches 50 times, the model training end condition is determined to be satisfied.

[0076] In some embodiments, the tags may be pre-labeled. The pre-labeled tags may be stored in a storage service, and when there is a need for model training, the computing function may directly obtain the labeled tags from the storage service.

[0077] In some embodiments, during the gradient feedback process, the calculation function can determine the gradient value of each network layer by derivation. The gradient value of each network layer may include the gradient value of the weight, the gradient value of the bias, and the gradient value of the model input. The gradient values ​​of the weight and bias can be used to update the weight and bias of the target model respectively, and the gradient value of the model input can be used for feedback to ensure that the gradient feedback process is not interrupted, so that the weight and bias of each layer can be updated.

[0078] In a specific application, the model parameters adjusted by the calculation function may be the weights of each network layer of the target model. When determining the weight gradient value of any network layer, the calculation function may calculate the partial derivative of the weight of the network layer according to the target loss to obtain the weight gradient value of the network layer. The calculation function may update the weight of the network layer based on the obtained weight gradient value.

[0079] In a specific application, during the back-propagation process, the calculation function can update the weights of each network layer of the target model by backpropagating the gradient. For example, for the update of the weights of any network layer, the calculation function can call the second number of tensor computing cores to calculate in parallel the weight gradient values ​​corresponding to each training image, and process each weight gradient value, such as averaging, to obtain the mean of the weight gradient values, and update the weight of the targeted network layer based on the mean of the weight gradient values.

[0080] In the above embodiment, in both the forward processing and the reverse processing of the calculation function, the training images can be processed in parallel by calling the second number of tensor computing cores, thereby effectively improving the processing efficiency of the target model.

[0081] In one embodiment, a second number of tensor computing cores are called to perform forward processing on multiple training images in parallel to obtain prediction results for each training image, including: calling a second number of tensor computing cores to perform feature extraction on multiple training images in parallel to obtain image features of the multiple training images; performing target detection based on the image features of each training image to obtain prediction results for each training image.

[0082] Among them, target detection can be related to specific tasks. For example, for autonomous driving tasks, target detection can include obstacle detection and lane line detection; in the field of life, target detection can include face detection, etc.

[0083] Specifically, the calculation function can allocate the determined second number of tensor calculation cores to determine the training images corresponding to each tensor calculation core, and each element included in the multiple training images can be matched with a corresponding thread. In the process of extracting features from the training images, the calculation function can perform feature extraction in parallel through the threads corresponding to each element to obtain image features of the multiple training images.

[0084] In some embodiments, each tensor computing core may carry an index identifier, which may be any identifier such as numbers, letters, and feature codes. The computing function may allocate a matching tensor computing core to each training image in the current batch based on the index identifier.

[0085] In a specific application, the calculation function can calculate according to the index identifier, the length and width of a single training image and the batch information of the current batch to determine the training image matching the index identifier. The batch information can be the first number of multiple training images in the current batch. For example, the calculation function can calculate the product of the width and the height, and then divide the product by the index identifier, and finally perform a modulo operation based on the batch information and the product, and based on the result of the modulo operation, assign a tensor computing core that matches each training image.

[0086] Exemplarily, the calculation function can allocate a matching tensor calculation core to each training image through the following code: bs_id=index (index identifier) / w / h%batch size (the first number of multiple training images in the current batch). Wherein, for index / w / h: first, index is divided twice, first by w, and then the result is divided by h, where w refers to the width of the image and h refers to the height of the image. Further, the result of index / w / h is modulo-operated with batch_size, and the result of the modulo-operation can be an integer, which represents the remainder after the result of index / w / h is divided by batch_size.

[0087] In the above embodiment, the computing function can assign a tensor computing core that matches each training image, so that based on the second number of tensor computing cores, feature extraction can be performed on the respectively assigned training images in parallel, thereby improving the processing efficiency of the target model.

[0088] In some embodiments, before describing the specific feature gradient return process involved in the gradient return process, the gradient return process of any training image is described as a whole:

[0089] The steps for returning the gradient of the target loss for any training image include:

[0090] For any network layer in the target model to be trained, the feature gradient is calculated according to the input and output of the network layer, a new gradient is obtained based on the feedback gradient and feature gradient transmitted in the subsequent network layer, and the new gradient is transmitted to the previous network layer as the feedback gradient to realize gradient feedback. In the process of gradient feedback, the model parameters of the network layer are updated according to the result of the output of the network layer and the feedback gradient transmitted in the subsequent network layer; wherein, for the last network layer in the target model to be trained, the result of the derivative of the target loss to the input of the last network layer is transmitted to the previous network layer as the feedback gradient, and in the process of gradient feedback, the model parameters of the last network layer are updated according to the result of the derivative of the target loss to the model parameters of the last network layer.

[0091] Among them, the target model includes multiple network layers, and the network layers may include input layers, convolutional layers, pooling layers, attention mechanism layers, etc. Different network layers can be used separately or combined to form a neural network structure. For a neural network structure composed of multiple network layers, including the network layers in the back and the network layers in the front, the front and the back are defined by the timing of the forward processing of the model. When the gradient is returned, it is transmitted from the network layer in the back to the network layer in the front. The output of any network layer can be used as the input of the network layer in the next layer of the network layer. Correspondingly, the input of any network layer is the output of the network layer in the previous layer of the network layer.

[0092] Feature gradient is used to characterize the contribution of the model input to the model output, usually referring to the partial derivative of the output of a certain network layer or the target loss with respect to a certain input feature. In the process of gradient backpropagation, the backpropagation gradient is backpropagated from the last layer of the target model to the first layer of the target model. For any network layer, its feature gradient is the gradient obtained by taking the derivative of the output of the network layer with respect to the input; its backpropagation gradient is passed from the subsequent network layer of the network layer. For example, the network layer of the target model includes the 1st layer...the i-th layer and the i+1th layer, i is not equal to 0, the backpropagation gradient of the i-th layer is passed from the i+1th layer after the i-th layer, and the backpropagation gradient of the i-1th layer is passed from the i-th layer. Furthermore, the calculation function can obtain a new gradient based on the backpropagation gradient and feature gradient passed from the subsequent network layer, and pass the new gradient as the backpropagation gradient to the previous network layer to realize gradient backpropagation.

[0093] Specifically, for the last network layer of the target model, the return gradient can be obtained by taking the partial derivative of the target loss with respect to the input of the last network layer. For any network layer except the last network layer of the target model, the return gradient of the network layer is obtained by determining the feature gradient by taking the derivative of the output with respect to the input, and combining the return gradient transmitted from the next network layer of the network layer.

[0094] In some embodiments, when the model parameters of a network layer of any layer are updated, the parameters of the network layer can be updated by the return gradient transmitted by the previous network layer of the network layer and the derivative result of the output of the network layer to the parameters of the network layer. The product obtained by multiplying the return gradient of the network layer and the derivative result can be used as the parameter gradient, and the model parameters of the network layer can be updated based on the parameter gradient.

[0095] In some embodiments, for the process of back-propagating the target loss of multiple training images in parallel, the calculation function can derive the model parameters of the targeted network layer by calculating the target loss of each training image, obtain the parameter gradient of the targeted network layer, further average the parameter gradient corresponding to each training image, and update the model parameters of the targeted network layer according to the average value of the parameter gradient. The derivative of the target loss to the model parameters of the targeted network layer can be equal to the product of the return gradient of the targeted network layer transmitted by the subsequent network layer and the result of the derivative of the output of the targeted network layer to the model parameters of the targeted network layer.

[0096] In a specific application, the model parameters of the network layer may be the weights of the target model. For the update of the weights of any network layer, the calculation function may derive the weights of the targeted network layer through the target loss to obtain the weight gradient of the targeted network layer. The derivative of the target loss to the weight of the targeted network layer may be equal to the product of the derivative of the output of the targeted network layer to the weight of the targeted network layer and the return gradient transmitted to the subsequent network layer.

[0097] In some embodiments, for the last network layer of the target model, the calculation function can derive the model parameters of the last network layer according to the target loss of each training image calculated, obtain the parameter gradient of the model parameters of the last network layer, average the parameter gradient corresponding to each training image, and update the model parameters of the last network layer according to the average value of the parameter gradient. For the return gradient, for each training image, that is, the result of partial derivative of the input of the last network layer according to the target loss of the training image calculated by the calculation function, the calculation function can transmit the return gradient of each training image calculated by the last network layer to the previous network layer to realize gradient return.

[0098] In some embodiments, the target model includes network layer 1, network layer 2, network layer 3...network layer N. The input of network layer N is the output of the previous layer of network layer N, and the output of network layer N is the prediction result of the target model. For other network layers except network layer N, they all include input and output, and the input of the network layer is the output of the previous network layer, and the output of the network layer is the input of the subsequent network layer. For example, when updating the model parameters of network layer 2, the calculation function can obtain the feedback gradient sent back by network layer 3 to network layer 2, and the result of deriving the model parameters of network layer 2 by the output of network layer 2, and update the model parameters of network layer 2. For example, when updating the model parameters of the last network layer N of the target model, the calculation function can obtain the target loss according to the prediction results and labels, and derive the model parameters of network layer N according to the target loss to obtain the derivative result, and update the model parameters of network layer N based on the derivative result.

[0099] In the above embodiment, for any network layer, the calculation function calculates the feature gradient through the input and output of the network layer, and obtains a new gradient based on the feedback gradient and feature gradient transmitted in the subsequent network layer, and transmits the new gradient as the feedback gradient to the previous network layer to realize gradient feedback. By means of gradient feedback, the parameter update of the target model is realized, thereby improving the training accuracy of the target model.

[0100] In the process of back propagation of the target model, when it comes to the return of position feature gradients, it is usually necessary to gather position feature gradients of different channels. In traditional methods, this is mostly achieved by using shared memory, which requires the opening of new memory and the gathering process is inefficient. Therefore, in the process of returning position feature gradients, the present application replaces the shared memory by means of thread bundles without opening new memory.

[0101] In one embodiment, the process of how to implement the position feature gradient backpropagation through a thread bundle is described in detail. During the backpropagation of the target loss of any training image, when the backpropagation gradient that needs to be transmitted in any network layer includes the position feature gradient, the step of backpropagating the position feature gradient includes: obtaining the position feature gradients belonging to different channels at the same position through each thread in the same thread bundle, and fusing the obtained multiple position feature gradients to obtain the updated position feature gradient, and transmitting the updated position feature gradient to the previous connected network layer. More specifically, the step of backpropagating the position feature gradient includes: the targeted network layer obtains the position feature gradients belonging to different channels at the same position through each thread in the same thread bundle to obtain multiple gradients at the same position, and each thread in the same thread bundle communicates between threads to fuse multiple gradients at the same position to obtain the updated position feature gradient, and transmits the updated position feature gradient to the previous connected network layer.

[0102] Among them, the position feature gradient is the gradient of the position-related feature in the model. A warp is a parallel thread group set on the GPU, including multiple threads. The individual threads that make up the warp start at the same program address at the same time. Each thread has its own instruction address counter and register state, so it can branch freely and execute independently.

[0103] Specifically, during the back-propagation process, the calculation function communicates between threads through each thread in the thread bundle. Each thread corresponds to a matching channel. The calculation function can determine the position feature gradients belonging to different channels at the same position based on each thread in the thread bundle, and perform stacking fusion, average fusion, weighted average fusion, etc. on the position feature gradients belonging to different channels at the same position. For example, the calculation function can sum the position feature gradients belonging to different channels at the same position to obtain the updated position feature gradients, and pass the updated position feature gradients to the connected network layer.

[0104] In some embodiments, a thread bundle may refer to warps (a group of threads executed in parallel). Warps may include 32 parallel threads, and 32 threads may work in parallel. When the number of channels of the target model is 32, each channel may correspond to a thread that matches it, and then when determining the feature gradient of any position in the position feature, warps may be used to achieve efficient communication between threads, determine the position feature gradient of different channels at the same position, obtain the updated position feature gradient, and pass the updated position feature gradient to the connected previous network layer.

[0105] In traditional technology, the updated position feature gradient is obtained by sharing thread data. The relevant code is as follows: CUDA 1D KERNEL LOOP (index, numkernels); {_shared_cache_grad_sampling[chl]; _shared_cache_grad_weight[chl]… Among them, this code shows that the threads corresponding to each channel use shared memory (shared_cache) for inter-thread communication.

[0106] Exemplarily, inter-thread communication is performed through thread warps to fuse multiple gradients at the same position to obtain the updated position feature gradient code as follows: for-loop(num_point){scalar_t grad_wha[3]=(0.0f,0.0f,0.0f);col2im_bilinear_opt(value_,w_,h_,grad_value_,grad_wha);warpReduceSumV2<scalar_t,3> (grad_wha)…}…def warpReduceSumV2(val

[0107] {for(mask=16,mask>0,mask / =2);val+=_shfl_xor_sync(0xffffffff,val,mask,32)}, in this code, the position feature gradients of different channels at the same position need to be summed, which is implemented by the warpReduceSumV2 function. The warpReduceSumV2 function is used to calculate the sum of all position feature gradients in a warp (usually 32 threads). This operation uses the built-in function shfl_xor_sync of CUDA to exchange data between different threads, thereby gradually aggregating their position feature gradients.

[0108] In a specific application, when the network layer includes an attention mechanism layer, refer to Figure 4 As shown in the figure, it is the forward propagation process. In the attention mechanism layer of the forward propagation process, the calculation function can extract the corresponding position features from the image features through the position information. The position information can be a preset position, which can be set in combination with the actual detection scene, detection purpose, etc. When the image features include multiple channels, such as Chl (channel) = 5, the corresponding position features can be obtained in five channels through the same position information. The calculation function can fuse the position features obtained from the five channels to determine the features at the preset position.

[0109] refer to Figure 5As shown, during the back propagation process, the gradient of the feature at the preset position can be directly transmitted back. As for the transmission of the position feature gradient of the position information, combined with the fact that the same position information will correspond to multiple channels during the forward propagation process, the position feature is determined in different channels at the same position when extracting the position feature. Therefore, for the position feature gradient (i.e., the gradient of the channel dimension), the threads in the same thread bundle can communicate with each other to process the position feature gradients belonging to different channels at the same position, so as to fuse multiple gradients at the same position, obtain the updated position feature gradient, and pass the updated position feature gradient to the connected previous network layer.

[0110] In the above embodiment, the calculation function can set a thread bundle and communicate between threads through each thread bundle in the same thread bundle. There is no need to use shared memory or open up new memory. It can fuse multiple position feature gradients of different channels at the same position to obtain an updated position feature gradient, thereby improving the feedback efficiency in the attention mechanism layer during the gradient feedback process.

[0111] In the process of back propagation of the target model, when it comes to the back propagation of the image feature gradient, it is usually necessary to determine the gradient corresponding to any element in the image feature gradient. In traditional methods, the original for-loop is mostly used to determine the pixel points related to any element in the image feature gradient in turn, so as to assign the gradient of the element to the pixel points related to it. This method requires multiple determinations of the pixel points, which is inefficient. Therefore, in this application, by obtaining multiple pixel points related to the element at one time and assigning values ​​to each pixel point at the same time, the problem of low efficiency in assigning pixel points through for loops in traditional solutions can be solved.

[0112] In one embodiment, during the back propagation of the target loss of any training image, when the returned gradient to be transmitted in any network layer includes the image feature gradient, the step of returning the image feature gradient includes: for the gradient corresponding to any element in the image feature gradient, determining the pixel points related to the targeted element during the forward processing of the target model, and assigning the gradient of the targeted element to the related pixel points to realize the return of the image feature gradient.

[0113] In some embodiments, during the forward processing, the calculation function can determine the pixel point (i, j), and obtain the value of the pixel point in the image according to the pixel point to obtain the element in the image feature. In general, the target pixel point determined by the calculation function is a floating point number, and the calculation function can obtain the element in the image feature by determining multiple related pixel points related to the target pixel point and averaging the values ​​of the related pixel points.

[0114] In some embodiments, for a pixel point of a floating point type, the calculation function may use bilinear interpolation to determine four pixel points around the targeted pixel point as relevant pixel points of the targeted pixel point, and the calculation function may extract the value of the relevant pixel point, and determine the element in the image feature based on the value of the relevant pixel point. The pixel points around the targeted pixel point refer to the pixel point to the upper left, the pixel point to the upper right, the pixel point to the lower left, and the pixel point to the lower right of the targeted pixel point.

[0115] In some embodiments, for the gradient return process, when the calculation function determines the gradient corresponding to any element in the image feature gradient, it can clarify the pixel points related to the element, that is, clarify which pixel points determine the element, and the computer can pass the gradient of the element to the pixel points related to the element. In the process of gradient return, the calculation function can directly obtain the upper left, lower left, lower right, upper right and other pixel points corresponding to the targeted element at one time, and assign them the corresponding gradient values.

[0116] In traditional technology, when returning the gradient of an element in an image feature, the calculation function uses a for-loop to sequentially determine the pixel points related to any element in the image feature gradient to assign the gradient of the element to the pixel point. The code is as follows: / / bilinear reverse for(dy=-2;dy<=2;dy++); for(dx=-2;dx<=2;dx++); weight=getweight(cur_h+dy,cur_w+dx...) (refers to a function call)... Among them, bilinear means bilinear interpolation, dy and dx represent the vertical and horizontal offsets, respectively, ranging from -2 to 2. For any element in the image feature gradient, there can be 4 adjacent pixel points. Traditional technology uses a for loop to sequentially assign gradient values ​​to these 4 adjacent pixel points.

[0117] In a specific application, the following code can be used to obtain the upper left, lower left, lower right, upper right and other pixel points corresponding to the element at one time and assign the corresponding gradient values: get_weight_opt(grad_input_ptr+input_pos_tmp,w1,w2,w3,w4,grad_...). Among them, get_weight_opt is a custom function used to directly obtain the 4 pixel points corresponding to the element and assign the gradient of the element to these 4 pixel points at the same time.

[0118] In the above embodiment, during the gradient feedback process, for the gradient corresponding to any element in the image feature gradient, the calculation function can directly determine the pixel points related to the targeted element, and assign the gradient of the element to the related pixel points. Compared with assigning gradients to each pixel point in turn in a loop, the efficiency of gradient feedback is improved, thereby improving the processing efficiency of the target model.

[0119] In one embodiment, during the process of processing the training image, if an atomic addition operator is involved, the data format of the data processed by the atomic addition operator and the temporary data generated during the calculation process is set to a single-precision floating point type.

[0120] The atomic addition operator may refer to the atomicAdd operator. In the process of processing the training image. For example, in the process of gradient return, if the atomic addition operator is involved, the efficiency of gradient return will also be affected for different data formats. As shown in Table 1, when the number of samples loaded by the gpu (graphics processor) is the same, the speed under fp16 precision and fp32 precision is compared. It can be seen from Table 1 that the efficiency is higher under float32 precision:

[0121] Table 1

[0122] Samples loaded by gpu Training speed gpu video memory speed ori fp32 (single-precision floating point) 3 ~6 ~78G 1 ori fp16 (half-precision floating point) 3 ~7.2 ~52.2G 0.83 (negative)

[0123] Specifically, during the gradient return process, if an atomic addition operator is involved, the calculation function can change the data format of the data processed by the atomic addition operator and the temporary data generated during the calculation process to a single-precision floating-point type. For example, during the processing of the atomic addition operator, the gradient value of the element involved, the gradient value of the pixel point, and the position information, etc., can all be in a single-precision floating-point type.

[0124] In a specific application, in the convolution layer, when assigning the gradient of the targeted element to the relevant pixel points, the instructions for atomicAdd involved are compiled differently under float (32-bit floating point number) and half (16-bit floating point number) precision. Float precision is more efficient, so the gradient values ​​involved can be converted into float for calculation acceleration.

[0125] For example, the data format conversion can be achieved by the following code: tmp = static cast <float>(w1 * cur top grad). Among them, static_cast is a type conversion operator used for type conversion at compile time. Static_cast is used to convert the result of w1 * cur_top_grad to float type and assign the converted value to the tmp variable. w1 can refer to weights, and cur_top_grad can refer to weight gradients.

[0126] In the above embodiment, an atomic addition operator is involved, and the calculation function can improve the efficiency of gradient return by changing the data processed by the atomic addition operator and the data format of temporary data generated during the calculation process.

[0127] In one embodiment, the model processing method also includes: acquiring multiple scene images of the target scene from different perspectives; performing target detection on the multiple scene images through the trained target model to obtain target detection results; and the target detection results are used to assist autonomous driving.

[0128] The scene image is a visual image used to describe a specific environment, place or scene. The scene image may specifically refer to an image of the vehicle's surrounding environment.

[0129] Specifically, the computer device can obtain scene images of multiple different perspectives acquired by multiple image acquisition devices, and any image acquisition device corresponds to one perspective. The image acquisition device can be a camera, and multiple cameras are deployed at different positions. The multiple cameras are used to acquire images of the vehicle's current scene to obtain scene images of multiple perspectives. Furthermore, the computer device can input the obtained scene images of multiple perspectives into the trained target model, and the target model performs feature extraction on each scene image in parallel, and then performs target detection based on the image features obtained by feature extraction to obtain target detection results, which are used to assist autonomous driving.

[0130] In some embodiments, multiple scene images at different perspectives can be obtained by acquiring video data. Specifically, video data of the current vehicle surroundings within a period of time can be collected. The computer device obtains multiple scene images at different perspectives by performing frame processing on the video data.

[0131] In some embodiments, the target detection results obtained by the computer device can be used to perform tasks such as obstacle target detection, obstacle trajectory prediction, drivable area identification, lane line recognition, traffic sign recognition, and traffic light recognition to assist autonomous driving.

[0132] In the above embodiment, the computer device obtains multiple scene images from different perspectives and inputs the multiple scene images from different perspectives into a trained target model. The target model performs feature extraction on each scene image in parallel, and performs target detection based on the features of each image obtained by feature extraction. This can obtain target detection results more quickly, improve the efficiency of the assisted autonomous driving process, and save user usage costs.

[0133] The present application also provides an application scenario, and the above-mentioned model processing method is applied to the application scenario. Specifically, the model processing method of the present application is described in detail below by taking an actual application scenario as an example, wherein the actual application scenario may be an autonomous driving scenario.

[0134] In autonomous driving scenarios, the trained target model can usually be used to process the collected images that represent the vehicle's surrounding environment to obtain detection results. The detection results can be used to achieve tasks such as lane line detection and obstacle detection, provide a basis for the autonomous driving vehicle's automatic cruising, lane keeping, lane overtaking and other behaviors, and provide protection for the vehicle's safe driving.

[0135] The training process of the target model can be referred to Figure 6 The flowchart shown is expanded:

[0136] The computer device can obtain multiple training images of the current batch and input the multiple training images of the current batch into the target model to be trained. The target model includes a convolution layer, an attention mechanism layer, a feedforward network and a task layer. Among them, for the convolution layer, the target model can include 3 deformable convolution networks, i.e., three DCNs; for the attention mechanism layer, it can mainly include a temporal attention mechanism and a spatial cross attention mechanism.

[0137] The target model can call the calculation function and process the training image based on the calculation function. The calculation function can input multiple training images into the convolution layer, and the multiple DCNs in the convolution layer can extract the image features. Figure 7 As shown in Figure 1, the convolution kernel in DCN only extracts features from one training image at a time. The convolution kernel size is k*k, and Figure 8 The process of converting the image to a matrix shown in the figure can be used to extract the image features. After processing one training image, the remaining training images are processed until all the training images are processed.

[0138] Different from traditional technology, reference Figure 8 As shown in Figure 2, the extraction of image features is carried out in parallel, such as Figure 8 For the three training images in , the image-to-matrix conversion process can be carried out in parallel. For the three training images, by increasing the number of tensor computing cores for feature extraction of the training images, multiple training images in the current batch can be processed in parallel, thus improving the processing efficiency of the target model.

[0139] Among them, when falling into the actual processing logic, it is reflected in the difference in the calculation method of the tensor computing core. In the traditional method, NUM_Kernerls (total number of threads) = in_chl (channel) * h (height) * W (width). By counting how many elements are included in the batch of images, the number of tensor computing cores required can be counted, and the number of tensor computing cores required can be passed to the cuda operator. In this application, based on the number of tensor computing cores required by the traditional calculation, it can be multiplied by batch_size (how many training images are in a batch) to obtain the second number of tensor computing cores, that is, NUM_Kernerls (total number of threads) = in_chl (channel) * h (height) * W (width) * batch_size in this application. Among them, the size of batch_size can be determined according to the video memory space of the gpu (graphics processing unit).

[0140] In the process of the computing function calling the second number of tensor computing cores to perform feature extraction on multiple training images in parallel, the computing function can expand the allocation to allocate a matching tensor computing core to each training image in the current batch. Specifically, the allocation can be expanded according to each index, the total batch_size (how many training images are in a batch), and the size of the training images.

[0141] In the process of image feature extraction, for the forward processing, the calculation function can determine the pixel point (i, j), and take the value of the pixel point in the training image according to the pixel point to obtain the element in the image feature. Under normal circumstances, the pixel point determined by the calculation function is a floating point number, and the calculation function can obtain the element in the image feature by determining multiple related pixel points related to the pixel point and averaging the values ​​of the related pixel points. After obtaining the image feature, the target model to be trained inputs the image feature into the attention mechanism layer, extracts the bev feature based on the time attention mechanism and the spatial cross attention mechanism in the attention mechanism layer, and obtains the bev feature; in this process, the position information to be extracted from the image feature can be determined according to the linear layer calculation. The position information can include four coordinate information. The four coordinate information is used to extract the elements corresponding to each channel in each channel of the image feature, and the bev feature is determined based on the elements extracted from each channel.

[0142] After bev features are extracted, bev features are input to the task layer via a feedforward network, where target detection is performed to obtain prediction results; the target model to be trained is trained based on the prediction results and labels, and the training of the target model is stopped until the preset training stop condition is met, thereby obtaining a trained target model. In the process of training based on prediction results and labels, the target loss can be calculated based on the prediction results and labels, and the gradient can be back-propagated according to the target loss to update the model parameters of the target model to be trained.

[0143] In the process of gradient backpropagation, the weights are updated through the gradient of the weights, and the gradient of the input features is used to ensure that the gradient backpropagation process is not interrupted, so that the weights of each layer can be updated. In the actual gradient backpropagation process: it mainly includes the gradient backpropagation of the attention mechanism layer and the gradient backpropagation of the DCN part.

[0144] The gradient feedback of the attention mechanism layer includes the gradient feedback of element values ​​and the gradient feedback of position points. The gradient feedback of element values ​​is the same as that of the DCN process. When extracting multiple elements in different channels, they are actually extracted from the same position point. When returning the gradient of the position point, the gradient feedback of the position point can be realized by adding the gradients of the same position of all different channels.

[0145] For the gradient feedback process in DCN: for the gradient of any element in the image feature gradient to be fed back, it is necessary to determine which pixels determine the element in the image feature gradient during the forward propagation process. After determination, the calculation function can assign the image feature gradient of the element to the relevant pixel points; when the image feature gradient is fed back, the calculation function can directly obtain the upper left, upper right, lower left, lower right and other pixel points corresponding to the targeted element at one time, and assign them the corresponding gradient values.

[0146] refer to Fig. 9 As shown in the figure, it is the process of returning the image feature gradient. In the process of returning the image feature gradient, when the computer function determines the gradient corresponding to any element in the image feature gradient, it can clarify the pixel points related to the element, that is, it is clear which pixel points determine the element, and the calculation function can pass the gradient of the element to the pixel points related to the element. In the process of returning the gradient, the calculation function can directly obtain the upper left, lower left, lower right, upper right and other pixel points corresponding to the element at one time, and assign them the corresponding gradient values.

[0147] It should be understood that, although the various steps in the flowcharts involved in the above-mentioned embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps does not have a strict order restriction, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above-mentioned embodiments can include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.

[0148] Based on the same inventive concept, the embodiment of the present application also provides a model processing device for implementing the model processing method involved above. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme recorded in the above method, so the specific limitations in one or more model processing device embodiments provided below can refer to the limitations on the model processing method above, and will not be repeated here.

[0149] In one embodiment, Fig.10 As shown, a model processing device 1000 is provided, comprising: a determination module 1002 and a processing module 1004, wherein:

[0150] The determination module 1002 is used to determine a first number of a current batch of multiple training images input to the target model to be trained.

[0151] The determination module 1002 is further configured to determine a second number of tensor computing cores required to process the plurality of training images in the current batch according to the first number of the plurality of training images in the current batch.

[0152] The processing module 1004 is used to call a second number of tensor computing cores to process multiple training images in parallel to train the target model.

[0153] In some embodiments, the determination module 1002 is further used to determine a second number of tensor computing cores required to process the current batch of training images based on the image feature size of the training image and the first number of the current batch of training images.

[0154] In some embodiments, the first number of the plurality of training images in the current batch is determined according to the size of the video memory of the graphics processor.

[0155] In some embodiments, the processing module 1004 is further used to call a second number of tensor computing cores to perform forward processing on multiple training images in parallel to obtain prediction results of each training image; determine the target loss of each training image based on the prediction results and labels of each training image; call a second number of tensor computing cores to perform back propagation on the target losses of multiple training images in parallel to update model parameters of the target model to be trained. Model parameters of the target model to be trained.

[0156] In some embodiments, the processing module 1004 is further used to call a second number of tensor computing cores to perform feature extraction on multiple training images in parallel to obtain image features of the multiple training images; perform target detection based on the image features of each training image to obtain prediction results for each training image.

[0157] In some embodiments, the processing module 1004 is also used to process the position feature gradients belonging to different channels at the same position of the targeted network layer through each thread in the same thread bundle to obtain multiple gradients at the same position. The threads in the same thread bundle perform inter-thread communication to fuse the multiple gradients at the same position to obtain an updated position feature gradient, and pass the updated position feature gradient to the previous connected network layer.

[0158] In some embodiments, the processing module 1004 is also used to determine the pixel points related to the targeted element during the forward processing of the target model for the gradient corresponding to any element in the image feature gradient, and assign the gradient of the targeted element to the relevant pixel points to realize the feedback of the image feature gradient.

[0159] In some embodiments, during the process of processing the training image, if an atomic addition operator is involved, the data format of the data processed by the atomic addition operator and the temporary data generated during the calculation process is set to a single-precision floating point type.

[0160] In some embodiments, the model processing device further includes an application module;

[0161] The application module is used to obtain multiple scene images of the target scene from different perspectives; target detection is performed on the multiple scene images through the trained target model to obtain target detection results; the target detection results are used to assist autonomous driving.

[0162] Each module in the above-mentioned model processing device can be implemented in whole or in part by software, hardware and a combination thereof. Each of the above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory in the computer device in the form of software, so that the processor can call and execute the operations corresponding to each of the above modules.

[0163] In one embodiment, a computer device is provided. The computer device may be a server or a terminal. The internal structure diagram thereof may be as follows: Fig.11 As shown. The computer device includes a processor, a memory, an input / output interface (Input / Output, referred to as I / O) and a communication interface. The processor, the memory and the input / output interface are connected through a system bus, and the communication interface is connected to the system bus through the input / output interface. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store training images. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a model processing method is implemented.

[0164] Those skilled in the art will understand that Fig.11 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.

[0165] In one embodiment, a computer device is provided, including a memory and a processor, wherein a computer program is stored in the memory, and the processor implements the steps of the above-mentioned model processing method when executing the computer program.

[0166] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored, and when the computer program is executed by a processor, the steps of the above-mentioned model processing method are implemented. In one embodiment, a computer program product is provided, including a computer program, and when the computer program is executed by a processor, the steps of the above-mentioned model processing method are implemented. It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data need to comply with relevant laws, regulations and standards of relevant countries and regions.

[0167] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, etc., but are not limited to this.

[0168] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0169] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.< / float>

Claims

1. A model processing method, It is characterized in that Applied to a GPU, the method comprises: Determining a first number of a current batch of multiple training images to be input to a target model to be trained; Determining a second number of tensor computing cores required to process the plurality of training images of the current batch according to an image feature size of the training image and a product of the first number of the plurality of training images of the current batch; The second number of tensor computing cores are called, and a matching tensor computing core is allocated to each training image of the current batch, and the multiple training images are processed in parallel to train the target model.

2. The method according to claim 1, It is characterized in that The first number of the plurality of training images in the current batch is determined according to the video memory size of the graphics processor.

3. The method according to claim 1, It is characterized in that The calling the second number of tensor computing cores to process the plurality of training images in parallel to train the target model includes: calling the second number of tensor computing cores, and assigning a matching tensor computing core to each training image of the current batch, and performing forward processing on the multiple training images in parallel to obtain prediction results for each training image; Determine the target loss for each training image based on the prediction result and label of each training image; The second number of tensor computing cores are called, and a matching tensor computing core is assigned to each training image of the current batch, and the target losses of the multiple training images are back-propagated in parallel to update the model parameters of the target model to be trained.

4. The method according to claim 3, It is characterized in that The calling of the second number of tensor computing cores, allocating a matching tensor computing core to each training image of the current batch, and performing forward processing on the multiple training images in parallel to obtain prediction results for each training image includes: calling the second number of tensor computing cores, and allocating a matching tensor computing core to each training image of the current batch, and performing feature extraction on the multiple training images in parallel to obtain image features of the multiple training images; Target detection is performed based on the image features of each training image to obtain the prediction results of each training image.

5. The method according to claim 3, It is characterized in that During the back propagation of the target loss of any training image, when the back propagation gradient to be transmitted in any network layer includes the position feature gradient, the back propagation step of the position feature gradient includes: The targeted network layer obtains position feature gradients belonging to different channels at the same position through each thread in the same thread bundle, and obtains multiple gradients at the same position. The threads in the same thread bundle communicate with each other to fuse the multiple gradients at the same position to obtain an updated position feature gradient, and the updated position feature gradient is passed to the previous connected network layer.

6. The method according to claim 3, It is characterized in that During the back propagation of the target loss of any training image, when the back propagated gradient to be transmitted in any network layer includes the image feature gradient, the back propagation step of the image feature gradient includes: For the gradient corresponding to any element in the image feature gradient, the pixel points related to the targeted element are determined during the forward processing of the target model, and the gradient of the targeted element is assigned to the related pixel points to realize the feedback of the image feature gradient.

7. The method according to claim 1, It is characterized in that In the process of processing the training image, if an atomic addition operator is involved, the data format of the data processed by the atomic addition operator and the temporary data generated in the calculation process is set to a single-precision floating point type.

8. The method according to any one of claims 1 to 7, It is characterized in that The method further comprises: Acquire multiple scene images of the target scene from different perspectives; The trained target model is used to perform target detection on the multiple scene images to obtain target detection results; the target detection results are used to assist autonomous driving.

9. A model processing device, It is characterized in that The device comprises: A determination module, configured to determine a first number of a current batch of multiple training images to be input to a target model to be trained; The determination module is further configured to determine a second number of tensor computing cores required to process the plurality of training images of the current batch according to the image feature size of the training image and the product of the first number of the plurality of training images of the current batch; A processing module is used to call the second number of tensor computing cores and allocate a matching tensor computing core to each training image of the current batch, and process the multiple training images in parallel to train the target model.

10. The device according to claim 9, It is characterized in that The first number of the plurality of training images in the current batch is determined according to the video memory size of the graphics processor.

11. The device according to claim 9, It is characterized in that The processing module is also used to call the second number of tensor computing cores, assign a matching tensor computing core to each training image of the current batch, and perform forward processing on the multiple training images in parallel to obtain prediction results of each training image; determine the target loss of each training image based on the prediction results and labels of each training image; call the second number of tensor computing cores, assign a matching tensor computing core to each training image of the current batch, and perform back propagation on the target losses of the multiple training images in parallel to update the model parameters of the target model to be trained.

12. The device according to claim 11, It is characterized in that The processing module is also used to: call the second number of tensor computing cores, and assign a matching tensor computing core to each training image of the current batch, perform feature extraction on the multiple training images in parallel to obtain image features of the multiple training images; perform target detection based on the image features of each training image to obtain prediction results for each training image.

13. The device according to claim 11, It is characterized in that During the back propagation of the target loss of any training image, when the returned gradient to be transmitted in any network layer includes a position feature gradient, the processing module is further used to: obtain the position feature gradients belonging to different channels at the same position through each thread in the same thread bundle for the targeted network layer, and obtain multiple gradients at the same position; the threads in the same thread bundle communicate with each other to fuse the multiple gradients at the same position, and obtain an updated position feature gradient; and transmit the updated position feature gradient to the previous connected network layer.

14. The device according to claim 11, It is characterized in that During the back propagation of the target loss of any training image, when the returned gradient that needs to be transmitted in any network layer includes the image feature gradient, the processing module is also used to: for the gradient corresponding to any element in the image feature gradient, determine the pixel points related to the targeted element during the forward processing of the target model, and assign the gradient of the targeted element to the related pixel points to realize the return of the image feature gradient.

15. The device according to claim 9, It is characterized in that The processing module is further used for: in the process of processing the training image, if an atomic addition operator is involved, setting the data format of the data processed by the atomic addition operator and the temporary data generated in the calculation process to a single-precision floating point type.

16. The device according to any one of claims 9 to 15, It is characterized in that The device also includes an application module, which is used to: obtain multiple scene images of the target scene from different perspectives; perform target detection on the multiple scene images through a trained target model to obtain target detection results; and the target detection results are used to assist autonomous driving.

17. A computer device comprising a memory and a processor, wherein the memory stores a computer program. It is characterized in that When the processor executes the computer program, the steps of the method according to any one of claims 1 to 8 are implemented.

18. A computer-readable storage medium having a computer program stored thereon, It is characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 8 are implemented.

19. A computer program product comprising a computer program, It is characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 8 are implemented.

Citation Information

Patent Citations

  • Tensor processor

    CN110033085A

  • Weight reduction method and system of deep convolutional neural network, and target detection method

    CN113420651A

  • Fast retraining of fully fused neural transceiver components

    CN115733569A

  • Convolution calculation data reusing method based on multi-tensor core processor

    CN116028384A

  • Methods for compressing and decompressing data using tensor train decomposition, and associated devices, computer programs and storage medium

    EP4332903A1