Function registration method, device and storage medium

By encapsulating the original function into encapsulated functions and registering it into the deep learning framework, the problem of custom operator debugging complexity in the deep learning framework is solved, and efficient function debugging and code reuse is achieved, which is suitable for a variety of deep learning frameworks and heterogeneous computing platforms.

CN117785178BActive Publication Date: 2024-12-31MOORE THREADS TECHNOLOGY (SHANGHAI) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311869778.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-12-29
Publication Date
2024-12-31
Estimated Expiration
2043-12-29

AI Technical Summary

Technical Problem

The debugging process of custom operators and functional modules in the deep learning framework is complicated, and existing tools cannot effectively solve the problem of operator errors, especially because the operator library is located at the bottom layer and cannot obtain global information. The debugging tool is limited by the operator library. and the debugging capability of custom operators is insufficient.

Method used

By encapsulating the original function, generating the encapsulated function, and registering it to the registered location of the original function, the encapsulated function is used to call or debug the original function, improving the universality, reusability and scalability of the code, and simplifying the debugging process .

Benefits of technology

It reduces the difficulty and cost of function debugging, realizes debugging on the framework-operator granularity, supports a variety of deep learning frameworks and heterogeneous computing platforms, and improves code clarity and flexibility.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117785178B_ABST
    Figure CN117785178B_ABST
Patent Text Reader

Abstract

The present disclosure relates to the field of artificial intelligence technology, and in particular to a function registration method, device and storage medium. The method comprises: obtaining an original function to be registered, the original function comprising an operator and / or an implementation function of a functional module; encapsulating the original function to obtain an encapsulated function, the encapsulated function being used to call the original function or debug the original function; registering the encapsulated function to a target location, the target location being a registration location corresponding to the original function. The embodiment of the present disclosure improves code reusability and scalability by encapsulating the original function and then registering it. Since the encapsulated function obtained after encapsulation can be used to call the original function or debug the original function, when a problem occurs with the encapsulated function during the subsequent use of the function, the encapsulated function can call or debug the original function, which greatly reduces the difficulty of function debugging and can be more generally and widely used in various C++ implementation adaptation codes.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of artificial intelligence technology, and in particular to a function registration method, device and storage medium. Background Art

[0002] Deep learning frameworks usually allow developers and users to implement some new operators in the form of custom operators, or expand functional modules in a way supported by the framework, in addition to the operators that are already supported. These operators and modules are then registered with the framework, allowing models using this framework or higher-level frameworks to indirectly use these operators and modules.

[0003] These operators and modules may have errors, insufficient precision, low efficiency and other problems, which are usually only exposed when the deep learning model indirectly uses the operators and modules. Since these operators and modules have been compiled and registered into the framework at this time, the debugging process becomes extremely complicated. Summary of the invention

[0004] In view of this, the present disclosure proposes a function registration method, device and storage medium. The technical solution includes:

[0005] According to one aspect of the present disclosure, a function registration method is provided, the method comprising:

[0006] Obtaining a primitive function to be registered, wherein the primitive function includes an operator and / or an implementation function of a functional module;

[0007] Encapsulating the original function to obtain an encapsulated function, wherein the encapsulated function is used to call the original function or debug the original function;

[0008] Register the encapsulated function to a target location, where the target location is a registration location corresponding to the original function.

[0009] In a possible implementation, encapsulating the original function to obtain the encapsulated function includes:

[0010] Acquire encapsulation data, where the encapsulation data is used to indicate an encapsulation operation control component, where the operation control component is used to start or shut down a debugging logic;

[0011] According to the encapsulation data, the original function and the operation control component are encapsulated to obtain the encapsulation function.

[0012] In another possible implementation, the working mode of the operation control component includes a startup mode or a shutdown mode, the startup mode is used to instruct the encapsulation function to debug the original function, and the shutdown mode is used to instruct the encapsulation function to call the original function.

[0013] In another possible implementation, the encapsulation data is further used to indicate encapsulation of other components, and encapsulating the original function and the operation control component according to the encapsulation data to obtain the encapsulated function includes:

[0014] According to the encapsulation data, encapsulate the original function, the operation control component and the other components to obtain the encapsulation function;

[0015] Among them, other components include at least one of a debugging component, a timing logic component and a data calculation component, the debugging component is used to indicate the debugging function of the original function, the timing logic component is used to indicate the timing logic of the original function, and the data calculation component is used to be called by the debugging component to perform data calculation.

[0016] In another possible implementation, encapsulating the original function, the operation control component, and the other components to obtain the encapsulated function includes:

[0017] Create a package template function with the target package name;

[0018] Calling the operation control component, the other components and the original function in the encapsulation template function;

[0019] Acquire first input and output data of the original function in the encapsulation template function, input the first input and output data into the debugging component for processing to obtain second input and output data, and return the second input and output data to the original function to obtain the encapsulation function;

[0020] The encapsulated function includes the processed original function, the operation control component and the other components, and the processed original function includes the first input and output data and the second input and output data.

[0021] In another possible implementation, the encapsulation data is further used to indicate an encapsulation mode, and the encapsulation mode is used to indicate whether the encapsulation function covers the original function.

[0022] In another possible implementation, the encapsulation mode is further used to indicate the reuse of the encapsulation function, and the method further includes:

[0023] Register the wrapper function to a location other than the target location.

[0024] In another possible implementation, the function registration method is executed by a packaging module.

[0025] In another possible implementation, the resources required in the function registration method are managed by a global control module.

[0026] In another possible implementation, the debugging function of the debugging component includes: obtaining the target data of the original function, timing, analyzing the abnormal values ​​of the original function, counting the characteristic data and data summary of the specified data type, forcibly modifying the input parameters and output results of the original function, replacing the abnormal values, interrupting the running of the debugging component in advance, and outputting at least one of the problem analysis logs.

[0027] In another possible implementation, the sequential logic component is used to control the state of an automaton in a global control module, and the state of the automaton is used to instruct the global control module to perform file system management and / or log management.

[0028] According to another aspect of the present disclosure, a function registration device is provided, the device comprising:

[0029] An acquisition unit, used for acquiring a primitive function to be registered, wherein the primitive function includes an operator and / or an implementation function of a functional module;

[0030] An encapsulation unit, used for encapsulating the original function to obtain an encapsulation function, wherein the encapsulation function is used to call the original function or debug the original function;

[0031] A registration unit is used to register the encapsulated function to a target location, where the target location is a registration location corresponding to the original function.

[0032] In a possible implementation, the encapsulation unit is further used to:

[0033] Acquire encapsulation data, where the encapsulation data is used to indicate an encapsulation operation control component, where the operation control component is used to start or shut down a debugging logic;

[0034] According to the encapsulation data, the original function and the operation control component are encapsulated to obtain the encapsulation function.

[0035] In another possible implementation, the working mode of the operation control component includes a startup mode or a shutdown mode, the startup mode is used to instruct the encapsulation function to debug the original function, and the shutdown mode is used to instruct the encapsulation function to call the original function.

[0036] In another possible implementation, the encapsulation data is further used to indicate encapsulation of other components, and the encapsulation unit is further used to:

[0037] According to the encapsulation data, encapsulate the original function, the operation control component and the other components to obtain the encapsulation function;

[0038] Among them, other components include at least one of a debugging component, a timing logic component and a data calculation component, the debugging component is used to indicate the debugging function of the original function, the timing logic component is used to indicate the timing logic of the original function, and the data calculation component is used to be called by the debugging component to perform data calculation.

[0039] In another possible implementation, the encapsulation unit is further used for:

[0040] Create a package template function with the target package name;

[0041] Calling the operation control component, the other components and the original function in the encapsulation template function;

[0042] Acquire first input and output data of the original function in the encapsulation template function, input the first input and output data into the debugging component for processing to obtain second input and output data, and return the second input and output data to the original function to obtain the encapsulation function;

[0043] The encapsulated function includes the processed original function, the operation control component and the other components, and the processed original function includes the first input and output data and the second input and output data.

[0044] In another possible implementation, the encapsulation data is further used to indicate an encapsulation mode, and the encapsulation mode is used to indicate whether the encapsulation function covers the original function.

[0045] In another possible implementation manner, the encapsulation mode is further used to indicate multiplexing of the encapsulation function, and the apparatus further includes:

[0046] The alias registration unit is used to register the encapsulated function to other locations except the target location.

[0047] In another possible implementation, the function registration method is executed by a packaging module.

[0048] In another possible implementation, the resources required in the function registration method are managed by a global control module.

[0049] In another possible implementation, the debugging function of the debugging component includes: obtaining the target data of the original function, timing, analyzing the abnormal values ​​of the original function, counting the characteristic data and data summary of the specified data type, forcibly modifying the input parameters and output results of the original function, replacing the abnormal values, interrupting the running of the debugging component in advance, and outputting at least one of the problem analysis logs.

[0050] In another possible implementation, the sequential logic component is used to control the state of an automaton in a global control module, and the state of the automaton is used to instruct the global control module to perform file system management and / or log management.

[0051] According to another aspect of the present disclosure, a computing device is provided, the computing device comprising: a processor; a memory for storing processor-executable instructions;

[0052] Wherein, the processor is configured to:

[0053] Obtaining a primitive function to be registered, wherein the primitive function includes an operator and / or an implementation function of a functional module;

[0054] Encapsulating the original function to obtain an encapsulated function, wherein the encapsulated function is used to call the original function or debug the original function;

[0055] Register the encapsulated function to a target location, where the target location is a registration location corresponding to the original function.

[0056] According to another aspect of the present disclosure, a non-volatile computer-readable storage medium is provided, on which computer program instructions are stored, and the computer program instructions implement the above method when executed by a processor.

[0057] The disclosed embodiment obtains the original function to be registered, wherein the original function includes the implementation function of the operator and / or the functional module; encapsulates the original function to obtain the encapsulated function, wherein the encapsulated function is used to call the original function or debug the original function; and registers the encapsulated function to the registration position corresponding to the original function, thereby improving code reusability and scalability. When a problem occurs with the encapsulated function during the subsequent use of the function, the encapsulated function can call the original function or debug the original function, thereby greatly reducing the difficulty of function debugging. The method can be more generally and widely used in various C++ implementation adaptation codes. BRIEF DESCRIPTION OF THE DRAWINGS

[0058] The accompanying drawings, which are incorporated in and constitute a part of the specification, illustrate exemplary embodiments, features, and aspects of the disclosure and, together with the description, serve to explain the principles of the disclosure.

[0059] Figure 1 A schematic diagram of the structure of a computing device provided by an exemplary embodiment of the present disclosure is shown;

[0060] Figure 2 A flowchart of a function registration method provided by an exemplary embodiment of the present disclosure is shown;

[0061] Figure 3 A schematic diagram of the structure of a function registration system provided by an exemplary embodiment of the present disclosure is shown;

[0062] Figure 4 A schematic diagram showing a packaging module provided by an exemplary embodiment of the present disclosure is shown;

[0063] Figure 5 A schematic diagram showing a packaging module provided by an exemplary embodiment of the present disclosure is shown;

[0064] Figure 6 A schematic diagram showing a principle of a data computing component provided by an exemplary embodiment of the present disclosure is shown;

[0065] Figure 7 A schematic diagram showing a principle of a global control module provided by an exemplary embodiment of the present disclosure is shown;

[0066] Figure 8 A schematic diagram of the structure of a function registration device provided by another exemplary embodiment of the present disclosure is shown;

[0067] Fig. 9 It is a block diagram of a device according to an exemplary embodiment. DETAILED DESCRIPTION

[0068] Various exemplary embodiments, features and aspects of the present disclosure will be described in detail below with reference to the accompanying drawings. The same reference numerals in the accompanying drawings represent elements with the same or similar functions. Although various aspects of the embodiments are shown in the accompanying drawings, the drawings are not necessarily drawn to scale unless otherwise specified.

[0069] The word “exemplary” is used exclusively herein to mean “serving as an example, example, or illustration.” Any embodiment described herein as “exemplary” is not necessarily to be construed as preferred or advantageous over other embodiments.

[0070] In addition, in order to better illustrate the present disclosure, numerous specific details are given in the following specific embodiments. It should be understood by those skilled in the art that the present disclosure can also be implemented without certain specific details. In some examples, methods, means, components and circuits well known to those skilled in the art are not described in detail in order to highlight the subject matter of the present disclosure.

[0071] In related technologies, the debugging process usually includes the following processes: discovering problems during training or inference (this process takes a long time and is unstable due to random factors in the model); retraining or inferring the model until the model reproduces the error (this process usually takes hours or even days); retaining the scene of the model failure. Segment and slice the model to narrow the scope until it is simplified to a small fragment of several components - due to the granularity of the deep learning framework, this small fragment may not be able to be further divided at a still relatively complex granularity. Find the operators and modules involved in this fragment, and restore the input and output data from the scene of the model failure. Use these input and output data to reproduce the calculations and functions of the operators and components until one or more errors are located. Re-executing the retraining or inference model until the problem is solved.

[0072] In order to reduce the time and manpower investment in the above debugging process, deep learning frameworks and operator libraries provide some debugging methods for analyzing the above problems: One debugging method is that the PyTorch framework provides a Hook mechanism and a Profiler tool. The Profiler tool can list the operator list and running time within a given range. The Hook mechanism can give the input and output of a specified layer, and support modification and insertion functions. Another debugging method is to use the debugging tool of the operator library. For example, the operator library itself can provide tools such as Msight, which can accurately give information such as time at the granularity of operator calculation. Similarly, the input and output data of the operator can also be provided. Another debugging method is to insert a data processing structure before and after the interface of the operator runtime, use the central processing unit (CPU) or graphics processing unit (GPU) to recalculate, and compare with the operator's results. Operator data can be obtained and operator accuracy can be verified. This debugging solution relies on the distribution mechanism and code generation mechanism.

[0073] There are several problems with these current debugging methods: On the one hand, the operator library is located at a relatively low level of the entire computing system and cannot obtain global information, which has obvious limitations. The debugging tools provided by the operator library are limited by the perspective of the operator library itself and cannot obtain global information. The implementation logic of the operator library tool is based on its specific design, and its functions may be inconsistent with those of the framework layer design - for example, a calculation may be composed of operators from multiple operator libraries. In many cases, the granularity of the operator library tool cannot meet the debugging requirements - the granularity of the operator library is the specific operator kernel, which is too fine and difficult to analyze.

[0074] On the other hand, the tools of the deep learning framework are mainly based on their own functions and logic, and there are deficiencies in the maintenance and support of custom operators. This is because custom operators are unique and flexible according to their designers, and the framework layer cannot fully understand the situation and characteristics of all custom operators, so the debugging capabilities are limited. The above tools of the PyTorch framework are runtime debugging tools. This tool needs to be set up, implemented and configured on the user's front end, and is a temporary and targeted tool. The Profiler tool can only give time and list information, and cannot solve or locate operator error information. The Hook mechanism can accurately give the operator of a certain stage, but it requires the user to manually implement a Hook module at runtime, and needs to be familiar with the debugging of the PyTorch framework, and needs to determine the specific information of the operator. The Hook module implemented by the user can only perform specified operations on a specified operator or fragment, and cannot be universally applied to all scenarios. It requires the user to clearly understand the list of operators used in the model, and requires the user to manually ensure that no operator is missed during the debugging process. It is only applicable to specific models and specific scenarios. If there are multiple models that need to be debugged, the Hook module needs to be implemented and applied separately.

[0075] On the other hand, for custom operators that have no distribution concept or cannot change the distribution logic, the distribution control mechanism cannot be used to process them. For operators that do not use generated code and do not have batch-generated interfaces, the input and output interfaces of the operators cannot be controlled. For operators that directly use the framework registration mechanism, distribution mechanism, and encapsulation mechanism, their interfaces and forms must meet the overall interface specifications of the native framework (for example, the PyTorch framework), and their operator interface forms cannot be adjusted or changed. It is not universal for functional modules and is limited by the operator concept and distribution mechanism.

[0076] The embodiment of the present disclosure provides a function registration mechanism, which encapsulates the original function to obtain an encapsulated function, registers the encapsulated function to the registration position of the original function, and the encapsulated function is used to call the original function or debug the original function. On the one hand, the universality of the code is improved, and it can be more generally and widely used in various C++ implementation adaptation codes, so that the adaptation code can encapsulate the original function and register it with little or no modification; on the other hand, because the encapsulated function can be used to debug the original function, the computing device is allowed to implement the debugging function at the framework-operator granularity at a relatively low cost when running the network; on the other hand, the code reusability is improved, that is, by encapsulating the original function, it can be used in multiple places or models The same encapsulated function implementation avoids repeated function writing and can be reused in a variety of different deep learning frameworks or other software that uses C++ function interfaces to call operators and / or functional modules; on the other hand, the scalability is improved, that is, the introduction and maintenance process of new functions is greatly simplified, and only the original function needs to be encapsulated and registered, without the need to modify the core code of the deep learning framework; on the other hand, the code clarity is improved, that is, the encapsulated function obtained after encapsulation can be used to call or debug the original function, and its function and usage method are clearer, easy for developers to understand and use; on the other hand, it adapts to diversified platforms, that is, the function registration mechanism provided in the embodiment of the present disclosure can support the unified system architecture (Moore Threads Unified System Architecture, MUSA) and CPU heterogeneous platforms, and also supports different deep learning frameworks, and even other software and platforms that support CPU and GPU heterogeneous computing architectures.

[0077] First, the application scenarios involved in the present disclosure are introduced.

[0078] Please refer to Figure 1 , which shows a schematic diagram of the structure of a computing device provided by an exemplary embodiment of the present disclosure.

[0079] The computing device may be a terminal or a server. The terminal includes a mobile terminal or a fixed terminal, such as a smart phone, a tablet computer, a laptop computer, a touch screen, a game console, a personal computer (PC), an intelligent robot, a car computer, and other terminal devices. The server may be a server, a server cluster consisting of several servers, or a cloud computing service center.

[0080] like Figure 1 As shown, the computing device includes a processor 10, a memory 20, and a communication interface 30. Those skilled in the art will appreciate that Figure 1The structure shown in the figure does not constitute a limitation on the computing device, and may include more or less components than shown in the figure, or combine certain components, or arrange the components differently.

[0081] in:

[0082] The processor 10 is the control center of the computing device, and uses various interfaces and lines to connect various parts of the entire computing device. It executes various functions of the computing device and processes data by running or executing software programs and / or modules stored in the memory 20, and calling data stored in the memory 20, thereby controlling the computing device as a whole. The processor 10 can be implemented by a CPU or a GPU.

[0083] The memory 20 can be used to store software programs and modules. The processor 10 executes various functional applications and data processing by running the software programs and modules stored in the memory 20. The memory 20 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system 21, an acquisition unit 22, a packaging unit 23, a registration unit 24, and an application 25 required for at least one function, etc.; the data storage area may store data created according to the use of the computing device, etc. The memory 20 may be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as a static random access memory (SRAM), an electrically erasable programmable read-only memory (EEPROM), an erasable programmable read-only memory (EPROM), a programmable read-only memory (PROM), a read-only memory (ROM), a magnetic memory, a flash memory, a magnetic disk or an optical disk. Accordingly, the memory 20 may further include a memory controller to provide the processor 10 with access to the memory 20 .

[0084] The processor 10 executes the following functions by running the acquisition unit 22: acquiring the original function to be registered, the original function includes the implementation function of the operator and / or the functional module. The processor 10 executes the following functions by running the encapsulation unit 23: encapsulating the original function to obtain the encapsulated function, the encapsulated function is used to call the original function or debug the original function. The processor 10 executes the following functions by running the registration unit 24: registering the encapsulated function to the target location, the target location is the registration location corresponding to the original function.

[0085] Below, an exemplary embodiment is used to introduce the function registration method provided by the embodiment of the present disclosure.

[0086] Please refer to Figure 2 , which shows a flowchart of a function registration method provided by an exemplary embodiment of the present disclosure. In this embodiment, the method is used for Figure 1 The method is illustrated by using the computing device shown in FIG.

[0087] Step 201: Obtain the primitive function to be registered, where the primitive function includes an operator and / or an implementation function of a functional module.

[0088] The original function may be a function to be encapsulated, does not contain debugging functions, and has been implemented. For example, the original function is a function implemented in C++ language.

[0089] The primitive function includes the implementation function of the operator and / or the implementation function of the functional module. An operator is a mathematical function or algorithm used to perform a specific calculation or operation. A functional module is a unit with a specific function, used to complete a specific task or provide a specific service.

[0090] Optionally, an operator is a basic computing unit in a deep learning framework (which may be referred to as a framework for short), and its input includes a tensor (English: tensor) or a combination of tensors. By calculating the tensor or the combination of tensors, a specific function is completed, such as a convolution operator, a pooling operator, etc. The operator can also be a component of customization, communication or other auxiliary functions, and the present disclosure does not limit the type of operator. For ease of understanding, the following is an exemplary explanation of an operator as a basic computing unit in a deep learning framework (which may be referred to as a framework for short).

[0091] Due to the different functional requirements and usage scenarios of operators, different operators support different types. Operators can support tensors of different data types, such as int8 (indicating 8-bit signed integers), int32 (indicating 32-bit signed integers), int64 (indicating 64-bit signed integers), float (floating point data type), float32 (32-bit floating point data type), double (double-precision floating point data type), bool (Boolean variable), etc. On the other hand, operators can also support tensors with different data layouts. For example, in the field of computer vision, the input tensor can be a four-dimensional tensor in any form of [NCHW] or [NHWC], where N is the number of images, C is the number of channels, H is the image height, and W is the image width. In addition, each operator also supports calculations on different running devices, such as different running devices including CPU and GPU.

[0092] In the deep learning framework, each operator usually consists of at least two main parts: description information and logical operation information. The description information is used to define the input and output of an operator, as well as describe the data types, data layout, and operating devices supported by the operator; the logical operation information is mainly responsible for tensor calculation logic. A tensor is a multilinear function that can be used to represent linear relationships between some vectors, scalars, and other tensors.

[0093] It should be noted that, through the function registration mechanism provided in the embodiments of the present disclosure, operators that support specific data types, specific data layouts, and specific operating devices can be added to the deep learning framework for calling by the C++ or Python side.

[0094] When the primitive function is an implementation function of an operator, the primitive function includes first input and output data, and the first input and output data includes a first input parameter and / or a first output result. In this case, the primitive function is generally a function. When the primitive function is an implementation function of a functional module, the primitive function may include the first input and output data, or may not include the first input and output data. In this case, the primitive function is generally a plurality of functions with a certain timing and logical relationship.

[0095] Step 202, encapsulate the original function to obtain an encapsulated function, where the encapsulated function is used to call or debug the original function.

[0096] Optionally, the computing device obtains encapsulation data, and encapsulates the original function according to the encapsulation data to obtain the encapsulated function. Schematically, the computing device obtains encapsulation data input by a user for registering a function with a deep learning framework.

[0097] The above-mentioned encapsulation data is the data required by the original function when encapsulating. The encapsulation data may include at least one of the original name of the original function, the registration information of the original function, and the encapsulation detail information. The registration information of the original function includes information for indicating the registration position corresponding to the original function. The encapsulation detail information includes at least one of the target encapsulation name of the encapsulated function, the encapsulation mode (i.e., the mode adopted when encapsulating), and the components used when encapsulating. The encapsulation detail information may be a default setting or a custom setting. For example, the target encapsulation name is a default or specified encapsulation name. This is not limited in the embodiments of the present disclosure.

[0098] Optionally, the encapsulation mode is used to indicate whether the encapsulation function covers the original function. Illustratively, the encapsulation mode includes a first mode and a second mode. The first mode is used to indicate that the original function is encapsulated and the encapsulation function covers the original function. In the first mode, the encapsulation name of the encapsulation function is the original name of the original function. The second mode is used to indicate that the original function is encapsulated and the original function is not covered. In the second mode, the encapsulation name of the encapsulation function is another name. The other name is any specified name other than the original name of the original function.

[0099] Optionally, the components used in encapsulation include a run control component, that is, the encapsulation data can be used to indicate the encapsulation run control component, and the run control component is used to start or shut down the debugging logic. Schematically, the working mode of the run control component includes a start mode or a shut down mode, the start mode is used to indicate the encapsulation function to debug the original function, and the shut down mode is used to indicate the encapsulation function to call the original function, so that the original function that can be debugged and the original function that cannot be debugged can be compatible.

[0100] Optionally, the components used in encapsulation may also include other components, that is, the encapsulation data may also be used to indicate the encapsulation of other components. The above encapsulation of the original function and the operation control component according to the encapsulation data to obtain the encapsulated function may include: encapsulating the original function, the operation control component and other components according to the encapsulation data to obtain the encapsulated function; wherein the other components include at least one of a debugging component, a sequential logic component and a data calculation component. The debugging component is used to indicate the debugging function of the original function, the sequential logic component is used to indicate the sequential logic of the original function, and the data calculation component is used to be called by the debugging component to perform data calculation.

[0101] Optionally, the debugging component is a component used to debug the original function, and has the debugging function of the original function, and the debugging function includes the function of finding and repairing errors in the original function. Indicatively, the debugging function of the debugging component includes at least one of: obtaining the target data of the original function, timing, analyzing the abnormal values ​​of the original function, counting the characteristic data and data summary of the specified data type, forcibly modifying the input parameters and output results of the original function, replacing abnormal values, interrupting the running of the debugging component in advance, and outputting the problem analysis log.

[0102] Among them, the encapsulated function can be written into at least some of the above-mentioned components or call at least some of the above-mentioned components. For example, the operation control component can be written into the encapsulation function, and the timing logic component and the data calculation component can be called or written by the encapsulation function. The present disclosure does not limit this.

[0103] It should be noted that the present disclosure does not limit the number and order of components written or called by the encapsulation function. The components written or called by the encapsulation function can be determined based on the encapsulation data, or can be specified in the specific implementation. For example, the encapsulation module can identify a specific debugging component based on the encapsulation data and data type, or can determine a specific debugging component based on default settings and original function identification features.

[0104] In some optional embodiments, the encapsulated function includes the original function and the running control component, so that the debugging operation for the original function can be skipped, which is suitable for scenarios where only a part of operators need to be debugged in certain types.

[0105] It should be noted that for the relevant description of each component, reference may be made to the relevant details in the following embodiments, which will not be introduced here.

[0106] In a possible implementation, the computing device calls the running control component and the debugging component, inputs the first input and output data of the original function into the debugging component for processing, and obtains the processed second input and output data; the processed second input and output data and the first input and output data of the original function are simultaneously used as the input and output data of the original function, and the first input and output data and the second input and output data are simultaneously backed up for debugging. In other words, the processed original function (including the first input and output data and the second input and output data), the running control component and the debugging component can be encapsulated to obtain an encapsulated function.

[0107] Optionally, the first input and output data of the original function are input into the debugging component for processing to obtain processed second input and output data, including: inputting the first input parameter of the original function into the debugging component for processing to obtain a processed second input parameter; and / or inputting the first output result of the original function into the debugging component for processing to obtain a processed second output result.

[0108] Step 203, registering the encapsulated function to a target location, where the target location is the registration location corresponding to the original function.

[0109] Optionally, the computing device registers the encapsulated function to a target location in the deep learning framework.

[0110] Since the above-mentioned encapsulation data includes the registration information of the original function, the encapsulated function can be registered into the target position according to the registration information of the original function. Optionally, the registration information of the original function includes information for indicating the registration position corresponding to the original function, and the registration position corresponding to the original function is used as the target position, and the encapsulated function is registered to the target position. For example, the registration logic and registration information of the original function can be reused, and the encapsulated function obtained by encapsulation replaces the original function and is registered into the registration position corresponding to the original function. Among them, the registration information can be determined based on the function name or the signature provided by the deep learning framework. The embodiment of the present disclosure can prevent the registration of the original function, for example, the registration of the original function is not performed, and the registration logic of the original function is reused to register the encapsulated function. It should be noted that the present disclosure does not limit whether the original function comes from the deep learning framework. It can be an original function from a deep learning framework, or it can be a custom original function of a third-party operator library.

[0111] Optionally, the above encapsulation mode is also used to indicate the reuse of encapsulation functions. When the encapsulation function is registered at the target location, the encapsulation function can also be reused and registered at other locations except the target location. Schematically, the encapsulation mode includes not only the first mode and the second mode, but also a third mode. The third mode is used to indicate that the encapsulation function obtained in the first mode or the second mode is reused and registered at other locations, and the other locations are any one or more locations except the target location.

[0112] In some embodiments of the present application, when it is detected that the encapsulated function has been successfully registered, a successful registration prompt message of the encapsulated function may be generated, and the successful registration prompt message may be provided to the user, so that the user can understand that the encapsulated function has been successfully registered through the prompt message. When it is detected that the registration of a registered operator has failed, the failure reason information may be obtained from the configuration information, and corresponding registration failure prompt message may be generated according to the failure reason information, and the registration failure prompt message may be provided to the user, so that the user can understand the reason for the registration failure of the registered operator according to the registration failure prompt message.

[0113] To summarize, the disclosed embodiment adds a debugging component with a debugging function on the basis of the original function before registering the original function, encapsulates the original function and the debugging component together, and then registers the encapsulated function. Since the encapsulated function has the debugging function, when a problem occurs in the encapsulated function during the subsequent use of the function, the encapsulated function can run the debugging function for debugging, which greatly reduces the difficulty of function debugging, ensures the flexibility and convenience of function debugging, and can be more commonly and widely used in various C++ implementation adaptation codes.

[0114] Please refer to Figure 3, which shows a schematic diagram of the structure of a function registration system provided by an exemplary embodiment of the present disclosure. The function registration system is used to execute the function registration method provided by the embodiment of the present disclosure through an encapsulation module 310. The system includes an encapsulation module 310, a component 320 used during encapsulation, and a global control module 330.

[0115] The encapsulation module 310 may be implemented as an encapsulator, and the encapsulation module 310 may include at least one universal encapsulation interface. The encapsulation module 310 is used to execute the function registration method provided in the embodiment of the present disclosure.

[0116] Optionally, the encapsulation module is implemented in the form of a set of C / C++ macros. However, it should be understood that the encapsulation module may also be a C++ template, a Python function decorator, or a module with similar functions in any other programming language, or may be a similar module in a compiler or system call. This disclosure embodiment does not limit this.

[0117] The component 320 used in packaging is called by the packaging module 310. The component 320 used in packaging may include an operation control component. The operation control component may be implemented as a controller for enabling or disabling debugging logic.

[0118] The component 320 used in the encapsulation may also include other components, including at least one of a debugging component, a sequential logic component, and a data computing component. That is, according to the actual situation, the three components of the debugging component, the sequential logic component, and the data computing component may not exist at the same time, may not exist at all, or may all exist. For the convenience of explanation, the following is only introduced as an example in which the debugging component, the sequential logic component, and the data computing component all exist.

[0119] The debugging component may include one or more components with debugging functions. The debugging component is also called a debugging function and may include at least one template function and / or at least one public function. A template function is a generic function whose internal type and function parameters are not specifically specified. A public function is a function that can be called by other functions or modules. These functions support multiple different debugging functions and can be customized and modified as needed.

[0120] The sequential logic component may include one or more public functions. The sequential logic component is used to indicate the sequential logic of the original function, for example, before running, during running, after running, etc. Optionally, the sequential logic component is used to record the start time point and the end time point of the original function, and the sequential logic component is also used to record other functions called inside the original function.

[0121] The data computing component may include one or more public functions. It is called by the debugging component to process data of a specific data type and support on-chip (such as GPU) computing and CPU computing. For example, the specific data type is a tensor type or a vector type. Tensors are used to describe various types of data. A tensor can be regarded as a multidimensional array, and a vector can be regarded as a special case of a tensor. For example, a one-dimensional tensor can be regarded as a vector.

[0122] The global control module 330 is a global class, which refers to a class shared within the entire program scope of the function registration system, that is, the global control module 330 can be accessed by any function within the entire program scope. The global control module 330 is used to store the above-mentioned encapsulation data. The global control module 330 is used to manage the various resources required in the function registration process, such as the resources that the above-mentioned components rely on when running. The various resources include user-configured parameters, resources in the file system, etc. Optionally, the global control module 330 is used to configure and display parameters through a configuration interface, and the configuration interface can be an interface provided in PyThon, C++ or other ways.

[0123] Below, exemplary embodiments are used to further introduce the above modules and components.

[0124] In an exemplary embodiment, the encapsulation mode of the encapsulation module includes a first mode or a second mode. The first mode is also called a quick mode for ease of use. The first mode is used to indicate that the original function is encapsulated and the encapsulated function covers the original function. In the first mode, the encapsulation name of the encapsulated function is the original name of the original function, that is, the default name. For example, the original name is "wrapper_original name".

[0125] The second mode is also called a precisely controllable dedicated mode. The second mode is used to indicate that the original function is encapsulated and the original function is not overwritten. In the second mode, the encapsulation name of the encapsulated function is other names, and the other names are any specified names other than the original name of the original function. Optionally, in the second mode, the encapsulation name is a new name related to the original name of the original function or a specified name unrelated to the original name.

[0126] In addition to the first mode or the second mode, the encapsulation mode may also include a third mode. The third mode is also called an alias mode for reusing existing encapsulation results. The third mode does not include an encapsulation step but only a registration step, that is, the third mode is a subsidiary mode of the first mode or the second mode.

[0127] The third mode is used to indicate that the encapsulated function obtained in the first mode or the second mode is reused and registered to other locations, where the other locations are any locations other than the target location. Schematically, the other locations are one or more registration locations. For example, the MusaEqual function can be encapsulated once and registered to both the first location and the second location without generating two encapsulated functions.

[0128] It should be noted that the encapsulation module can be implemented as an encapsulator, and the encapsulation mode of the encapsulator includes the first mode or the second mode, and the encapsulator can also be in the third mode when it is in the first mode or the second mode. Alternatively, the encapsulation module can be implemented as two encapsulators, namely the first encapsulator and the second encapsulator. The encapsulation mode of the first encapsulator includes the first mode or the second mode, and the second encapsulator is an encapsulator in the third mode. Alternatively, the encapsulation module can be implemented as three encapsulators, namely a shortcut encapsulator, a dedicated encapsulator, and an alias encapsulator. The shortcut encapsulator is an encapsulator in the first mode, the dedicated encapsulator is an encapsulator in the second mode, and the alias encapsulator is an encapsulator in the third mode.

[0129] In an illustrative example, Figure 4 As shown, the encapsulation module can be implemented as three encapsulators, namely, a quick encapsulator 41, a dedicated encapsulator 42, and an alias encapsulator 43. The quick encapsulator 41 or the dedicated encapsulator 42 is used to encapsulate the original function to obtain an encapsulated function, reuse the registration logic and registration information of the original function, and register the encapsulated function to replace the original function in the target position of the deep learning framework. The alias encapsulator 43 is used to obtain the encapsulated function encapsulated by the quick encapsulator 41 or the dedicated encapsulator 42, reuse the registration logic and registration information of the original function, and register the encapsulated function to other positions except the target position.

[0130] Optionally, the input parameters of the encapsulation module include: the original function and the encapsulation data, and the encapsulation data may include the original name of the original function, the registration information of the original function, and the encapsulation detail information. The function of the encapsulation module includes: encapsulating the original function according to the encapsulation data to obtain the encapsulation function. Optionally, the encapsulation module encapsulates the original function into an encapsulation function with a specified or default encapsulation name according to the original name of the registered name and the encapsulation detail information. The encapsulation function will insert the run control component on the basis of the original function, and insert specific debugging components, timing logic components, and data calculation components before and after it. It should be noted that, according to actual conditions, the three components of the debugging component, the timing logic component, and the data calculation component may not exist at the same time, do not exist, or exist. For the convenience of explanation, the following is only introduced as an example that the debugging component, the timing logic component, and the data calculation component all exist. According to the registration information of the original function, the above-mentioned encapsulation function is registered into the target location so that it can be called like the original function. For example, the registration location corresponding to the original function is the PyTorch framework, and the encapsulation function is also registered into the PyTorch framework in the same way.

[0131] Optionally, the implementation method of the encapsulation module includes: first, creating an encapsulation template function with a target encapsulation name, which can be a specified or default encapsulation name. Then, calling the run control component, other components and the original function in the encapsulation template function, such as calling the run control component first, and then calling the debugging component, the data calculation component, the timing logic component and the original function in a preset order. In the encapsulation template function, the first input and output data of the original function is obtained, the first input and output data is input into the debugging component for processing to obtain the second input and output data, and the second input and output data is returned to the original function to obtain the encapsulation function, the encapsulation function includes the processed original function, the run control component and other components, and the processed original function includes the first input and output data and the second input and output data.

[0132] Schematically, the first input and output data of the original function is obtained in the encapsulation template function, the first input and output data is input into the debugging component for processing to obtain the second input and output data, and the second input and output data is returned to the original function, including: obtaining the first input parameter of the original function, processing through the debugging component related to the input to obtain the second input parameter, and inputting the second input parameter to the original function. The first output result of the original function is calculated, the first output result of the original function is obtained in the encapsulation template function, and the second output result is processed through the debugging component related to the output to obtain the second output result, and the second output result is used as the return value, that is, the first input parameter, the first output result, the second input parameter and the second output result are used as the input and output data of the original function at the same time, and are backed up at the same time for debugging. In the above logic, the timing logic component can be inserted as required to obtain a new encapsulation template function, that is, the encapsulation function, which includes the processed original function (including the first input and output data and the second input and output data) and the components used during encapsulation (for example, it may include the operation control component, the debugging component, the data calculation component and the timing logic component). Finally, the registration logic and registration information of the original function are reused, and the encapsulation function replaces the original function and is registered into the target position.

[0133] In an exemplary embodiment, the run control component may be the first component encapsulated by the encapsulation module. The run control component may be managed by the global control module. The working mode of the run control component includes a start mode or a shutdown mode. The start mode is used to instruct the encapsulated function to debug the original function, such as allowing the encapsulated function to run the debugging component to perform the debugging function; the shutdown mode is used to instruct the encapsulated function to call the original function, that is, to control the encapsulated function to directly call the original function, so that the logic is completely consistent with the original logic.

[0134] In an exemplary embodiment, the debugging component may be a template function or a combination of multiple template functions (including functional components and data calculation components).

[0135] Optionally, the debugging component may include one or more template functions that support basic data types and are used for specific types (such as tensor types). Debugging components can be nested and combined, that is, a debugging component can call other debugging components to complete complex functions.

[0136] Optionally, the debugging component includes but is not limited to the following sub-components: an acquisition sub-component with an acquisition function, an analysis sub-component with an analysis function, a processing sub-component with a processing function, a recording sub-component with a recording function, and a write-back sub-component with a write-back function.

[0137] 1. Get subcomponent: used to automatically obtain one or more target data of the original function, such as input parameters, output results, intermediate variables, etc.

[0138] 2. Analysis subcomponent: Generally used in combination with the acquisition subcomponent, it is used to perform specific analysis and calculations on the acquired data, generate problem analysis logs, feature data, and data summaries. The functions of the numerator component include automatically analyzing the abnormal values ​​of the original function, and counting the feature data and data summaries of the specified data type.

[0139] The specified data type can be a tensor type used in a deep learning framework, or a data type used in scientific computing such as a vector or matrix that has similar logic and usage to a tensor type, or a special type derived from the above types in a specific deep learning framework or other specific application scenarios.

[0140] Feature data can be information that can characterize mathematical features such as data distribution obtained by mathematical induction or logical calculation of specified data, including but not limited to the mean, variance, maximum and minimum values, etc. The scope can be expanded or the required content can be filtered according to the needs of actual application scenarios.

[0141] The data summary can be a macro-descriptive information about the data form due to the characteristics of the specified data (used for scientific computing or deep learning, or any other specific needs), including but not limited to scale, shape, step size, type, device, device number, mounting function, corresponding weight, etc.

[0142] 3. Processing subcomponent: used to process data in a specified form, including but not limited to user-specified, program preset, automatic processing according to the results of the analysis component, etc. The processing subcomponent is used to force the modification of the input and output data of the original function (including the first input and output data and the second input and output data mentioned above), replace abnormal values ​​or arbitrary values, interrupt the running debugging component in advance, call specific components, and call other encapsulated and / or unencapsulated functions, including operators and functional modules (including encapsulated and unencapsulated, etc.). The processing subcomponent can use GPU and / or CPU for data processing.

[0143] 4. Recording subcomponent: used to record the data output by the analysis subcomponent and / or the data output by the acquisition subcomponent. Optionally, the data can be recorded in a customized or default recording method, including displaying on the screen (standard input and output), recording to a file, or recording to a file in a specific format (such as binary format).

[0144] The recording subcomponent can also be used to output debugging-related data of interest to a specific location according to importance, for example, outputting warning data with abnormal values ​​to a log file or displaying it on the screen, while writing other data without abnormal values ​​to a normal file.

[0145] 5. Write-back subcomponent: used to write the processed data back to the original location, for example, using the processed second input parameter as the input parameter of the original function, thereby allowing users to perform complex breakpoint debugging functions.

[0146] It should be noted that the data in the debugging process may continue to be encapsulated or handed over to the global control module for processing. Optionally, if it is mandatory modified data, replaced input and output results or abnormal values, it can continue to be encapsulated with the original function. If it is data summary, data characteristics, statistical timing and other data, it can be managed and saved by the global control module.

[0147] Another point that needs to be explained is that the above subcomponents are not classifications or limitations of specific functions. A debugging function can have the functions of multiple subcomponents at the same time, can call other functions and components to implement complex functions, or can only include one of the above functions. In addition to the above functions, more functional components that are helpful for debugging may be expanded in the future. This disclosure embodiment does not limit this.

[0148] In an exemplary embodiment, the data computing component may be a component set for deep learning and GPU computing. The data computing component is called by the debugging component to perform data processing. Optionally, the data computing component is called by an analysis subcomponent or a processing subcomponent in the debugging component.

[0149] The data computing component includes computing logic implemented on the CPU and / or GPU, such as calculating mean, variance, absolute value, and scientific calculations. The data computing component can be optimized for specific computing functions and is more efficient than the basic debugging component.

[0150] Optionally, the data computing component is used to classify the data into tensor data, scalar data, and other custom types of data, where tensor data is generally calculated in the GPU and scalar data is generally calculated in the CPU. The data is analyzed (mainly tensor data) according to the specified analysis and statistical logic, and summary data and feature data are output.

[0151] In an illustrative example, Figure 5As shown, the data computing component is used to classify the data, and classify the data into tensor data, scalar data or other custom types of data. When the data is classified as scalar data, the data type and data value of the data are output; when the data is classified as other custom types of data, the custom data information of the data is output; when the data is classified as tensor data, if there is no I / O access to the data, the basic tensor information is output, where I / O represents input (Input) and output (Output). If the data has I / O access, the data is analyzed according to the specified analysis and statistical mode (used to indicate the specified analysis and statistical logic) of the global control module. Data analysis includes: determining whether to perform on-chip calculation (such as GPU calculation); if on-chip calculation is performed, on-chip data statistics, on-chip summary analysis and on-chip feature analysis are performed in the GPU, and the data summary and feature data obtained by the analysis are output. If on-chip calculation is not performed, the data is copied to the CPU, CPU data statistics, CPU summary analysis and CPU feature analysis are performed in the CPU, and the data summary and feature data obtained by the analysis are output. After the data analysis is completed, determine whether the data needs to be retained. If the data does not need to be retained, only the basic log file is retained. If the data needs to be retained, determine whether the data is on-chip. If the data is on-chip, copy the on-chip data (that is, the complete data including the data and the corresponding data analysis results) to the CPU, that is, indirectly output the complete data through the CPU. If the data is not on-chip, output the complete data directly.

[0152] In an exemplary embodiment, the timing logic component is a function for identifying the running timing, and the timing logic component is used to record, mark and control the global timing, so that more comprehensive running information can be obtained.

[0153] The functions of the sequential logic component include but are not limited to the following functions: recording the start time and end time of the original function; recording other functions and their logic called inside the original function; passing the information of calling and running functions to the global management module to realize the combination logic between multiple operators and components. Among them, the combination logic of the sequential logic component can be realized by the automaton of the global control module. It should be noted that the automaton is only one way to realize the combination logic. On the basis of the calling information provided by the sequential logic component, the combination logic can also be realized by the message system, the preset response mechanism, etc. The embodiments of the present disclosure are not limited to this.

[0154] Optionally, the sequential logic component is used to control the state of the automaton in the global control module, and the state of the automaton is used to instruct the global control module to perform file system management and / or log management. The relevant description of the automaton can refer to the relevant details in the following embodiments, which will not be introduced here.

[0155] In an illustrative example, Figure 6 As shown, the original function 61, the operation control component 62, the debugging component 63 and the sequential logic component 64 are encapsulated by the encapsulation module 65 to obtain the encapsulated function 66, that is, the encapsulated function 66 includes the original function 61, the operation control component 62, the debugging component 63 and the sequential logic component 64.

[0156] In an exemplary embodiment, the global control module is used to manage global resources, that is, to manage the resources required in the function registration method, for example, the global control module manages the operation control component. The global control module includes configuration parameter information, an automaton for resource management, and a manager, the automaton is used to switch states according to the sequential logic component, and the state of the automaton is used to instruct the global control module to perform file system management and / or log management, such as the state of the automaton is used to indicate the designated location of information storage in the file system or to perform operations, and the information includes data and / or logs; the manager is used to receive information output by the debugging component, and store the information in a designated location or perform a designated operation according to the state of the automaton.

[0157] Optionally, the automaton includes a file system automaton and a global state automaton, and the manager includes a data manager and a log manager. Figure 7 As shown, the global control module includes configuration parameter information 71 , a file system automaton 72 , a global state automaton 73 , a data manager 74 and a log manager 75 .

[0158] The parameter information 71 is used to indicate global resources. For example, the parameter information includes the encapsulation logic of the encapsulation module and the operation control logic of the operation control component required in the function encapsulation and registration process.

[0159] The file system automaton 72 is an automaton implemented to save the information required for encapsulation to the file system. The file system automaton 72 is used to control file access. The global state automaton 73 provides management of the global state, thereby realizing complex debugging functions. The global state automaton 73 is used to control the system state. The file system automaton 72 and the global state automaton 73 are used to realize state transfer through sequential logic components, so as to automatically switch the path for storing information such as logs and data, and control the operating state of the entire system.

[0160] The above two types of state machines can have a variety of different implementations as needed. For example, the file system automaton 72 can be used to complete data tree archiving using a sequential logic component. For another example, the global state automaton 73 can be used to trigger the logic of pre-processing and post-processing of debugging using a sequential logic component. For another example, the global state automaton 73 can also be used to implement the combinational logic of a pair of operators using a sequential logic component. This embodiment of the present disclosure is not limited to this.

[0161] The data manager 74 is used to manage data, and the log manager 75 is used to manage logs. The data manager 74 and the log manager 75 are used to receive information (such as logs, data, etc.) from the debugging component, and select to print and / or save the information in a specified location, or perform a specified operation, such as specifying a special operation such as ignore or alarm, according to the status of the file system automaton 72 and the global state automaton 73. Optionally, the above parameter information is configured through a configuration interface, which is an interface for configuring the global control module. The types of configuration interfaces include but are not limited to environment variables, configuration files, system information, environmental information, application programming interface (Application Programming Interface, API), etc.

[0162] In summary, based on the above design of the embodiment of the present disclosure, a mechanism is implemented to encapsulate and register the original function. This allows users to implement debugging functions at the framework-operator granularity at a relatively low cost when running the network. In addition, the method provided by the embodiment of the present disclosure has good scalability and can be reused in a variety of different deep learning frameworks or other software that uses C++ function interfaces to call operators and functional modules.

[0163] Compared with the solutions in the related arts, the embodiments of the present disclosure provide functions such as data analysis, data summary, time series, and logs, which greatly reduce the difficulty and cost of users locating and analyzing problems. The generated logs, data summaries and other information can conveniently and clearly reflect the occurrence of typical problems in the deep learning process.

[0164] Compared with the debugging interface provided by the deep learning framework in the related art, the debugging tool implemented in the embodiment of the present disclosure does not require the user to design and implement it, and can be directly called through a simple configuration interface. It is comprehensive, convenient, and has no omissions.

[0165] Compared with the debugging function provided by the operator library in the related art, the encapsulated function implemented in the embodiment of the present disclosure can also include a timing logic component, which is used to indicate the timing logic of the original function, and can realize the logical arrangement of function calls, which is convenient for analyzing the recursion, splicing and nesting of operators. At the same time, the data name and other information of the debugging tool are consistent with the framework, which is closer to the user's usage scenario than the operator library, and is convenient for query and analysis.

[0166] Compared with the solutions in related technologies, the tool implemented by this solution does not rely on the distribution mechanism and operator generation mechanism, and has better flexibility and scalability. At the same time, it provides convenient data summary and data analysis functions.

[0167] The following is an apparatus embodiment of the present disclosure. For parts not described in detail in the apparatus embodiment, reference may be made to the technical details disclosed in the above method embodiment.

[0168] Please refer to Figure 8 , which shows a schematic diagram of the structure of a function registration device provided by another exemplary embodiment of the present disclosure. The function registration device can be implemented as all or part of a computing device through software, hardware, or a combination of both. The device includes: an acquisition unit 22, an encapsulation unit 23, and a registration unit 24.

[0169] An acquisition unit 22, used to acquire a primitive function to be registered, wherein the primitive function includes an operator and / or an implementation function of a functional module;

[0170] An encapsulation unit 23, used for encapsulating the original function to obtain an encapsulated function, where the encapsulated function is used to call or debug the original function;

[0171] The registration unit 24 is used to register the encapsulated function to a target location, where the target location is a registration location corresponding to the original function.

[0172] In a possible implementation, the encapsulation unit 23 is further configured to:

[0173] Obtaining encapsulation data, where the encapsulation data is used to instruct the encapsulation operation control component, and the operation control component is used to start or shut down the debugging logic;

[0174] According to the encapsulation data, the original function and the operation control component are encapsulated to obtain the encapsulated function.

[0175] In another possible implementation, the working mode of the operation control component includes a startup mode or a shutdown mode, the startup mode is used to instruct the encapsulation function to debug the original function, and the shutdown mode is used to instruct the encapsulation function to call the original function.

[0176] In another possible implementation, the encapsulation data is further used to indicate encapsulation of other components, and the encapsulation unit 23 is further used to:

[0177] According to the encapsulation data, the original function, the operation control component and other components are encapsulated to obtain the encapsulated function;

[0178] Among them, other components include at least one of a debugging component, a timing logic component and a data calculation component. The debugging component is used to indicate the debugging function of the original function, the timing logic component is used to indicate the timing logic of the original function, and the data calculation component is used to be called by the debugging component to perform data calculation.

[0179] In another possible implementation, the encapsulation unit is further configured to:

[0180] Create a package template function with the target package name;

[0181] Call the run control component, other components and original functions in the encapsulated template function;

[0182] Obtaining first input and output data of the original function in the encapsulation template function, inputting the first input and output data into the debugging component for processing to obtain second input and output data, and returning the second input and output data to the original function to obtain the encapsulation function;

[0183] The encapsulated function includes the processed original function, the operation control component and other components, and the processed original function includes the first input and output data and the second input and output data.

[0184] In another possible implementation, the encapsulation data is also used to indicate an encapsulation mode, and the encapsulation mode is used to indicate whether the encapsulation function covers the original function.

[0185] In another possible implementation, the encapsulation mode is further used to indicate a multiplexing encapsulation function, and the device further includes:

[0186] Alias ​​registration unit, used to register the encapsulated function to a location other than the target location.

[0187] In another possible implementation, the function registration method is executed by the encapsulation module.

[0188] In another possible implementation, the resources required in the function registration method are managed by a global control module.

[0189] In another possible implementation, the debugging functions of the debugging component include: obtaining at least one of the target data of the original function, timing, analyzing abnormal values ​​of the original function, counting characteristic data and data summaries of specified data types, forcibly modifying input parameters and output results of the original function, replacing abnormal values, interrupting the running of the debugging component in advance, and outputting a problem analysis log.

[0190] In another possible implementation, the sequential logic component is used to control the state of the automaton in the global control module, and the state of the automaton is used to instruct the global control module to perform file system management and / or log management.

[0191] It should be noted that the device provided in the above embodiment only uses the division of the above-mentioned functional modules as an example to implement its functions. In practical applications, the above-mentioned functions can be assigned to different functional modules according to actual needs, that is, the content structure of the device can be divided into different functional modules to complete all or part of the functions described above.

[0192] Regarding the device in the above embodiment, the specific manner in which each unit performs the operation has been described in detail in the embodiment of the method, and will not be elaborated here.

[0193] The embodiments of the present disclosure further provide a computing device, which includes: a processor; and a memory for storing instructions executable by the processor; wherein the processor is configured to: implement the steps executed by the computing device in the above-mentioned various method embodiments.

[0194] The embodiments of the present disclosure further provide a non-volatile computer-readable storage medium on which computer program instructions are stored. When the computer program instructions are executed by a processor, the methods in the above-mentioned various method embodiments are implemented.

[0195] The embodiments of the present disclosure also provide a computer program product, including a computer-readable code, or a non-volatile computer-readable storage medium carrying the computer-readable code. When the computer-readable code runs in a processor of a computing device, the processor in the computing device executes the above method.

[0196] Fig. 9 is a block diagram of a device 900 according to an exemplary embodiment. The device 900 is used to execute the function registration method provided by the embodiment of the present disclosure. For example, the device 900 can be provided as a server or a terminal device. Fig. 9 , the apparatus 900 includes a processing component 922, which further includes one or more processors, and a memory resource represented by a memory 932 for storing instructions, such as an application, that can be executed by the processing component 922. The application stored in the memory 932 may include one or more modules, each corresponding to a set of instructions. In addition, the processing component 922 is configured to execute the instructions to perform the above method.

[0197] The device 900 may also include a power supply component 926 configured to perform power management of the device 900, a wired or wireless network interface 950 configured to connect the device 900 to a network, and an input / output interface 958 (I / O interface). The device 900 may operate based on an operating system stored in the memory 932, such as Windows Server™, Mac OSX™, Unix™, Linux™, FreeBSD™ or the like.

[0198] In an exemplary embodiment, a non-volatile computer-readable storage medium is also provided, such as a memory 932 including computer program instructions that can be executed by the processing component 922 of the device 900 to perform the above method.

[0199] The present disclosure may be a system, a method and / or a computer program product. The computer program product may include a computer-readable storage medium carrying computer-readable program instructions for causing a processor to implement various aspects of the present disclosure.

[0200] A computer-readable storage medium may be a tangible device that can hold and store instructions used by an instruction execution device. A computer-readable storage medium may be, for example, but not limited to, an electrical storage device, a magnetic storage device, an optical storage device, an electromagnetic storage device, a semiconductor storage device, or any suitable combination of the foregoing. More specific examples of computer-readable storage media (a non-exhaustive list) include: a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a static random access memory (SRAM), a portable compact disk read-only memory (CD-ROM), a digital versatile disk (DVD), a memory stick, a floppy disk, a mechanical encoding device, such as a punch card or a raised structure in a groove on which instructions are stored, and any suitable combination of the foregoing. As used herein, a computer-readable storage medium is not to be interpreted as a transient signal per se, such as a radio wave or other freely propagating electromagnetic wave, an electromagnetic wave propagating through a waveguide or other transmission medium (e.g., a light pulse through a fiber optic cable), or an electrical signal transmitted through a wire.

[0201] The computer-readable program instructions described herein can be downloaded from a computer-readable storage medium to each computing / processing device, or downloaded to an external computer or external storage device via a network, such as the Internet, a local area network, a wide area network, and / or a wireless network. The network can include copper transmission cables, optical fiber transmissions, wireless transmissions, routers, firewalls, switches, gateway computers, and / or edge servers. The network adapter card or network interface in each computing / processing device receives the computer-readable program instructions from the network and forwards the computer-readable program instructions for storage in the computer-readable storage medium in each computing / processing device.

[0202] The computer program instructions for performing the operation of the present disclosure may be assembly instructions, instruction set architecture (ISA) instructions, machine instructions, machine-related instructions, microcode, firmware instructions, state setting data, or source code or object code written in any combination of one or more programming languages, including object-oriented programming languages, such as Smalltalk, C++, etc., and conventional procedural programming languages, such as "C" language or similar programming languages. Computer-readable program instructions may be executed completely on a user's computer, partially on a user's computer, as an independent software package, partially on a user's computer, partially on a remote computer, or completely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer via any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., using an Internet service provider to connect via the Internet). In some embodiments, an electronic circuit, such as a programmable logic circuit, a field programmable gate array (FPGA), or a programmable logic array (PLA), may be customized by utilizing the state information of the computer-readable program instructions, and the electronic circuit may execute the computer-readable program instructions, thereby realizing various aspects of the present disclosure.

[0203] Various aspects of the present disclosure are described herein with reference to the flowcharts and / or block diagrams of the methods, devices (systems) and computer program products according to the embodiments of the present disclosure. It should be understood that each box in the flowchart and / or block diagram and the combination of each box in the flowchart and / or block diagram can be implemented by computer-readable program instructions.

[0204] These computer-readable program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, thereby producing a machine, so that when these instructions are executed by the processor of the computer or other programmable data processing device, a device that implements the functions / actions specified in one or more boxes in the flowchart and / or block diagram is generated. These computer-readable program instructions can also be stored in a computer-readable storage medium, and these instructions cause the computer, programmable data processing device, and / or other equipment to work in a specific manner, so that the computer-readable medium storing the instructions includes a manufactured product, which includes instructions for implementing various aspects of the functions / actions specified in one or more boxes in the flowchart and / or block diagram.

[0205] Computer-readable program instructions may also be loaded onto a computer, other programmable data processing apparatus, or other device so that a series of operating steps are performed on the computer, other programmable data processing apparatus, or other device to produce a computer-implemented process, thereby causing the instructions executed on the computer, other programmable data processing apparatus, or other device to implement the functions / actions specified in one or more boxes in the flowchart and / or block diagram.

[0206] The flow chart and block diagram in the accompanying drawings show the possible architecture, function and operation of the system, method and computer program product according to multiple embodiments of the present disclosure. In this regard, each square box in the flow chart or block diagram can represent a part of a module, program segment or instruction, and a part of the module, program segment or instruction includes one or more executable instructions for realizing the specified logical function. In some alternative implementations, the function marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two continuous square boxes can actually be executed substantially in parallel, and they can sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs the specified function or action, or can be implemented with a combination of special hardware and computer instructions.

[0207] The embodiments of the present disclosure have been described above, and the above description is exemplary, not exhaustive, and is not limited to the disclosed embodiments. Many modifications and variations will be apparent to those of ordinary skill in the art without departing from the scope and spirit of the described embodiments. The selection of terms used herein is intended to best explain the principles of the embodiments, practical applications, or technical improvements to the technology in the market, or to enable other persons of ordinary skill in the art to understand the embodiments disclosed herein.

Claims

1. A function registration method, characterized in that: The method comprises: Obtaining a primitive function to be registered, wherein the primitive function includes an implementation function of an operator and / or a functional module, and the primitive function does not include a debugging function; Encapsulating the original function to obtain an encapsulated function, where the encapsulated function is used to call the original function or debug the original function, and the encapsulated function includes the original function and a running control component, where the running control component is used to start or shut down the debugging logic; Register the encapsulated function to a target location, where the target location is a registration location corresponding to the original function; The encapsulating the original function to obtain the encapsulated function comprises: Acquire encapsulation data, where the encapsulation data is used to indicate encapsulation of the operation control component; According to the encapsulation data, encapsulate the original function and the operation control component to obtain the encapsulation function; The encapsulation data is also used to indicate encapsulation of other components, and encapsulating the original function and the operation control component according to the encapsulation data to obtain the encapsulation function includes: According to the encapsulation data, encapsulate the original function, the operation control component and the other components to obtain the encapsulation function; Among them, the other components include at least one of a debugging component, a timing logic component and a data calculation component, the debugging component is used to indicate the debugging function of the original function, the timing logic component is used to indicate the timing logic of the original function, the data calculation component is used to be called by the debugging component to perform data calculation, the encapsulation function includes the processed original function, the operation control component and the other components, and when the original function includes first input and output data, the processed original function includes the first input and output data and the processed second input and output data.

2. The method according to claim 1, characterized in that The working mode of the operation control component includes a startup mode or a shutdown mode, the startup mode is used to instruct the encapsulation function to debug the original function, and the shutdown mode is used to instruct the encapsulation function to call the original function.

3. The method according to claim 1, characterized in that The encapsulating the original function, the operation control component and the other components to obtain the encapsulated function includes: Create a package template function with the target package name; Calling the operation control component, the other components and the original function in the encapsulation template function; Acquire first input and output data of the original function in the encapsulation template function, input the first input and output data into the debugging component for processing to obtain second input and output data, and return the second input and output data to the original function to obtain the encapsulation function; The encapsulated function includes the processed original function, the operation control component and the other components, and the processed original function includes the first input and output data and the second input and output data.

4. The method according to claim 1, characterized in that: The encapsulation data is also used to indicate an encapsulation mode, and the encapsulation mode is used to indicate whether the encapsulation function covers the original function.

5. The method according to claim 4, characterized in that The encapsulation mode is also used to indicate the reuse of the encapsulation function, and the method further includes: Register the wrapper function to a location other than the target location.

6. The method according to any one of claims 1 to 5, characterized in that: The function registration method is executed by the encapsulation module.

7. The method according to any one of claims 1 to 5, characterized in that: The resources required in the function registration method are managed by the global control module.

8. The method according to claim 1, characterized in that The debugging functions of the debugging component include: obtaining the target data of the original function, timing, analyzing the abnormal values ​​of the original function, counting the characteristic data and data summary of the specified data type, forcibly modifying the input parameters and output results of the original function, replacing the abnormal values, interrupting the running of the debugging component in advance, and outputting at least one of the problem analysis logs.

9. The method according to claim 1, characterized in that: The sequential logic component is used to control the state of the automaton in the global control module, and the state of the automaton is used to instruct the global control module to perform file system management and / or log management.

10. A function registration device, characterized in that: The device comprises: An acquisition unit, used for acquiring a primitive function to be registered, wherein the primitive function includes an implementation function of an operator and / or a functional module, and the primitive function does not include a debugging function; An encapsulation unit, used for encapsulating the original function to obtain an encapsulation function, wherein the encapsulation function is used to call the original function or debug the original function, and the encapsulation function includes the original function and a running control component, and the running control component is used to start or shut down the debugging logic; A registration unit, used to register the encapsulated function to a target location, where the target location is a registration location corresponding to the original function; The encapsulation unit is further used for: Acquire encapsulation data, where the encapsulation data is used to indicate encapsulation of the operation control component; According to the encapsulation data, encapsulate the original function and the operation control component to obtain the encapsulation function; The encapsulation data is also used to indicate encapsulation of other components, and the encapsulation unit is also used to: According to the encapsulation data, encapsulate the original function, the operation control component and the other components to obtain the encapsulation function; Among them, the other components include at least one of a debugging component, a timing logic component and a data calculation component, the debugging component is used to indicate the debugging function of the original function, the timing logic component is used to indicate the timing logic of the original function, the data calculation component is used to be called by the debugging component to perform data calculation, the encapsulation function includes the processed original function, the operation control component and the other components, and when the original function includes first input and output data, the processed original function includes the first input and output data and the processed second input and output data.

11. A computing device, characterized in that: The computing device comprises: a processor; a memory for storing instructions executable by the processor; Wherein, the processor is configured to: Obtaining a primitive function to be registered, wherein the primitive function includes an implementation function of an operator and / or a functional module, and the primitive function does not include a debugging function; Encapsulating the original function to obtain an encapsulated function, where the encapsulated function is used to call the original function or debug the original function, and the encapsulated function includes the original function and a running control component, where the running control component is used to start or shut down the debugging logic; Register the encapsulated function to a target location, where the target location is a registration location corresponding to the original function; The encapsulating the original function to obtain the encapsulated function comprises: Acquire encapsulation data, where the encapsulation data is used to indicate encapsulation of the operation control component; According to the encapsulation data, encapsulate the original function and the operation control component to obtain the encapsulation function; The encapsulation data is also used to indicate encapsulation of other components, and encapsulating the original function and the operation control component according to the encapsulation data to obtain the encapsulation function includes: According to the encapsulation data, encapsulate the original function, the operation control component and the other components to obtain the encapsulation function; Among them, the other components include at least one of a debugging component, a timing logic component and a data calculation component, the debugging component is used to indicate the debugging function of the original function, the timing logic component is used to indicate the timing logic of the original function, the data calculation component is used to be called by the debugging component to perform data calculation, the encapsulation function includes the processed original function, the operation control component and the other components, and when the original function includes first input and output data, the processed original function includes the first input and output data and the processed second input and output data.

12. A non-volatile computer-readable storage medium having computer program instructions stored thereon, characterized in that: When the computer program instructions are executed by a processor, the method according to any one of claims 1 to 9 is implemented.