Operator calling method of deep learning framework, storage medium and electronic device

By introducing an adaptation layer into the deep learning framework and using string names to query the registry to dynamically load the operator library, the problem of low versatility of the adaptation layer is solved, and efficient operator calls across frameworks are achieved.

CN118428426BActive Publication Date: 2025-12-16SHANDONG YUNHAI GUOCHUANG CLOUD COMPUTING EQUIP IND INNOVATION CENT CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202410527060.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-04-28
Publication Date
2025-12-16
Estimated Expiration
2044-04-28

AI Technical Summary

Technical Problem

In the operator calling methods of deep learning frameworks, the adaptor layer has low versatility, which means that when the same chip is connected between different frameworks, the adaptor layer needs to be developed repeatedly, wasting human and material resources.

Method used

By introducing an adaptation layer into the deep learning framework, operator interface function pointers in the operator libraries of different chips are encapsulated, and the backend operator library is dynamically loaded by querying the registry using string names on the front end, thus enabling the calling of operator functions on the target chip.

Benefits of technology

The adaptor layer has been improved in terms of its versatility, enabling the same chip to use the same adaptor layer across different frameworks. This reduces the need for redundant development and improves efficiency and the versatility of the adaptor layer.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118428426B_ABST
    Figure CN118428426B_ABST
Patent Text Reader

Abstract

The embodiment of the application provides a kind of operator calling method of deep learning framework, storage medium and electronic equipment, wherein deep learning framework is the framework of artificial intelligence model, deep learning framework includes front end, back end and adaptation layer, back end maintains with the string name of operator as key, with the operator interface function pointer of adaptation layer as value's register table, front end is used to dynamically load the operator library of back end;Method includes: using the string name of the operator to be called of front end to query register table, wherein the operator to be called belongs to the target operator library of target chip;In the case where the operator interface function pointer of the operator to be called is found, the operator interface function of the operator to be called in adaptation layer is called using the operator interface function pointer of the operator to be called, to call the operator function of the operator to be called in target operator library.By the present application, the operator calling method of deep learning framework in the related art is solved Adaptation layer low universality problem.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computers, and more specifically, to an operator invocation method, storage medium, and electronic device for a deep learning framework. Background Technology

[0002] To call the operators of AI (Artificial Intelligence) chips, deep learning frameworks need to provide an adaptation layer. This adaptation layer encapsulates the AI ​​chip's operators and provides interfaces. The deep learning framework also needs to register the AI ​​chip's operators, that is, assign the interface function pointer of the adaptation layer to the framework's reserved variables. The framework calls the AI ​​chip's operators by calling the reserved variables.

[0003] In related technologies, the front-end and back-end of deep learning frameworks are not completely isolated. The framework calls operators through its own function pointer variables. When registering operators, it needs to implement the adaptation layer according to its own defined interface, which makes the framework's adaptation layer unusable for other frameworks.

[0004] This shows that the operator calling methods of deep learning frameworks in related technologies suffer from low adaptability of the layer. Summary of the Invention

[0005] This application provides an operator invocation method, storage medium, and electronic device for a deep learning framework, in order to at least solve the problem of low adaptability of the operator invocation method for deep learning frameworks in related technologies.

[0006] According to one embodiment of this application, a method for calling operators in a deep learning framework is provided. The deep learning framework is a framework for an artificial intelligence model. The deep learning framework includes a front-end, a back-end, and an adaptation layer. The adaptation layer is located in the front-end, the back-end, or independent of the front-end and the back-end. The adaptation layer is used to encapsulate operators in the operator libraries of different chips to obtain corresponding operator interface function pointers. The operators encapsulated by the adaptation layer are used to implement the neural network layer of the artificial intelligence model. The back-end maintains a registry with the string name of the operator as the key and the operator interface function pointer of the adaptation layer as the value. The front-end is used to dynamically load the operator library of the back-end. The method includes: querying the registry using the string name of the operator to be called from the front-end, wherein the operator to be called belongs to the target operator library of the target chip; if the operator interface function pointer of the operator to be called is found, calling the operator interface function of the operator to be called in the adaptation layer using the operator interface function pointer of the operator to be called, so as to call the operator function of the operator to be called in the target operator library.

[0007] According to another embodiment of this application, an operator invocation device for a deep learning framework is provided. The deep learning framework is a framework for an artificial intelligence model. The deep learning framework includes a front-end, a back-end, and an adaptation layer. The adaptation layer is located in the front-end, back-end, or independent of the front-end and back-end. The adaptation layer is used to encapsulate operators in the operator libraries of different chips to obtain corresponding operator interface function pointers. The operators encapsulated by the adaptation layer are used to implement the neural network layer of the artificial intelligence model. The back-end maintains a registry with the string name of the operator as the key and the operator interface function pointer of the adaptation layer as the value. The front-end is used to dynamically load the operator library of the back-end. The device includes: a query unit, used to query the registry using the string name of the operator to be invoked from the front-end, wherein the operator to be invoked belongs to the target operator library of the target chip; and an invocation unit, used to invoke the operator interface function of the operator to be invoked in the adaptation layer using the operator interface function pointer of the operator to be invoked when the operator interface function pointer of the operator to be invoked is found, so as to invoke the operator function of the operator to be invoked in the target operator library.

[0008] According to yet another embodiment of this application, a computer-readable storage medium is also provided, wherein a computer program is stored therein, and the computer program is configured to perform the steps in any of the above method embodiments when it is run.

[0009] According to yet another embodiment of this application, an electronic device is also provided, including a memory and a processor, wherein the memory stores a computer program and the processor is configured to run the computer program to perform the steps in any of the above method embodiments.

[0010] According to yet another embodiment of this application, a computer program product is also provided, including a computer program that, when executed by a processor, implements the steps in any of the above method embodiments.

[0011] This application describes a deep learning framework, which is a framework for artificial intelligence models. The deep learning framework includes a front-end, a back-end, and an adaptation layer. The adaptation layer may be located within or independent of the front-end and back-end. The adaptation layer encapsulates operators from operator libraries of different chips, obtaining corresponding operator interface function pointers. The encapsulated operators in the adaptation layer are used to implement the neural network layers of the artificial intelligence model. The back-end maintains a registry with the string name of the operator as the key and the operator interface function pointer of the adaptation layer as the value. The front-end dynamically loads the operator library from the back-end. The method includes: querying the registry using the string name of the operator to be called from the front-end, where the operator to be called belongs to the target operator library of the target chip; and finding the operator to be called... In the case of operator interface function pointers, the operator interface function pointer of the operator to be called is used to call the operator interface function of the operator to be called in the adaptation layer, so as to call the operator function of the operator to be called in the target operator library. Compared with related technologies, where the framework needs to call the operator through its own function pointer, in this embodiment, the operator function of the operator to be called in the target chip's target operator library can be called by the front end using the string name of the operator to be called. This allows the same adaptation layer to be used when connecting to different frameworks for the same chip, effectively increasing the versatility of the adaptation layer and solving the problem of low versatility of the adaptation layer in the operator calling method of deep learning frameworks in related technologies. Attached Figure Description

[0012] Figure 1 This is a schematic diagram of the hardware environment for an operator invocation method of an optional deep learning framework according to an embodiment of this application;

[0013] Figure 2 This is a flowchart illustrating an optional deep learning framework operator invocation method according to an embodiment of this application;

[0014] Figure 3 This is a schematic diagram of an optional deep learning framework according to an embodiment of this application;

[0015] Figure 4 This is a flowchart illustrating an operator invocation method for another optional deep learning framework according to an embodiment of this application.

[0016] Figure 5 This is a schematic diagram of another optional deep learning framework according to an embodiment of this application;

[0017] Figure 6 This is a flowchart illustrating an alternative deep learning framework operator invocation method according to an embodiment of this application.

[0018] Figure 7 This is a flowchart illustrating an alternative deep learning framework operator invocation method according to an embodiment of this application.

[0019] Figure 8 This is a structural block diagram of a computer system for an optional electronic device according to an embodiment of this application. Detailed Implementation

[0020] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present application, and not all embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative effort should fall within the scope of protection of the present application.

[0021] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.

[0022] The methods and embodiments provided in this application can be executed on a server, mobile terminal, computer terminal, or similar computing device. Taking running on a server as an example, Figure 1 This is a schematic diagram of the hardware environment for an operator invocation method of a deep learning framework according to an embodiment of this application. Figure 1 As shown, a server may include one or more ( Figure 1 Only one is shown in the diagram. A processor 102 (which may include, but is not limited to, a microprocessor MCU or a programmable logic device FPGA, etc.) and a memory 104 for storing data are also shown. The server may further include a transmission device 106 for communication functions and an input / output device 108. Those skilled in the art will understand that... Figure 1 The structure shown is for illustrative purposes only and does not limit the structure of the server described above. For example, the server may also include components that are more complex than... Figure 1 The more or fewer components shown, or having the same Figure 1 The different configurations shown.

[0023] The memory 104 can be used to store computer programs, such as application software programs and modules, like the computer program corresponding to the operator calling method of the deep learning framework in this embodiment. The processor 102 executes various functional applications and data processing by running the computer programs stored in the memory 104, thus implementing the above-described method. The memory 104 may include high-speed random access memory and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 104 may further include memory remotely located relative to the processor 102, and these remote memories can be connected to the mobile terminal via a network. Examples of such networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof.

[0024] The transmission device 106 is used to receive or send data via a network. Specific examples of the network described above may include a wireless network provided by a communication provider for the computer terminal. In one example, the transmission device 106 includes a Network Interface Controller (NIC), which can connect to other network devices via a base station to communicate with the Internet. In another example, the transmission device 106 may be a Radio Frequency (RF) module used for wireless communication with the Internet.

[0025] Optionally, the operator invocation method of the deep learning framework in this embodiment can be executed by the server. Here, "server" refers to the entire server, including the relevant components and processors within the server that need to execute the operator invocation method of the deep learning framework. Alternatively, the operator invocation method of the deep learning framework in this embodiment can be executed by the BMC. Here, BMC refers to the Baseboard Management Controller and Intelligent Platform Management Interface, which is the basic core functional subsystem of the server, responsible for core functions such as hardware status management, operating system management, health status management, and power consumption management. In some examples of this embodiment, the operator invocation method of the deep learning framework is illustrated by being executed by the server.

[0026] See Figure 2 , Figure 2 This is a flowchart illustrating an optional deep learning framework operator invocation method according to an embodiment of this application, as shown below. Figure 2 As shown, the above method includes the following steps:

[0027] Step S202: Use the string name of the operator to be invoked from the front end to query the registry, where the operator to be invoked belongs to the target operator library of the target chip.

[0028] In this embodiment, the deep learning framework is the framework of the artificial intelligence model. The deep learning framework includes a front-end, a back-end, and an adaptation layer. The adaptation layer is located in the front-end, back-end, or independent of the front-end and back-end. The adaptation layer is used to encapsulate operators in the operator libraries of different chips to obtain the corresponding operator interface function pointers. The operators encapsulated by the adaptation layer are used to implement the neural network layer of the artificial intelligence model. The back-end maintains a registry with the string name of the operator as the key and the operator interface function pointer of the adaptation layer as the value. The front-end is used to dynamically load the operator library of the back-end.

[0029] The operator invocation method of the deep learning framework in this embodiment can be applied to scenarios where the deep learning framework invokes chip operators. Here, the deep learning framework is a software tool used to build, train, and deploy deep learning models. The deep learning model refers to a specific neural network structure, such as CNN (Convolutional Neural Network) and RNN (Recurrent Neural Network). Operators are located in the deep learning framework. An operator is a computational unit, which refers to a function or module that performs a specific operation or computation, such as convolution, pooling, and activation functions. Operators are used to build neural network models in the deep learning framework. The AI ​​(Artificial Intelligence) chip is a chip used to accelerate the operator computation process. The AI ​​chip has an operator library containing the implementation of operators and the corresponding interface descriptions. When the deep learning framework connects to a chip, it actually loads the chip's operator library and invokes the chip's operators.

[0030] Deep learning frameworks are frameworks for artificial intelligence models. They serve deep learning tasks, and deep learning generally refers to AI. Deep learning relies on AI models, which are trained to perform specific tasks such as speech recognition and image classification. Operators are the computational units of AI models. They are used to implement neural network layers. Simple neural network layers correspond to one operator, while complex layers correspond to multiple operators. When the model is relatively simple, the computation of operators can be performed using a CPU (Central Processing Unit). However, as the complexity of the model increases, CPU computation becomes too slow, and training a complex model takes a long time. Therefore, dedicated AI chips are needed to implement operator computation.

[0031] Under different hardware, the implementation of operators with the same function can be completely different. Typically, chip manufacturers provide a C++ (C++ Plus Plus, a high-level programming language) operator library, which contains the implementation of each operator and its corresponding interface description. For a deep learning framework to connect to a chip, it essentially loads the chip's operator library and calls the chip's operators. To enable deep learning frameworks to call different chip operators without changing the upper-level Python code, they need to provide an adaptation layer. This adaptation layer is a layer in the deep learning framework's software architecture used to adapt the interfaces of external systems or components to meet the requirements of the current system. The adaptation layer helps the system integrate with external systems while maintaining internal stability and consistency. In this embodiment, the adaptation layer encapsulates the AI ​​chip's operators, with each operator corresponding to an interface in the adaptation layer, shielding some operations related to the hardware chip.

[0032] A deep learning framework consists of a front-end, a back-end, and an adaptation layer. The front-end primarily refers to the user interface and tools used to build, train, and test deep learning models. The back-end refers to the framework's underlying implementation, including mathematical computation libraries, optimization algorithms, automatic differentiation, etc., used to support model training and inference. The adaptation layer may be located in the front-end, back-end, or independent of either. The adaptation layer adapts input data and model structure to the framework's requirements. Its role is to convert external data into a format that the framework can process. The adaptation layer also encapsulates operators from different chip operator libraries, obtaining corresponding operator interface function pointers. See also... Figure 3 , Figure 3 This is a schematic diagram of an optional deep learning framework. The Adapter API (Application Programming Interface) refers to the adaptation layer. The Hardware A Operator Library, Hardware B Operator Library, and Hardware C Operator Library refer to the operator libraries of different AI chips. The adaptation layer encapsulates the operators in the operator libraries of different chips to obtain the corresponding operator interface function pointers.

[0033] Before calling the operators of an AI chip, a deep learning framework needs to register the AI ​​chip's operators. This involves assigning the interface function pointer of the adaptation layer to a reserved variable in the framework. The framework then calls the AI ​​chip's operators by calling the reserved variable. In related technologies, because the front-end and back-end of deep learning frameworks are not completely isolated, the framework needs to call operators through its own function pointer variable. When registering operators, the adaptation layer needs to be implemented according to its own defined interface, which makes the adaptation layer of this framework unusable for other frameworks. Therefore, the operator calling method of deep learning frameworks in related technologies suffers from low adaptability of the adaptation layer. When the same chip is used for different frameworks, the adaptation layer needs to be developed repeatedly, wasting human and material resources.

[0034] In this embodiment, the backend of the deep learning framework maintains a registry with the string name of the operator as the key and the operator interface function pointer of the adaptation layer as the value. The frontend is used to dynamically load the operator library of the backend and query the registry using the string name of the operator to be called on the frontend. Here, the operator to be called belongs to the target operator library of the target chip, and the target chip is the AI ​​chip connected to the adaptation layer.

[0035] Optionally, the specific way to query the registry using the string name of the operator to be called from the front end can be that the front end uses the dlsym technology to query the registry by the string name of the operator to be called, and then queries the registry for the interface function pointer corresponding to the string name of the operator to be called. Here, dlsym is a function used to find symbols in dynamic link libraries. Dynamic link libraries refer to .cpp dynamic libraries, which contain functions and data that can be dynamically loaded and linked by the program.

[0036] Optionally, the interface form used by the operator interface function of the adaptation layer shall be a specified interface form, wherein the specified interface form is: operator name(std::vector&input, std::vector&output), where std::vector is a container class used to store integer sequences.

[0037] It should be noted that std::vector is a standard library container in C++ that can support an indefinite number of parameters. Therefore, by using the specified interface form for all operator interface functions in the adaptation layer, the number and type of parameters can be standardized, thereby improving the convenience of subsequent operator calls.

[0038] For example, UTensor can be used to unify the interface form of operator interface functions. Here, UTensor is a defined data structure that can accept parameters of different types. UTensor achieves the purpose of handling various data types and data values ​​by encapsulating UValue and UType. UValue is a union that defines the values ​​of various types, with a maximum of 64 bytes. UType is a data encapsulation that defines the type of each data value. When initializing UTensor, only UValue and UType need to be passed in.

[0039] Here is a specific example:

[0040] enum UType{

[0041] UTYPE_INT = 1,

[0042] UTYPE_FLOAT = 2, ...

[0044] UTYPE_DLTENSORHANDLE = 5,

[0045] ...};

[0046] union UValue{

[0047] int32_t v_int32_;

[0048] DLTensor*p_dl_;};

[0049] struct UTensor{

[0050] UTensor(UType t, UValue v): m_type_(t), m_value_(v), bInit_(true){}

[0051] }

[0052] Step S204: If the operator interface function pointer of the operator to be called is found, the operator interface function of the operator to be called in the adaptation layer is called using the operator interface function pointer of the operator to be called, so as to call the operator function of the operator to be called in the target operator library.

[0053] An interface function pointer is a pointer to an interface function, specifically a pointer to the memory address of a specific interface function. Interface function pointers are used to dynamically invoke interface functions, which in turn invoke operator functions in the chip's operator library. When the operator interface function pointer of the operator to be invoked is found, it is used to call the operator interface function of the operator to be invoked in the adaptation layer. This allows the call to the operator function of the operator to be invoked in the target operator library. In this embodiment, the front-end uses the string name of the operator to invoke to call the operator function of the target chip's target operator library. For the same chip, the same adaptation layer can be used when connecting to different frameworks, effectively increasing the adapt layer's versatility and making it applicable to different frameworks.

[0054] The embodiments provided in this application provide a deep learning framework, which is a framework for artificial intelligence models. The deep learning framework includes a front-end, a back-end, and an adaptation layer. The adaptation layer is located within the front-end, back-end, or independent of both. The adaptation layer encapsulates operators from operator libraries of different chips to obtain corresponding operator interface function pointers. The encapsulated operators in the adaptation layer are used to implement the neural network layers of the artificial intelligence model. The back-end maintains a registry with the string name of the operator as the key and the operator interface function pointer of the adaptation layer as the value. The front-end dynamically loads the operator library of the back-end. The method includes: querying the registry using the string name of the operator to be called from the front-end, wherein the operator to be called belongs to the target operator library of the target chip; and, if the operator interface function pointer of the operator to be called is found, calling the operator interface function of the operator to be called in the adaptation layer using the operator interface function pointer of the operator to be called, thereby calling the operator function of the operator to be called in the target operator library. This solves the problem of low adaptability of the operator calling method in related technologies and improves the versatility of the adaptation layer.

[0055] As an optional approach, before querying the registry using the string name of the operator to be invoked on the front end, the method also includes:

[0056] S11, when the operator library of the backend is dynamically loaded by the frontend, the backend registers the plugin function by calling the backend using the string corresponding to the backend's register plugin function, so that the registry is initialized by the backend's register plugin function. The initialized registry is filled with key-value pairs with the string name of the operator as the key and the operator interface function pointer of the adaptation layer as the value.

[0057] When the operator library of the backend is dynamically loaded by the frontend, the frontend calls the backend's registration plugin function by using the string corresponding to the registration plugin function of the backend. Here, the registration plugin function refers to the process of associating and installing the plugin with a specific software or system. The frontend can load the backend's cpp dynamic library and use the cpp's dlsym technology to call the backend's registration plugin function by using the string corresponding to the registration plugin function, so that the registry is initialized by the backend's registration plugin function. Optionally, the registration plugin function is the RegisterPlugin function.

[0058] It should be noted that the key-value pairs filled in the initialized registry, with the string name of the operator as the keyword and the operator interface function pointer of the adaptation layer as the value, are related data preset by the backend.

[0059] For example, see Figure 4 , Figure 4 This is a flowchart illustrating the operator invocation method of another optional deep learning framework. Figure 4The method steps described are the operator registration methods before operator invocation. The operator registration method can include the following four steps:

[0060] Define a general API interface for the adapter layer; that is, all operator interface functions of the adapter layer shall adopt the specified interface form. Here, the adapter layer refers to the adaptation layer.

[0061] The backend maintains a key-value structure to store the API interfaces of the backend adapter; that is, the backend maintains a registry with the string name of the operator as the key and the pointer of the operator interface function of the adapter layer as the value.

[0062] The backend provides an operator registration interface for registering operators. Here, the operator registration interface refers to the interface used to register custom operators (i.e., custom functions or operations) to the deep learning framework. Through this interface, operators can be registered into the deep learning framework so that they can be recognized and called by the framework.

[0063] The front-end dynamically loads the back-end C++ dynamic library and calls the back-end operator registration interface to register operators; that is, the front-end can load the back-end C++ dynamic library and use the C++'s dlsym technology to call the back-end's registration plugin function with the string corresponding to the registration plugin function, so that the back-end's registration plugin function initializes the registry.

[0064] It should be noted that in this embodiment, the registry is initialized, that is, the map is initialized. Here, map refers to a data structure used to store the mapping relationship between key-value pairs.

[0065] The embodiments provided in this application demonstrate that by registering operators using a registration plugin function, the registry can be initialized, thereby improving the accuracy of operator calling methods in deep learning frameworks.

[0066] As an optional approach, after querying the registry using the string name of the operator to be invoked from the front end, the method also includes:

[0067] S21. If no operator interface function pointer for the operator to be called is found, and a reference operator exists in the backend operator library whose string name is similar to the string name of the operator to be called and meets the preset conditions, a construction operation is performed on the operator to be called based on the reference operator to obtain the constructed operator to be called. The preset conditions are that the string name is most similar to the string name of the operator to be called, and the similarity between the string name and the string name of the operator to be called is greater than or equal to the preset similarity threshold.

[0068] If no operator interface function pointer for the operator to be called is found, and a reference operator exists in the backend operator library whose string name has a similarity to the string name of the operator to be called that meets the preset conditions, it means that the string name of the operator to be called does not exist in the backend registry. Since a reference operator exists in the backend operator library whose string name has a similarity to the string name of the operator to be called that meets the preset conditions, a construction operation can be performed on the operator to be called based on the reference operator to obtain the constructed operator to be called. That is, a new operator is created based on the reference operator to obtain the constructed operator to be called. The constructed operator to be called is used to respond to the query from the frontend and outputs the interface function pointer of the constructed operator to be called.

[0069] Optionally, if the operator interface function pointer of the operator to be called is not found, and there is no reference operator in the backend operator library whose string name is similar to the string name of the operator to be called and meets the preset conditions, the deep learning framework outputs an exception message. The exception message is used to indicate that the string name of the operator to be called does not exist in the backend registry.

[0070] Since the string names of operators with similar functions have a high degree of similarity, reference operators can be selected based on the similarity between the string names of the operators. In this embodiment, the preset condition is that the string name has the highest similarity with the string name of the operator to be called, and the similarity between the string name and the string name of the operator to be called is greater than or equal to a preset similarity threshold. By filtering based on the preset conditions in this embodiment, the reference operator with the highest similarity to the operator to be called can be obtained.

[0071] Through the embodiments provided in this application, when no operator interface function pointer to the operator to be called is found, reference operators are selected based on preset conditions, and the constructed operator to be called is obtained based on the reference operators. This can effectively improve the fault tolerance of the operator calling method of the deep learning framework.

[0072] As an optional approach, before querying the registry using the string name of the operator to be invoked on the front end, the method also includes:

[0073] S31, obtain the operator configuration file corresponding to the operator to be generated, wherein the operator to be generated is the operator whose corresponding operator interface function is to be generated in the adaptation layer, and the operator configuration file corresponding to the operator to be generated records the rule information of a set of specified rules corresponding to the operator to be generated, wherein the specified rule in the set of specified rules corresponds to the rule class in the rule library, and the rule class in the rule library is a preset code string used to implement at least part of the operator;

[0074] S32, the rule engine performs the generation operation of the operator interface function of the operator to be called based on the operator configuration file corresponding to the operator to be generated, and obtains the operator interface function corresponding to the operator to be generated. The rule engine is an engine used to process the rule classes in the rule base, and the operator interface function corresponding to the operator to be generated is generated based on the code string of the rule class corresponding to the specified rule in a set of specified rules.

[0075] For the same deep learning framework, the adaptation layer needs to be updated when a new chip is connected. Different chips have a set of corresponding operator interfaces. In related technologies, during the adaptation layer update process, staff often manually modify and debug the code, which is prone to errors and wastes a lot of time.

[0076] In this implementation, before querying the registry using the string name of the operator to be called from the front end, the operator configuration file corresponding to the operator to be generated is obtained. The operator to be generated is the operator whose corresponding operator interface function is to be generated in the adaptation layer. The operator configuration file corresponding to the operator to be generated records the rule information of a set of specified rules corresponding to the operator to be generated. Specifically, the rule information of a set of specified rules may include the number of interface parameters of the operator, the position of the parameters, and the format parsed by the operator, etc. The specified rules in the set of specified rules correspond to the rule classes in the rule library. Here, the rule classes in the rule library are preset code strings used to implement at least part of the operator. The rule classes in the rule library are manually defined.

[0077] See Figure 5 , Figure 5 This is a schematic diagram of another optional deep learning framework according to an embodiment of this application, by... Figure 5 As can be seen, before querying the registry using the string name of the operator to be called from the front end, the adaptation layer also needs to generate operator interface functions through the rule parsing engine. The rule configuration file refers to the operator configuration file, the Device API refers to the chip operator library, and the rule library refers to the library that stores and manages rule classes.

[0078] Optionally, the rules can be categorized and organized into general rules and specific rules. For example, the following are the rules for the activation operator:

[0079]

[0080] The rule engine generates the operator interface function corresponding to the operator to be called based on the operator configuration file corresponding to the operator to be generated. The rule engine is used to process the rule classes in the rule base. The operator interface function corresponding to the operator to be generated is generated based on the code string of the rule class corresponding to the specified rule in a set of specified rules.

[0081] For example, rule information can be represented in YAML (Yarn Aint Markup Language) format, and Python can be used to parse the rules and generate C++ code, that is, to generate operator interface functions corresponding to the operators to be generated. For example, the following is an example of generating C++ code based on input rules:

[0082]

[0083] The resulting C++ code, after being parsed by the rules engine, is as follows:

[0084] DLTensor*x = (*input[0]);

[0085] TensorDescriptor x_desc(x);

[0086] In the code above, the rule engine automatically generates a line of cpp code based on the input rule: DLTensor*x=(*input[0]); where x corresponds to the name of the input rule, DLTensor* corresponds to the type of the input rule, etc. The cpp code obtained here is the operator interface function.

[0087] The embodiments provided in this application enable the automatic generation of operator interface functions corresponding to the operators to be generated, avoiding manual writing and improving the efficiency of operator calling methods in deep learning frameworks.

[0088] As an optional approach, the rule engine performs an operation to generate the operator interface function corresponding to the operator to be generated, based on the operator configuration file corresponding to the operator to be generated. This generates the operator interface function corresponding to the operator to be generated, including:

[0089] S41, the rule information of a set of specified rules in the operator configuration file corresponding to the operator to be generated is converted into a set of target key-value pairs by the rule engine. The target key-value pairs in the set of target key-value pairs are key-value pairs with rule identifier as key and rule information as value. The rule information recorded in the operator configuration file corresponding to the operator to be generated includes at least one of the following: name, type, value.

[0090] S42, define a string through the rule engine, and write the header file and namespace name into the defined string to obtain the operator code string. The operator code string is a string used to store the function code of the operator interface function corresponding to the operator to be generated.

[0091] S43, a set of target key-value pairs are passed as parameters to the operator parsing body function through the rule engine. The operator parsing body function generates the function body of the operator to be generated by calling the rule class corresponding to the set of specified rules. The operator parsing body function is the parsing body function used to generate the function body of the operator. The code string of the rule class in the rule base contains the corresponding rule parameters. The rule information in the set of target key-value pairs is used to replace the rule parameters in the code string of the corresponding rule class. The function body of the generated operator to be generated is written into the operator code string.

[0092] S44: The rule engine prints a specified character on the operator code string containing the function body of the operator to be generated, thereby wrapping the function body of the operator to be generated and obtaining the operator interface function corresponding to the operator to be generated. The specified character is the end character of the interface operator function.

[0093] For example, see Figure 6 , Figure 6 This is a flowchart illustrating an alternative operator invocation method for a deep learning framework according to an embodiment of this application. Figure 6 As shown, Figure 6 Includes the following steps:

[0094] Parsing the yml file into a key-value dictionary corresponds to step S41. Here, the configuration file is represented in yml format, and the rule engine converts the yml file into a Python dictionary, i.e., a key-value pair. For example, ...

[0095] input:

[0096] name:x

[0097] type: DLTensor*

[0098] Transform into

[0099] {"input": {"name": x, "type": DLTensor}}

[0100] The rule engine defines a string called "content" and writes the header file and namespace name into it. This corresponds to step S42. The rule engine defines a string and writes the header file and namespace name into the defined string to obtain the operator code string. The operator code string is used to store the function code of the operator interface function corresponding to the operator to be generated. Here, the namespace name corresponds to the namespace name.

[0101] The system calls the specific rule class based on the rule name and assigns the parameter corresponding to the rule name to the rule class. It checks whether the parameter contains the rule name. If it does, it executes the rule class and generates the main body of the code. Corresponding to step S43, the system passes a set of target key-value pairs as parameters to the operator parsing function through the rule engine. The operator parsing function then generates the function body of the operator to be generated by calling the rule class corresponding to a set of specified rules.

[0102] For example, the rule engine calls the `parse_body` function, which takes a set of key-value pairs as parameters to generate the operator's function body. `parse_body` then calls the specific rule class based on the rule name to generate the corresponding code, such as `{"input": {"name": x, "type": DLTensor}}`. This calls the `Input` class, taking `name` and `type` as parameters. The `Input` class uses the `name` and `type` parameters to generate the corresponding string of the cpp code and writes the string to `content`.

[0103] Print the other half of the curly braces to complete the wrapping of the entire function body. Corresponding to step S44, the rule engine prints the specified characters in the operator code string of the function body to be generated, so as to complete the wrapping of the function body to be generated and obtain the operator interface function corresponding to the operator to be generated.

[0104] Alternatively, for new hardware, you only need to add or modify your own rules. For example, the configuration file for the tanh operator is as follows:

[0105]

[0106] Generating different operator code simply requires executing "generate.py tanh.yml hardware_name", such as "generate.py tanh.yml cnnl". The generated code is as follows:

[0107]

[0108]

[0109] To adapt the tanh operator to different hardware, you only need to modify the input parameters of generate.py, such as changing cnnl to cuda, to generate the operator for the specific hardware.

[0110]

[0111] The embodiments provided in this application can improve the accuracy of the operator interface function corresponding to the operator to be generated.

[0112] As an alternative approach, after passing a set of target key-value pairs as parameters to the operator parsing body function through the rule engine, the method also includes:

[0113] S51, the operator parsing function sequentially uses the target key-value pairs from the input set of target key-value pairs as the current target key-value pairs to perform the following rule class call operation to generate the function body of the operator to be generated. Here, the key of the current target key-value pair is the rule identifier of the currently specified rule, the rule class corresponding to the currently specified rule is the current rule class, and the value of the current target key-value pair is the current rule information:

[0114] Based on the rule identifier of the currently specified rule, the current rule information is used as input parameters to call the current rule class through the operator parsing body function, so as to replace the specified identifier in the current rule class with the current rule information and obtain the code string corresponding to the currently specified rule. The function body of the operator to be generated includes the code string corresponding to the currently specified rule.

[0115] See Figure 7 , Figure 7 This is a flowchart illustrating an alternative operator invocation method for a deep learning framework according to an embodiment of this application. Figure 7 As shown, Figure 7 Includes the following steps:

[0116] The rule class first assigns the parameters in the dictionary to the parameters of its own class. That is, based on the rule identifier of the currently specified rule, the current rule information is called as input parameters through the operator parsing body function. According to the implementation of the specified rule, the parameters are filled into the rule string and the rule string is written into the content. That is, the specified identifier in the current rule class is replaced with the current rule information to obtain the code string corresponding to the currently specified rule. Here, the function body of the operator to be generated includes the code string corresponding to the currently specified rule.

[0117] The embodiments provided in this application describe a process for generating code strings based on rule identifiers of currently specified rules, thereby improving the practicality of operator invocation methods in deep learning frameworks.

[0118] As an optional approach, before calling the current rule class with the current rule information as input parameters through the operator parsing body function based on the rule identifier of the currently specified rule, the method also includes:

[0119] S61, if the current rule information contains associated rule information, convert the associated rule information into associated key-value pairs, wherein the associated key-value pairs are key-value pairs with the rule identifier of the associated rule as the key and the rule information of the associated rule as the value;

[0120] S62, the association key-value pair is passed as a parameter to the operator parsing body function through the rule engine, so that the operator parsing body function can generate the code string corresponding to the association rule by calling the rule class corresponding to the association rule;

[0121] S63, replace the associated rule information in the current rule information with the code string corresponding to the associated rule to obtain the updated current rule information.

[0122] It should be noted that the corresponding code string refers to the code string after the parameters have been replaced.

[0123] For example, if the dictionary corresponding to the rule also contains the rule name, such as

[0124] {"variable": {"name": x, "type": DLTensor, "value": {variable": {"name": x, "type": DLTensor}}}

[0125] At this point, the rule engine can call parse_body again to parse and write the string corresponding to the cpp code into content. That is, it replaces the associated rule information in the current rule information with the code string corresponding to the associated rule to obtain the updated current rule information.

[0126] Through the embodiments provided in this application, when the current rule information contains associated rule information, the accuracy of the obtained current rule information can be improved by replacing the associated rule information in the current rule information with the code string corresponding to the associated rule.

[0127] It should be noted that, for the sake of simplicity, the foregoing method embodiments are all described as a series of actions. However, those skilled in the art should understand that this application is not limited to the described order of actions, as some steps may be performed in other orders or simultaneously according to this application. Furthermore, those skilled in the art should also understand that the embodiments described in the specification are preferred embodiments, and the actions and modules involved are not necessarily essential to this application.

[0128] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods according to the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM (Read-Only Memory) / RAM (Random Access Memory), magnetic disk, optical disk), and includes several instructions to cause a terminal device (which may be a mobile phone, computer, server, or network device, etc.) to execute the methods described in the various embodiments of this application.

[0129] According to another aspect of the embodiments of this application, an operator invocation apparatus for a deep learning framework is also provided. This apparatus is used to implement the operator invocation method for the deep learning framework provided in the above embodiments, and will not be repeated hereafter. As used below, the term "module" can be a combination of software and / or hardware that implements a predetermined function. Although the apparatus described in the following embodiments is preferably implemented in software, hardware implementation, or a combination of software and hardware, is also possible and contemplated.

[0130] A deep learning framework is a framework for artificial intelligence models. A deep learning framework includes a front-end, a back-end, and an adaptation layer. The adaptation layer is located in the front-end, back-end, or independent of the front-end and back-end. The adaptation layer is used to encapsulate operators in the operator libraries of different chips to obtain the corresponding operator interface function pointers. The operators encapsulated by the adaptation layer are used to implement the neural network layers of the artificial intelligence model. The back-end maintains a registry with the string name of the operator as the key and the operator interface function pointer of the adaptation layer as the value. The front-end is used to dynamically load the operator library of the back-end.

[0131] The device includes:

[0132] The query unit is used to query the registry using the string name of the operator to be invoked from the front end, wherein the operator to be invoked belongs to the target operator library of the target chip;

[0133] The calling unit is used to call the operator interface function of the operator to be called in the adaptation layer when the operator interface function pointer of the operator to be called is found, so as to call the operator function of the operator to be called in the target operator library.

[0134] The embodiments provided in this application provide a deep learning framework, which is a framework for artificial intelligence models. The deep learning framework includes a front-end, a back-end, and an adaptation layer. The adaptation layer is located within the front-end, back-end, or independent of both. The adaptation layer encapsulates operators from operator libraries of different chips to obtain corresponding operator interface function pointers. The encapsulated operators in the adaptation layer are used to implement the neural network layers of the artificial intelligence model. The back-end maintains a registry with the string name of the operator as the key and the operator interface function pointer of the adaptation layer as the value. The front-end dynamically loads the operator library of the back-end. The method includes: querying the registry using the string name of the operator to be called from the front-end, wherein the operator to be called belongs to the target operator library of the target chip; and, if the operator interface function pointer of the operator to be called is found, calling the operator interface function of the operator to be called in the adaptation layer using the operator interface function pointer of the operator to be called, thereby calling the operator function of the operator to be called in the target operator library. This solves the problem of low adaptability of the operator calling method in related technologies and improves the versatility of the adaptation layer.

[0135] As an optional solution, the above-mentioned device further includes:

[0136] The initialization unit is used to query the registry before using the string name of the operator to be called from the front end. In the case of dynamically loading the operator library from the front end, the front end calls the registration plugin function of the back end using the string corresponding to the registration plugin function of the back end, so that the registration plugin function of the back end initializes the registry. The initialized registry is filled with key-value pairs with the string name of the operator as the key and the operator interface function pointer of the adaptation layer as the value.

[0137] As an optional solution, the above-mentioned device further includes:

[0138] The construction unit is used to perform a construction operation on the operator to be called based on the reference operator after querying the registry using the string name of the operator to be called from the front end. If no operator interface function pointer of the operator to be called is found, and there is a reference operator in the back end operator library whose string name has a similarity to the string name of the operator to be called that meets the preset conditions, the construction unit obtains the constructed operator to be called. The preset conditions are that the string name has the highest similarity to the string name of the operator to be called, and the similarity between the string name and the string name of the operator to be called is greater than or equal to a preset similarity threshold.

[0139] As an optional solution, the above-mentioned device further includes:

[0140] The acquisition unit is used to obtain the operator configuration file corresponding to the operator to be generated before querying the registry using the string name of the operator to be called from the front end. The operator to be generated is the operator whose corresponding operator interface function is to be generated in the adaptation layer. The operator configuration file corresponding to the operator to be generated records the rule information of a set of specified rules corresponding to the operator to be generated. The specified rule in the set of specified rules corresponds to the rule class in the rule library. The rule class in the rule library is a preset code string used to implement at least part of the operator.

[0141] The generation unit is used to generate the operator interface function corresponding to the operator to be called by the rule engine based on the operator configuration file corresponding to the operator to be generated. The rule engine is an engine used to process rule classes in the rule base, and the operator interface function corresponding to the operator to be generated is generated based on the code string of the rule class corresponding to the specified rule in a set of specified rules.

[0142] As an optional approach, the generation unit includes:

[0143] The first conversion module is used to convert the rule information of a set of specified rules in the operator configuration file corresponding to the operator to be generated into a set of target key-value pairs through the rule engine. The target key-value pairs in the set of target key-value pairs are key-value pairs with rule identifier as key and rule information as value. The rule information recorded in the operator configuration file corresponding to the operator to be generated includes at least one of the following: name, type, and value.

[0144] The first execution module is used to define a string through the rule engine and write the header file and namespace name into the defined string to obtain the operator code string. The operator code string is a string used to store the function code of the operator interface function corresponding to the operator to be generated.

[0145] The first input module is used to pass a set of target key-value pairs as parameters to the operator parsing body function through the rule engine. The operator parsing body function generates the function body of the operator to be generated by calling the rule class corresponding to the set of specified rules. The operator parsing body function is the parsing body function used to generate the function body of the operator. The code string of the rule class in the rule base contains the corresponding rule parameters. The rule information in the set of target key-value pairs is used to replace the rule parameters in the code string of the corresponding rule class. The function body of the generated operator to be generated is written into the operator code string.

[0146] The printing module is used by the rule engine to print a specified character on the operator code string containing the function body of the operator to be generated, so as to complete the wrapping of the function body of the operator to be generated and obtain the operator interface function corresponding to the operator to be generated. The specified character is the end character of the interface operator function.

[0147] As an optional approach, the generation unit also includes:

[0148] The second execution module, after passing a set of target key-value pairs as parameters to the operator parsing function via the rule engine, uses the operator parsing function to sequentially execute the following rule class call operations on the target key-value pairs from the passed set of target key-value pairs as the current target key-value pairs, in order to generate the function body of the operator to be generated. Here, the key of the current target key-value pair is the rule identifier of the currently specified rule, the rule class corresponding to the currently specified rule is the current rule class, and the value of the current target key-value pair is the current rule information:

[0149] Based on the rule identifier of the currently specified rule, the current rule information is used as input parameters to call the current rule class through the operator parsing body function, so as to replace the specified identifier in the current rule class with the current rule information and obtain the code string corresponding to the currently specified rule. The function body of the operator to be generated includes the code string corresponding to the currently specified rule.

[0150] As an optional approach, the generation unit also includes:

[0151] The second conversion module is used to convert associated rule information into associated key-value pairs when the current rule information contains associated rule information, before calling the current rule class with the current rule information as input parameter through the operator parsing body function based on the rule identifier of the currently specified rule. The associated key-value pairs are key-value pairs with the rule identifier of the associated rule as the key and the rule information of the associated rule as the value.

[0152] The second input module is used to pass the associated key-value pairs as parameters to the operator parsing body function through the rule engine, so that the operator parsing body function can generate the code string corresponding to the associated rule by calling the rule class corresponding to the associated rule;

[0153] The replacement module is used to replace the associated rule information in the current rule information with the code string corresponding to the associated rule, so as to obtain the updated current rule information.

[0154] As an optional approach, the operator interface functions of the adaptation layer all adopt a specified interface form, which is: operator name(std::vector&input, std::vector&output), where std::vector is a container class used to store integer sequences.

[0155] According to another aspect of the embodiments of this application, a computer-readable storage medium is also provided, the computer-readable storage medium including a stored program, wherein the program executes the steps in any of the above method embodiments when it is run.

[0156] In one exemplary embodiment, the aforementioned computer-readable storage medium may include, but is not limited to, various media capable of storing computer programs, such as a USB flash drive, read-only memory (ROM), random access memory (RAM), portable hard disk, magnetic disk, or optical disk.

[0157] According to another aspect of the embodiments of this application, an electronic device is also provided, including a memory and a processor, wherein the memory stores a computer program and the processor is configured to perform the steps of any of the above method embodiments through the computer program.

[0158] In one exemplary embodiment, the electronic device may further include a transmission device and an input / output device, wherein the transmission device is connected to the processor and the input / output device is connected to the processor.

[0159] Specific examples in this embodiment can be found in the examples described in the above embodiments and exemplary implementations, and will not be repeated here.

[0160] According to another aspect of the embodiments of this application, a computer program product is provided, the computer program product including a computer program / instructions comprising program code for performing the method shown in the flowchart. In such an embodiment, reference is made to... Figure 8 The computer program can be downloaded and installed from a network via the communication section 809, and / or installed from the removable medium 811. When the computer program is executed by the central processing unit 801, it performs various functions provided in the embodiments of this application. The sequence numbers of the embodiments of this application above are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.

[0161] refer to Figure 8 , Figure 8 This is a structural block diagram of a computer system for an optional electronic device according to an embodiment of this application.

[0162] Figure 8 A schematic block diagram of a computer system architecture for implementing embodiments of the present application is shown. Figure 8As shown, the computer system 800 includes a central processing unit (CPU) 801, which can perform various appropriate actions and processes based on programs stored in read-only memory (ROM) 802 or programs loaded from storage section 808 into random access memory (RAM). The random access memory 803 also stores various programs and data required for system operation. The CPU 801, ROM 802, and RAM 803 are interconnected via a bus 804. An input / output interface 805 (I / O interface) is also connected to the bus 804.

[0163] The following components are connected to the input / output interface 805: an input section 806 including a keyboard, mouse, etc.; an output section 807 including a cathode ray tube (CRT), liquid crystal display (LCD), etc., and speakers, etc.; a storage section 808 including a hard disk, etc.; and a communication section 809 including a network interface card such as a local area network card, modem, etc. The communication section 809 performs communication processing via a network such as the Internet. A drive 810 is also connected to the input / output interface 805 as needed. A removable medium 811, such as a disk, optical disk, magneto-optical disk, semiconductor memory, etc., is installed on the drive 810 as needed so that computer programs read from it can be installed into the storage section 808 as needed.

[0164] Specifically, according to embodiments of this application, the processes described in the various method flowcharts can be implemented as computer software programs. For example, embodiments of this application include a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via communication section 809, and / or installed from removable medium 811. When the computer program is executed by central processing unit 801, it performs various functions defined in the system of this application.

[0165] It should be noted that, Figure 8 The computer system 800 of the electronic device shown is merely an example and should not impose any limitation on the functionality and scope of use of the embodiments of this application.

[0166] Obviously, those skilled in the art should understand that the modules or steps of the embodiments of this application described above can be implemented using general-purpose computing devices. They can be centralized on a single computing device or distributed across a network of multiple computing devices. They can be implemented using computer-executable program code, and thus can be stored in a storage device for execution by a computing device. In some cases, the steps shown or described can be performed in a different order than those presented here, or they can be fabricated as separate integrated circuit modules, or multiple modules or steps can be fabricated as a single integrated circuit module. Thus, the embodiments of this application are not limited to any particular combination of hardware and software.

[0167] The above are merely preferred embodiments of this application and are not intended to limit the embodiments of this application. For those skilled in the art, various modifications and variations can be made to the embodiments of this application. Any modifications, equivalent substitutions, improvements, etc., made within the principles of the embodiments of this application should be included within the protection scope of the embodiments of this application.

Claims

1. A method for invoking operators in a deep learning framework, characterized in that, The deep learning framework is a framework for artificial intelligence models. The deep learning framework includes a front-end, a back-end, and an adaptation layer. The adaptation layer is located in the front-end, the back-end, or independent of the front-end and the back-end. The adaptation layer is used to encapsulate operators in the operator libraries of different chips to obtain corresponding operator interface function pointers. The operators encapsulated by the adaptation layer are used to implement the neural network layer of the artificial intelligence model. The back-end maintains a registry with the string name of the operator as the key and the operator interface function pointer of the adaptation layer as the value. The front-end is used to dynamically load the operator library of the back-end. The method includes: The registry is queried using the string name of the operator to be invoked from the front end, wherein the operator to be invoked belongs to the target operator library of the target chip; If the pointer to the operator interface function of the operator to be invoked is found, the pointer to the operator interface function of the operator to be invoked in the adaptation layer is used to invoke the operator interface function of the operator to be invoked in the target operator library.

2. The method according to claim 1, characterized in that, Before querying the registry using the string name of the operator to be invoked using the front end, the method further includes: When the operator library of the backend is dynamically loaded through the frontend, the frontend calls the registration plugin function of the backend using a string corresponding to the registration plugin function of the backend, so that the registration plugin function of the backend initializes the registry. The initialized registry is filled with key-value pairs with the string name of the operator as the keyword and the operator interface function pointer of the adaptation layer as the value.

3. The method according to claim 1, characterized in that, After querying the registry using the string name of the operator to be invoked using the front end, the method further includes: If no operator interface function pointer for the operator to be called is found, and a reference operator exists in the backend operator library whose string name has a similarity to the string name of the operator to be called that satisfies a preset condition, a construction operation is performed on the operator to be called based on the reference operator to obtain the constructed operator to be called. The preset condition is that the string name has the highest similarity to the string name of the operator to be called, and the similarity between the string name and the string name of the operator to be called is greater than or equal to a preset similarity threshold.

4. The method according to claim 1, characterized in that, Before querying the registry using the string name of the operator to be invoked using the front end, the method further includes: Obtain the operator configuration file corresponding to the operator to be generated, wherein the operator to be generated is the operator whose corresponding operator interface function is to be generated in the adaptation layer, and the operator configuration file corresponding to the operator to be generated records rule information of a set of specified rules corresponding to the operator to be generated, wherein the specified rules in the set of specified rules correspond to the rule classes in the rule library, and the rule classes in the rule library are preset code strings used to implement at least part of the operator; The rule engine performs an operator interface function generation operation on the operator to be called based on the operator configuration file corresponding to the operator to be generated, thereby obtaining the operator interface function corresponding to the operator to be generated. The rule engine is an engine used to process rule classes in the rule library, and the operator interface function corresponding to the operator to be generated is generated based on the code string of the rule class corresponding to the specified rule in the set of specified rules.

5. The method according to claim 4, characterized in that, The step of generating operator interface functions for the operator to be called by the rule engine based on the operator configuration file corresponding to the operator to be generated, thereby obtaining the operator interface functions corresponding to the operator to be generated, includes: The rule engine converts the rule information of a set of specified rules in the operator configuration file corresponding to the operator to be generated into a set of target key-value pairs. The target key-value pairs in the set of target key-value pairs are key-value pairs with rule identifier as the key and rule information as the value. The rule information recorded in the operator configuration file corresponding to the operator to be generated includes at least one of the following: name, type, and value. The rule engine defines a string and writes the header file and namespace name into the defined string to obtain the operator code string. The operator code string is a string used to store the function code of the operator interface function corresponding to the operator to be generated. The rule engine passes the set of target key-value pairs as parameters to the operator parsing function, which then generates the function body of the operator to be generated by calling the rule class corresponding to the set of specified rules. The operator parsing function is a parsing function used to generate the function body of the operator. The code string of the rule class in the rule library contains the corresponding rule parameters. The rule information in the set of target key-value pairs is used to replace the rule parameters in the code string of the corresponding rule class. The function body of the generated operator to be generated is written into the operator code string. The rule engine prints a specified character into the operator code string containing the function body of the operator to be generated, thereby wrapping the function body of the operator to be generated and obtaining the operator interface function corresponding to the operator to be generated. The specified character is the end character of the interface operator function.

6. The method according to claim 5, characterized in that, After passing the set of target key-value pairs as parameters to the operator parsing body function through the rule engine, the method further includes: The operator parsing function takes the target key-value pairs from the input set of target key-value pairs as the current target key-value pairs and performs the following rule class invocation operation to generate the function body of the operator to be generated. Here, the key of the current target key-value pair is the rule identifier of the currently specified rule, the rule class corresponding to the currently specified rule is the current rule class, and the value of the current target key-value pair is the current rule information. Based on the rule identifier of the currently specified rule, the current rule information is used as an input parameter to call the current rule class through the operator parsing body function, so as to replace the specified identifier in the current rule class with the current rule information to obtain the code string corresponding to the currently specified rule. The function body of the operator to be generated includes the code string corresponding to the currently specified rule.

7. The method according to claim 6, characterized in that, Before calling the current rule class using the current rule information as input parameters through the operator parsing body function based on the rule identifier of the currently specified rule, the method further includes: If the current rule information contains associated rule information, the associated rule information is converted into associated key-value pairs, wherein the associated key-value pairs are key-value pairs with the rule identifier of the associated rule as the key and the rule information of the associated rule as the value; The rule engine passes the associated key-value pair as a parameter to the operator parsing function, which then generates the code string corresponding to the associated rule by calling the rule class corresponding to the associated rule. The current rule information is updated by replacing the associated rule information in the current rule information with the code string corresponding to the associated rule.

8. The method according to any one of claims 1 to 7, characterized in that, The operator interface functions of the adaptation layer all adopt a specified interface form, wherein the specified interface form is: operator name(std::vector&input, std::vector&output), where std::vector is a container class used to store integer sequences.

9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program, wherein the computer program, when executed by a processor, implements the steps of the method described in any one of claims 1 to 8.

10. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the steps of the method described in any one of claims 1 to 8.

Citation Information

Patent Citations

  • Deep learning framework operator registration method and device, equipment and storage medium

    CN113342346A

  • Apparatus and method for performing box queries in ray traversal hardware

    CN113470157A