Data processing method and related equipment

By determining the relationship between operators and computing libraries in neural networks at the chip level, heterogeneous processing performance is improved, the problem of insufficient existing heterogeneous computing performance is solved, and more efficient AI computing reasoning and lower power consumption are achieved.

CN118779092APending Publication Date: 2024-10-15HUAWEI TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202310397898.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-04-06
Publication Date
2024-10-15

AI Technical Summary

Technical Problem

Existing heterogeneous computing has poor performance at the chip level, making it difficult to effectively improve AI computing reasoning performance and insufficient perception capabilities.

Method used

By determining the correlation between multiple operators in the neural network and multiple computing libraries, heterogeneous processing is performed based on the correlation to improve heterogeneous processing performance at the chip level.

Benefits of technology

It improves the performance of heterogeneous processing, determines correlations through real machine data, ensures the best combination of operators and computing libraries, improves inference performance and reduces power consumption.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118779092A_ABST
    Figure CN118779092A_ABST
Patent Text Reader

Abstract

The embodiment of the invention discloses a data processing method, the method is applied to a heterogeneous processing scene, the method is applied to data processing equipment, the data processing equipment comprises a plurality of processors and a plurality of calculation libraries corresponding to the plurality of processors, and the method comprises the following steps: obtaining a plurality of operators of a neural network; determining an association relationship between the plurality of operators and the plurality of calculation libraries; and performing heterogeneous processing based on the association relationship. By determining the association relationship between the plurality of operators and the plurality of calculation libraries in the neural network, heterogeneous processing can be carried out according to the association relationship of the chip levels, so that the performance of heterogeneous processing can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present application relate to the field of artificial intelligence, and in particular, to a data processing method and related equipment. Background Art

[0002] Artificial intelligence (AI) is the theory, method, technology and application system that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results. In other words, artificial intelligence is a branch of computer science that attempts to understand the essence of intelligence and produce a new intelligent machine that can respond in a similar way to human intelligence. Artificial intelligence is also the study of the design principles and implementation methods of various intelligent machines, so that machines have the functions of perception, reasoning and decision-making. Research in the field of artificial intelligence includes robotics, natural language processing, computer vision, decision-making and reasoning, human-computer interaction, recommendation and search, basic AI theory, etc.

[0003] At present, the AI ​​computing framework is based on chips for computing and is compatible with multiple chip hardware. With the development of chips, the computing power of chips has increased slowly, resulting in reduced AI computing reasoning performance. In order to maximize the reasoning performance, multiple processors need to collaborate. Splitting the high-computing-power model to different processors for reasoning is called heterogeneous computing. Another advantage of using heterogeneous computing is that it reduces the power consumption of a certain processor. However, existing heterogeneous computing all belongs to the application layer framework, and the perception ability within the chip is poor, resulting in poor performance of heterogeneous computing.

[0004] Therefore, how to improve the performance of heterogeneous computing at the chip level is a technical problem that needs to be solved urgently. Summary of the invention

[0005] The present application provides a data processing method for improving the performance of heterogeneous processing.

[0006] A first aspect of an embodiment of the present application provides a data processing method, which is applied to a data processing device, wherein the data processing device includes multiple processors and multiple computing libraries corresponding to the multiple processors, and the method includes: obtaining multiple operators of a neural network; determining an association relationship between the multiple operators and the multiple computing libraries; and performing heterogeneous processing based on the association relationship.

[0007] In an embodiment of the present application, by determining the association relationship between multiple operators and multiple computing libraries in a neural network, heterogeneous processing can be performed according to the association relationship at the chip level, thereby improving the performance of heterogeneous processing.

[0008] Optionally, in a possible implementation of the first aspect, the above-mentioned multiple calculation libraries include a first calculation library and a second calculation library; the method also includes: obtaining input samples of the neural network; determining the association relationship between multiple operators and multiple calculation libraries, including: calculating a first calculation result of each operator in the first calculation library based on the input sample; calculating a second calculation result of each operator in the second calculation library based on the input sample; and determining the calculation library corresponding to each operator based on the first calculation result and the second calculation result.

[0009] In this possible implementation, the association relationship is determined by real machine data, the operator performance is real and reliable, and the optimal combination of operators and computing libraries can be obtained.

[0010] Optionally, in a possible implementation of the first aspect, the above step of: determining a calculation library corresponding to each operator based on the first calculation result and the second calculation result includes: determining that the calculation library corresponding to the better calculation result between the first calculation result and the second calculation result of each operator is the calculation library corresponding to each operator.

[0011] In this possible implementation, the matching relationship between the operator and the computing library is determined by the calculation results of the operator in different computing libraries, which can improve the subsequent heterogeneous processing performance.

[0012] Optionally, in a possible implementation of the first aspect, the above step: determining the calculation library corresponding to each operator based on the first calculation result and the second calculation result includes: calculating the ratio of the first calculation result to the second calculation result; if the ratio is less than or equal to a first preset threshold, determining that the calculation library corresponding to the operator is the first calculation library.

[0013] In this possible implementation, a computing library with better calculation results of an operator among different computing libraries is selected as the computing library of the operator, and then the operator is subsequently heterogeneously processed in the computing library, which can improve the heterogeneous processing performance.

[0014] Optionally, in a possible implementation of the first aspect, the above step: determining the association relationship between multiple operators and multiple computing libraries includes: calculating the results of each operator in the first computing library respectively; determining that the computing library of the operator corresponding to the result greater than or equal to the second preset threshold is the second computing library.

[0015] In this possible implementation, the results of operators in the same calculation library are determined, and the calculation library is determined based on the comparison between the results and the threshold. Alternatively, the results are negated and operators with poor results are selected and migrated to other calculation libraries.

[0016] Optionally, in a possible implementation manner of the first aspect, the above steps also include: determining that a calculation library of multiple operators connected to the first operator is a second calculation library, and the first operator is an operator corresponding to a result of the first calculation library that is greater than or equal to a second preset threshold.

[0017] In this possible implementation, the databases of multiple operators connected to the first operator are consistent with the first operator, which facilitates reducing communication overhead between the multiple operators.

[0018] Optionally, in a possible implementation of the first aspect, the above step: before performing heterogeneous processing based on the association relationship, the method also includes: calculating the communication overhead between multiple operators based on the input samples; determining the association relationship between multiple operators and multiple computing libraries, including: determining the association relationship based on the communication overhead.

[0019] In this possible implementation, the communication overhead between multiple operators is taken into account when determining the association relationship, which can improve the subsequent overall heterogeneous processing performance.

[0020] Optionally, in a possible implementation manner of the first aspect, the above-mentioned multiple operators are non-fused operators.

[0021] In this possible implementation, the association relationship is determined for non-fused operators to improve the heterogeneous splitting performance of the non-fused operators.

[0022] Optionally, in a possible implementation manner of the first aspect, the above steps also include: acquiring input data; performing heterogeneous processing based on association relationships, including: performing heterogeneous processing based on the input data and the association relationships to obtain inference results.

[0023] In this possible implementation, the reasoning performance can be improved by introducing association relationships in the running scenario.

[0024] The second aspect of the embodiment of the present application provides a data processing device, which can be applied to heterogeneous processing scenarios. The data processing device includes multiple processors and multiple computing libraries corresponding to the multiple processors, and the data processing device includes: an acquisition unit for acquiring multiple operators of a neural network; a determination unit for determining the association relationship between the multiple operators and the multiple computing libraries; and a processing unit for performing heterogeneous processing based on the association relationship.

[0025] Optionally, in a possible implementation of the second aspect, the above-mentioned multiple calculation libraries include a first calculation library and a second calculation library; an acquisition unit is also used to acquire input samples of the neural network; a determination unit is specifically used to calculate a first calculation result of each operator in the first calculation library based on the input samples; a determination unit is specifically used to calculate a second calculation result of each operator in the second calculation library based on the input samples; and a determination unit is specifically used to determine the calculation library corresponding to each operator based on the first calculation result and the second calculation result.

[0026] Optionally, in a possible implementation manner of the second aspect, the above-mentioned determination unit is specifically used to determine that the calculation library corresponding to the better calculation result between the first calculation result and the second calculation result of each operator is the calculation library corresponding to each operator.

[0027] Optionally, in a possible implementation of the second aspect, the above-mentioned determination unit is specifically used to calculate the ratio of the first calculation result to the second calculation result; the determination unit is specifically used to determine that the calculation library corresponding to the operator is the first calculation library if the ratio is less than or equal to a first preset threshold.

[0028] Optionally, in a possible implementation of the second aspect, the above-mentioned determination unit is specifically used to calculate the results of each operator in the first calculation library respectively; the determination unit is specifically used to determine that the calculation library of the operator corresponding to the result greater than or equal to the second preset threshold is the second calculation library.

[0029] Optionally, in a possible implementation of the second aspect, the above-mentioned determination unit is also used to determine that a calculation library of multiple operators connected to the first operator is a second calculation library, and the first operator is an operator corresponding to a result of the first calculation library that is greater than or equal to a second preset threshold.

[0030] Optionally, in a possible implementation manner of the second aspect, the above-mentioned data processing device also includes: a calculation unit, used to calculate the communication overhead between multiple operators based on the input samples; and a determination unit, specifically used to determine the association relationship based on the communication overhead.

[0031] Optionally, in a possible implementation manner of the second aspect, the above-mentioned multiple operators are non-fused operators.

[0032] Optionally, in a possible implementation manner of the second aspect, the above-mentioned acquisition unit is also used to acquire input data; the processing unit is specifically used to perform heterogeneous processing based on the input data and the association relationship to obtain an inference result.

[0033] A third aspect of the present application provides a data processing device, comprising: a processor, the processor is coupled to a memory, the memory is used to store programs or instructions, when the program or instructions are executed by the processor, the data processing device implements the method in the above-mentioned first aspect or any possible implementation of the first aspect.

[0034] A fourth aspect of the present application provides a computer-readable medium having a computer program or instruction stored thereon. When the computer program or instruction is executed on a computer, the computer executes the method in the aforementioned first aspect or any possible implementation of the first aspect.

[0035] A fifth aspect of the present application provides a computer program product. When the computer program product is executed on a computer, it enables the computer to execute the method in the aforementioned first aspect or any possible implementation manner of the first aspect.

[0036] A sixth aspect of an embodiment of the present application provides a chip system, which includes at least one processor for supporting a data processing device to implement the functions involved in the above-mentioned first aspect or any possible implementation method of the first aspect.

[0037] In one possible design, the chip system may also include a memory for storing program instructions and data necessary for the data processing device. The chip system may be composed of a chip, or may include a chip and other discrete devices. Optionally, the chip system also includes an interface circuit, which provides program instructions and / or data for at least one processor.

[0038] Among them, the technical effects brought about by the second, third, fourth, fifth, and sixth aspects or any possible implementation methods thereof can refer to the technical effects brought about by the first aspect or different possible implementation methods of the first aspect, and will not be repeated here.

[0039] It can be seen from the above technical solutions that the present application has the following advantages: by determining the association between multiple operators and multiple computing libraries in a neural network, heterogeneous processing can be performed according to the association at the chip level, thereby improving the performance of heterogeneous processing. BRIEF DESCRIPTION OF THE DRAWINGS

[0040] Figure 1 A schematic diagram of an application scenario provided for an embodiment of the present application;

[0041] Figure 2 A schematic diagram of another application scenario provided for an embodiment of the present application;

[0042] Figure 3A A structural diagram of a data processing system provided in an embodiment of the present application;

[0043] Figure 3B Another structural diagram of the data processing system provided in the embodiment of the present application;

[0044] Figure 4 A flowchart of a data processing method provided in an embodiment of the present application;

[0045] Figure 5 A schematic diagram of a process for determining an association relationship provided in an embodiment of the present application;

[0046] Figure 6 A schematic diagram of the diffusion mechanism provided in the embodiment of the present application;

[0047] Figure 7 Another schematic diagram of a flow chart for determining an association relationship provided in an embodiment of the present application;

[0048] Figure 8 Another schematic diagram of a flow chart for determining an association relationship provided in an embodiment of the present application;

[0049] Fig. 9 A before and after schematic diagram of eliminating the Cast operator provided in an embodiment of the present application;

[0050] Fig.10 A schematic diagram of cache flushing optimization provided in an embodiment of the present application;

[0051] Fig.11 Another flowchart of the data processing method provided in the embodiment of the present application;

[0052] Fig.12 A schematic diagram of a heterogeneous search tool provided in an embodiment of the present application;

[0053] Fig.13 A schematic diagram of the development state and deployment state provided in an embodiment of the present application;

[0054] Fig.14 A structural schematic diagram of a data processing device provided in an embodiment of the present application;

[0055] Fig.15 Another structural schematic diagram of a data processing device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0056] The present application provides a data processing method for improving the performance of heterogeneous processing.

[0057] To facilitate understanding, the relevant terms and concepts mainly involved in the embodiments of the present application are first introduced below.

[0058] 1. Neural Networks

[0059] A neural network can be composed of neural units. A neural unit can be a s and intercept b as inputs, the output of the operation unit can be:

[0060]

[0061] Where, s = 1, 2, ... n, n is a natural number greater than 1, W s For X s The weight of the neural unit, b is the bias of the neural unit. f is the activation function of the neural unit, which is used to introduce nonlinear characteristics into the neural network to convert the input signal in the neural unit into the output signal. The output signal of the activation function can be used as the input of the next convolutional layer. The activation function can be a Relu function. A neural network is a network formed by connecting many of the above-mentioned single neural units together, that is, the output of one neural unit can be the input of another neural unit. The input of each neural unit can be connected to the local receptive field of the previous layer to extract the features of the local receptive field. The local receptive field can be an area composed of several neural units.

[0062] The work of each layer in the neural network can be described by the mathematical expression y=a(Wx+b): From a physical level, the work of each layer in the neural network can be understood as completing the transformation from the input space to the output space (i.e., the row space to the column space of the matrix) through five operations on the input space (the set of input vectors). These five operations include: 1. Dimension increase / reduction; 2. Zoom in / out; 3. Rotation; 4. Translation; 5. "Bending". Among them, operations 1, 2, and 3 are completed by Wx, operation 4 is completed by +b, and operation 5 is implemented by a(). The word "space" is used here because the classified object is not a single thing, but a class of things, and space refers to the collection of all individuals of this class of things. Among them, W is a weight vector, and each value in the vector represents the weight value of a neuron in the neural network of this layer. The vector W determines the spatial transformation from the input space to the output space mentioned above, that is, the weight W of each layer controls how to transform the space. The purpose of training a neural network is to finally obtain the weight matrix of all layers of the trained neural network (the weight matrix formed by many layers of vectors W). Therefore, the training process of a neural network is essentially about learning how to control spatial transformations, or more specifically, learning the weight matrix.

[0063] 2. Computational Graph

[0064] The computation process in the model / neural network is often expressed by a computation graph. That is, the AI ​​framework often uses a computation graph to express the network structure. A computation graph is a computation function expressed by a directed graph with operators as nodes. In the AI ​​framework, this computation function sequentially calls the operator nodes in the directed graph to execute the input Tensor and obtains the final output tensor. The operator is essentially a computation function. For example, Add and Sigmoid are both called operators. However, the mathematical implementation of a complex operator such as Sigmoid includes basic operators such as Neg, Exp, Add, and Reciprocal. Therefore, through the above analysis, it can be seen that the computation graph and the operator are essentially the same in terms of computation. The operator is a packaged computation graph, and the computation graph is an unpacked operator. Therefore, in theory, a small-scale set of "basic operators" can be defined first, and then any existing operator can be equivalently expressed by combining one or more basic operators, thereby further expressing any existing computation graph. This computation graph composed of multiple basic operators is called a "fusion operator". Alternatively, the fused subgraph / fused operator refers to all subgraphs that contain different basic operators. From the layer level, it is a subgraph, and from the operator level, it is a fused operator.

[0065] At present, the AI ​​computing framework is based on chips for calculations and is compatible with multiple chip hardware. With the development of chips, the computing power of chips has increased slowly, resulting in reduced AI computing reasoning performance. In order to maximize the reasoning performance, multiple processors need to collaborate. Splitting the high-computing-power model to different processors for reasoning is called heterogeneous computing. Another advantage of using heterogeneous computing is that it reduces the power consumption of a certain processor. However, existing heterogeneous computing all belongs to the application layer framework, and has poor perception capabilities within the chip, resulting in poor performance of heterogeneous computing. Therefore, how to improve the performance of heterogeneous computing at the chip layer is a technical problem that needs to be solved urgently.

[0066] In order to solve the above technical problems, an embodiment of the present application provides a data processing method, which determines the association between multiple operators and multiple computing libraries in a neural network, and then performs heterogeneous processing according to the association at the chip level, thereby improving the performance of heterogeneous processing.

[0067] The following describes the application scenarios provided by the embodiments of the present application.

[0068] See attached Figure 1 , an embodiment of the present invention provides an application scenario. The application scenario can also be understood as a development scenario.

[0069] Figure 1The scenario shown includes: obtaining the calculation graph stage, the search preparation stage, and the search environment. Specifically, the calculation graph of the neural network is obtained, and the calculation graph is input into the search preparation stage (search prepare) to check whether the operator supports calculation (check support) (or understand it as judging whether the operator is a fusion operator, if it enters the subsequent stage), and then the heterogeneous splitting strategy (policy) is used for heterogeneous splitting, and then the real machine (device) or database modeling (model) is used to start searching for heterogeneous configurations.

[0070] Should Figure 1 The application scenario shown can be understood as a developer inputting an algorithm model in the development state to start searching based on a real machine or database modeling and outputting heterogeneous configurations.

[0071] The heterogeneous configuration in the embodiment of the present application includes at least one of: an operator name, an operator type, and an association relationship with a compute library (CL) corresponding to the operator. The compute library can be understood as a compute library corresponding to an XPU (e.g., CPU, GPU, etc.) in a device. The operator type can include at least one of the following: a convolution operator, a deconvolution operator, a cast operator, etc.

[0072] See attached Figure 2 , the embodiment of the present invention provides another application scenario. This application scenario can also be understood as a deployment scenario. The deployment scenario includes multiple situations, which are described below.

[0073] In the first case, heterogeneous configurations are deployed on the cloud side.

[0074] In this case, the user obtains heterogeneous configurations from the cloud, and reads the heterogeneous configurations at the same time when compiling the model to generate a compiled model. Heterogeneous configurations can be upgraded, and the upgraded results are regularly uploaded to the cloud to regularly update the user's heterogeneous configurations. For example, heterogeneous configurations in an Android application package (APK).

[0075] Such a situation Figure 3A As shown, the application scenario includes a terminal device ( Figure 3AIn the figure, only the terminal device is a mobile phone as an example) and a data processing device (or cloud device). It is understandable that, in addition to mobile phones, terminal devices can also be tablet computers (pads), portable game consoles, personal digital assistants (PDAs), laptops, ultra mobile personal computers (UMPCs), handheld computers, netbooks, vehicle-mounted media playback devices, wearable electronic devices, virtual reality (VR) terminal devices, augmented reality (AR), vehicles, vehicle-mounted terminals, aircraft terminals, intelligent robots and other terminal devices. The terminal device is the initiator of data processing. As the initiator of the data processing request, the request is usually initiated by the user through the terminal device.

[0076] The above-mentioned data processing device can be a device or server with data processing function such as a cloud server, a network server, an application server and a management server. The data processing device receives data processing requests from the terminal device through an interactive interface, and then performs data processing in the form of machine learning, deep learning, search, reasoning, decision-making, etc. through the memory that stores data and the processor link of data processing. The memory in the data processing device can be a general term, including local storage and databases that store historical data. The database can be on the data processing device or on other network servers.

[0077] exist Figure 3A In the data processing system shown, the terminal device can receive the user's instructions. For example, the terminal device can obtain the input sample (e.g., image, text, audio, etc.) input / selected by the user, and then initiate a request to the data processing device, so that the data processing device performs a data processing application (e.g., classification, segmentation, detection, image generation, and other reasoning tasks) for the input sample obtained by the terminal device, thereby obtaining a processing result corresponding to the input sample. Exemplarily, the terminal device can obtain the image input by the user, and then initiate an image detection request to the data processing device, so that the data processing device detects the image, thereby obtaining the detection result of the image, and displays the detection result of the image for the user to view and use.

[0078] exist Figure 3A In the embodiment of the present application, the data processing device can execute the data processing method of the embodiment of the present application.

[0079] In one possible implementation, when the user uses the model for reasoning, the user obtains the input sample, then downloads the heterogeneous configuration from the cloud, and obtains the reasoning result based on the input sample and the heterogeneous configuration. That is, the input of the model includes the input sample on the user side and the heterogeneous configuration on the cloud side, and the output is the reasoning result.

[0080] In another possible implementation, when the user uses the model for reasoning, the user obtains input samples input by the user and sends the input samples to the cloud. The cloud processes the input samples and the heterogeneous configuration to obtain the reasoning results.

[0081] In the second case, heterogeneous configurations are deployed on the terminal side.

[0082] Users deploy heterogeneous configurations and algorithm models on data processing devices through the Android application package (APK), and read the heterogeneous configurations at the same time to generate a compiled model (compiled mosel) during model compilation.

[0083] Such a situation Figure 3B As shown, the terminal device ( Figure 3B In this example, the terminal device is a mobile phone. The terminal device can directly obtain input samples (such as images, text, audio, etc.) and process them directly by the hardware of the terminal device itself. The specific process is similar to Figure 3A Similarly, please refer to the above description and will not repeat them here.

[0084] Optionally, in Figure 3B In the data processing system shown, the terminal device can receive instructions from the user. For example, the terminal device can obtain the input sample selected by the user in the terminal device, and then the terminal device itself executes a data processing application (for example, classification, segmentation, detection, image generation and other reasoning tasks) for the input sample, thereby obtaining the processing result corresponding to the input sample, and displaying the processing result for the user to view and use.

[0085] Optionally, in Figure 3B In the data processing system shown, the terminal device can collect images in real time or periodically, and then the terminal device itself executes data processing applications (for example, computer vision tasks such as classification, segmentation, detection, image generation, etc.) on the image, thereby obtaining the corresponding processing results for the image, and implementing functions (classification function, segmentation function, detection function, image generation function, etc.) based on the processing results.

[0086] exist Figure 3B In the embodiment of the present application, the terminal device itself can execute the data processing method.

[0087] When the user uses the model for reasoning, the user obtains the input sample, obtains the heterogeneous configuration from the data processing device database, and obtains the reasoning result based on the input sample and the heterogeneous configuration. That is, the input of the model includes the input sample on the user side and the heterogeneous configuration on the user side, and the output is the reasoning result.

[0088] Figure 3A and Figure 3B The processor in the system can perform data training / machine learning / deep learning through a neural network model or other models (such as an attention model, MLP, etc.), and use input samples and heterogeneous configurations to execute data processing applications to obtain corresponding processing results.

[0089] The data processing method provided in the embodiment of the present application is described below. The method can be executed by a data processing device, or by a component of the data processing device (such as a processor, a chip, or a chip system, etc.). The data processing device can be a cloud device (such as the aforementioned Figure 3A as shown), or a terminal device (such as Figure 3B Of course, the method can also be executed by a system consisting of a cloud device and a terminal device (as described above). Figure 3A shown).

[0090] The method provided in the embodiment of the present application is mainly applicable to heterogeneous processing scenarios.

[0091] See also Figure 4 , a flow chart of a data processing method provided by an embodiment of the present application, the method may include steps 401 to 403. Steps 401 to 403 are described in detail below.

[0092] Step 401, obtaining multiple operators of a neural network.

[0093] The data processing device in the embodiment of the present application includes multiple processors and multiple compute libraries (CL) corresponding to the multiple processors.

[0094] In the embodiment of the present application, only a plurality of processors including a central processing unit (CPU) and an embedded neural network processing unit (NPU) are used as an example for exemplary description. In practical applications, the plurality of processors may also include at least one of the following: a graphics processing unit (GPU), an accelerated processing unit (APU), a branch processing unit (BPU), an energy processing unit (EPU), a floating point unit (FPU), a holographic processor (HPU), an image processing unit (IPU), a tensor processing unit (TPU), a vector processing unit (VPU), and other XPUs, which are not specifically limited here.

[0095] The data processing device obtains multiple operators (Op) of the neural network. There are many ways to obtain them, such as obtaining them from the memory of the data processing device or by receiving data sent by a cloud device, etc., which are not limited here.

[0096] Optionally, the multiple operators are non-fused operators.

[0097] Step 402: Determine the association relationship between multiple operators and multiple computing libraries.

[0098] After the data processing device obtains multiple operators of the neural network, it can determine the association relationship between the multiple operators and the multiple computing libraries.

[0099] In order to improve the accuracy of the correlation and the authenticity of the operator performance, the above correlation can be obtained by real machine testing. That is, the data processing device obtains the input samples of the neural network and calculates the performance of the operator based on the input samples.

[0100] Optionally, when the multiple processors of the data processing device include a CPU and an NPU, the multiple computing libraries include a first computing library and a second computing library, wherein the first computing library corresponds to the CPU computing library, and the second computing library corresponds to the NPU computing library.

[0101] In the embodiment of the present application, the data processing device may determine the association relationship by searching based on rules, exhaustive search, heuristic search, etc., which is not limited here.

[0102] For example, a rule-based search (or a rule-based heterogeneous splitting method) is used as an example for illustrative description. The following is a pseudo code example of a rule-based search:

[0103] enter:

[0104] computeGraph (ComputeGraph is a deep learning model expressed in graphs)

[0105] checkSupportList{a list of each operator in computeGraph supported by the computing library}

[0106] limit: maximum number of segments

[0107] Output:

[0108] opDeviceOrder (computeGraph is the split result of each operator calculated based on the algorithm, that is, the association relationship)

[0109] Among them, the strategy (that is, the subsequent ways to determine the association relationship) directly affects the number of segments of computeGraph. If the number of segments exceeds the limit, the split with the worst performance will be rolled back to the computing library of the same type as the connected operator.

[0110] In the embodiment of the present application, there are multiple ways for the data processing device to determine the association relationship, which are described below respectively:

[0111] The first one is to determine the association between operators and computing libraries through the calculation results of each operator in different computing libraries.

[0112] The data processing device obtains the input samples of the neural network, and calculates the calculation results of each operator in different calculation libraries through the input samples, and then determines the association relationship between the operator and the calculation library according to the calculation results of different calculation libraries.

[0113] Optionally, when the multiple calculation libraries include a first calculation library and a second calculation library, the data processing device calculates a first calculation result of each operator in the first calculation library according to the input sample. The data processing device calculates a second calculation result of each operator in the second calculation library according to the input sample. Then, the calculation library corresponding to each operator is determined according to the first calculation result and the second calculation result (that is, the association relationship between the operator and the calculation library is determined).

[0114] The calculation results in the embodiments of the present application include at least one of the following: result accuracy, calculation time, etc., which are not specifically limited here.

[0115] There are multiple ways for the data processing device to determine the calculation library corresponding to each operator according to the first calculation result and the second calculation result, which are described below:

[0116] 1. Directly select the calculation library corresponding to the better calculation result from the first calculation result and the second calculation result as the calculation library of the operator.

[0117] In this manner, the data processing device directly selects the calculation library corresponding to the better calculation result from the first calculation result and the second calculation result as the calculation library of the operator.

[0118] For example, if the time consumption of an operator in the CPU computing library is 1 millisecond, and the time consumption of an operator in the NPU computing library is 0.5 milliseconds, the data processing device determines that the computing library corresponding to the operator is the NPU computing library.

[0119] 2. Calculate the ratio of the first calculation result to the second calculation result, and determine the calculation library corresponding to the operator according to the ratio and the first preset threshold.

[0120] In this manner, the data processing device calculates the ratio of the first calculation result to the second calculation result, and determines the calculation library corresponding to the operator according to the ratio and the first preset threshold.

[0121] Optionally, if the above ratio is less than or equal to a first preset threshold, the calculation library corresponding to the operator is determined to be the first calculation library. If the above ratio is greater than the first preset threshold, the calculation library corresponding to the operator is determined to be the second calculation library. The first preset threshold can be set according to actual needs and is not specifically limited here.

[0122] Optionally, the determination process in this manner may be as follows: Figure 5 As shown, the operators (graphnode) of the computation graph are traversed to determine whether the current operator is a fusion operator. If so, a computation library is selected according to the previous operator. If not, the ratio of the first computation result to the second computation result of the operator is calculated. It is determined whether the ratio is less than or equal to the first preset threshold. If so, the computation library of the operator is determined to be the second computation library. If not, the computation library of the operator is determined to be the first computation library.

[0123] It can be understood that the above two methods are just a few examples of the data processing device determining the association relationship between operators and calculation libraries through the calculation results of each operator in different calculation libraries. In practical applications, there may be other methods, which are not limited here.

[0124] The second method is to determine the association between the operator and the calculation library through the calculation results of each operator in the same calculation library.

[0125] In this case, the data processing device determines the association relationship between the operator and the calculation library through the calculation result of each operator in the same calculation library. This case can also be understood as determining the association relationship based on the result of each operator in the same calculation library.

[0126] Optionally, the data processing device calculates the result of each operator in the first calculation library respectively; determines that the calculation library of the operator corresponding to the result whose result is greater than or equal to the second preset threshold is the second calculation library. Determine that the calculation library of the operator corresponding to the result whose result is less than the second preset threshold is the first calculation library.

[0127] Specifically, the data processing device sorts the performance of each operator in the first computing library from low to high, and selects the top K operators with the worst performance. The computing library of the K operators is determined to be the second computing library. K is a value greater than or equal to 0, which can be set according to actual needs and is not specifically limited here.

[0128] Optionally, the calculation library of multiple operators connected to the first operator is determined to be the second calculation library, and the first operator is the operator corresponding to the result of the first calculation library being greater than or equal to the second preset threshold. It can also be understood as a diffusion mechanism. The diffusion mechanism can be as follows Figure 6 That is, diffusion is performed around several operators with poor performance, and the corresponding computing library is adjusted to another computing library (that is, the computing libraries corresponding to several operators around the operators with poor performance in the first computing library are determined as the second computing library).

[0129] Optionally, the determination process in this manner may be as follows: Figure 7 As shown, the operators (graphnode) of the computation graph are traversed to determine whether the current operator is a fusion operator. If so, a computation library is selected based on the previous operator. If not, the operators are sorted from high to low based on the result of the first computation. The computation libraries of the first K operators with poor performance are determined as the second computation library.

[0130] In addition, this situation can be understood as a supplement to the first situation to prevent local optimality.

[0131] The third method is to determine the association between operators and computing libraries through the communication overhead between multiple operators.

[0132] In this case, the data processing device determines the association between the operator and the computing library through the communication overhead between multiple operators.

[0133] Although the performance of the computing library in which the operator is applied is more important in the reasoning process of the neural network, the communication overhead between operators is also an indispensable part that affects the overall reasoning performance. In this case, determining the correlation relationship through the communication overhead of multiple operators can improve the performance of the neural network in the entire reasoning process.

[0134] Optionally, the data processing device uses the input samples as input to the neural network and calculates the communication overhead between multiple operators during the inference process.

[0135] Optionally, the determination process in this manner may be as follows: Figure 8 As shown, traverse the operators (graphnode) of the computation graph to determine whether the current operator is a fusion operator. If so, select a computation library based on the previous operator. If not, calculate the time it takes to split the operator to the first processor (corresponding to the first computation library) and the sum of the overheads of multiple operators (i.e., T-CPU), and the time it takes to split the operator to the second processor (corresponding to the second computation library) and the sum of the overheads of multiple operators (i.e., T-NPU). If T-CPU is less than or equal to T-NPU, determine that the computation library of the operator is the first computation library (i.e., CPU computation library). If T-CPU is greater than T-NPU, determine that the computation library of the operator is the second computation library (i.e., NPU computation library).

[0136] Furthermore, the more heterogeneous segments there are, the longer the reasoning process of the neural network will be, which may mask the benefits brought by heterogeneity. Therefore, it is necessary to minimize the subgraph communication overhead. The embodiments of the present application use the following two methods to minimize the subgraph communication overhead.

[0137] The first method is to delete the Cast operator that has the opposite effect.

[0138] There will be two consecutive cast operators with opposite effects between different operators. These two cast operators are deleted. Therefore, multiple operators are directly connected, eliminating the time consumption of two casts and reducing the communication overhead between subgraphs.

[0139] Among them, the Cast operator is a conversion operator that can convert data types, such as converting data from float type to int type (format of different databases). The opposite effect means that in two consecutive Cast operators, the first Cast operator converts the data type from type1 to type2, and the second Cast operator converts the data type from type2 to type1.

[0140] For example, the schematic diagram before and after eliminating the cast operator is as follows: Fig. 9 As shown in the figure, two consecutive cast operators with opposite effects are removed, namely Cast(16->32) and Cast(32->16). It can be seen that the communication overhead is reduced after the removal.

[0141] The second method is cache optimization.

[0142] When moving data, you can use the cache to move data. Because the cache needs to be refreshed between the input and output of different hardware subgraphs. For example Fig.10 In this case, the cache needs to be flushed three times. The embodiment of the present application proposes an optimization method: if the input of the next operator comes from the same memory, the cache is only flushed once, which reduces the communication time between subgraphs.

[0143] It can be understood that the above three situations are just a few examples of how the data processing device determines the association relationship between the operator and the computing library. In practical applications, there may be other situations (for example, factors such as subgraph switching overhead can also be considered in the process of determining the association relationship. For another example, the above three situations are all adopted, and the one with the best performance is selected as the final determined association relationship), which is not limited here.

[0144] Step 403: Perform heterogeneous processing based on the association relationship.

[0145] After the data processing device obtains the association relationship, it performs heterogeneous processing based on the association relationship. The heterogeneous processing includes at least one of the following: reasoning process, online compilation, etc.

[0146] Optionally, in a deployment scenario, the data processing device also obtains input data and performs heterogeneous processing based on the input data and association relationships to obtain inference results.

[0147] In addition, the data involved in the embodiments of the present application may refer to text, images, audio and video, etc., which are not specifically limited here.

[0148] In the embodiment of the present application, on the one hand, by determining the association relationship between multiple operators and multiple computing libraries in the neural network, heterogeneous processing can be performed according to the association relationship at the chip level, thereby improving the performance of heterogeneous processing. On the other hand, the association relationship is determined by real machine data, the operator performance is real and reliable, and heterogeneous processing is performed according to the association relationship in the heterogeneous processing of the deployment scenario. On the other hand, heterogeneous search assigns different computing tasks to appropriate computing libraries to enable the collaboration of multiple processors, improve the performance of whole-graph reasoning, reduce the power consumption of using the same hardware, and solve the problem of unbalanced load on multiple processors. In addition, in the cloud deployment scenario, the use of heterogeneous configuration is simple, and the performance of user equipment can be regularly improved and power consumption can be reduced. And the search technology (i.e., the process of determining the association relationship) is independent of online compilation, and the generated heterogeneous splitting results are used for online compilation without additional compilation time.

[0149] Another flowchart of the data processing method provided in the embodiment of the present application is as follows Fig.11The process includes:

[0150] 1. Developers download and install the search tool.

[0151] 2. Search based on real machines or using modeling methods. Based on real machines means that the search tool searches for the performance, power consumption and other data of operators on real machines, while based on modeling means that the performance, power consumption and other data of the search tool during the search comes from offline statistics and mathematical modeling (ensuring that the data is equivalent to that of real machines).

[0152] 3. The tool starts searching. The search steps are: 1) Start the search. 2) Search the data of operators in different IPs. 3) Split the model using the heterogeneous splitting strategy. 4) Compile the model. 5) Infer the model.

[0153] 4. The search results are returned to the developer or submitted to the cloud server.

[0154] 5. If the search results are returned to the developer, the developer will add the heterogeneous configuration to the APK. If the search results are uploaded to the developer cloud, the cloud can push the heterogeneous configuration to the APK.

[0155] 6. Parse heterogeneous configurations in APK and compile and load models.

[0156] Optionally, the search tool provides the developer with usage options (such as Fig.12 shown):

[0157] 1. High-performance pattern search - search for the configuration with the best inference performance of the model, so that the model can achieve the best performance during inference

[0158] 2. Low power mode search - search for the configuration with the lowest inference power consumption of the model, so that the model can achieve the lowest power consumption during inference

[0159] 3. Load balancing mode search - search for the configuration with the lowest inference power consumption of the model, so that different IP loads are balanced during model inference (load balancing: balancing the load (work tasks) and distributing them to multiple operation units for operation)

[0160] 4. Energy efficiency priority mode search - search for the configuration with the best energy efficiency of the model, so that the performance / power consumption ratio is optimized during model inference

[0161] For example, the software level of heterogeneous search is as follows: Fig.13 As shown, the heterogeneous search tool is in development and can be provided by major reasoning frameworks. After developers download the toolkit, they use the heterogeneous search tool to search for heterogeneous configurations and integrate them with the model into the user's device for model reasoning.

[0162] The data processing method in the embodiment of the present application is described above. The data processing device in the embodiment of the present application is described below. Fig.14 , an embodiment of the data processing device in the embodiment of the present application includes:

[0163] An acquisition unit 1401 is used to acquire multiple operators of a neural network;

[0164] A determining unit 1402 is used to determine the association relationship between multiple operators and multiple computing libraries;

[0165] The processing unit 1403 is used to perform heterogeneous processing based on the association relationship.

[0166] Optionally, the multiple calculation libraries include a first calculation library and a second calculation library; the acquisition unit 1401 is also used to obtain input samples of the neural network; the determination unit 1402 is specifically used to calculate the first calculation result of each operator in the first calculation library based on the input samples; the determination unit 1402 is specifically used to calculate the second calculation result of each operator in the second calculation library based on the input samples; the determination unit 1402 is specifically used to determine the calculation library corresponding to each operator based on the first calculation result and the second calculation result.

[0167] Optionally, the determining unit 1402 is specifically configured to determine that the calculation library corresponding to the better calculation result between the first calculation result and the second calculation result of each operator is the calculation library corresponding to each operator.

[0168] Optionally, the determination unit 1402 is specifically used to calculate the ratio of the first calculation result to the second calculation result; the determination unit 1402 is specifically used to determine that the calculation library corresponding to the operator is the first calculation library if the ratio is less than or equal to a first preset threshold.

[0169] Optionally, the determination unit 1402 is specifically used to calculate the results of each operator in the first calculation library respectively; the determination unit 1402 is specifically used to determine that the calculation library of the operator corresponding to the result greater than or equal to the second preset threshold is the second calculation library.

[0170] Optionally, the determination unit 1402 is further used to determine that the calculation library of multiple operators connected to the first operator is a second calculation library, and the first operator is an operator corresponding to a result of the first calculation library that is greater than or equal to a second preset threshold.

[0171] Optionally, the data processing device further includes: a calculation unit 1404, configured to calculate the communication overhead between multiple operators based on the input samples; and a determination unit 1402, specifically configured to determine the association relationship based on the communication overhead.

[0172] Optionally, the multiple operators are non-fused operators.

[0173] Optionally, the acquisition unit 1401 is further used to acquire input data; the processing unit 1403 is specifically used to perform heterogeneous processing based on the input data and the association relationship to obtain an inference result.

[0174] In this embodiment, the operations performed by each unit in the data processing device are the same as those described above. Figures 1 to 13 The description in the illustrated embodiment is similar and will not be repeated here.

[0175] In this embodiment, on the one hand, the association between multiple operators and multiple computing libraries in the neural network is determined by the determination unit 1402, and then the processing unit 1403 can perform heterogeneous processing according to the association at the chip level, thereby improving the performance of heterogeneous processing. On the other hand, the association is determined by real machine data, the operator performance is real and reliable, and heterogeneous processing is performed according to the association in the heterogeneous processing of the deployment scenario. On the other hand, heterogeneous search assigns different computing tasks to appropriate computing libraries to enable the collaboration of multiple processors, improve the performance of whole-graph reasoning, reduce the power consumption of using the same hardware, and solve the problem of unbalanced load on multiple processors. In addition, in the cloud deployment scenario, the use of heterogeneous configuration is simple, and the performance of user equipment can be regularly improved and power consumption can be reduced. And the search technology (i.e., the process of determining the association) is independent of online compilation, and the generated heterogeneous splitting results are used for online compilation without additional compilation time.

[0176] See also Fig.15 , a schematic diagram of the structure of another data processing device provided by the present application. The data processing device may include a processor 1501, a memory 1502 and a communication port 1503. The processor 1501, the memory 1502 and the communication port 1503 are interconnected via a line. The memory 1502 stores program instructions and data.

[0177] The memory 1502 stores the aforementioned Figures 1 to 13 In the corresponding embodiment shown, the steps executed by the data processing device correspond to program instructions and data.

[0178] Processor 1501, used to execute the above Figures 1 to 13 The steps shown in any of the illustrated embodiments are performed by a data processing device.

[0179] Communication port 1503 can be used to receive and send data, and to perform the above Figures 1 to 13 The steps related to obtaining, sending and receiving in any of the embodiments shown.

[0180] In one implementation, the data processing device may include Fig.15 More or fewer components are merely illustrative in this application and are not limiting.

[0181] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.

[0182] In the several embodiments provided in the present application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, 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 an indirect coupling or communication connection through some interfaces, devices or units, which can be electrical, mechanical or other forms.

[0183] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0184] In addition, each functional unit in each embodiment of the present application 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. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.

[0185] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, read-only memory), random access memory (RAM, random access memory), disk or optical disk and other media that can store program code.

Claims

1. A data processing method, characterized in that: The method is applied to a data processing device, the data processing device comprising a plurality of processors and a plurality of computing libraries corresponding to the plurality of processors, and the method comprises: Get multiple operators of the neural network; Determining association relationships between the multiple operators and the multiple computing libraries; Heterogeneous processing is performed based on the association relationship.

2. The method according to claim 1, characterized in that: The plurality of computing libraries include a first computing library and a second computing library; The method further comprises: Obtaining an input sample of the neural network; The determining the association relationship between the multiple operators and the multiple computing libraries includes: Calculate a first calculation result of each operator in the first calculation library based on the input sample; Calculate a second calculation result of each operator in the second calculation library based on the input sample; A calculation library corresponding to each operator is determined based on the first calculation result and the second calculation result.

3. The method according to claim 2, characterized in that The determining, based on the first calculation result and the second calculation result, a calculation library corresponding to each operator includes: Determine that the calculation library corresponding to the better calculation result between the first calculation result and the second calculation result of each operator is the calculation library corresponding to each operator.

4. The method according to claim 2, characterized in that: The determining, based on the first calculation result and the second calculation result, a calculation library corresponding to each operator includes: Calculating a ratio of the first calculation result to the second calculation result; If the ratio is less than or equal to a first preset threshold, it is determined that the calculation library corresponding to the operator is the first calculation library.

5. The method according to any one of claims 1 to 4, characterized in that The determining the association relationship between the multiple operators and the multiple computing libraries includes: Calculate the result of each operator in the first calculation library respectively; Determine that the calculation library of the operator corresponding to the result whose result is greater than or equal to the second preset threshold is the second calculation library.

6. The method according to claim 5, characterized in that The method further comprises: A calculation library of multiple operators connected to the first operator is determined as a second calculation library, and the first operator is an operator corresponding to a result of the first calculation library being greater than or equal to a second preset threshold.

7. The method according to any one of claims 1 to 6, characterized in that Before performing heterogeneous processing based on the association relationship, the method further includes: Calculating communication overhead between the multiple operators based on the input samples; The determining the association relationship between the multiple operators and the multiple computing libraries includes: The association relationship is determined based on the communication overhead.

8. The method according to any one of claims 1 to 7, characterized in that The multiple operators are non-fused operators.

9. The method according to any one of claims 1 to 8, characterized in that The method further comprises: Get input data; The performing heterogeneous processing based on the association relationship includes: Heterogeneous processing is performed based on the input data and the association relationship to obtain an inference result.

10. A data processing device, characterized in that: The data processing device includes a plurality of processors and a plurality of computing libraries corresponding to the plurality of processors, and the data processing device includes: An acquisition unit, used for acquiring multiple operators of a neural network; A determination unit, configured to determine associations between the plurality of operators and the plurality of computing libraries; A processing unit is used to perform heterogeneous processing based on the association relationship.

11. The data processing device according to claim 10, characterized in that The plurality of computing libraries include a first computing library and a second computing library; The acquisition unit is further used to acquire input samples of the neural network; The determining unit is specifically configured to calculate a first calculation result of each operator in the first calculation library based on the input sample; The determining unit is specifically configured to calculate a second calculation result of each operator in the second calculation library based on the input sample; The determining unit is specifically configured to determine a calculation library corresponding to each operator based on the first calculation result and the second calculation result.

12. The data processing device according to claim 11, characterized in that The determining unit is specifically configured to determine that a calculation library corresponding to a better calculation result between the first calculation result and the second calculation result of each operator is the calculation library corresponding to each operator.

13. The data processing device according to claim 11, characterized in that The determining unit is specifically configured to calculate a ratio of the first calculation result to the second calculation result; The determining unit is specifically configured to determine that the calculation library corresponding to the operator is the first calculation library if the ratio is less than or equal to a first preset threshold.

14. The data processing device according to any one of claims 10 to 13, characterized in that: The determining unit is specifically used to calculate the result of each operator in the first calculation library respectively; The determining unit is specifically configured to determine that the calculation library of the operator corresponding to the result whose result is greater than or equal to the second preset threshold is the second calculation library.

15. The data processing device according to claim 14, characterized in that The determining unit is further used to determine that a calculation library of multiple operators connected to the first operator is a second calculation library, and the first operator is an operator corresponding to a result of the first calculation library being greater than or equal to a second preset threshold.

16. The data processing device according to any one of claims 10 to 15, characterized in that: The data processing device further comprises: A computing unit, configured to compute the communication overhead between the plurality of operators based on the input samples; The determining unit is specifically configured to determine the association relationship based on the communication overhead.

17. The data processing device according to any one of claims 10 to 16, characterized in that: The multiple operators are non-fused operators.

18. The data processing device according to any one of claims 10 to 17, characterized in that: The acquisition unit is further used to acquire input data; The processing unit is specifically used to perform heterogeneous processing based on the input data and the association relationship to obtain an inference result.

19. A data processing device, characterized in that: include: A processor, the processor is coupled to a memory, the memory is used to store programs or instructions, when the program or instructions are executed by the processor, the data processing device executes the method according to any one of claims 1 to 9.

20. A computer storage medium, characterized in that The method comprises computer instructions, which, when executed on a data processing device, cause the data processing device to execute the method according to any one of claims 1 to 9.

21. A computer program product, characterized in that When the computer program product is run on a computer, the computer is caused to execute the method according to any one of claims 1 to 9.