Brain simulation platform and operator registration method, device and storage medium thereof

Through the user module, code conversion module and operator registration module of the brain simulation platform, the registration of custom operators is automatically completed, which solves the problem that users need to master the underlying development language and registration process, reduces learning costs and improves registration efficiency.

CN116596066BActive Publication Date: 2025-10-17BEIJING CHANGSHENG INTELLIGENT TECHNOLOGY CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202310216994.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-03-07
Publication Date
2025-10-17
Estimated Expiration
2043-03-07

AI Technical Summary

Technical Problem

In the existing technology, custom operators require users to be proficient in the underlying development language and the registration process of the platform framework, resulting in a high learning cost for registering custom operators.

Method used

A brain simulation platform and an operator registration method thereof are provided. User-defined operators and their description information are obtained through a user module. A code conversion module is used for real-time compilation and encapsulation. The custom operators are encapsulated as callback functions of the underlying programming language of the brain simulation platform, and are registered as primitives within the platform framework through an operator registration module.

Benefits of technology

Automatic registration of custom operators is implemented, which reduces the time users spend on operator registration and compilation, reduces the learning cost, and eliminates the need for users to understand the internal details of the platform framework and the compilation process.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116596066B_ABST
    Figure CN116596066B_ABST
Patent Text Reader

Abstract

The application relates to the field of brain simulation and brain-like computing, and provides a brain simulation platform and an operator registration method, equipment and storage medium thereof. The brain simulation platform comprises a user module used for enabling a user to write a custom operator based on a high-level programming language and description information of the custom operator; a code conversion module used for performing instant compilation conversion and encapsulation processing on the custom operator, encapsulating the custom operator as a callback function of a bottom programming language of the brain simulation platform; and an operator registration module used for registering the callback function and the description information as a primitive inside a framework of the brain simulation platform. Through the code conversion module and the operator registration module, automatic registration of the operator written by the user in the high-level programming language is realized, the user does not need to learn registration details and a compilation process inside the framework of the brain simulation platform, time consumed by the user in the operator registration and compilation process is reduced, and learning cost of the user in the operator registration is reduced.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the field of brain simulation and brain-like computing, and in particular to a brain simulation platform and an operator registration method, device and storage medium thereof. BACKGROUND

[0002] In the field of deep learning, an operator is a basic computing unit in a programming framework, which generally processes tensor type data. The model and training algorithm in the framework are implemented by the underlying operator. Therefore, the richness of the operator determines the richness and completeness of the function of the deep learning framework, and the efficiency of the operator and the compilation optimization strategy determine the efficiency of the running model of the programming framework. Brain dynamics simulation is different from the field of deep learning, and some special operators are needed to realize specific functions, such as sparse computing and event-driven computing related operators. These operators can be used to efficiently run in various types of synaptic models, which greatly reduces the memory occupancy from the space and speeds up the synaptic update from the time. At present, brain dynamics programming is still in the stage of vigorous development, and there are few special operators designed for brain dynamics simulation. Therefore, the current strategy is to provide users with a custom operator function in the simulation platform to facilitate users to add special operators to speed up their model running.

[0003] In order to adapt to the rapid development of the field of deep learning, the current custom operator function is only used in deep learning frameworks, and is less used in brain dynamics simulation platforms. Moreover, the current operator registration in deep learning frameworks is mostly implemented by using a bottom language to realize the operator computing logic, such as using C++ to realize the CPU version of the operator and using CUDA to realize the GPU version of the operator. This way has a large learning cost for users. Users not only need to design the operator computing logic itself, but also need to master the bottom development language and the registration process of the platform framework. Any error in the middle needs to be corrected by the user, and a large amount of programming time of the user will be used for registering the operator, so that the user cannot focus on operator design and theoretical innovation. SUMMARY

[0004] The present application provides a brain simulation platform and an operator registration method, device and storage medium thereof, to solve the defect that the custom operator in the prior art needs the user to master the bottom development language and the registration process of the platform framework, and the registration of the operator needs to consume a large amount of programming time of the user, resulting in a high learning cost of the user to register the custom operator.

[0005] The present application provides an operator registration method of a brain simulation platform, the brain simulation platform comprising a user module, a code conversion module and an operator registration module, the method comprising:

[0006] obtaining a user-defined operator written by a user based on a high-level programming language and description information of the user-defined operator through the user module;

[0007] performing instant compilation conversion and encapsulation processing on the user-defined operator by using the code conversion module, and encapsulating the user-defined operator as a callback function of a bottom programming language of the brain simulation platform;

[0008] registering the callback function and the description information as primitives inside a framework of the brain simulation platform based on the operator registration module.

[0009] According to the operator registration method of the brain simulation platform provided in the application, the description information comprises input definition information, output definition information, data types supported by the user-defined operator and data layout.

[0010] According to the operator registration method of the brain simulation platform provided in the application, the operator registration module is provided with a primitive abstract information inference function, a primitive logical operation function and a primitive transformation dictionary; each type of transformation in the primitive transformation dictionary is stored by using a dictionary data structure;

[0011] The registering the callback function and the description information as primitives inside a framework of the brain simulation platform based on the operator registration module comprises:

[0012] The operator name of the user-defined operator is registered as a primary key of an operator registration table of the brain simulation platform based on the operator registration module; the primary key is used for table search and user calling;

[0013] The description information is registered based on the primitive abstract information inference function; the callback function is registered based on the primitive logical operation function; an implementation function of operator transformation of the user-defined operator is registered as a dictionary value based on the primitive transformation dictionary, so that the callback function and the description information are primitives inside the framework of the brain simulation platform.

[0014] According to the operator registration method of the brain simulation platform provided in the application, the user-defined operator comprises an operator supporting instant compilation, an operator supporting batch processing, an operator supporting forward differentiation and an operator supporting reverse differentiation; and the operator transformation comprises instant compilation transformation, batch processing transformation, forward differentiation transformation and reverse differentiation transformation.

[0015] According to the operator registration method of the brain simulation platform provided in the application, the code conversion module is provided with an instant compiler and a conversion function;

[0016] The performing instant compilation conversion and encapsulation processing on the user-defined operator by using the code conversion module, and encapsulating the user-defined operator as a callback function of a bottom programming language of the brain simulation platform comprises:

[0017] compile a calculation logic function of the custom operator by means of an instant compiler in the code conversion module, to obtain a compiled function corresponding to the custom operator;

[0018] perform conversion and encapsulation processing on the compiled function by means of a conversion function in the code conversion module, to encapsulate the custom operator as a callback function of the underlying programming language of the brain simulation platform.

[0019] According to the application, the instant compiler comprises a computation graph converter.

[0020] The compiling of the calculation logic function of the custom operator by means of the instant compiler in the code conversion module comprises:

[0021] The calculation logic function of the custom operator is converted into a computation graph by means of the instant compiler in the code conversion module, and an optimizable part in the computation graph is determined.

[0022] The optimizable part is optimized by means of the code conversion module, and the optimized computation graph is converted by means of the computation graph converter in the instant compiler, to obtain the compiled function corresponding to the custom operator.

[0023] According to the application, the user module is further used to provide an operator registration interface for user calling.

[0024] The application further provides a brain simulation platform, which adopts the operator registration method of any one of the above brain simulation platforms for operator registration.

[0025] A user module is used to write a custom operator and description information of the custom operator by a user based on a high-level programming language.

[0026] A code conversion module is used to perform instant compilation conversion and encapsulation processing on the custom operator, to encapsulate the custom operator as a callback function of the underlying programming language of the brain simulation platform.

[0027] An operator registration module is used to register the callback function and the description information as a primitive in the framework of the brain simulation platform.

[0028] The application further provides an electronic device, which comprises a memory, a processor, and a computer program stored in the memory and capable of running on the processor, and the processor implements the operator registration method of any one of the above brain simulation platforms when executing the program.

[0029] The application further provides a non-transitory computer-readable storage medium, which stores a computer program, and the computer program is executed by a processor to implement the operator registration method of the brain simulation platform.

[0030] The application further provides a computer program product, which comprises a computer program, and the computer program is executed by a processor to implement the operator registration method of the brain simulation platform.

[0031] The brain simulation platform and the operator registration method, the device and the storage medium thereof provided by the application obtain a user-defined operator and description information of the user-defined operator written by the user in a high-level programming language through a user module, perform machine code conversion and encapsulation processing on the user-defined operator written by the user by using a code conversion module, encapsulate the user-defined operator into a callback function of a bottom programming language of the brain simulation platform, and register the description information and the callback function of the user-defined operator as primitives in a framework of the brain simulation platform based on an operator registration module, so as to complete registration of the user-defined operator. The automatic registration of the user-defined operator written by the user in the high-level programming language is implemented through the code conversion module and the operator registration module, without the need for the user to learn registration details and a compilation process in the framework of the brain simulation platform, so that the time consumed by the user in the operator registration and the compilation process is reduced, and the learning cost of the user in the registration of the user-defined operator is reduced. BRIEF DESCRIPTION OF DRAWINGS

[0032] In order to more clearly illustrate the technical solutions in the application or prior art, the following will briefly introduce the drawings needed in the embodiments or prior art description. Obviously, the drawings in the following description are some embodiments of the application, and for those skilled in the art, other drawings can be obtained without creative labor.

[0033] Figure 1 is a flowchart of the operator registration method of the brain simulation platform provided by the application;

[0034] Figure 2 is a structural schematic diagram of the brain simulation platform provided by the application;

[0035] Figure 3 is a structural schematic diagram of the electronic device provided by the application. DETAILED DESCRIPTION

[0036] In order to make the objects, technical solutions and advantages of the application clearer, the technical solutions in the application will be described clearly and completely in the following with reference to the drawings in the application. Obviously, the described embodiments are some embodiments of the application, but not all the embodiments. Based on the embodiments in the application, all other embodiments obtained by those skilled in the art without creative labor are within the protection scope of the application.

[0037] The application is described below Figures 1-3 The brain simulation platform and the operator registration method, device and storage medium thereof are described.

[0038] The operator registration method of the brain simulation platform provided by the application is applied to the brain simulation platform, and the brain simulation platform comprises a user module, a code conversion module and an operator registration module. Figure 1 , Figure 1 The flowchart of the operator registration method of the brain simulation platform provided by the application is based on Figure 1 The operator registration method of the brain simulation platform provided by the application comprises the following steps.

[0039] In step 100, the user module is used to obtain a custom operator written by a user based on a high-level programming language and description information of the custom operator.

[0040] In step 200, the code conversion module is used for instant compiling conversion and encapsulation processing of the custom operator, and the custom operator is encapsulated into a callback function of a bottom programming language of the brain simulation platform.

[0041] In step 300, the callback function and the description information are registered as primitives in the framework of the brain simulation platform based on the operator registration module.

[0042] Specifically, the operator registration method of the brain simulation platform provided by the embodiment of the present application is applied to a brain simulation platform (hereinafter referred to as a platform), which provides a user-defined operator mode of a brain dynamics general programming framework (hereinafter referred to as a framework), and allows a user to write the calculation logic of a user-defined operator and the description information of the user-defined operator based on a high-level programming language, such as Python, etc. A user module in the platform is mainly oriented to the user and realizes the interaction with the user. The user writes the user-defined operator and the description information of the user-defined operator in the user module by using the high-level programming language. A code conversion module in the platform converts the user-defined operator written by the user in the user module into a callback function of a programming language at the bottom layer of the platform. An operator registration module registers the callback function and the description information of the user-defined operator as a primitive in the framework, and completes the registration of the user-defined operator. Finally, the primitive of the user-defined operator obtained will be compiled into efficient machine code at the runtime, so that the user-defined operator written by using the high-level programming language can achieve the running speed of an operator written by using a low-level programming language.

[0043] The operator registration method of the brain simulation platform provided by the embodiment of the present application firstly acquires the user-defined operator written by the user by using the high-level programming language and the description information of the user-defined operator through the user module. Then, the code conversion module is used to convert the user-defined operator written by the user into a callback function of a programming language at the bottom layer of the platform. Finally, the callback function and the description information of the user-defined operator are registered as a primitive in the framework of the platform based on the operator registration module, and the registration of the user-defined operator is completed. When writing the user-defined operator, the user can use the high-level programming language without learning the programming language at the bottom layer of the platform, and does not need to pay attention to the design details in the programming framework of the platform and the operator registration process, thereby reducing the programming time consumed by the user in the registration and compilation process of the operator and reducing the learning cost of the user in the registration of the user-defined operator.

[0044] Preferably, the description information of the user-defined operator written by the user in the user module is mainly used to describe the shape information and the data type of the output of the operator, and includes the definition of the input and the output of the operator, and the description of the data type and the data layout supported by the operator, etc. When the input and the output of the operator are defined, the user can directly give the output information, or can infer the output information by using the shape information and the data type of the input parameter through the function, which is not limited here. Therefore, the description information of the user-defined operator mainly includes the input definition information of the operator, the output definition information, the data type and the data layout supported by the user-defined operator, etc.

[0045] For the user module, its main function is to implement the operator computing logic and discover the operator registration, wherein the internal logic of the operator registration is implemented by the underlying operator registration module, and the user module serves as an upper module for interacting with the user, and is used to provide an operator registration interface for the user to call. The user implements the computing logic of the custom operator in the user module, which can decouple the implementation process of the custom operator computing logic from the framework itself, and the specific reason is that the user does not need to understand the design details of the framework itself, nor needs to integrate the internal classes or call the internal methods in the framework, and can directly use a high-level programming language to write the operator to implement the computing logic of the operator. Moreover, the user module supports the user to arbitrarily name the custom operator when writing the custom operator; in the definition of the input and output of the custom operator, the limitation of the parameters is that the returned values of the operator contained in the output can be one or more, which allows the user to decouple the output into a custom output variable inside the function of the operator, and similarly, the parameters contained in the input of the custom operator can also be one or more, which also allows the user to decouple the input of the operator into a custom input parameter; and the user is also allowed to arbitrarily design the intermediate computing logic according to the custom input parameter and the output returned value.

[0046] Further, when the user calls the operator registration interface in the user module, the user needs to pass the information required by the operator registration to the operator registration module through the interface, and the information to be passed includes the operator name, the computing logic function of the operator, the description information of the operator and various transformations of the operator. Among them, the operator name is used for the user to call the operator, and various transformations of the operator are selectively provided by the user according to the design requirements of the user. For simple brain dynamics simulation, the user only needs to implement the basic version of the custom operator to efficiently complete the simulation task. The brain simulation platform provided in the embodiment is a general programming platform that integrates simulation and training, and the custom operator used for the training scene needs to implement some transformations, which include support for just-in-time (JIT) compilation, support for batch processing, support for forward differentiation and reverse differentiation, etc. Based on this, the custom operator written by the user includes an operator supporting JIT compilation, an operator supporting batch processing, an operator supporting forward differentiation and an operator supporting reverse differentiation. Correspondingly, the various transformations of the operator to be passed to the operator registration module include JIT compilation transformation, batch processing transformation, forward differentiation transformation and reverse differentiation transformation.

[0047] For the operators supporting JIT compilation, in order to support the operators to run successfully in JIT compilation and for other transformations, the platform framework needs to abstractly evaluate the shape information and types of the operators. The description information of the operators written by the user needs to include the shape and type of the output variable of the operator, and is wrapped using the abstract data type provided by the platform framework to obtain the description information of the operator required by the abstract evaluation. For the operators supporting batch processing, the batch processing transformation converts a point-to-point calculation into a vector calculation, and the user needs to give a transformation function supporting batch processing when writing a custom operator, and the framework internally registers the transformation function when registering the operator, so that the corresponding operator can support batch processing operation. For the operators supporting forward differentiation, forward differentiation is implemented in the form of Jacobian vector product (jvp), and the user needs to give a transformation function for evaluating the original output and its tangent when writing a custom operator, and the framework internally registers the transformation function when registering the operator, so that the corresponding operator can support forward differentiation operation. For the operators supporting reverse differentiation, the reverse differentiation is calculated by processing the jvp calculation in reverse, and for each operation in the tangent calculation, the operator will accumulate the cotangent of the variable used by the operation, and use the cotangent of the result of the operation, and the user needs to give a transformation function for evaluating the transpose of the primitive when writing a custom operator, and the framework internally registers the transformation function when registering the operator, so that the corresponding operator can support reverse differentiation operation.

[0048] Further, the code conversion module and the operator registration module in the platform both belong to the internal modules of the framework, wherein the code conversion module is provided with a just-in-time compiler and a conversion function, and the just-in-time compiler is a JIT compiler. The operator written by the user can select to use the JIT compiler in the code conversion module for decoration. The decorator accepts compilation parameters, and typical compilation parameters include but are not limited to: Nopython: whether to compile in the nopython mode; Fastmath: whether to perform fast mathematical optimization; Parallel: whether to use automatic parallelism; Nogil: whether to remove the gil lock of python, etc.

[0049] For the code conversion module, the input is the operator calculation logic function provided by the user module, which is a function written in a high-level programming language, such as a Python function. Taking the Python function as an example, the code conversion module compiles the function using a JIT compiler and passes the resulting compiled function into a conversion function to become a callback function in the programming language at the bottom of the framework. At this point, the operator function has become a callback function in the programming language at the bottom of the framework and is no longer a Python function. The code conversion module encapsulates the user-written custom operator as a callback function in the programming language at the bottom of the platform through machine code conversion and encapsulation processing. Taking C language as the programming language at the bottom of the framework, the code conversion module compiles the Python function using a JIT compiler to obtain a corresponding compiled function, and passes the compiled function into a conversion function to obtain a corresponding C callback function.

[0050] In step 200, the code conversion module is used to perform just-in-time compilation and encapsulation processing on the custom operator to encapsulate the custom operator as a callback function in the programming language at the bottom of the platform, including:

[0051] In step 201, a just-in-time compiler in the code conversion module is used to compile the calculation logic function of the custom operator to obtain a compiled function corresponding to the custom operator.

[0052] In step 202, a conversion function in the code conversion module is used to perform conversion and encapsulation processing on the compiled function to encapsulate the custom operator as a callback function in the programming language at the bottom of the brain simulation platform.

[0053] Specifically, first, the calculation logic function of the custom operator is compiled by a JIT compiler in the code conversion module to obtain a compiled function corresponding to the custom operator. Then, the conversion function is used to perform conversion and encapsulation processing on the compiled function to encapsulate the custom operator as a callback function in the programming language at the bottom of the platform.

[0054] Further, the JIT compiler includes a computation graph converter. In step 201, the calculation logic function of the custom operator is compiled by the JIT compiler to obtain a compiled function corresponding to the custom operator, which can further include:

[0055] In step 2011, the calculation logic function of the custom operator is converted into a computation graph by a just-in-time compiler in the code conversion module, and the optimizable part in the computation graph is determined.

[0056] In step 2022, the code conversion module is used to optimize the optimizable part, and a computation graph converter in the just-in-time compiler is used to convert the optimized computation graph to obtain a compiled function corresponding to the custom operator.

[0057] The JIT compilation mechanism based on the JIT compiler first converts the computing logic function of the operator into a computing graph, and optimizes the optimizable part in the computing graph, specifically, fusing a large number of fine-grained operations into a small number of coarse-grained special kernel functions. These kernel functions generate efficient binary code through compilation, which can reduce the memory allocation and context switching overhead of the computing graph during execution. After obtaining the computing graph optimized by JIT compilation, the computing graph is converted into a high-level optimization intermediate representation layer (HLO IR) through a computing graph converter. The intermediate representation layer (HLO IR) connects the front end and the back end of the JIT compiler. The front end of the JIT compiler parses the HLO and performs target-independent optimization, and then sends the HLO computation to the back end. The back end further performs target-specific optimization analysis, which is applicable to machine instructions of various architectures. After the back end of the compiler lowers the HLO to the intermediate representation (LLVM IR) of the underlying virtual machine, the underlying virtual machine LLVM is used for low-level intermediate representation (IR), optimization and code generation, to obtain the corresponding binary file, and perform binary code optimization, complete the compilation of the computing logic function of the custom operator, and obtain the corresponding compiled function.

[0058] The function of the conversion function in the code conversion module is to convert the compiled function into a callback function of the underlying programming language. Taking Python functions and C callback functions as an example, the input of the conversion function is a Python compiled function obtained through the JIT compiler, and the C language signature of the compiled function is required as a parameter, and a C callback function is returned. The C callback function exposes the compiled C callback address as an address attribute, so it can be passed to any other C or C++ library. Through the two-layer conversion of the code conversion module, the input Python operator computing logic function is converted into a C callback function, which is passed to the operator registration module as the output of the code conversion module.

[0059] Preferably, for the operator registration module, there are primitive abstraction information inference functions, primitive logic operation functions and primitive transformation dictionaries. Each type of transformation in the primitive transformation dictionary is stored in a dictionary data structure. In step 300, based on the operator registration module, the description information of the custom operator and the corresponding callback function are registered as primitives in the platform framework, specifically including:

[0060] In step 301, based on the operator registration module, the operator name of the custom operator is registered as the primary key of the operator registration table of the brain simulation platform; the primary key is used for table lookup and user calling;

[0061] At step 302, the description information is registered based on the primitive abstract information inference function; the callback function is registered based on the primitive logical operation function, and the implementation function of the operator transformation of the custom operator is registered as a dictionary value based on the primitive transformation dictionary, to obtain the primitives of the callback function and the description information inside the brain simulation platform framework.

[0062] Specifically, according to the operator description information provided by the user, the C callback function provided by the code conversion module and a series of operator transformations are written into the global operator table, the operator name is first given, the operator name is registered as the primary key in the operator registration table of the platform, and is used for table lookup and user call. Then the operator description information is registered based on the primitive abstract information inference function; the callback function is registered based on the primitive logical operation function, and the implementation function of the operator transformation of the custom operator is registered as a dictionary value of the primitive transformation dictionary, to obtain the primitives of the callback function and the operator description information inside the platform framework. Specifically, the operator description information is transmitted into the primitive abstract information inference function, and the description information is used to define the input, output of an operator, and information such as data types and data layout supported by the operator. The callback function is transmitted into the primitive logical operation function, and a series of operator transformations are transmitted into the corresponding transformation dictionary of the primitive. Each type of transformation in the primitive transformation dictionary is stored using a dictionary data structure, and the specific implementation function of the corresponding operator transformation is transmitted as a value into the primitive transformation dictionary when the operator transformation is registered, so that the operator registration is completed, and the primitives of the custom operator inside the platform framework are obtained. Finally, the operator registration module returns the registered primitives, which can be called as the custom operator of the user to realize the specific function required by the user.

[0063] The brain simulation platform provided in the embodiment allows the user to write a custom operator using a high-level programming language, realizes the calculation logic and registration of the operator, and does not need to learn a middle or low-level programming language or the registration details and compilation process of the platform framework, so that the brain simulation platform is simple and easy to use, and the learning cost of the user for registering the operator of the brain simulation platform can be reduced.

[0064] Further, the custom operator written by the user based on the brain simulation platform can run under JIT compilation, so that the operator written by the user using a high-level programming language can reach the running speed of a low-level language operator, and the operator is efficient.

[0065] The embodiment of the application also provides a brain simulation platform, which registers an operator by using the operator registration method of the brain simulation platform described in each of the above embodiments. Figure 2 The brain simulation platform provided in the embodiment is described below, and the brain simulation platform described below can be correspondingly referred to the operator registration method of the brain simulation platform described above.

[0066] Referring to Figure 2 The brain simulation platform provided by the embodiments of the present application comprises:

[0067] A user module 10 is configured to allow a user to write a custom operator based on a high-level programming language and description information of the custom operator.

[0068] A code conversion module 20 is configured to perform machine code conversion and encapsulation processing on the custom operator, and encapsulate the custom operator as a callback function of a bottom programming language of the brain simulation platform.

[0069] An operator registration module 30 is configured to register the callback function and the description information as a primitive inside a framework of the brain simulation platform.

[0070] In an embodiment, the description information comprises input definition information, output definition information, a data type supported by the custom operator, and a data layout.

[0071] In an embodiment, the operator registration module 30 is provided with a primitive abstraction information inference function, a primitive logical operation function, and a primitive transformation dictionary; each type of transformation in the primitive transformation dictionary is stored in a dictionary data structure.

[0072] The operator registration module 30 is further configured to:

[0073] register an operator name of the custom operator as a primary key of an operator registration table of the brain simulation platform; the primary key is used for table lookup and for user calling;

[0074] register the description information based on the primitive abstraction information inference function; register the callback function based on the primitive logical operation function, and register an implementation function of operator transformation of the custom operator as a dictionary value based on the primitive transformation dictionary, to obtain a primitive of the callback function and the description information inside the framework of the brain simulation platform.

[0075] In an embodiment, the custom operator comprises an operator supporting just-in-time compilation, an operator supporting batch processing, an operator supporting forward differentiation, and an operator supporting backward differentiation; the operator transformation comprises just-in-time compilation transformation, batch processing transformation, forward differentiation transformation, and backward differentiation transformation.

[0076] In an embodiment, the code conversion module 20 is provided with a just-in-time compiler and a conversion function.

[0077] The code conversion module 20 is further configured to:

[0078] compile a calculation logic function of the custom operator by using the just-in-time compiler to obtain a compilation function corresponding to the custom operator.

[0079] The conversion function is used to convert and encapsulate the compiled function, and the custom operator is encapsulated as a callback function of the underlying programming language of the brain simulation platform.

[0080] In one embodiment, the just-in-time compiler includes a computation graph converter, and the code conversion module 20 is further configured to:

[0081] Converting the computation logic function of the custom operator into a computation graph by the just-in-time compiler, and determining an optimizable portion in the computation graph;

[0082] The optimizable part is optimized, and the optimized computation graph is converted using a computation graph converter in the just-in-time compiler to obtain a compilation function corresponding to the custom operator.

[0083] In one embodiment, the user module 10 is further configured to provide an operator registration interface for user invocation.

[0084] Figure 3 An example of a physical structure diagram of an electronic device is shown below. Figure 3 As shown, the electronic device may include: a processor 310, a communication interface 320, a memory 330, and a communication bus 340, wherein the processor 310, the communication interface 320, and the memory 330 communicate with each other via the communication bus 340. The processor 310 may call the logic instructions in the memory 330 to execute the operator registration method of the brain simulation platform, which includes:

[0085] Obtaining, through the user module, a custom operator written by the user in a high-level programming language, as well as description information of the custom operator;

[0086] Using a code conversion module to perform real-time compilation conversion and encapsulation processing on the custom operator, encapsulating the custom operator into a callback of the underlying programming language of the brain simulation platform;

[0087] Based on the operator registration module, the callback and the description information are registered as primitives within the brain simulation platform framework.

[0088] In addition, the logic instructions in the memory 330 described above can be implemented in the form of a software function unit and sold or used as an independent product, and can be stored in a computer readable storage medium. Based on such understanding, the technical solutions of the present application essentially or the parts that contribute to the prior art or parts of the technical solutions can be embodied in the form of a software product. The computer software product is stored in a storage medium, and includes a plurality of instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present application. The aforementioned storage medium includes: a U disk, a mobile hard disk, a read-only memory (ROM, Read-Only Memory), a random access memory (RAM, Random Access Memory), a magnetic disk or an optical disk, and various media that can store program codes.

[0089] In another aspect, the present application also provides a computer program product, which comprises a computer program, the computer program can be stored on a non-transitory computer readable storage medium, and the computer program can be executed by a processor to enable a computer to perform the operator registration method of the brain simulation platform provided by the above-mentioned methods, and the method comprises:

[0090] obtaining a custom operator written by a user based on a high-level programming language and description information of the custom operator through a user module;

[0091] performing instant compilation conversion and encapsulation processing on the custom operator by using a code conversion module, and encapsulating the custom operator as a callback of a bottom programming language of the brain simulation platform;

[0092] registering the callback and the description information as primitives inside a framework of the brain simulation platform based on an operator registration module.

[0093] In another aspect, the present application also provides a non-transitory computer readable storage medium, which stores a computer program, and the computer program is executed by a processor to implement the operator registration method of the brain simulation platform provided by the above-mentioned methods, and the method comprises:

[0094] obtaining a custom operator written by a user based on a high-level programming language and description information of the custom operator through a user module;

[0095] performing instant compilation conversion and encapsulation processing on the custom operator by using a code conversion module, and encapsulating the custom operator as a callback of a bottom programming language of the brain simulation platform;

[0096] registering the callback and the description information as primitives inside a framework of the brain simulation platform based on an operator registration module.

[0097] The device embodiments described above are merely illustrative, wherein the units described as separate components can or can not be physically separate, and the components displayed as units can or can not be physical units, i.e., can be located in one place, or can be distributed to multiple network units. Part or all of the modules can be selected to achieve the purposes of the embodiments according to actual needs. Those skilled in the art can understand and implement without creative labor.

[0098] Through the description of the above embodiments, those skilled in the art can clearly understand that the embodiments can be realized by means of software and the necessary universal hardware platform, and of course can also be realized by hardware. Based on such understanding, the above technical solutions can be embodied in the form of a software product, which can be stored in a computer readable storage medium, such as a ROM / RAM, a magnetic disk, an optical disk, etc., and includes a plurality of instructions to make a computer device (which can be a personal computer, a server, or a network device, etc.) execute the methods described in each embodiment or some parts of the embodiments.

[0099] Finally, it should be noted that: the above embodiments are only used to illustrate the technical solutions of the present application, and not to limit them; although the present application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that: it can still modify the technical solutions recorded in the foregoing embodiments, or make equivalent replacement to part of the technical features; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present application.

Claims

1. A method for registering an operator for a brain simulation platform, characterized in that: The brain simulation platform includes a user module, a code conversion module and an operator registration module, and the method includes: Obtaining, through the user module, a custom operator written by the user in a high-level programming language, and description information of the custom operator; Using the code conversion module to perform real-time compilation conversion and encapsulation processing on the custom operator, the custom operator is encapsulated as a callback function of the underlying programming language of the brain simulation platform; Based on the operator registration module, the callback function and the description information are registered as primitives within the brain simulation platform framework, The operator registration module is provided with a primitive abstract information inference function, a primitive logic operation function and a primitive transformation dictionary; each type of transformation in the primitive transformation dictionary is stored in a dictionary data structure; The registering of the callback function and the description information as primitives within the brain simulation platform framework based on the operator registration module includes: Based on the operator registration module, the operator name of the custom operator is registered as the primary key of the operator registration table of the brain simulation platform; the primary key is used for search in the table and for user call; The description information is registered based on the primitive abstract information inference function; the callback function is registered based on the primitive logical operation function, and the implementation function of the operator transformation of the custom operator is registered as a dictionary value based on the primitive transformation dictionary to obtain the callback function and the description information in the primitive within the brain simulation platform framework.

2. The operator registration method for a brain simulation platform according to claim 1, characterized in that: The description information includes input definition information, output definition information, data types supported by the custom operator, and data layout.

3. The operator registration method for a brain simulation platform according to claim 1, characterized in that: The custom operators include operators supporting just-in-time compilation, operators supporting batch processing, operators supporting forward differentiation and operators supporting reverse differentiation; the operator transformations include just-in-time compilation transformation, batch processing transformation, forward differentiation transformation and reverse differentiation transformation.

4. The operator registration method for a brain simulation platform according to claim 1, characterized in that: The code conversion module is provided with a real-time compiler and a conversion function; The method of using the code conversion module to perform real-time compilation, conversion, and encapsulation processing on the custom operator, and encapsulating the custom operator into a callback function of the underlying programming language of the brain simulation platform, includes: Compiling the calculation logic function of the custom operator through the just-in-time compiler in the code conversion module to obtain a compiled function corresponding to the custom operator; The compiled function is converted and encapsulated using the conversion function in the code conversion module, and the custom operator is encapsulated as a callback function of the underlying programming language of the brain simulation platform.

5. The operator registration method for a brain simulation platform according to claim 4, characterized in that: The just-in-time compiler includes a computation graph converter; The step of compiling the calculation logic function of the custom operator by the just-in-time compiler in the code conversion module to obtain a compiled function corresponding to the custom operator includes: Converting the computation logic function of the custom operator into a computation graph through a just-in-time compiler in the code conversion module, and determining an optimizable portion in the computation graph; The optimizable part is optimized using the code conversion module, and the optimized calculation graph is converted using the calculation graph converter in the just-in-time compiler to obtain a compilation function corresponding to the custom operator.

6. The operator registration method for a brain simulation platform according to claim 1, characterized in that: The user module is also used to provide an operator registration interface for users to call.

7. A brain simulation platform, characterized in that: Operator registration is performed using the operator registration method for a brain simulation platform according to any one of claims 1 to 6, wherein the brain simulation platform comprises: A user module is used for users to write custom operators based on high-level programming languages, as well as description information of the custom operators; A code conversion module, configured to perform real-time compilation, conversion, and packaging processing on the custom operator, and encapsulate the custom operator into a callback function of the underlying programming language of the brain simulation platform; An operator registration module is used to register the callback function and the description information as primitives within the brain simulation platform framework.

8. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the program, the operator registration method for the brain simulation platform according to any one of claims 1 to 6 is implemented.

9. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the operator registration method of the brain simulation platform according to any one of claims 1 to 6 is implemented.

Citation Information

Patent Citations

  • Method and device for generating real-time calculation logic data

    CN113515285A

  • Operator calling system, operator generating method and electronic equipment

    CN115309562A