Deep learning reasoning method and device based on operator selection and fine granularity fusion
By adopting the method of operator selection and fine-grained fusion in the deep learning inference system, combined with the linear regression model and persistent thread block strategy, the problems of resource waste and low throughput rate in the existing technology are solved, and a more efficient GPU is achieved. Resource utilization and system performance improvements.
Patent Information
- Application Number
- CN202410647065.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-23
- Publication Date
- 2024-08-23
AI Technical Summary
The existing deep learning inference system fails to fully utilize the two heterogeneous computing cores of Tensor Core and CUDA Core in the GPU in parallel, resulting in resource waste and reduced throughput. This is mainly due to the limited operator fusion range and the lack of clear operators to be fused. Choose a strategy.
Using a method based on operator selection and fine-grained fusion, the linear regression model is used to simulate the execution time of operator fusion in the data flow graph, dynamic programming selects the operator pair with the shortest execution time for fusion, and uses persistent thread block-based The operator horizontal fusion strategy integrates the CD kernel and the TC kernel, and divides the thread blocks into operators with smaller granularity to improve GPU resource utilization.
It improves the parallel utilization of Tensor Core and CUDA Core in the GPU, expands the scope of operator fusion, reduces online compilation overhead, and improves system throughput performance.
Smart Images

Figure CN118535332A
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of deep neural network hardware acceleration, and in particular to a deep learning reasoning method and device based on operator selection and fine-grained fusion. Background Art
[0002] In recent years, with the rapid development of big data and deep learning technologies, the scale of data and the size of neural network models have continued to grow, creating an increasingly urgent demand for computing power. To handle this massive amount of data, heterogeneous accelerators such as GPUs, NPUs, and TPUs have gained widespread adoption in industry and academia. GPUs, with their outstanding general-purpose parallel computing capabilities and compatible software ecosystem (e.g., NVIDIA's CUDA), play a crucial role in deep learning model training and inference.
[0003] Deep Neural Network (DNN) models are typically abstracted into data flow graphs consisting of operators and their dependencies. Currently, mainstream GPUs feature two types of computing cores: Tensor Cores and CUDA Cores. Tensor Cores accelerate the underlying matrix multiplications of operators, while CUDA Cores accelerate other underlying computations. Therefore, for deep learning inference systems, the core of DNN deployment, the key to improving system throughput and resource utilization is whether their design can fully utilize the two heterogeneous GPU computing cores in parallel.
[0004] Currently, two main optimization methods are commonly used to improve system throughput in deep learning inference systems: 1) Operator fusion: This targets groups of operators in a neural network that have direct upstream and downstream dependencies. Existing methods fuse these groups into a single operator, thereby reducing the frequent memory accesses caused by swapping intermediate results in and out of memory and reducing the overhead of multiple kernel launches. 2) Multitasking parallelism: By estimating task overhead, multiple tasks with low resource contention are co-located and run in parallel on the same GPU. This improves GPU resource utilization when multiple subtasks are run in parallel, while maintaining essentially the same execution latency, thereby increasing system throughput.
[0005] Currently, most AI computing scenarios involve multi-tenant, high-throughput operations using GPUs as computing platforms. However, existing technologies still have shortcomings. Existing technologies mainly include operator fusion, multi-stream mechanism (Multi-Stream), multi-process service (MPS), etc. Most of these methods do not take into account the parallel utilization of CUDA Core and Tensor Core, two heterogeneous computing cores. At the same time, because the NVIDIA GPU architecture after Tesla supports scheduling different thread bundles warps within the same block to different computing cores, the latest operator horizontal fusion technology can achieve parallel utilization of CUDA Core and Tensor Core. However, this method still cannot fully utilize these two heterogeneous computing cores in parallel, resulting in a certain amount of resource waste. The specific reasons are as follows:
[0006] 1. When horizontally fusing operators, if it is determined that the operators cannot be fused, they are executed sequentially. However, only one GPU computing core can be utilized at a time, leaving the other core idle. If a submitted job contains a high proportion of large-grained operators (operators that consume a high proportion of the GPU's underlying shared resources), many operators cannot be fused and must be executed sequentially. Consequently, the GPU's CUDA Cores and Tensor Cores cannot be fully utilized in parallel, resulting in wasted GPU resources.
[0007] 2. When submitting operators for fusion, random combinations are selected without a clear strategy for selecting operators. This can prevent otherwise fused operator pairs from being combined due to inappropriate combinations, leading to inability to fuse them. Consequently, they must execute sequentially or experience suboptimal performance after fusion. This ultimately prevents the full parallel utilization of the GPU's CUDA Cores and Tensor Cores, reducing GPU resource utilization.
[0008] The essence of the above problem lies in the limited scope of operator fusion, which results in the heterogeneous computing cores in the GPU not being fully utilized in parallel. Summary of the Invention
[0009] In view of the deficiencies in the prior art, the present invention Figure 9 As shown in the figure, a deep learning reasoning method based on operator selection and fine-grained fusion is proposed, which includes:
[0010] Operator selection step 1: obtain the data flow graph of the deep neural network model, simulate the fusion execution time of the operators in the data flow graph through the linear regression model, and select the operator pair with the shortest fusion execution time as the operator pair to be fused through dynamic programming;
[0011] Operator fusion step 2: adopt the operator horizontal fusion strategy based on persistent thread blocks to fuse the operator pair to be fused, and fuse the CD kernel and TC kernel of the operator pair to be fused to obtain the fused operator;
[0012] Operator segmentation step 3: split the thread blocks of operators in the data flow graph except the operator to be fused into operators with smaller granularity to obtain low-granularity operators;
[0013] Run management step 4, orchestrate the fusion operator and low-granularity operator of the deep neural network model and input them into the GPU containing Tensor Core and CUDA Core to obtain the execution result of the deep neural network model.
[0014] The deep learning reasoning method based on operator selection and fine-grained fusion, wherein the operator selection step includes:
[0015] Take an operator pair from the data flow graph, and use the single operator performance estimation linear regression model to estimate the execution time of each operator in the operator pair, and obtain the sequential execution time of the operators;
[0016] Determine whether the two operators in the operator pair are run through Tensor Cores and CUDA Cores; if so, estimate the fusion execution time of the fused operator pair using the fusion operator performance estimation linear regression model.
[0017] The deep learning reasoning method based on operator selection and fine-grained fusion, wherein the operator fusion step includes:
[0018] Determine whether there is an operator pair to be fused in the local offline library. If so, directly call the corresponding fusion operator in the offline library. Otherwise, perform online fusion on the operator pair to be fused to obtain a new fusion operator, recompile the operator library and register the new fusion operator in the offline library.
[0019] The deep learning reasoning method based on operator selection and fine-grained fusion, wherein the operator segmentation step includes:
[0020] The low-granularity operator is obtained by splitting the operator by replacing the operator execution configuration.
[0021] like Figure 10 As shown, the present invention also proposes a deep learning reasoning device B based on operator selection and fine-grained fusion, which includes:
[0022] Operator selection module M1 obtains the data flow graph of the deep neural network model, simulates the fusion execution time of the operators in the data flow graph through a linear regression model, and selects the operator pair with the shortest fusion execution time as the operator pair to be fused through dynamic programming;
[0023] The operator fusion module M2 adopts the operator horizontal fusion strategy based on persistent thread blocks to fuse the operator pair to be fused, and fuses the CD kernel and TC kernel of the operator pair to be fused to obtain the fused operator;
[0024] The operator splitting module M3 splits the thread blocks of operators in the data flow graph except the operators to be fused into operators with smaller granularity to obtain low-granularity operators;
[0025] The operation management module M4 arranges the fusion operators and low-granularity operators of the deep neural network model and inputs them into the GPU containing Tensor Core and CUDA Core to obtain the execution result of the deep neural network model.
[0026] The deep learning inference device based on operator selection and fine-grained fusion, wherein the operator selection module includes:
[0027] Take an operator pair from the data flow graph, and use the single operator performance estimation linear regression model to estimate the execution time of each operator in the operator pair, and obtain the sequential execution time of the operators;
[0028] Determine whether the two operators in the operator pair are run through Tensor Cores and CUDA Cores; if so, estimate the fusion execution time of the fused operator pair using the fusion operator performance estimation linear regression model.
[0029] The deep learning inference device based on operator selection and fine-grained fusion, wherein the operator fusion module includes:
[0030] Determine whether there is an operator pair to be fused in the local offline library. If so, directly call the corresponding fusion operator in the offline library. Otherwise, perform online fusion on the operator pair to be fused to obtain a new fusion operator, recompile the operator library and register the new fusion operator in the offline library.
[0031] The deep learning inference device based on operator selection and fine-grained fusion, wherein the operator segmentation module includes:
[0032] The low-granularity operator is obtained by splitting the operator by replacing the operator execution configuration.
[0033] The present invention also proposes an electronic device, which includes the aforementioned deep learning inference device, and the electronic device is connected to an information display device, which is used to display the execution results using display parameters and attributes set by the user or through an artificial intelligence model.
[0034] The present invention also proposes a storage medium for storing a computer program for executing the deep learning reasoning method.
[0035] From the above scheme, it can be seen that the advantages of the present invention are:
[0036] 1) High operator fusion performance: Operator performance modeling is performed before fusion, and based on this modeling result, a dynamic programming strategy is used to select and submit operator pairs that can maximize system throughput, thereby improving the parallel utilization of Tensor Cores and CUDA Cores in the GPU. 2) Wide operator fusion range: For operator pairs that cannot be fused due to high competition for shared resources or have suboptimal performance after fusion, their thread blocks are split separately to reduce the demand for shared resources and thus expand the scope of operator fusion. 3) Low offline compilation overhead: Common fusion operator pairs and operator pairs that can be fused after splitting are compiled offline in advance. When online tasks arrive, the offline library can be called, thereby reducing the overhead of online compilation. BRIEF DESCRIPTION OF THE DRAWINGS
[0037] Figure 1 This is a structural diagram of the deep learning reasoning system;
[0038] Figure 2 Schematic diagram of the operator selection strategy based on the performance evaluation of heterogeneous kernel functions;
[0039] Figure 3 Flowchart of operator selection strategy based on performance evaluation of heterogeneous kernel functions;
[0040] Figure 4 This is a diagram showing the execution principle of the PTB-based operator horizontal fusion strategy;
[0041] Figure 5 This is a flow chart of the code generation method based on the heterogeneous computing core fusion operator;
[0042] Figure 6 Schematic diagram for dividing operator thread blocks;
[0043] Figure 7 This is a flow chart of the operator fusion range optimization method based on operator thread block segmentation;
[0044] Figure 8 A flowchart for the online management and control of the system by the runtime management module;
[0045] Figure 9 Flow chart of the method of the present invention;
[0046] Figure 10 This is a module diagram of the device of the present invention;
[0047] Figure 11 This is a schematic structural diagram of a first electronic device of the present invention;
[0048] Figure 12 This is a schematic diagram of the application environment structure of the first electronic device of the present invention;
[0049] Figure 13 This is a schematic structural diagram of a second electronic device according to the present invention.
[0050] Reference numerals:
[0051] 1-Operator selection step;
[0052] 2-Operator fusion step;
[0053] 3-Operator segmentation step;
[0054] 4- Operation management steps;
[0055] M1-operator selection module;
[0056] M2-operator fusion module;
[0057] M3-operator segmentation module;
[0058] M4-operation management module;
[0059] A-First electronic device;
[0060] B-deep learning inference device;
[0061] C-data acquisition equipment;
[0062] D-information display device;
[0063] 1000- second electronic device;
[0064] Ⅰ-computing unit;
[0065] II-ROM;
[0066] III-RAM;
[0067] IV-bus;
[0068] V-interface;
[0069] VI-input unit;
[0070] VII-output unit;
[0071] VIII-Storage medium;
[0072] IX-Communication unit. DETAILED DESCRIPTION
[0073] It should be noted that the processor described in the present invention is the control center of an electronic device and can be a single processor or a collective term for multiple processing elements. For example, it can be one or more central processing units (CPUs), application-specific integrated circuits (ASICs), or one or more integrated circuits configured to implement embodiments of the present invention, such as one or more digital signal processors (DSPs) or one or more field programmable gate arrays (FPGAs).
[0074] Optionally, the processor can perform various functions of the electronic device by running or executing a software program stored in the memory, and calling data stored in the memory.
[0075] In a specific implementation, as an example, the processor may include one or more CPUs. Each of these processors may be a single-core processor (single-CPU) or a multi-core processor (multi-CPU). The processor herein may refer to one or more devices, circuits, and / or processing cores for processing data (e.g., computer program instructions). Electronic devices may include servers, desktop computers, laptop computers, smartphones, tablet computers, embedded computers, etc., where the embedded computers include vehicles and robots, etc.
[0076] The memory is used to store the software program for executing the solution of the present invention, and the execution is controlled by the processor. The specific implementation method can refer to the above method embodiment and will not be repeated here.
[0077] It should be noted that the structure of the electronic device shown in the drawings of the present invention does not constitute a limitation thereto, and the actual knowledge structure recognition device may include more or fewer components than shown in the drawings, or a combination of certain components, or a different arrangement of components.
[0078] The above embodiments can be implemented in whole or in part via software, hardware (e.g., circuits), firmware, or any other combination thereof. When implemented using software, the above embodiments can be implemented in whole or in part in the form of a computer program product. The computer program product comprises one or more computer instructions or computer programs. When loaded or executed on a computer, the processes or functions described in accordance with the embodiments of the present invention are fully or partially performed. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired means (e.g., infrared, wireless, microwave, etc.). The computer-readable storage medium can be any available medium accessible by a computer or a data storage device such as a server or data center that contains a collection of one or more available media. The available medium can be magnetic media (e.g., floppy disks, hard disks, magnetic tapes), optical media (e.g., DVDs), or semiconductor media. The semiconductor media can be a solid-state drive.
[0079] It should also be understood that the term "and / or" in this document simply describes an association between related objects, indicating that three possible relationships exist. For example, "A and / or B" can represent: A alone, A and B together, or B alone. A and B can be singular or plural. Furthermore, the character " / " in this document generally indicates an "or" relationship between the related objects, but it may also indicate an "and / or" relationship. For specific understanding, please refer to the context.
[0080] In this disclosure, "at least one" means one or more, and "plurality" means two or more. "At least one of the following" or similar expressions refers to any combination of these items, including any combination of single or plural items. For example, "at least one of a, b, or c" can mean: a, b, c, ab, ac, bc, or abc, where a, b, and c can be single or plural.
[0081] It should also be understood that in various embodiments of the present invention, the size of the serial numbers of the above-mentioned processes does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present invention.
[0082] In the several embodiments provided by the present invention, it should be understood that the disclosed devices, apparatuses, and methods can be implemented in other ways. For example, the device embodiments described above are merely illustrative. For example, the division of the units is merely a logical function division. In actual implementation, there may be other division methods, such as multiple units or components can be combined or integrated into another device, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interface, indirect coupling or communication connection of the device or unit, which can be electrical, mechanical or other forms.
[0083] The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of these units may be selected to achieve the purpose of this embodiment according to actual needs.
[0084] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
[0085] If the functions are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the portion that contributes to the prior art, or the portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions for enabling a computer device (which can be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in various embodiments of the present invention. The aforementioned storage media include various media that can store program code, such as USB flash drives, mobile hard drives, read-only memories (ROM), random access memories (RAM), magnetic disks, or optical disks.
[0086] The core starting point for expanding the scope of operator fusion in this invention is to explore more opportunities for operator fusion to further fully utilize the two heterogeneous computing cores in the GPU in parallel. Specifically, before the operator fusion, the operator pairs to be fused are pre-selected, and a fine-grained segmentation strategy is adopted for operator pairs that cannot be fused, thereby further expanding the scope of operator fusion. Therefore, in principle, this is an optimization method that explores more opportunities for operator fusion to further fully utilize the two heterogeneous computing cores in parallel in the GPU.
[0087] Furthermore, the present invention implements horizontal operator fusion by automatically generating operator code based on persistent thread blocks (PTBs). This horizontal operator fusion design not only allows for the parallel utilization of the GPU's heterogeneous computing cores, Tensor Cores and CUDA Cores, but also improves the execution performance of online services.
[0088] To achieve the aforementioned technical effects, the present invention provides a deep learning inference system with an operator selection strategy and a fine-grained fusion mechanism. The system includes an operator selection strategy based on heterogeneous kernel performance evaluation, a code generation method for heterogeneous computing core fusion operators, and an operator fusion range optimization method based on operator thread block partitioning. The system comprises an operator selection module, an operator fusion module, an operator partitioning module, and a runtime management module.
[0089] The operator selection module can be divided into two stages. First, the linear regression model is used to estimate the execution time of the fusion operator. Then, based on the estimated execution time of the fusion operator, the best fusion operator pair is selected through a dynamic programming strategy.
[0090] The operator fusion module adopts the PTB-based operator horizontal fusion strategy to fuse the fused operator pairs, fusing the CDkernel and TC kernel into one operator, so that it can utilize the two heterogeneous computing cores in the GPU in parallel.
[0091] The operator splitting module splits operators that cannot be fused or have suboptimal performance after fusion into smaller-granularity operators by splitting their thread blocks. This reduces the operators' demand for shared resources and reduces resource competition between operators to be fused, allowing them to fully utilize the Tensor Cores designed specifically to accelerate matrix multiplication operations and the CUDA Cores that mainly perform general logical operations in parallel.
[0092] The runtime management module, with the support of the operator selection module and the operator fusion module, orchestrates the operators in the DNN inference jobs submitted online and determines which operators to fuse or execute sequentially.
[0093] To illustrate the above-mentioned features and effects of the present invention more clearly and easily, the following embodiments are specifically described below with reference to the accompanying drawings. This specification discloses one or more embodiments incorporating the features of the present invention. The disclosed embodiments are for illustrative purposes only. The scope of protection of the present invention is not limited to the disclosed embodiments; the present invention is defined by the appended claims.
[0094] like Figure 1As shown, the present invention includes four submodules: operator selection module, operator fusion module, operator segmentation module, and runtime management module.
[0095] For the operator selection module, the present invention provides an operator selection strategy based on the performance evaluation of heterogeneous kernel functions. Its features are as follows: Figure 2 As shown, there are three:
[0096] 1) Low operator performance estimation overhead: Each time a user submits a DNN inference job, the operator selection module is activated. The performance modeling of this module is strategically different from traditional performance modeling methods. Traditional operator performance modeling methods require a syntax tree scan of the entire user program, resulting in high modeling overhead. Figure 2 As shown, the operator selection strategy based on heterogeneous kernel performance evaluation only requires building a single-operator performance estimation linear regression model using a limited amount of historical data. This model is used to estimate the execution time of the CD kernel (running on CUDA Cores) and the TC kernel (running on Tensor Cores). (The horizontal axis represents the number of blocks required for operator execution, while the vertical axis represents the operator execution time.) This historical data is then used to build a fusion operator performance estimation linear regression model. (The horizontal axis represents the ratio of the CD kernel to the TC kernel execution time, while the vertical axis represents the fusion operator execution time.) Furthermore, the execution time ratio of the original CD kernel to the TC kernel is divided into two ranges, and three scenarios are modeled separately. In the first scenario, the CD kernel completes first; in the second scenario, the TC kernel completes first; and in the third scenario, both complete simultaneously.) In this way, operator execution time can be estimated using a simple regression model, resulting in low operator performance modeling overhead. Furthermore, this framework pre-selects the optimal fusion operator pairs for some common DNN inference jobs offline, further reducing system overhead.
[0097] 2) Wide range of operator selection: Compared with the random operator selection strategy, the operator selection strategy based on the performance evaluation of heterogeneous kernel functions can obtain the best operator pair to be fused, and try to avoid the competition for shared resources between the operator pairs to be fused, thereby improving the performance of subsequent fused operators. At the same time, unlike the traditional computational graph fusion method, the operator performance modeling method in this paper is not limited to a specific fusion mode. Figure 2 As shown in Figure 2, this paper adopts a dynamic programming strategy to select operators to be fused, and the state transfer equation is as follows:
[0098]
[0099] in, Represents the execution time corresponding to the optimal substructure (consisting of several fused operator pairs and single operators currently traversed) in state (i, j), Represents the execution time of operator i, Represents the execution time of operator j, Represents the execution time of the fusion of operator i and operator j. The execution time of the optimal substructure in each state is updated based on the execution times of the optimal substructures in the three adjacent states. The fusion operator set corresponding to the optimal substructure is also updated. When all operators included in the submitted jobs are traversed, the fusion operator set contains all optimal fusion operator pairs.
[0100] In summary, this strategy minimizes execution time under the current optimal substructure, and thus selects all operator combinations that minimize the total execution time of multiple jobs. When tasks containing new operators arrive online, our method can still select the optimal operator combination.
[0101] 3) High user program security: Since operator performance modeling does not require scanning of user programs, internal implementation details can be hidden. This separation of performance modeling from user programs effectively prevents malicious code from tampering with user programs, ensuring user program security.
[0102] Based on the above technical concept, the present invention proposes an operator selection strategy based on the performance evaluation of heterogeneous kernel functions. The specific implementation details are as follows: Figure 3 The detailed steps are as follows:
[0103] Step 11: Taking two DNN inference jobs submitted by the user as an example, place the operators contained in each job into the operator set of the corresponding job. Number each operator based on its upstream and downstream dependencies in the corresponding computation graph.
[0104] Step 12: Initialize the state table that records the shortest execution time corresponding to the current optimal substructure. Initialize each element value in the state table to a maximum value MAX_INT.
[0105] Step 13: Select one operator from each of the two operator sets and estimate their execution time using the single-operator performance estimation linear regression model. The linear regression model takes as input the number of blocks required for operator execution and outputs the execution time of a single operator.
[0106] Step 14: Preset the fusion time of the two operators to a maximum value MAX_INT.
[0107] Step 15: Determine whether the two operators are running on different types of computing cores, i.e., heterogeneous core operators. If so, use the fusion operator performance estimation linear regression model to estimate the execution time of direct fusion, the execution time of splitting and then fusion (without actually splitting the operators), and the execution time of sequential execution. Finally, select the minimum of these three times (and also record the recommended execution method corresponding to the shortest time: direct fusion, splitting and then fusion, or sequential execution) as the final execution time for the operator pair. Otherwise, continue with the following steps.
[0108] Step 16: Calculate the minimum execution time corresponding to the current optimal substructure (consisting of the currently traversed fusion operator pairs and single operators) using the state transition equation. Simultaneously, update the time corresponding to this state in the state table.
[0109] Step 17: Update the set of operator pairs to be fused. For example, based on the optimal substructure calculated by the above state transition equation, adjust the operator combination method in the current set of operator pairs to be fused to complete the update.
[0110] Step 18: Determine whether there is an empty set in the two operator sets. If not, jump to step 13; otherwise, submit the operator set to be fused and end the process.
[0111] The characteristics of the operator fusion module include the following three.
[0112] 1) Operator Horizontal Fusion Design: On the one hand, the operator fusion module adopts a horizontal fusion strategy, allowing the TC kernel and CD kernel to be fused into a large operator. Different thread bundles of the fused operator occupy different types of heterogeneous computing cores and run, thereby utilizing Tensor Cores and CUDA Cores in parallel.
[0113] 2) Offline compilation reduces online fusion overhead: Furthermore, because this paper adopts a PTB-based operator horizontal fusion strategy, the block size and number required for operator execution are fixed. Therefore, the operator fusion module can compile a batch of common fusion operators offline before officially processing DNN inference jobs submitted by users online. When online operator pairs to be fused match the fusion pattern in the offline operator library, they can be directly called, minimizing online compilation overhead.
[0114] 3) Support for dynamic shapes: In addition, the input of fusion operators in the offline operator library supports dynamic shapes. When the operator pairs to be fused submitted online match the fusion mode in the offline library, the corresponding fusion operators in the offline library can be directly called without being affected by the input shape, thereby expanding the support range of the offline operator library.
[0115] The execution principle diagram of the horizontal fusion of operators based on PTB is as follows: Figure 4 As shown, the present invention proposes a code generation method based on heterogeneous computing core fusion operators, and the specific implementation steps are as follows Figure 5 The detailed steps are as follows:
[0116] Step 21: Submit the operator pairs in the set of operator pairs to be fused to the operator fusion module in sequence according to the dependency order of the computation graph.
[0117] Step 22: If the current pair of operators to be fused needs to be split, they are not fused and are merged after the subsequent operators are split; otherwise, continue with the following steps.
[0118] Step 23: If the operator fusion module determines that the current fusion operator exists in the offline library, it directly calls the corresponding fusion operator in the offline library, thereby avoiding the overhead of online fusion. Furthermore, when the operator pair to be fused matches the fusion mode in the offline library, the corresponding fusion operator in the offline library can be directly called without being affected by the input shape, thereby expanding the support range of the offline operator library.
[0119] Step 24: For the new fusionable operator that appears in step 23, if the corresponding fusion mode cannot be found in the offline library, the fusion operator pair to be fused is fused online, the operator library is recompiled, and the new fusion operator is registered in the offline library, thereby expanding the support range of the offline library.
[0120] The characteristics of the operator segmentation module include the following two.
[0121] 1) Thread block splitting design: When the operator fusion module is unable to fuse the fused operator pair, it is submitted to the operator splitting module. Figure 6 As shown, the block size of the original TC kernel 64, number of blocks The size of the CDkernel block is 4, which is divided into two kernels with finer granularity (TC_kernel_1 and TC kernel_2) according to the grid dimension. Increasing the number of divisions will lead to operator startup overhead, so two is the preferred embodiment. 128, number of blocks is 2, and it is divided into finer-grained kernels (CD kernel_1 and CD kernel_2) according to the grid dimension. According to the following formula:
[0122]
[0123]
[0124] Calculate the block size of the two fusion operators Equal to 192, number of blocks Equal to 2.
[0125] 2) Shielding user program implementation details: The design based on operator thread block partitioning does not require modifying the internal implementation of the operator. Instead, it only needs to replace the operator execution configuration, thereby shielding the user program implementation details, preventing malicious processes from tampering with the user program, and ensuring the security of the user program.
[0126] The present invention proposes an operator fusion range optimization method based on operator thread block segmentation, and the specific implementation steps are as follows: Figure 7 The detailed steps are as follows:
[0127] Step 31: When the operator fusion module receives the operator pair to be fused from the operator selection module, it obtains the recorded fusion method. If the operator pair is to be fused after segmentation, it submits the fused operator pair to the operator segmentation module. This module uses the thread block segmentation strategy to segment the operators to be fused separately, without modifying the internal implementation details of the operators. This module then obtains fine-grained operators after segmentation while ensuring the security of the user program.
[0128] Step 32: For the fine-grained operators obtained in step 31, the split operator pairs are directly submitted to the operator fusion module according to the combination of TC kernel and CD kernel.
[0129] The runtime management module is responsible for the scheduling and management of the entire online runtime system. The specific implementation steps are as follows: Figure 8 The detailed steps are as follows:
[0130] Step 41: After the operators included in the DNN inference job submitted by the user online are divided into the operator sets of the corresponding job, the runtime management module calls the operator selection module to perform performance modeling and select operator pairs to be fused for all operators in the above two sets.
[0131] Step 42: For the operator pair obtained in step 41, determine whether it is executed sequentially. If it is executed sequentially, directly submit the operator pair to the GPU for execution; otherwise, continue to the following steps.
[0132] Step 43: For the operator pairs that can be directly fused in step 41, the runtime management module calls the operator fusion module to fuse the operator pairs, and submits the fused operators to the GPU for execution.
[0133] Step 44: For the operators that need to be split and then fused in step 41, the runtime management module calls the operator splitting module to split the operators. The split operators are submitted to the operator fusion module and, after fusion, are submitted to the GPU for execution.
[0134] The following is a system embodiment corresponding to the above method embodiment. This embodiment can be implemented in conjunction with the above embodiment. The relevant technical details mentioned in the above embodiment are still valid in this embodiment and will not be repeated here to reduce repetition. Accordingly, the relevant technical details mentioned in this embodiment can also be applied to the above embodiment.
[0135] like Figure 10 As shown, the present invention also proposes a deep learning reasoning device B based on operator selection and fine-grained fusion, which includes:
[0136] Operator selection module M1 obtains the data flow graph of the deep neural network model, simulates the fusion execution time of the operators in the data flow graph through a linear regression model, and selects the operator pair with the shortest fusion execution time as the operator pair to be fused through dynamic programming;
[0137] The operator fusion module M2 adopts the operator horizontal fusion strategy based on persistent thread blocks to fuse the operator pair to be fused, and fuses the CD kernel and TC kernel of the operator pair to be fused to obtain the fused operator;
[0138] The operator splitting module M3 splits the thread blocks of operators in the data flow graph except the operators to be fused into operators with smaller granularity to obtain low-granularity operators;
[0139] The operation management module M4 arranges the fusion operators and low-granularity operators of the deep neural network model and inputs them into the GPU containing Tensor Core and CUDA Core to obtain the execution result of the deep neural network model.
[0140] The deep learning inference device based on operator selection and fine-grained fusion, wherein the operator selection module includes:
[0141] Take an operator pair from the data flow graph, and use the single operator performance estimation linear regression model to estimate the execution time of each operator in the operator pair, and obtain the sequential execution time of the operators;
[0142] Determine whether the two operators in the operator pair are run through Tensor Cores and CUDA Cores; if so, estimate the fusion execution time of the fused operator pair using the fusion operator performance estimation linear regression model.
[0143] The deep learning inference device based on operator selection and fine-grained fusion, wherein the operator fusion module includes:
[0144] Determine whether there is an operator pair to be fused in the local offline library. If so, directly call the corresponding fusion operator in the offline library. Otherwise, perform online fusion on the operator pair to be fused to obtain a new fusion operator, recompile the operator library and register the new fusion operator in the offline library.
[0145] The deep learning inference device based on operator selection and fine-grained fusion, wherein the operator segmentation module includes:
[0146] The low-granularity operator is obtained by splitting the operator by replacing the operator execution configuration.
[0147] like Figure 11 As shown, the present invention further proposes a first electronic device A in another embodiment which includes the aforementioned deep learning inference device.
[0148] like Figure 12 As shown, the first electronic device A can also be connected to a data acquisition device C and an information display device D via a wired or wireless information transmission scheme. The data acquisition device C is used to acquire a data flow graph, and the information display device D is used to display the execution results obtained by the analysis of the present invention. The data flow graph can be an image classification model, and the corresponding execution results are image classification results or semantic segmentation results.
[0149] The information display device D can organize and process the data output by the first electronic device A based on the information display mechanism to improve the readability of the data output by the first electronic device A. The information display mechanism can be manually preset, for example, the data output by the first electronic device A is visually displayed, which can be based on the display parameters and / or attributes set by the user. The display parameters can be, for example, the display data range, and the display attributes can be, for example, the display font, color, whether to scroll, etc. The user is presented with the key information specified by the user, such as news updates, system information, etc. The user can understand this information more promptly without having to visit the secondary page or scroll the page, saving the user's operation. Or the information display mechanism can be an artificial intelligence AI display model, which can learn the user's key information based on the user's previous usage habits, such as viewing time, number of clicks, number of edits, etc., and then automatically present the user with rich and necessary key information.
[0150] The present invention also proposes a storage medium VIII in another embodiment for storing a computer program for executing the deep learning reasoning method. It should be understood that the storage medium in the embodiment of the present invention can be a volatile memory or a non-volatile memory, or can include both volatile and non-volatile memories. Among them, the non-volatile memory can be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory. The volatile memory can be a random access memory (RAM), which is used as an external cache. By way of example and not limitation, many forms of random access memory (RAM) are available, such as static RAM (SRAM), dynamic random access memory (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDR SDRAM), enhanced SDRAM (ESDRAM), synchronous link DRAM (SLDRAM), and direct rambus RAM (DR RAM).
[0151] Figure 13 A schematic block diagram of a second electronic device 1000 that can be used to implement an embodiment of the present invention is shown. The second electronic device 1000 electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The second electronic device 1000 can also represent various forms of mobile devices, such as personal digital assistants, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present invention described and / or required herein. The second electronic device 1000 may be the same as or different from the first electronic device A.
[0152] Second electronic device 1000 includes a computing unit I, which can perform various appropriate actions and processes based on a computer program stored in a read-only memory (ROM) II or loaded from a storage medium VIII into a random access memory (RAM) III. RAM III may also store various programs and data required for the operation of device 1000. Computing unit I, ROM II, and RAM III are interconnected via a bus IV. An input / output (I / O) interface V is also connected to bus IV.
[0153] Multiple components in the second electronic device 1000 are connected to the I / O interface V, including: an input unit VI, such as a keyboard and mouse; an output unit VII, such as various types of displays and speakers; a storage medium VIII, such as a magnetic disk and optical disk; and a communication unit IX, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit IX allows the second electronic device 1000 to exchange information / data with other devices via a computer network such as the Internet and / or various telecommunication networks.
[0154] Computing unit I can be various general-purpose and / or specialized processing components with processing and computing capabilities. Some examples of computing unit I include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various specialized artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, a digital signal processor (DSP), and any suitable processor, controller, microcontroller, etc. Computing unit I performs the various methods and processes described above, such as method steps 1-4. For example, in some embodiments, the method can be implemented as a computer software program tangibly embodied on a machine-readable medium, such as storage medium VIII. In some embodiments, part or all of the computer program can be loaded and / or installed onto device 1000 via ROM II and / or communication unit IX. When the computer program is loaded into RAM III and executed by computing unit I, one or more steps of the method described above can be performed. Alternatively, in other embodiments, computing unit I can be configured to perform the method by any other suitable means (e.g., via firmware).
[0155] Although the embodiments of the present invention have been disclosed above, they are not limited to the applications listed in the description and implementation methods. They can be fully applied to various fields suitable for the present invention. For those familiar with the art, additional modifications can be easily implemented. Therefore, without departing from the general concept defined by the claims and the scope of equivalents, the present invention is not limited to the specific details and illustrations shown and described herein.
Claims
1. A deep learning reasoning method based on operator selection and fine-grained fusion, characterized in that: include: Operator selection step: obtaining the data flow graph of the deep neural network model, simulating the fusion execution time of the operators in the data flow graph after fusion through a linear regression model, and selecting the operator pair with the shortest fusion execution time as the operator pair to be fused through dynamic programming; In the operator fusion step, a horizontal fusion strategy of operators based on persistent thread blocks is adopted to fuse the operator pair to be fused, and the CD kernel and TC kernel of the operator pair to be fused are fused to obtain a fused operator. Operator segmentation step: splitting the thread blocks of operators other than the operators to be fused in the data flow graph into operators with smaller granularity to obtain low-granularity operators; The operation management step arranges the fusion operators and low-granularity operators of the deep neural network model and inputs them into the GPU containing Tensor Core and CUDA Core to obtain the execution result of the deep neural network model.
2. The deep learning reasoning method based on operator selection and fine-grained fusion as claimed in claim 1, characterized in that: The operator selection step includes: An operator pair is taken from the data flow graph, and the execution time of each operator in the operator pair is estimated respectively by using a single operator performance estimation linear regression model to obtain the sequential execution time of the operators; Determine whether the two operators in the operator pair are run through Tensor Core and CUDA Core; if so, estimate the fusion execution time of the fused operator pair after fusion through the fusion operator performance estimation linear regression model.
3. The deep learning reasoning method based on operator selection and fine-grained fusion as claimed in claim 1, characterized in that: The operator fusion steps include: Determine whether there is an operator pair to be fused in the local offline library. If so, directly call the corresponding fusion operator in the offline library. Otherwise, perform online fusion on the operator pair to be fused to obtain a new fusion operator, recompile the operator library and register the new fusion operator in the offline library.
4. The deep learning reasoning method based on operator selection and fine-grained fusion as claimed in claim 1, characterized in that: The operator segmentation steps include: The operator is split by replacing the operator execution configuration to obtain the low-granularity operator.
5. A deep learning reasoning device based on operator selection and fine-grained fusion, characterized in that: include: The operator selection module obtains the data flow graph of the deep neural network model, simulates the fusion execution time of the operators in the data flow graph after fusion through the linear regression model, and selects the operator pair with the shortest fusion execution time as the operator pair to be fused through dynamic programming; The operator fusion module adopts the operator horizontal fusion strategy based on persistent thread blocks to fuse the operator pair to be fused, and fuses the CD kernel and TC kernel of the operator pair to be fused to obtain the fused operator; The operator segmentation module splits the thread blocks of operators other than the operators to be fused in the data flow graph into operators with smaller granularity to obtain low-granularity operators; The operation management module arranges the fusion operators and low-granularity operators of the deep neural network model and inputs them into the GPU containing Tensor Core and CUDA Core to obtain the execution result of the deep neural network model.
6. The deep learning reasoning device based on operator selection and fine-grained fusion as claimed in claim 5, characterized in that: The operator selection module includes: An operator pair is taken from the data flow graph, and the execution time of each operator in the operator pair is estimated respectively by using a single operator performance estimation linear regression model to obtain the sequential execution time of the operators; Determine whether the two operators in the operator pair are run through Tensor Core and CUDA Core; if so, estimate the fusion execution time of the fused operator pair after fusion through the fusion operator performance estimation linear regression model.
7. The deep learning reasoning device based on operator selection and fine-grained fusion as claimed in claim 5, characterized in that: The operator fusion module includes: Determine whether there is an operator pair to be fused in the local offline library. If so, directly call the corresponding fusion operator in the offline library. Otherwise, perform online fusion on the operator pair to be fused to obtain a new fusion operator, recompile the operator library and register the new fusion operator in the offline library.
8. The deep learning reasoning device based on operator selection and fine-grained fusion as claimed in claim 5, characterized in that: The operator segmentation module includes: The operator is split by replacing the operator execution configuration to obtain the low-granularity operator.
9. An electronic device, characterized in that: It includes a deep learning reasoning device as described in claims 5-8, and the electronic device is connected to an information display device, and the information display device is used to display the execution result according to display parameters and attributes set by the user or through an artificial intelligence model.
10. A storage medium for storing a computer program for executing the deep learning reasoning method described in claims 1-4.
Citation Information
Cited By
Embedded RTOS-oriented memory dynamic adaptive DNN reasoning method and system
CN119597470A
Model reasoning operator fusion optimization method and system based on operator calling
CN119847731A
A model inference operator fusion optimization method and system based on operator call
CN119847731B
Thread group-based operator fusion method and device, equipment, medium and product
CN122152542A
Computing kernel node starting optimization method and system for NPU computing graph execution, medium, program product and terminal
CN122412120A
