Data processing method, device, electronic device and storage medium
By generating shaders corresponding to each network level of the neural network model in the central processor and determining the computing pipeline based on the target device parameters, the problem of excessive communication between the CPU and the GPU is solved, and the performance of the neural network model is improved.
Patent Information
- Application Number
- CN202111644074.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-29
- Publication Date
- 2025-02-07
- Estimated Expiration
- 2041-12-29
AI Technical Summary
When a computer performs calculations based on a neural network model, there is too much communication interaction between the CPU and the GPU, which reduces the computing efficiency of the neural network and has a performance bottleneck.
By obtaining neural network parameters corresponding to the target neural network model in the central processor, a shader to be used corresponding to each network level is generated, and the calculation pipeline is determined based on the target device parameters to receive the to-process data when , the data is processed by the retrieval pipeline.
It greatly reduces the interaction between the CPU and the GPU, reduces the limitations of the GPU communication bandwidth on the model computing process, and improves the performance of the neural network model.
Smart Images

Figure CN114330689B_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present disclosure relate to the field of data processing technology, and in particular, to a data processing method, device, electronic device, and storage medium. Background Art
[0002] With the continuous development of artificial intelligence technology, neural network models have been widely used in various fields. Relying on their large-scale parallel processing and distributed information storage characteristics, they can process a variety of data.
[0003] However, when computers perform calculations based on neural network models, a large amount of communication and interaction between the central processing unit (CPU) and the graphics processing unit (GPU) reduces the computing efficiency of the neural network and creates a performance bottleneck for the model. Summary of the invention
[0004] The present disclosure provides a data processing method, device, electronic device and storage medium, which greatly reduce the interaction between the CPU and the GPU, reduce the limitation of the GPU communication bandwidth on the model calculation process, and improve the performance of the neural network model.
[0005] In a first aspect, an embodiment of the present disclosure provides a data processing method, which is applied to a central processing unit, and includes:
[0006] Obtaining neural network parameters corresponding to a target neural grid model;
[0007] According to the neural network parameters, a shader to be used corresponding to each network level is generated; wherein the target neural network model includes multiple network levels;
[0008] According to the target device parameters of the device to which the target neural network model belongs, the computing pipeline corresponding to the shader to be used is determined, so that when the data to be processed is received, the computing pipeline is called to process the data to be processed according to the target device parameters to obtain the target processing result.
[0009] In a second aspect, the embodiment of the present disclosure further provides a data processing method, which is applied to a graphics processor, comprising:
[0010] When receiving the data to be processed, loading the predetermined computing pipeline and neural network parameters; wherein the computing pipeline is determined based on the neural network parameters of the target neural network model and the target device parameters of the target neural network model by the central processor;
[0011] According to the target device parameters, determining a target processing mode for each shader to be used to process the data to be processed; wherein the shader to be used is obtained after the central processing unit processes the neural network parameters;
[0012] The data to be processed is processed based on the target processing method to obtain a target processing result.
[0013] In a third aspect, an embodiment of the present invention further provides a data processing device, which is configured in a central processing unit and includes:
[0014] A network parameter determination module, used to obtain neural network parameters corresponding to a target neural grid model;
[0015] A shader determination module, used to generate a shader to be used corresponding to each network level according to the neural network parameters; wherein the target neural network model includes multiple network levels;
[0016] The pipeline determination module is used to determine the computing pipeline corresponding to the shader to be used according to the target device parameters of the device to which the target neural network model belongs, so that when receiving the data to be processed, the computing pipeline is called according to the target device parameters to process the data to be processed to obtain the target processing result.
[0017] In a fourth aspect, an embodiment of the present invention further provides a data processing device, which is configured in a graphics processor and includes:
[0018] A network parameter loading module, used to load predetermined computing pipeline and neural network parameters when receiving data to be processed; wherein the computing pipeline is determined based on the neural network parameters of the target neural network model and the target device parameters of the target neural network model by the central processing unit;
[0019] A processing mode determination module is used to determine the target processing mode of each shader to be used to process the data to be processed according to the target device parameters; wherein the shader to be used is obtained after the central processing unit processes the neural network parameters;
[0020] The processing result determination module is used to process the data to be processed based on the target processing method to obtain a target processing result.
[0021] In a fifth aspect, an embodiment of the present disclosure further provides an electronic device, the electronic device comprising:
[0022] one or more processors;
[0023] a storage device for storing one or more programs,
[0024] When the one or more programs are executed by the one or more processors, the one or more processors implement the data processing method as described in any one of the embodiments of the present disclosure.
[0025] In a sixth aspect, an embodiment of the present disclosure further provides a storage medium comprising computer executable instructions, which, when executed by a computer processor, are used to execute a data processing method as described in any one of the embodiments of the present disclosure.
[0026] The technical solution of the disclosed embodiment obtains neural network parameters corresponding to the target neural network model; generates shaders to be used corresponding to each network level according to the neural network parameters, that is, generates corresponding shaders to be used for multiple network levels in the target neural network model; further, determines the computing pipeline corresponding to the shader to be used according to the target device parameters of the device to which the target neural network model belongs, so that when receiving the data to be processed, the computing pipeline is called to process the data to be processed according to the target device parameters to obtain the target processing result, generates shaders corresponding to each network level of the neural network model by the CPU, and then performs coarse-grained calculations based on each shader after receiving the data to be processed, so as to greatly reduce the interaction between the CPU and the GPU, reduce the limitation of the GPU communication bandwidth on the model calculation process, and improve the performance of the neural network model. BRIEF DESCRIPTION OF THE DRAWINGS
[0027] The above and other features, advantages and aspects of the embodiments of the present disclosure will become more apparent with reference to the following detailed description in conjunction with the accompanying drawings. Throughout the accompanying drawings, the same or similar reference numerals represent the same or similar elements. It should be understood that the drawings are schematic and the originals and elements are not necessarily drawn to scale.
[0028] Figure 1 A flowchart of a data processing method provided in the first embodiment of the present disclosure;
[0029] Figure 2 A flowchart of a data processing method provided in Embodiment 2 of the present disclosure;
[0030] Figure 3 A flowchart of a data processing method provided in Embodiment 3 of the present disclosure;
[0031] Figure 4 A flowchart of a data processing method provided in Embodiment 4 of the present disclosure;
[0032] Figure 5 A schematic diagram of the structure of a data processing device provided in Embodiment 5 of the present disclosure;
[0033] Figure 6A schematic diagram of the structure of a data processing device provided in Embodiment 6 of the present disclosure;
[0034] Figure 7 This is a schematic diagram of the structure of an electronic device provided in Embodiment 7 of the present disclosure. DETAILED DESCRIPTION
[0035] Embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although certain embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be construed as being limited to the embodiments described herein, which are instead provided for a more thorough and complete understanding of the present disclosure. It should be understood that the drawings and embodiments of the present disclosure are only for exemplary purposes and are not intended to limit the scope of protection of the present disclosure.
[0036] It should be understood that the various steps described in the method embodiments of the present disclosure may be performed in different orders and / or in parallel. In addition, the method embodiments may include additional steps and / or omit the steps shown. The scope of the present disclosure is not limited in this respect.
[0037] The term "including" and its variations used herein are open inclusions, i.e., "including but not limited to". The term "based on" means "based at least in part on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments". The relevant definitions of other terms will be given in the following description.
[0038] It should be noted that the concepts of "first", "second", etc. mentioned in the present disclosure are only used to distinguish different devices, modules or units, and are not used to limit the order or interdependence of the functions performed by these devices, modules or units. It should be noted that the modifications of "one" and "multiple" mentioned in the present disclosure are illustrative rather than restrictive, and those skilled in the art should understand that unless otherwise clearly indicated in the context, they should be understood as "one or more".
[0039] The names of the messages or information exchanged between multiple devices in the embodiments of the present disclosure are only used for illustrative purposes and are not used to limit the scope of these messages or information.
[0040] Embodiment 1
[0041] Figure 1A flow chart of a data processing method provided in the first embodiment of the present disclosure is provided. The embodiment of the present disclosure is suitable for enabling a central processing unit to generate a coarse-grained shader according to neural network parameters so that when receiving data to be processed, the data can be quickly processed based on the shaders to be used corresponding to each network level. The method can be executed by a data processing device, which can be implemented in the form of software and / or hardware, and optionally, by an electronic device, which can be a mobile terminal, a PC or a server, etc.
[0042] like Figure 1 As shown, the method includes:
[0043] S110, obtaining neural network parameters corresponding to the target neural grid model.
[0044] It should be noted that the solution of this embodiment can be executed based on the target device, wherein the target device can be any terminal device equipped with a CPU and a GPU. When the target device receives the data to be processed, it can use the processing capabilities of the CPU and the GPU to process the received data.
[0045] Among them, the neural network model (NN) is a mathematical method that simulates the actual human neural network. Specifically, each neural network is a complex network system formed by a large number of simple processing units (which can be called neurons) that are widely connected to each other. It can at least reflect many basic characteristics of human brain functions and is a highly complex nonlinear dynamic learning system. Therefore, the neural network model has large-scale parallel, distributed storage and processing, self-organization, self-adaptation and self-learning capabilities, and is suitable for processing imprecise and fuzzy information processing problems that require considering many factors and conditions at the same time.
[0046] In this embodiment, the target neural network model can be one or more neural network models associated with a specific business. For example, when it is necessary to process graphics-related business, the corresponding convolutional neural network (CNN) model can be determined; when it is necessary to process business with multiple time periods, the corresponding recurrent neural network (RNN) model can be determined.
[0047] In this embodiment, in order for the computer device to perform calculations corresponding to the target neural network model, it is also necessary to obtain the neural network parameters corresponding to the target neural network. Among them, the neural network parameters are the multi-dimensional algorithm information involved in the target neural network model, which may include the identification of the target neural network model, the network structure, the number of neural network layers, the tensor of the neural network, the execution order of each layer, and at least one of the input and output of each layer. For example, when the target neural network model is a CNN model, the determined neural network parameters may be the data types of the input and output of the CNN, as well as the execution order of the input layer, convolution layer, activation function, pooling layer, and fully connected layer. It can be understood that based on the obtained neural network parameters, the computer can at least construct the target neural network model in the memory.
[0048] It can be understood that the structure of the target neural network model can be set according to the actual situation, and its specific neural network parameters correspond to each network level of the model. The CPU only needs to obtain the neural network parameters to construct the corresponding network levels, thereby obtaining the target neural network model.
[0049] It should be noted that, in the actual application process, the neural network parameters corresponding to each target business can be obtained in advance and stored in the corresponding server, and called when the model-related calculation needs to be performed, or the required neural network parameters can be obtained in real time in a dynamic manner when the target neural network model-related heterogeneous calculation needs to be performed. Those skilled in the art should understand that the specific method of obtaining the neural network parameters can be selected according to the actual situation, and the embodiments of the present disclosure are not specifically limited here.
[0050] S120. Generate a shader to be used corresponding to each network level according to the neural network parameters.
[0051] In this embodiment, heterogeneous computing of neural networks is a special form of parallel and distributed computing. It can be understood that the performance characteristics required by heterogeneous computing are actually very similar to those of graphics-related algorithms, which usually involve a large number of buffers for parameters, activation values, and gradient values, each of which is updated in each training iteration or data processing process. These buffers are too large and will exceed the cache of traditional desktop computers. Therefore, a GPU with very high memory bandwidth can be used to perform related calculations of neural networks.
[0052] Therefore, in this embodiment, after obtaining the neural network parameters, in order to use the GPU to process the business-related data when receiving the data, it is first necessary to use the CPU to generate a shader to be used that corresponds to the target neural network model and can be run in the GPU. Among them, the shader to be used can be understood as a calculation shader that is not related to conventional graphics rendering. When the GPU loads the generated calculation shader, it can perform calculations related to the target neural network model.
[0053] At the same time, since the target neural network model determined by the CPU includes multiple network levels, when generating shaders to be used, it is usually necessary to generate corresponding shaders to be used for each network level. Specifically, it is necessary to call the shader generation module to process the neural network parameters to obtain the shaders to be used for each network level in the target neural network model. Among them, the shader generation module refers to a processing module deployed on the CPU side, which at least has the function of constructing shaders to be used. Since the neural network parameters correspond to each network level of the target neural network model, the shaders to be used generated by the CPU using the shader generation module also correspond to each network level of the model.
[0054] In this embodiment, the CPU constructs coarse-grained shaders to be used for each network level of the target neural network model, rather than constructing fine-grained shaders for specific operators in each network level. This avoids frequent interactions between the CPU and GPU during neural network calculations and reduces the limitations of the GPU communication bandwidth on the neural network performance.
[0055] Exemplarily, when it is determined that the target neural network model is a CNN model and the neural network parameters of the CNN model are obtained, the CPU can determine the input layer, convolution layer, pooling layer and fully connected layer of the CNN based on the obtained neural network parameters, and then generate shaders to be used corresponding to each network layer. It can be understood that after generating corresponding shaders to be used for each layer of the target neural network model, whichever shader the GPU executes in the subsequent process represents the execution of calculations of the network layer corresponding to the shader.
[0056] S130. Determine the computing pipeline corresponding to the shader to be used according to the target device parameters of the device to which the target neural network model belongs, so that when receiving the data to be processed, the computing pipeline is called according to the target device parameters to process the data to be processed and obtain the target processing result.
[0057] In this embodiment, since not all GPUs use the same instruction set, only by converting the program into a binary file can the GPU load and use the shaders to be used corresponding to each network level based on its own architecture set. Therefore, after the CPU generates the shaders to be used corresponding to each network level of the target neural network model, it is also necessary to call the GPU's driving capability to generate the computing pipeline corresponding to each shader to be used.
[0058] Among them, for a computer, a computing pipeline can be understood as the pipeline required by a GPU to run a program, and the process of determining the computing pipeline can be understood as the process in which the CPU calls the GPU's driving capability to compile, encapsulate, and store each shader to be used in the target cache based on a pre-set data structure. Exemplarily, after pre-setting the json format as the data structure of the computing pipeline, the CPU can call the GPU's driving capability to compile, encapsulate, and cache each shader to be used. It can be understood that the data in the json format finally stored in the target cache is the key data in each shader to be used. When processing specific business data later, the GPU can load these key data as the computing pipeline based on the target cache, thereby performing corresponding heterogeneous calculations according to the execution order of each network layer of the target neural network model.
[0059] In this embodiment, each computing pipeline can be determined according to the target device parameters of the device to which the target neural network model belongs. The target device can be a device that performs target neural network model-related calculations based on a GPU, and correspondingly, the target device parameters are the attribute information of the GPU carried by the target device.
[0060] In actual application, the target device parameters include an indirect buffer parameter (IndirectBuffer), which can be understood as information that characterizes whether the GPU supports the indirect buffer function. Specifically, when the GPU supports indirect buffering, the GPU can determine the execution order of the loaded shaders to be used based on itself when processing business data. When the GPU does not support indirect buffering, when the GPU processes business data, it needs to determine the next shader to be executed based on the instructions sent by the CPU after executing a shader to be used.
[0061] It can be understood that when the GPU supports indirect caching, the overall heterogeneous computing process of the target neural network model can be completed without the CPU sending instructions. However, when the GPU does not support indirect caching, it is necessary to interact with the CPU multiple times in the process of executing calculations related to the target neural network model, and determine the next shader to be executed based on the instructions sent by the CPU.
[0062] Based on this, when the target device parameters are different, the CPU determines the computing pipelines in different ways. It can be understood that, depending on whether the GPU supports indirect cache, the CPU has two corresponding ways to determine the computing pipelines corresponding to each shader to be used.
[0063] The first method is that if the indirect buffer parameter of the device to which the target neural network model belongs is the first parameter, a scheduling shader corresponding to each shader to be used is generated; and a computing pipeline is obtained by compiling and processing the scheduling shader and the shader to be used.
[0064] Specifically, when the indirect buffer parameter is the first parameter, it means that the GPU equipped with the target device supports indirect buffering, and therefore, a scheduling shader corresponding to each shader to be used can be generated. Among them, the scheduling shader can be understood as a program code running in the GPU for controlling the execution order of each shader to be used. For example, when the target device parameter is determined to be the first buffer parameter, the corresponding scheduling shader can be generated for the input layer, convolution layer, pooling layer and fully connected layer in the CNN model. When the relevant image data is subsequently processed, the GPU can determine the execution order of each layer in the CNN model based on the scheduling shader. It can be understood that after the GPU completes the execution of the shader to be used corresponding to the input layer, it can be determined according to the scheduling shader that the next shader to be executed is the shader to be used corresponding to the convolution layer.
[0065] In this embodiment, after generating the scheduling shader and each shader to be used, the generated shaders can be compiled based on the CPU to obtain the computing pipeline corresponding to each shader. Among them, the computing pipeline includes a sub-computing pipeline corresponding to each shader to be used, and a control pipeline corresponding to each sub-computing pipeline. It can be understood that the sub-computing pipeline contains key data corresponding to the corresponding network level, and the control pipeline contains key data for controlling the execution order of each network level.
[0066] The second method is, if the indirect buffer parameter of the device to which the target neural network model belongs is the second parameter, then determining the sub-computing pipeline corresponding to each shader to be used; and determining the computing pipeline based on each sub-computing pipeline.
[0067] Specifically, when the indirect buffer parameter is the second parameter, it means that the GPU equipped with the target device does not support indirect buffering. Therefore, there is no need to generate a scheduling shader corresponding to each shader to be used, but directly generate a sub-computing pipeline corresponding to each shader to be used. Further, the determined sub-computing keys are integrated to obtain a computing pipeline corresponding to the target neural network model. It can be understood that when the indirect buffer parameter is the second parameter, when the GPU processes each business data, it cannot determine the execution order of each shader to be used based on itself. Therefore, it is necessary to execute each segment of the shader to be used based on the instructions sent by the CPU.
[0068] In this embodiment, after determining the computing pipeline, the CPU can cache the neural network parameters and computing pipeline of the target neural network model, so that when receiving the data to be processed, the neural network parameters and computing pipeline are called to process the data to be processed. The data to be processed can be data related to the business associated with the target neural network model, and the data to be processed is also the input of the target neural network model.
[0069] Exemplarily, after the CPU determines the neural network parameters of the CNN model, the sub-computation pipelines corresponding to each network level, and the control pipelines corresponding to the scheduling shaders, these data can be stored in the target cache. After receiving the business data associated with the CNN model (i.e., the data to be processed), the GPU of the target device can load the sub-computation pipelines and control pipelines corresponding to the target neural network model based on the target cache to process the data to be processed, that is, under the scheduling of the control pipeline, the business data is first input to the input layer, and after the shader to be used corresponding to the input layer is executed, the result output by the layer is sequentially input to the convolution layer, the pooling layer, and the fully connected layer under the scheduling of the control pipeline, and the shaders to be used corresponding to each network level are executed, so as to obtain the processing result corresponding to the data to be processed for the business.
[0070] The technical solution of the disclosed embodiment obtains neural network parameters corresponding to the target neural network model; generates shaders to be used corresponding to each network level according to the neural network parameters, that is, generates corresponding shaders to be used for multiple network levels in the target neural network model; further, determines the computing pipeline corresponding to the shader to be used according to the target device parameters of the device to which the target neural network model belongs, so that when receiving the data to be processed, the computing pipeline is called to process the data to be processed according to the target device parameters to obtain the target processing result, generates shaders corresponding to each network level of the neural network model by the CPU, and then performs coarse-grained calculations based on each shader after receiving the data to be processed, so as to greatly reduce the interaction between the CPU and the GPU, reduce the limitation of the GPU communication bandwidth on the model calculation process, and improve the performance of the neural network model.
[0071] Embodiment 2
[0072] As an alternative embodiment of the above embodiment, Figure 2 A flow chart of a data processing method provided in the second embodiment of the present disclosure. In order to clearly introduce the technical solution of this embodiment, the application scenario can be described as an example of dynamically generating a shader program based on a central processing unit, and processing the data to be processed by a target device when receiving the data to be processed. However, it is not limited to the above scenario and can be applied to various scenarios where data related to a target neural network model needs to be processed.
[0073] See also Figure 2 In the process of CPU building a neural network, it is first necessary to obtain the model parameters of the target neural network model. The parameters can be determined based on the configuration parameters entered by the caller. For example, when the caller who needs to carry out a certain business enters the relevant configuration parameters of the CNN model on the target page, the processing module on the CPU side can obtain these parameters and use them as neural network parameters.
[0074] Continue to see Figure 2 After the CPU determines the target neural network model and the corresponding neural network parameters, it can generate shaders to be used for neural network calculations for each level of the model; further, it determines whether the GPU of the target device supports indirect caching. When it is determined that the GPU supports indirect caching, the CPU also needs to generate scheduling shaders for each level, and call the GPU driver to compile the scheduling shaders and each shader to be used to obtain the corresponding computing pipeline. It can be understood that the computing pipeline includes sub-computing pipelines corresponding to each shader to be used, and control pipelines corresponding to the scheduling shader. When it is determined that the GPU does not support indirect caching, the CPU directly generates sub-computing pipelines corresponding to each shader to be used.
[0075] Continue to see Figure 2 After the CPU generates the computing pipeline, the neural network parameters and the computing pipeline can be cached, so that when receiving the data to be processed, the associated GPU can retrieve the above data from the cache and process the data to be processed.
[0076] The technical solution of the disclosed embodiment is to generate shaders corresponding to each network level of the neural network model through the CPU, and then perform coarse-grained calculations based on each shader after receiving the data to be processed, so as to greatly reduce the interaction between the CPU and the GPU, reduce the limitation of the GPU communication bandwidth on the model calculation process, and improve the performance of the neural network model.
[0077] Embodiment 3
[0078] Figure 3 A flow chart of a data processing method provided in the third embodiment of the present disclosure is applicable to a situation in which a computing pipeline in a cache is loaded based on a graphics processor to process data to be processed. The method can be executed by a data processing device, which can be implemented in the form of software and / or hardware, and optionally, by an electronic device, which can be a mobile terminal, a PC or a server, etc.
[0079] like Figure 3 As shown, the method includes:
[0080] S210. When receiving data to be processed, load predetermined computing pipeline and neural network parameters.
[0081] In this embodiment, since the computing pipeline is determined based on the neural network parameters of the target neural network model and the target device parameters to which the target neural network model belongs by the central processing unit, and at the same time, the CPU has stored the neural network parameters of each target neural network model and the computing pipeline in the target cache, when the target device receives the data to be processed, the CPU is first required to load the above-mentioned data determined based on the cache, and further, the GPU equipped with the device loads the target neural network model and each computing pipeline based on the application programming interface (Application Programming Interface, API) that interacts with the CPU, that is, the model, i.e., the computing pipeline, is deployed on the GPU to process the data to be processed.
[0082] Exemplarily, when the CPU determines the computing pipeline for the neural network parameters of the CNN model and the target device parameters of the target device (i.e., information characterizing whether the target device supports indirect caching), and pre-stores the neural network parameters and the computing pipeline in the target cache, when the target device receives the to-be-processed data of the service associated with the CNN model, the CPU can load the CNN model and the corresponding computing pipelines, and at the same time, send a program execution instruction to the GPU, so as to deploy the model and the computing pipeline in the GPU using the corresponding API interface, that is, the GPU loads the CNN model corresponding to the service, and the computing pipeline corresponding to the input layer, convolution layer, pooling layer and fully connected layer, so as to perform heterogeneous computing corresponding to the above-mentioned network layers.
[0083] S220: Determine, according to the target device parameters, a target processing method for each shader to be used to process the data to be processed.
[0084] Among them, the shader to be used is obtained after the central processing unit processes the neural network parameters, that is, the CPU can process the neural network parameters in the manner of the first embodiment of the present disclosure, so as to obtain the shader to be used corresponding to each network level of the target neural network model. The embodiment of the present disclosure will not be repeated here.
[0085] In this embodiment, when the target device parameters are different, the processing methods of the GPU are also different. Optionally, if the target device parameter is a first parameter, the target processing method for each shader to be used to process the data to be processed is determined to be the first target processing method; if the target device parameter is a second parameter, the target processing method is determined to be the second target processing method.
[0086] It can be understood that when it is determined that the GPU equipped with the target device supports indirect caching, the first target processing method is determined, so that the data to be processed is processed based on each shader to be used. When it is determined that the GPU equipped with the target device does not support indirect caching, the second target processing method is determined, so that the data to be processed is processed based on each shader to be used.
[0087] S230: Process the data to be processed based on the target processing method to obtain a target processing result.
[0088] In this embodiment, optionally, when the target processing mode is the first target processing mode, the execution order of each sub-computing pipeline is determined based on the control pipeline corresponding to the computing pipeline; based on the execution order and the corresponding sub-computing pipeline, a program execution instruction is sent to the corresponding shader to be used, so that each shader to be used processes the data to be processed to obtain the target processing result.
[0089] Exemplarily, when the GPU carried by the target device supports indirect caching, the target processing mode can be determined as the first target processing mode. At the same time, since the CPU has constructed corresponding sub-computing pipelines for each network level of the CNN model as the target neural network model, as well as control pipelines that control the execution order of each network level, and the above-mentioned computing pipelines are stored in the target cache, when processing the data to be processed, the GPU can directly load the control pipeline in the cache, thereby determining the execution order as the input layer, convolution layer, pooling layer, and fully connected layer. Furthermore, based on the determined execution order, the GPU can use the input layer sub-computing pipeline, the convolution layer sub-computing pipeline, the pooling layer sub-computing pipeline, and the fully connected layer sub-computing pipeline to send program execution instructions to the corresponding shaders to be used in each network level in turn, so as to run each segment of the program to process the data to be processed.
[0090] Optionally, a program execution instruction sent based on the current sub-computing pipeline is received; based on the program execution instruction, the data to be processed is processed to obtain a data processing result, and the data processing result is fed back to the central processing unit, so that when the central processing unit receives the data processing result, the next sub-computing pipeline of the current sub-computing pipeline is used as the current sub-computing pipeline, and the program execution instruction is sent based on the current sub-computing pipeline until the current sub-computing pipeline is the last sub-computing pipeline, so as to obtain the target processing result corresponding to the data to be processed.
[0091] Specifically, when the GPU on the target device does not support indirect caching, the target processing mode can be determined as the second target processing mode. In this case, the CPU only builds corresponding sub-computing pipelines for each network level of the target neural network model, and stores the above-mentioned computing pipelines in the target cache. Therefore, when processing the data to be processed, the GPU cannot determine the execution order of the shaders to be used associated with each network level based on itself, but needs to process the data to be processed according to the program execution instructions sent by the CPU. It can be understood that the program execution instructions are determined based on the sub-computing pipelines of each neural network level by the central processing unit.
[0092] Exemplarily, when the CPU only constructs a corresponding sub-computing pipeline for each network layer of the CNN model as the target neural network model, and stores the above-mentioned computing pipeline in the target cache, the GPU cannot determine the execution order of each shader to be used when processing the data to be processed, and needs to receive the program execution instruction sent by the CPU and parse the instruction to determine that the first shader to be executed is the shader to be used corresponding to the CNN input layer, and further, the corresponding shader to be used is loaded and executed based on the sub-computing pipeline corresponding to the input layer, so as to process the data to be processed; at the same time, the CPU The processing module on the U side can perform asynchronous queries on the execution results of the GPU, or receive feedback information sent by the GPU based on the execution results. When the CPU determines that the shader to be used associated with the input layer executed by the GPU is correct and obtains valid data processing results, it can determine that the next network layer to be executed for the GPU is the convolution layer, and after using the sub-computing pipeline corresponding to the convolution layer as the current sub-computing pipeline, the corresponding message is sent to the GPU again in the form of a program execution instruction. The GPU executes the shader to be used corresponding to the CNN convolution layer based on the current sub-computing pipeline and executes it, and obtains the corresponding processing results again. Based on this method, the GPU executes the shaders to be used corresponding to the pooling layer and the fully connected layer in sequence, and obtains the final target processing result.
[0093] The above process can be understood as follows: after the CPU constructs the corresponding sub-computing pipelines for the four network layers of the target neural network model, it can send instructions to the GPU, so that the GPU executes the first layer of shaders to be used based on the sub-computing pipelines corresponding to the first layer. When the GPU completes the execution, it sends a message to the CPU that the program has been executed. After receiving the message, the CPU can send instructions to the GPU to execute the second layer of shaders to be used, and so on, until the GPU completes the execution of all shaders to be used in the four network layers. When the GPU obtains the target processing result, the CPU can directly read the target processing result, or store the target processing result on the GPU side for subsequent calls by other shaders to be used.
[0094] The technical solution of the disclosed embodiment loads predetermined computing pipeline and neural network parameters when receiving the data to be processed, and determines the target processing mode for each shader to be used to process the data to be processed according to the target device parameters; the data to be processed is processed based on the target processing mode to obtain the target processing result, so that after receiving the data to be processed, the GPU performs coarse-grained calculations based on each shader in the cache, thereby greatly reducing the interaction between the CPU and the GPU, reducing the limitation of the GPU communication bandwidth on the model calculation process, and improving the performance of the neural network model.
[0095] Embodiment 4
[0096] As an alternative embodiment of the above embodiment, Figure 4 A flow chart of a data processing method provided in the fourth embodiment of the present disclosure. In order to clearly introduce the technical solution of this embodiment, the application scenario can be based on the computing pipeline in the GPU loading cache, and the case of processing the data to be processed can be used as an example to introduce, but it is not limited to the above scenario, and can be applied to various scenarios that need to process data related to the target neural network model.
[0097] See also Figure 4 In the process of GPU calling the neural network, the processing module on the CPU side first needs to load the built computing pipeline and neural network parameters. At the same time, the processing module on the CPU side also needs to load business data, and the GPU loads the computing pipeline based on the cache.
[0098] Continue to see Figure 4When the above data is loaded, it is necessary to determine whether the GPU supports indirect buffering. When the GPU supports indirect buffering, the GPU-side processing module can directly load the control pipeline into the indirect buffer, and determine the execution order of each network layer of the target neural network model based on the control pipeline. Further, according to the determined execution order, the corresponding shader program to be used is executed in turn based on the sub-computing pipeline corresponding to each network layer, thereby completing the scheduling of the entire process of the target neural network model; when the GPU does not support indirect buffering, the CPU-side processing module is required to schedule each network layer of the target neural network model. Under the control of the CPU, the GPU can determine the execution order of each layer of the target neural network model, thereby executing the corresponding shader to be used in the order given by the CPU.
[0099] Continue to see Figure 4 When the GPU processes the data to be processed based on the shader programs to be used, the CPU-side processing module can determine whether the target neural network model has been executed by asynchronous query. When it is determined that the model has been executed, the target processing result can be directly read, or the target processing result can be saved on the GPU side for use by other shaders to be used.
[0100] The technical solution of the disclosed embodiment enables the GPU to perform coarse-grained calculations based on the shaders in the cache after receiving the data to be processed, thereby greatly reducing the interaction between the CPU and the GPU, reducing the limitations of the GPU communication bandwidth on the model calculation process, and improving the performance of the neural network model.
[0101] Embodiment 5
[0102] Figure 5 A schematic diagram of the structure of a data processing device provided in Embodiment 5 of the present disclosure is shown in FIG. Figure 5 As shown, the apparatus includes: a network parameter determination module 310 , a shader determination module 320 and a pipeline determination module 330 .
[0103] The network parameter determination module 310 is used to obtain the neural network parameters corresponding to the target neural grid model.
[0104] The shader determination module 320 is used to generate a shader to be used corresponding to each network level according to the neural network parameters; wherein the target neural network model includes multiple network levels.
[0105] The pipeline determination module 330 is used to determine the computing pipeline corresponding to the shader to be used according to the target device parameters of the device to which the target neural network model belongs, so that when receiving the data to be processed, the computing pipeline is called according to the target device parameters to process the data to be processed to obtain the target processing result.
[0106] Optionally, the shader determination module 320 is further used to call the shader generation module to process the neural network parameters to obtain the shader to be used for each network level in the target neural network model.
[0107] Based on the above technical solutions, the target device parameters include indirect buffer parameters.
[0108] Based on the above technical solutions, the pipeline determination module 330 includes a scheduling shader generation unit and a computing pipeline determination unit.
[0109] A scheduling shader generation unit is used to generate a scheduling shader corresponding to each shader to be used if the indirect buffer parameter of the device to which the target neural network model belongs is the first parameter.
[0110] The computing pipeline determination unit is used to obtain a computing pipeline by compiling and processing the scheduling shader and the shader to be used; wherein the computing pipeline includes a sub-computing pipeline corresponding to each shader to be used, and a control pipeline corresponding to each sub-computing pipeline.
[0111] On the basis of the above technical solutions, the pipeline determination module 330 further includes a sub-computing pipeline determination unit.
[0112] The sub-computing pipeline determination unit is used to determine the sub-computing pipeline corresponding to each shader to be used if the indirect buffer parameter of the device to which the target neural network model belongs is the second parameter.
[0113] The computing pipeline determining unit is further configured to determine the computing pipeline based on each sub-computing pipeline.
[0114] The technical solution provided in this embodiment obtains neural network parameters corresponding to the target neural network model; generates shaders to be used corresponding to each network level according to the neural network parameters, that is, generates corresponding shaders to be used for multiple network levels in the target neural network model; further, determines the computing pipeline corresponding to the shader to be used according to the target device parameters of the device to which the target neural network model belongs, so that when receiving the data to be processed, the computing pipeline is called to process the data to be processed according to the target device parameters to obtain the target processing result, and generates shaders corresponding to each network level of the neural network model through the CPU, and then performs coarse-grained calculations based on each shader after receiving the data to be processed, so as to greatly reduce the interaction between the CPU and the GPU, reduce the limitation of the GPU communication bandwidth on the model calculation process, and improve the performance of the neural network model.
[0115] The data processing device provided in the embodiments of the present disclosure can execute the data processing method provided in any embodiment of the present disclosure, and has the corresponding functional modules and beneficial effects of the execution method.
[0116] It is worth noting that the various units and modules included in the above-mentioned device are only divided according to functional logic, but are not limited to the above-mentioned division, as long as the corresponding functions can be achieved; in addition, the specific names of the functional units are only for the convenience of distinguishing each other, and are not used to limit the protection scope of the embodiments of the present disclosure.
[0117] Embodiment 6
[0118] Figure 6 A schematic diagram of the structure of a data processing device provided in Embodiment 6 of the present disclosure is shown in FIG. Figure 6 As shown, the device includes: a network parameter loading module 410, a processing method determination module 420 and a processing result determination module 430.
[0119] The network parameter loading module 410 is used to load the predetermined computing pipeline and neural network parameters when receiving the data to be processed; wherein the computing pipeline is determined based on the neural network parameters of the target neural network model and the target device parameters of the target neural network model by the central processing unit.
[0120] The processing mode determination module 420 is used to determine the target processing mode for each shader to be used to process the data to be processed based on the target device parameters; wherein the shader to be used is obtained after the central processing unit processes the neural network parameters.
[0121] The processing result determination module 430 is used to process the data to be processed based on the target processing method to obtain a target processing result.
[0122] Optionally, the processing mode determination module 420 is also used to determine that the target processing mode for each shader to be used to process the processed data is the first target processing mode if the target device parameter is the first parameter; if the target device parameter is the second parameter, determine that the target processing mode is the second target processing mode.
[0123] Optionally, the processing result determination module 430 is also used to determine the execution order of each sub-computing pipeline based on the control pipeline corresponding to the computing pipeline; based on the execution order and the corresponding sub-computing pipeline, send program execution instructions to the corresponding shader to be used, so that each shader to be used processes the data to be processed and obtains the target processing result.
[0124] Optionally, the processing result determination module 430 is also used to receive a program execution instruction sent based on the current sub-computing pipeline; wherein the program execution instruction is determined based on the sub-computing pipeline of each neural network layer by the central processing unit; based on the program execution instruction, the data to be processed is processed to obtain an image processing result, and the image processing result is fed back to the central processing unit, so that when the central processing unit receives the image processing result, the next sub-computing pipeline of the current sub-computing pipeline is used as the current sub-computing pipeline, and a program execution instruction is sent based on the current sub-computing pipeline until the current sub-computing pipeline is the last sub-computing pipeline, and a target processing result corresponding to the data to be processed is obtained.
[0125] The technical solution provided in this embodiment loads the predetermined computing pipeline and neural network parameters when receiving the data to be processed, and determines the target processing method for each shader to be used to process the data to be processed based on the target device parameters; the data to be processed is processed based on the target processing method to obtain the target processing result, so that after receiving the data to be processed, the GPU performs coarse-grained calculations based on each shader in the cache, thereby greatly reducing the interaction between the CPU and the GPU, reducing the limitation of the GPU communication bandwidth on the model calculation process, and improving the performance of the neural network model.
[0126] The data processing device provided in the embodiments of the present disclosure can execute the data processing method provided in any embodiment of the present disclosure, and has the corresponding functional modules and beneficial effects of the execution method.
[0127] It is worth noting that the various units and modules included in the above-mentioned device are only divided according to functional logic, but are not limited to the above-mentioned division, as long as the corresponding functions can be achieved; in addition, the specific names of the functional units are only for the convenience of distinguishing each other, and are not used to limit the protection scope of the embodiments of the present disclosure.
[0128] Embodiment 7
[0129] Figure 7 This is a schematic diagram of the structure of an electronic device provided by Embodiment 7 of the present disclosure. Figure 7 , which shows an electronic device (eg, Figure 7 The terminal device in the embodiment of the present disclosure may include but is not limited to mobile terminals such as mobile phones, notebook computers, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), vehicle-mounted terminals (such as vehicle-mounted navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, etc. Figure 7The electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.
[0130] like Figure 7 As shown, the electronic device 500 may include a processing device (e.g., a central processing unit, a graphics processing unit, etc.) 501, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 502 or a program loaded from a storage device 506 into a random access memory (RAM) 503. In the RAM 503, various programs and data required for the operation of the electronic device 500 are also stored. The processing device 501, the ROM 502, and the RAM 503 are connected to each other via a bus 504. An edit / output (I / O) interface 505 is also connected to the bus 504.
[0131] Typically, the following devices may be connected to the I / O interface 505: an editing device 506 including, for example, a touch screen, a touch pad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; an output device 507 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 506 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 509. The communication device 509 may allow the electronic device 500 to communicate with other devices wirelessly or by wire to exchange data. Although Figure 7 The electronic device 500 is shown with various devices, but it should be understood that it is not required to implement or possess all the devices shown. More or fewer devices may be implemented or possessed instead.
[0132] In particular, according to an embodiment of the present disclosure, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a non-transitory computer-readable medium, and the computer program contains program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication device 509, or installed from the storage device 506, or installed from the ROM 502. When the computer program is executed by the processing device 501, the above-mentioned functions defined in the method of the embodiment of the present disclosure are executed.
[0133] The names of the messages or information exchanged between multiple devices in the embodiments of the present disclosure are only used for illustrative purposes and are not used to limit the scope of these messages or information.
[0134] The electronic device provided by the embodiment of the present disclosure and the data processing method provided by the above embodiment belong to the same inventive concept. The technical details not fully described in this embodiment can be referred to the above embodiment, and this embodiment has the same beneficial effects as the above embodiment.
[0135] Embodiment 8
[0136] The embodiments of the present disclosure provide a computer storage medium on which a computer program is stored. When the program is executed by a processor, the data processing method provided by the above embodiments is implemented.
[0137] It should be noted that the computer-readable medium disclosed above may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program that may be used by or in combination with an instruction execution system, device or device. In the present disclosure, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, in which a computer-readable program code is carried. This propagated data signal may take a variety of forms, including but not limited to an electromagnetic signal, an optical signal, or any suitable combination of the above. The computer readable signal medium may also be any computer readable medium other than a computer readable storage medium, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer readable medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, RF (radio frequency), etc., or any suitable combination of the above.
[0138] In some embodiments, the client and the server may communicate using any currently known or future developed network protocol such as HTTP (HyperText Transfer Protocol), and may be interconnected with any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network ("LAN"), a wide area network ("WAN"), an internet (e.g., the Internet), and a peer-to-peer network (e.g., an ad hoc peer-to-peer network), as well as any currently known or future developed network.
[0139] The computer-readable medium may be included in the electronic device, or may exist independently without being incorporated into the electronic device.
[0140] The computer-readable medium carries one or more programs. When the one or more programs are executed by the electronic device, the electronic device:
[0141] Obtaining neural network parameters corresponding to a target neural grid model;
[0142] According to the neural network parameters, a shader to be used corresponding to each network level is generated; wherein the target neural network model includes multiple network levels;
[0143] According to the target device parameters of the device to which the target neural network model belongs, the computing pipeline corresponding to the shader to be used is determined, so that when the data to be processed is received, the computing pipeline is called to process the data to be processed according to the target device parameters to obtain the target processing result.
[0144] or,
[0145] When receiving the data to be processed, loading the predetermined computing pipeline and neural network parameters; wherein the computing pipeline is determined based on the neural network parameters of the target neural network model and the target device parameters of the target neural network model by the central processor;
[0146] According to the target device parameters, determining a target processing mode for each shader to be used to process the data to be processed; wherein the shader to be used is obtained after the central processing unit processes the neural network parameters;
[0147] The data to be processed is processed based on the target processing method to obtain a target processing result.
[0148] Computer program code for performing the operations of the present disclosure may be written in one or more programming languages or a combination thereof, including, but not limited to, object-oriented programming languages, such as Java, Smalltalk, C++, and conventional procedural programming languages, such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., through the Internet using an Internet service provider).
[0149] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present disclosure. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some implementations as replacements, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0150] The units involved in the embodiments described in the present disclosure may be implemented by software or hardware. The name of a unit does not limit the unit itself in some cases. For example, the first acquisition unit may also be described as a "unit for acquiring at least two Internet Protocol addresses".
[0151] The functions described above herein may be performed at least in part by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that may be used include: field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), complex programmable logic devices (CPLDs), and the like.
[0152] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0153] According to one or more embodiments of the present disclosure, [Example 1] provides a data processing method, which is applied to a central processing unit, and the method includes:
[0154] Obtaining neural network parameters corresponding to a target neural grid model;
[0155] According to the neural network parameters, a shader to be used corresponding to each network level is generated; wherein the target neural network model includes multiple network levels;
[0156] According to the target device parameters of the device to which the target neural network model belongs, the computing pipeline corresponding to the shader to be used is determined, so that when the data to be processed is received, the computing pipeline is called to process the data to be processed according to the target device parameters to obtain the target processing result.
[0157] According to one or more embodiments of the present disclosure, [Example 2] provides a data processing method, the method further comprising:
[0158] Optionally, generating a shader to be used corresponding to each network level according to the neural network parameters includes:
[0159] The shader generation module is called to process the neural network parameters to obtain the shader to be used for each network level in the target neural network model.
[0160] According to one or more embodiments of the present disclosure, [Example 3] provides a data processing method, the method further comprising:
[0161] Optionally, the target device parameter includes an indirect buffer parameter, and determining the computing pipeline corresponding to the shader to be used according to the target device parameter of the device to which the target neural network model belongs includes:
[0162] If the indirect buffer parameter of the device to which the target neural network model belongs is the first parameter, generating a scheduling shader corresponding to each shader to be used;
[0163] Obtain a computing pipeline by compiling the scheduling shader and the shader to be used;
[0164] The computing pipeline includes a sub-computing pipeline corresponding to each shader to be used, and a control pipeline corresponding to each sub-computing pipeline.
[0165] According to one or more embodiments of the present disclosure, [Example 4] provides a data processing method, the method further comprising:
[0166] Optionally, the target device parameter includes an indirect buffer parameter, and determining the computing pipeline corresponding to the shader to be used according to the target device parameter of the device to which the target neural network model belongs includes:
[0167] If the indirect buffer parameter of the device to which the target neural network model belongs is the second parameter, determining the sub-computation pipeline corresponding to each shader to be used;
[0168] Based on each sub-computation pipeline, the computation pipeline is determined.
[0169] According to one or more embodiments of the present disclosure, [Example 5] provides a data processing method, the method further comprising:
[0170] Optionally, the neural network parameters and computing pipeline of the target neural network model are cached so that when the data to be processed is received, the neural network parameters and computing pipeline are called to process the data to be processed.
[0171] According to one or more embodiments of the present disclosure, [Example 6] provides a data processing method, which is applied to a graphics processor, and the method includes:
[0172] When receiving the data to be processed, loading the predetermined computing pipeline and neural network parameters; wherein the computing pipeline is determined based on the neural network parameters of the target neural network model and the target device parameters of the target neural network model by the central processor;
[0173] According to the target device parameters, determining a target processing mode for each shader to be used to process the data to be processed; wherein the shader to be used is obtained after the central processing unit processes the neural network parameters;
[0174] The data to be processed is processed based on the target processing method to obtain a target processing result.
[0175] According to one or more embodiments of the present disclosure, [Example 7] provides a data processing method, the method further comprising:
[0176] Optionally, determining, according to the target device parameters, a target processing mode for each shader to be used to process the data to be processed includes:
[0177] If the target device parameter is the first parameter, determining that the target processing mode for processing the data to be processed by each shader to be used is the first target processing mode;
[0178] If the target device parameter is the second parameter, the target processing method is determined to be the second target processing method.
[0179] According to one or more embodiments of the present disclosure, [Example 8] provides a data processing method, the method further comprising:
[0180] Optionally, the target processing method is a first target processing method, and the processing of the data to be processed based on the target processing method to obtain a target processing result includes:
[0181] Determining the execution order of each sub-computing pipeline based on the control pipeline corresponding to the computing pipeline;
[0182] Based on the execution order and the corresponding sub-computing pipelines, program execution instructions are sent to corresponding shaders to be used, so that each shader to be used processes the data to be processed to obtain the target processing result.
[0183] According to one or more embodiments of the present disclosure, [Example 9] provides a data processing method, the method further comprising:
[0184] Optionally, the processing the data to be processed based on the target processing mode to obtain a target processing result includes:
[0185] Receiving a program execution instruction sent based on the current sub-computing pipeline; wherein the program execution instruction is determined by the central processing unit according to the sub-computing pipeline of each neural network layer;
[0186] Based on the program execution instructions, the data to be processed is processed to obtain a data processing result, and the data processing result is fed back to the central processing unit, so that when the central processing unit receives the data processing result, the next sub-computing pipeline of the current sub-computing pipeline is used as the current sub-computing pipeline, and program execution instructions are sent based on the current sub-computing pipeline until the current sub-computing pipeline is the last sub-computing pipeline, thereby obtaining a target processing result corresponding to the data to be processed.
[0187] According to one or more embodiments of the present disclosure, [Example 10] provides a data processing device, configured in a central processing unit, the device comprising:
[0188] A network parameter determination module, used to obtain neural network parameters corresponding to a target neural grid model;
[0189] A shader determination module, used to generate a shader to be used corresponding to each network level according to the neural network parameters; wherein the target neural network model includes multiple network levels;
[0190] The pipeline determination module is used to determine the computing pipeline corresponding to the shader to be used according to the target device parameters of the device to which the target neural network model belongs, so that when receiving the data to be processed, the computing pipeline is called according to the target device parameters to process the data to be processed to obtain the target processing result.
[0191] According to one or more embodiments of the present disclosure, [Example 11] provides a data processing device, configured in a graphics processor, the device comprising:
[0192] A network parameter loading module, used to load predetermined computing pipeline and neural network parameters when receiving data to be processed; wherein the computing pipeline is determined based on the neural network parameters of the target neural network model and the target device parameters of the target neural network model by the central processing unit;
[0193] A processing mode determination module is used to determine the target processing mode of each shader to be used to process the data to be processed according to the target device parameters; wherein the shader to be used is obtained after the central processing unit processes the neural network parameters;
[0194] The processing result determination module is used to process the data to be processed based on the target processing method to obtain a target processing result.
[0195] The above description is only a preferred embodiment of the present disclosure and an explanation of the technical principles used. Those skilled in the art should understand that the scope of disclosure involved in the present disclosure is not limited to the technical solutions formed by a specific combination of the above technical features, but should also cover other technical solutions formed by any combination of the above technical features or their equivalent features without departing from the above disclosed concept. For example, the above features are replaced with the technical features with similar functions disclosed in the present disclosure (but not limited to) by each other to form a technical solution.
[0196] In addition, although each operation is described in a specific order, this should not be understood as requiring these operations to be performed in the specific order shown or in a sequential order. Under certain circumstances, multitasking and parallel processing may be advantageous. Similarly, although some specific implementation details are included in the above discussion, these should not be interpreted as limiting the scope of the present disclosure. Some features described in the context of a separate embodiment can also be implemented in a single embodiment in combination. On the contrary, the various features described in the context of a single embodiment can also be implemented in multiple embodiments individually or in any suitable sub-combination mode.
[0197] Although the subject matter has been described in language specific to structural features and / or methodological logical actions, it should be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or actions described above. On the contrary, the specific features and actions described above are merely example forms of implementing the claims.
Claims
1. A data processing method, characterized in that: Applied in CPU, including: Obtaining neural network parameters corresponding to a target neural grid model; According to the neural network parameters, a shader to be used corresponding to each network level is generated; wherein the target neural network model includes multiple network levels; According to the target device parameters of the device to which the target neural network model belongs, the computing pipeline corresponding to the shader to be used is determined, so that when the data to be processed is received, the computing pipeline is called to process the data to be processed according to the target device parameters to obtain the target processing result.
2. The method according to claim 1, characterized in that The step of generating a shader to be used corresponding to each network level according to the neural network parameters comprises: The shader generation module is called to process the neural network parameters to obtain the shader to be used for each network level in the target neural network model.
3. The method according to claim 1, characterized in that: The target device parameter includes an indirect buffer parameter, and determining the computing pipeline corresponding to the shader to be used according to the target device parameter of the device to which the target neural network model belongs includes: If the indirect buffer parameter of the device to which the target neural network model belongs is the first parameter, generating a scheduling shader corresponding to each shader to be used; Obtain a computing pipeline by compiling the scheduling shader and the shader to be used; The computing pipeline includes a sub-computing pipeline corresponding to each shader to be used, and a control pipeline corresponding to each sub-computing pipeline.
4. The method according to claim 1, characterized in that: The target device parameters include indirect buffer parameters, and determining the computing pipeline corresponding to the shader to be used according to the target device parameters of the device to which the target neural network model belongs includes: If the indirect buffer parameter of the device to which the target neural network model belongs is the second parameter, determining the sub-computation pipeline corresponding to each shader to be used; Based on each sub-computation pipeline, the computation pipeline is determined.
5. The method according to claim 1, characterized in that Also includes: The neural network parameters and computing pipeline of the target neural network model are cached so that when the data to be processed is received, the neural network parameters and computing pipeline are called to process the data to be processed.
6. A data processing method, characterized in that: Applied in graphics processors, including: When receiving the data to be processed, loading the predetermined computing pipeline and neural network parameters; wherein the computing pipeline is determined based on the neural network parameters of the target neural network model by the central processor and the target device parameters to which the target neural network model belongs; According to the target device parameters, determining a target processing mode for each shader to be used to process the data to be processed; wherein the shader to be used is obtained after the central processing unit processes the neural network parameters; The data to be processed is processed based on the target processing method to obtain a target processing result.
7. The method according to claim 6, characterized in that Determining, according to the target device parameters, a target processing mode for each shader to be used to process the data to be processed includes: If the target device parameter is the first parameter, determining that the target processing mode for processing the data to be processed by each shader to be used is the first target processing mode; If the target device parameter is the second parameter, the target processing method is determined to be the second target processing method.
8. The method according to claim 7, characterized in that The target processing method is a first target processing method, and the data to be processed is processed based on the target processing method to obtain a target processing result, including: Determining the execution order of each sub-computing pipeline based on the control pipeline corresponding to the computing pipeline; Based on the execution order and the corresponding sub-computing pipelines, program execution instructions are sent to corresponding shaders to be used, so that each shader to be used processes the data to be processed to obtain the target processing result.
9. The method according to claim 8, characterized in that The processing of the data to be processed based on the target processing mode to obtain a target processing result includes: Receiving a program execution instruction sent based on the current sub-computing pipeline; wherein the program execution instruction is determined by the central processing unit according to the sub-computing pipeline of each neural network layer; Based on the program execution instructions, the data to be processed is processed to obtain a data processing result, and the data processing result is fed back to the central processing unit, so that when the central processing unit receives the data processing result, the next sub-computing pipeline of the current sub-computing pipeline is used as the current sub-computing pipeline, and program execution instructions are sent based on the current sub-computing pipeline until the current sub-computing pipeline is the last sub-computing pipeline, thereby obtaining a target processing result corresponding to the data to be processed.
10. A data processing device, characterized in that: Configured in the central processing unit, including: A network parameter determination module, used to obtain neural network parameters corresponding to a target neural grid model; A shader determination module, used to generate a shader to be used corresponding to each network level according to the neural network parameters; wherein the target neural network model includes multiple network levels; The pipeline determination module is used to determine the computing pipeline corresponding to the shader to be used according to the target device parameters of the device to which the target neural network model belongs, so that when receiving the data to be processed, the computing pipeline is called according to the target device parameters to process the data to be processed to obtain the target processing result.
11. A data processing device, characterized in that: Configured in the graphics processor, including: A network parameter loading module, used to load predetermined computing pipeline and neural network parameters when receiving data to be processed; wherein the computing pipeline is determined based on the neural network parameters of the target neural network model by the central processing unit and the target device parameters to which the target neural network model belongs; A processing mode determination module is used to determine the target processing mode of each shader to be used to process the data to be processed according to the target device parameters; wherein the shader to be used is obtained after the central processing unit processes the neural network parameters; The processing result determination module is used to process the data to be processed based on the target processing method to obtain a target processing result.
12. An electronic device, characterized in that: The electronic device comprises: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the data processing method as described in any one of claims 1-5 or 6-9.
13. A storage medium comprising computer executable instructions, wherein the computer executable instructions are used to perform the data processing method according to any one of claims 1 to 5 or 6 to 9 when executed by a computer processor.
Citation Information
Patent Citations
Execution model for heterogeneous cpu-GPU computing
CN104137070A
Data processing method, device and system for neural networks and storage medium
CN108875899A