A general-purpose programming system and methodology for brain dynamics based on just-in-time compilation

CN115809049BActive Publication Date: 2026-08-14BEIJING CHANGSHENG INTELLIGENT TECHNOLOGY CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-11-18
Publication Date
2026-08-14

AI Technical Summary

Technical Problem

[0006]本发明提供一种基于即时编译的脑动力学通用编程系统,用以解决现有技术中脑动力学编程方案存在的通用性较差的技术问题

Benefits of technology

[0033]本发明提供的一种基于即时编译的脑动力学通用编程系统,前端编程层根据输入的计算图构建指令,调用预设的多个计算图构建模块中的至少一个,以构建脑动力学模型对应的计算图;后端编译层用于接收输入的脑动力学模型对应的编译指令,以调用预设的不同功能的代码编译模块中的至少一个,根据构建的计算图进行代码编译,得到脑动力学模型的二进制机器码。因此,本发明的计算图构建过程更加灵活,不受描述性语言的限制,使得本发明的编程系统的通用性较强。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115809049B_ABST
    Figure CN115809049B_ABST
Patent Text Reader

Abstract

This invention relates to the field of computer technology, and more particularly to a general-purpose brain dynamics programming system and method based on just-in-time (JIT) compilation. The programming system includes a front-end programming layer and a back-end compilation layer. The front-end programming layer includes multiple preset computational graph construction modules, and the back-end compilation layer includes preset code compilation modules with different functions. The front-end programming layer, based on input computational graph construction instructions, calls at least one of the preset computational graph construction modules to construct the computational graph corresponding to the brain dynamics model. The back-end compilation layer receives input compilation instructions corresponding to the brain dynamics model, calls at least one of the preset code compilation modules with different functions, and compiles the code based on the constructed computational graph to obtain the binary machine code of the brain dynamics model on the target device. The brain dynamics programming method provided by this invention is simple to use, flexible, efficient, and not limited by descriptive languages, making the programming system of this invention highly versatile.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of computer technology, and in particular to a general programming system and method for brain dynamics based on just-in-time compilation. Background Technology

[0002] Brain dynamics modeling has become a fundamental tool for understanding how the brain works and a key pathway to inspiring the development of next-generation artificial intelligence, and is now a foundational discipline for brain science and AI development. The development of any discipline is inseparable from the advancement of tools. Taking Artificial Intelligence (AI) as an example, the rapid development of AI in this round has largely benefited from the widespread adoption of deep learning frameworks. Deep learning frameworks have become the infrastructure of AI research because they provide a universal programming interface that allows researchers to flexibly and efficiently define various AI models across different application areas. However, the field of brain dynamics modeling has long lacked a similar, user-friendly, flexible, and efficient universal brain dynamics programming framework. However, with the increasing generation of massive amounts of neural data, the growing complexity of model simulations, and the increasing diversity of modeling methods, approaches, and objectives, we have a more urgent need than ever before to develop universal modeling tools to help us easily build, simulate, train, and analyze multi-scale and large-scale brain dynamics models.

[0003] Achieving general-purpose neurodynamic programming is inherently difficult due to numerous significant differences between neurodynamic models and deep learning models. First, neurodynamic models generally have low computational density. For example, the classic Leaky Integrate-and-Fire (LIF) model relies heavily on memory-intensive operators such as addition, subtraction, multiplication, and division. Computationally intensive operators frequently used in deep learning models and capable of significantly improving device efficiency, such as convolution and matrix multiplication, are rarely seen. This means that applying purely computation graph-based deep learning frameworks to neurodynamic programming incurs substantial computationally irrelevant overhead, as operator activation and data transfer make this overhead significant. Second, another fundamental difference between neurodynamic models and deep learning models is the event-driven and sparsely connected nature of the former. For instance, neurons typically connect with each other with less than a 20% probability; under this sparse connection, the evolution of the state of postsynaptic neurons and synapses is usually triggered by some neural event (such as a presynaptic impulse). This characteristic makes it difficult for traditional deep learning operators to achieve optimal computational performance in brain dynamics models. Therefore, we need brain dynamics-specific operators designed specifically for sparse and event-driven characteristics.

[0004] Current brain dynamics programming solutions still fail to provide users with a truly universal brain dynamics programming framework. Existing frameworks include NEURON, NEST, Brian2, NetPyNE, and BMTK. NEURON, developed by Yale University, is a programming software for detailed neuronal simulation; NEST, developed by the EU Brain Project, is a programming software for large-scale neurodynamics simulation; Brian2, developed by the École Normale Supérieure in Paris, is a lightweight neurodynamics simulation software; NetPyNE is a descriptive language framework based on NEURON, capable of generating NEURON code from user-described models using dictionaries, lists, etc.; BMTK, developed by the Allen Institute for Brain Research, is a descriptive language programming framework based on NEURON and NEST, capable of generating code for NEURON and NEST from user model descriptions. Generally speaking, these brain dynamics programming software programs fall into two main categories: low-level programming languages ​​and descriptive programming languages. NEURON and NEST are representative of "low-level programming languages," both written in C++ and containing numerous built-in programming models. Meanwhile, a Python interface is provided on the user interface, allowing users to call predefined built-in models via Python. The drawback of this approach is its lack of flexibility; once users need to customize the dynamics model, they must learn low-level programming languages ​​such as C++ / SLI / Hoc. Therefore, the learning cost for users is high, and it severely limits the flexibility of model customization. The second programming paradigm, "descriptive programming languages," is represented by Brian2, NetPyNE, and BMTK. This type of software has inherent limitations in terms of transparency, scalability, and flexibility. For example, it cannot be executed directly, and model debugging, error correction, and direct logic control are impossible. Furthermore, descriptive languages ​​are usually designed for specific types of models or specific modeling methods. Once they fail to meet new user needs, users must program simultaneously in both high-level and low-level languages ​​to extend them, which is almost impossible for ordinary users. Therefore, their versatility is poor, and the need for simultaneous programming in both high-level and low-level languages ​​reduces the efficiency of system programming. In addition, descriptive languages ​​significantly reduce the expressive power of general-purpose programming languages.

[0005] Therefore, existing brain dynamics programming schemes still suffer from poor versatility and low programming efficiency. Summary of the Invention

[0006] This invention provides a general-purpose brain dynamics programming system based on just-in-time compilation, which solves the technical problem of poor universality in existing brain dynamics programming schemes.

[0007] A general-purpose programming system for brain dynamics based on just-in-time compilation includes: a front-end programming layer and a back-end compilation layer. The front-end programming layer includes multiple preset computation graph construction modules, and the back-end compilation layer includes preset code compilation modules with different functions.

[0008] The front-end programming layer is used to receive the input computational graph construction instructions corresponding to the brain dynamics model to be constructed, and to call at least one of the preset multiple computational graph construction modules according to the computational graph construction instructions, and to run the called computational graph construction module to obtain the computational graph corresponding to the brain dynamics model.

[0009] The backend compilation layer is used to receive the compilation instructions corresponding to the input brain dynamics model, and to call at least one of the preset code compilation modules with different functions. The called code compilation module is used to compile the code according to the computation graph to obtain the binary machine code of the brain dynamics model on the target device.

[0010] According to the present invention, a general programming system for brain dynamics based on just-in-time compilation is provided, wherein the computation graph construction module includes at least one of an operator module, a tool module, and a brain dynamics model module; the operator module, tool module, and brain dynamics model module are each pre-configured with different computation graph construction operators;

[0011] The computation graph construction instructions include computation graph construction module selection instructions and model construction parameters;

[0012] The front-end programming layer is used to call at least one of the operator module, tool module and brain dynamics model module according to the selection instruction of the computation graph construction module. The called module is used to construct operators according to the model construction parameters and the computation graph to obtain the computation graph corresponding to the brain dynamics model.

[0013] According to the present invention, a general-purpose brain dynamics programming system based on just-in-time compilation is provided, wherein the operator module includes at least one of the following:

[0014] Dense matrix operator module, sparse matrix operator module, event-driven operator module, automatic differentiation module.

[0015] According to the present invention, a general-purpose brain dynamics programming system based on just-in-time compilation is provided, wherein the tool module includes at least one of the following:

[0016] The system includes modules for solving Ordinary Differential Equations (ODE), Stochastic Differential Equations (SDE), Delayed Differential Equations (DDE), Fractional Differential Equations (FDE), Synaptic Connections, and Weight Initialization.

[0017] According to the present invention, a general programming system for brain dynamics based on just-in-time compilation is provided, wherein the brain dynamics model module includes at least one of a computational neuroscience model module and a brain-like intelligent computing model module.

[0018] According to the present invention, a general programming system for brain dynamics based on just-in-time compilation is provided, wherein the front-end programming layer further includes an operator custom interface module and a model custom interface module;

[0019] The operator customization interface module is used to receive input customized operator information in order to generate the corresponding operator module;

[0020] The model customization interface module is used to receive input customized model information to generate the corresponding brain dynamics model module.

[0021] According to the present invention, a general programming system for brain dynamics based on just-in-time compilation is provided, wherein the code compilation module includes at least one of a just-in-time compilation module, an automatic parallelization module, and an automatic vectorization module;

[0022] The compilation instructions include compilation method selection instructions and the target device for applying the brain dynamics model;

[0023] The backend compilation layer is used to select at least one of the just-in-time compilation module, the automatic parallelization module, and the automatic vectorization module according to the selected compilation method; the selected module is used to generate binary machine code for the brain dynamics model applicable to the target device according to the target device to which the brain dynamics model is applied.

[0024] According to the present invention, a general programming system for brain dynamics based on just-in-time compilation is provided. The just-in-time compilation module is used to perform target device-independent compilation analysis and optimization on the brain dynamics model according to a preset optimization strategy, and to perform device-dependent compilation analysis and optimization according to the target device, and generate binary machine code suitable for the target device.

[0025] The automatic parallelization module is used to simultaneously generate binary machine code for brain dynamics models applicable to multiple target devices based on the target devices to which the brain dynamics model is applied.

[0026] The automatic vectorization module is used to generate binary machine code suitable for the brain dynamics model of the target device using a single instruction stream and multiple data streams in parallel.

[0027] According to the present invention, a general programming system for brain dynamics based on just-in-time compilation is provided, wherein the back-end compilation layer further includes a computation graph conversion module;

[0028] The computation graph conversion module is used to convert the computation graph corresponding to the brain dynamics model into an intermediate expression that is independent of programming language. The called code compilation module is used to compile the code according to the intermediate expression to obtain the binary machine code of the brain dynamics model.

[0029] On the other hand, the present invention also provides a programming method based on a general brain dynamics programming system, the general brain dynamics programming system comprising: a front-end programming layer and a back-end compilation layer, the front-end programming layer comprising a plurality of preset computation graph construction modules, and the back-end compilation layer comprising preset code compilation modules with different functions;

[0030] The programming method includes:

[0031] The front-end programming layer receives the computational graph construction instruction corresponding to the brain dynamics model to be constructed, and calls at least one of the preset multiple computational graph construction modules according to the computational graph construction instruction, and runs the called computational graph construction module to obtain the computational graph corresponding to the brain dynamics model.

[0032] The backend compilation layer receives the compilation instructions corresponding to the input brain dynamics model, and calls at least one of the preset code compilation modules with different functions. The called code compilation module is used to compile the code according to the computation graph to obtain the binary machine code of the brain dynamics model.

[0033] This invention provides a general-purpose brain dynamics programming system based on just-in-time compilation. The front-end programming layer, based on input computational graph construction instructions, calls at least one of a plurality of preset computational graph construction modules to construct the computational graph corresponding to the brain dynamics model. The back-end compilation layer receives the input compilation instructions corresponding to the brain dynamics model and calls at least one of preset code compilation modules with different functions to compile the code based on the constructed computational graph, obtaining the binary machine code of the brain dynamics model. Therefore, the computational graph construction process of this invention is more flexible and not limited by descriptive languages, making the programming system of this invention highly versatile.

[0034] In addition, the general programming system for brain dynamics based on just-in-time compilation of the present invention has multiple pre-set computation graph construction modules and code compilation modules with mature functions. During the computation graph construction process and the code compilation process, the corresponding modules can be called and executed according to the instructions, which improves the generation efficiency of brain dynamics model code. Attached Figure Description

[0035] To more clearly illustrate the technical solutions in this invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.

[0036] Figure 1 This is a schematic diagram of the structure of the general programming system for brain dynamics provided by the present invention;

[0037] Figure 2 This is a schematic diagram of the operator module provided by the present invention;

[0038] Figure 3 This is a schematic diagram of the structure of the tool module provided by the present invention;

[0039] Figure 4 This is a schematic diagram of the brain dynamics model module provided by the present invention;

[0040] Figure 5 This is a schematic diagram of a calculation graph provided by the present invention;

[0041] Figure 6 This is a flowchart illustrating the operation of the programming system provided by the present invention;

[0042] Figure 7 This is a flowchart of the general programming method for brain dynamics provided by the present invention. Detailed Implementation

[0043] To make the objectives, technical solutions, and advantages of this invention clearer, the technical solutions of this invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this invention. All other embodiments obtained by those skilled in the art based on the embodiments of this invention without creative effort are within the scope of protection of this invention.

[0044] This invention provides a general-purpose brain dynamics programming system based on just-in-time (JIT) compilation. The system includes a front-end programming layer and a back-end compilation layer. The front-end programming layer includes multiple pre-defined computational graph construction modules, and the back-end compilation layer includes pre-defined code compilation modules with different functions. Based on different brain dynamics models to be built, different required computational graph construction modules are invoked to construct the corresponding computational graph (i.e., computer graph). Then, according to different compilation requirements, the corresponding code compilation modules are invoked to quickly generate the code for the brain dynamics model. The computational graph construction process of this invention is more flexible, making the programming system more versatile. During the computational graph construction and code compilation processes, the corresponding modules can be executed according to instructions, improving the efficiency of brain dynamics model code generation.

[0045] Example 1:

[0046] This embodiment provides a general-purpose programming system for brain dynamics based on just-in-time compilation, such as... Figure 1 The programming system includes a front-end programming layer 10 and a back-end compilation layer 20. The front-end programming layer 10 includes multiple preset computation graph construction modules, and the back-end compilation layer 20 includes preset code compilation modules with different functions.

[0047] The front-end programming layer 10 receives input computational graph construction instructions corresponding to the brain dynamics model to be constructed, and calls at least one of a plurality of preset computational graph construction modules according to the computational graph construction instructions, and runs the called computational graph construction module to obtain the computational graph corresponding to the brain dynamics model. The back-end compilation layer 20 receives input compilation instructions corresponding to the brain dynamics model, and calls at least one of preset code compilation modules with different functions. The called code compilation module is used to compile the code according to the computational graph to obtain the binary machine code of the brain dynamics model on the target device.

[0048] The computation graph construction process in this embodiment is more flexible, making the programming system of the present invention more versatile; it can be implemented by calling the corresponding module according to the instructions during the computation graph construction process and the code compilation process, thereby improving the generation efficiency of brain dynamics model code.

[0049] According to the system of this embodiment, the user provides a brain dynamics model equation, and firstly, based on the front-end programming layer 10, relevant operators, tools, and models are combined to form a programming implementation of the model. This programming implementation actually defines a computational flow graph, and based on this computational flow graph, back-end compilation tools are used to perform compilation optimization, code generation, and hardware deployment on the computational graph.

[0050] The computational graph construction module includes at least one of an operator module 101, a tool module 102, and a brain dynamics model module 103; different computational graph construction operators are preset in the operator module 101, the tool module 102, and the brain dynamics model module 103.

[0051] Generally, a computational graph construction module includes any one of the operator module 101, tool module 102, and brain dynamics model module 103. In other words, a computational graph construction module can be considered as an operator module 101, or a computational graph construction module can also be considered as a tool module 102 or a brain dynamics model module 103.

[0052] In this embodiment, the computational graph construction instruction includes a computational graph construction module selection instruction and model construction parameters. The front-end programming layer 10 is used to call at least one of the operator module, tool module, and brain dynamics model module according to the computational graph construction module selection instruction. The called module is used to construct operators based on the model construction parameters and the computational graph to obtain the computational graph corresponding to the brain dynamics model.

[0053] like Figure 7 This is a schematic diagram of the programming flow of the programming system in this embodiment. Wherein, as... Figure 2 The operator module in this embodiment includes at least one of the following: a dense matrix operator module, a sparse matrix operator module, an event-driven operator module, and an automatic differentiation module. Specifically, in this embodiment, one operator module can be understood as including one type of operator, while this embodiment includes multiple such operators. Figure 2 The different types of operator modules shown are used to implement different operator operations.

[0054] Neurodynamic programming often involves traditional dense matrix-related computational operators, such as addition, subtraction, multiplication, division, and exponentiation, as well as specialized operators, such as sparse matrix-related operators and event-driven computation operators. This invention provides comprehensive operator support for this characteristic of neurodynamic programming.

[0055] To ensure the integrity of traditional scientific computing logic, the system's operator module provides numerous programming operators for dense matrix computations, including common array operations, trigonometric functions, arithmetic functions, statistical functions, sorting functions, linear algebra functions, random sampling functions, Fourier transform functions, and so on. These programming operators are already widely used in existing scientific computing frameworks, and their implementation can be referenced from mature scientific computing frameworks.

[0056] To address the sparse connectivity characteristic of brain dynamics models, the operator module of this system provides sparse matrix-related operator operations, including sparse matrix multiplication and element-wise operations.

[0057] Given the event-driven nature of brain dynamics models, the operator module of this system provides operator operations for event-driven computation, such as the calculation of postsynaptic neurons driven by the spiking events of presynaptic neurons, matrix addition and multiplication operations under sparse neuronal connections, etc.

[0058] For numerical optimization in brain dynamics modeling involving the first or second derivative of functions, the operator module of this system provides automatic differentiation support for the above operators, implementing the corresponding differential function for each operator.

[0059] This system's operator module not only provides the numerous operator operations mentioned above, but also supports user-defined operators. In particular, the system offers a simple and flexible operator customization interface module, enabling users to directly define basic operators using high-level programming languages ​​(such as Python). Users do not need to use low-level languages ​​for operator customization, which greatly reduces the learning cost for users.

[0060] Among them, such as Figure 2 The tool modules in this embodiment include at least one of the following: an ODE solving tool module, an SDE solving tool module, a DDE solving tool module, an FDE solving tool module, a synaptic connection tool module, a weight initialization tool module, and a numerical optimizer module. Specifically, in this embodiment, one tool module can be understood to include, for example, the following: Figure 3 The tool module shown in this embodiment includes multiple such modules. Figure 3 The different types of tool modules shown.

[0061] Neurodynamic programming typically involves numerically solving various differential equations, synaptic connections, initializing synaptic weights, and using numerical optimizers. This system provides a library of commonly used neurodynamic programming tools based on the aforementioned operator operations.

[0062] The tool module of this system provides general numerical integration methods for ordinary differential equations (ODEs) commonly used in brain dynamics programming, including explicit Runge-Kutta methods, adaptive Runge-Kutta methods, implicit Runge-Kutta methods, and exponential integration methods.

[0063] The tool module of this system provides general numerical integration methods for stochastic differential equations (SDEs) commonly used in brain dynamics programming, supports numerical integration of Ito-type and Stranonovich-type differential equations, and supports numerical integration of differential equations with high-dimensional Wiener stochastic processes.

[0064] The tool module of this system provides general numerical integration methods for fractional differential equations (FDEs), supporting numerical integration of Caputo fractional, Grünwald-Letnikov fractional, and Riemann-Liouville fractional differential equations.

[0065] The system's tool module provides general numerical integration methods for Delay Differential Equations (DDEs), commonly used in brain dynamics programming. Specifically, it supports numerical integration of delay ordinary differential equations, delay stochastic differential equations, and delay fractional differential equations. For various differential equations, it supports numerical integration of constant delays, state-dependent delays, and neutral delays.

[0066] The system's tool module provides commonly used synaptic connection methods for brain dynamics programming, including regular connection methods (such as one-to-one connections, full connections, grid connections, etc.), random connection methods (such as fixed probability connections, fixed number of presynaptic connections, fixed number of postsynaptic connections, Gaussian probability connections, probabilistic distance connections, small-world network connections, scale-free connections, double-superior scale-free connections, power-law connections, etc.), and supports user-defined connections.

[0067] The system's tool modules provide commonly used weight initialization methods for brain dynamics programming, including regular initialization (such as constant initialization, identity matrix initialization, etc.), random initialization (such as normal distribution initialization, uniform distribution initialization, truncated normal distribution initialization, orthogonal matrix initialization, LeCun uniform initialization, LeCun normal distribution initialization, Glorot normal distribution initialization, Glorot uniform distribution initialization, He normal distribution initialization, He uniform variance scaling initialization, etc.), and decay initialization methods (such as Gaussian decay initialization, Gaussian difference decay initialization, etc.).

[0068] The system's tool module provides commonly used numerical optimizers for brain dynamics programming, including stochastic gradient descent optimizer, RMSProp optimizer, Adagrad optimizer, Adadelta optimizer, Adam optimizer, and Adamax optimizer.

[0069] Among them, such as Figure 4 The brain dynamics model module 103 in this embodiment includes at least one of a computational neuroscience model module and a brain-like intelligent computing model module. Specifically, this embodiment includes two brain dynamics model modules, namely a computational neuroscience model module and a brain-like intelligent computing model module.

[0070] Brain dynamics modeling has yielded several classic neural computational models at various levels, including neuron models, synapse models, and network models. This system provides numerous classic neural computational models in its brain dynamics model module.

[0071] In one embodiment, the system's neurodynamics model module provides numerous classic models in computational neuroscience, including classic neuron models such as the Hodgkin-Huxley (HH) neuron model, the Leaky Integrate-and-Fire (LIF) neuron model, the Quadratic Integrate-and-Fire (QIF) neuron model, the Exponential Integrate-and-Fire (ExpIF) model, the Adaptive Exponential Integrate-and-Fire (AdEx) model, the Izhikevich neuron model, the Hindmarsh-Rose neuron model, the Generalized Integrate-and-Fire (GIF) model, and so on; and classic synaptic models such as the Voltage-Jump synaptic model, the Exponential Decay synaptic model, the Alpha function synaptic model, and the Dual Exponential... The synaptic models include Decay, AMPA, GABAA, NMDA, GABAB, electrical synaptic models, short-term plasticity synaptic models, and long-term plasticity synaptic models.

[0072] In one embodiment, the brain dynamics model module of this system provides many classic models in the field of brain-like computing, including the continuous attractor neural network model, the decision making network model, the excitation / inhibition balanced network model, and the reservoir computing model.

[0073] In this embodiment, if the equations corresponding to the brain dynamics model to be constructed have already been implemented in an existing model library (including "computational neuroscience model" and "brain-like intelligent computing model"), then the implementation of the existing standard model is directly called, that is, the computational neuroscience model module and the brain-like intelligent computing model module are directly called. If the equations of the brain dynamics model to be constructed can be decomposed into a combination of standard models in the existing model library, then the models in the existing model library are directly combined and stacked to implement the model equations specified by the user. If the equations of the brain dynamics model to be constructed are non-standard models and cannot be completely formed by combining standard models, then the parts that can be decomposed into standard models are still implemented by calling the standard models, and the non-standard model parts are implemented using operators and tools in "Front-end Programming Layer 10". For example, ordinary differential equations, stochastic differential equations, etc. in the model can be implemented using "ODE solver" and "SDE solver", event-driven updates in the model can be implemented using "event-driven operators", and operations related to dense matrices and sparse matrices in the model can be implemented using "dense matrix operators" and "sparse matrix operators".

[0074] In one embodiment, the front-end programming layer 10 further includes an operator customization interface module and a model customization interface module. The operator customization interface module is used to receive input custom operator information to generate corresponding operator modules. The system's tool modules not only provide the aforementioned rich tool library but also support user-defined tool libraries. In particular, users can freely combine the operator modules provided by the system to program their desired tool libraries.

[0075] The model customization interface module receives custom model information as input to generate corresponding brain dynamics model modules. For example, this system's model customization interface module provides a "DynamicalSystem" interface for defining arbitrary brain dynamics models. The "DynamicalSystem" interface offers modular and composable programming paradigms to help users implement brain dynamics models at any level.

[0076] The computation graph provides a bridge connecting the front-end programming layer 10 and the back-end compilation layer 20. It is the output of the front-end programming layer and the input of the back-end compilation layer. The computation graph is a directed graph composed of operators, where each node is either an input value or corresponds to a mathematical operation defined by that operator. Each execution of a brain dynamics model corresponds to a computation graph. For example... Figure 5 A typical integral leakage model is provided. The computational graph.

[0077] Among them, the backend compilation layer 20 provides the compilation, running and deployment of the brain dynamics model.

[0078] like Figure 1In this embodiment, the code compilation module includes at least one of a just-in-time (JIT) compilation module, an automatic parallelization module, and an automatic vectorization module. Specifically, this embodiment includes three code compilation modules: a JIT compilation module, an automatic parallelization module, and an automatic vectorization module.

[0079] In this embodiment, the backend compilation layer 20 receives compilation instructions including compilation method selection instructions and the target device for the brain dynamics model application. Common target devices typically include CPUs (Central Processing Units), GPUs (Graphics Processing Units), and TPUs (Tensor Processing Units).

[0080] The backend compilation layer 20 is used to select at least one of the following modules based on the selected compilation method: just-in-time compilation module, automatic parallelization module, and automatic vectorization module; the selected module is used to generate code for the brain dynamics model applicable to the target device based on the target device for which the brain dynamics model is applied.

[0081] The just-in-time compilation module 201 is used to perform target device-independent compilation analysis and optimization on the brain dynamics model according to a preset optimization strategy, and to perform device-dependent compilation analysis and optimization according to the target device, and generate binary machine code suitable for the target device.

[0082] The automatic parallelization module 202 is used to simultaneously generate binary machine code for brain dynamics models applicable to multiple target devices based on the target devices for which the brain dynamics model is applied.

[0083] The automatic vectorization module 203 is used to generate binary machine code suitable for the brain dynamics model of the target device in a single instruction stream and multiple data stream parallel manner.

[0084] Specifically, the just-in-time (JIT) compilation module 201 of this system provides various device-independent analysis and optimization processes, including Static Single Assignment (SSA), Common Subexpression Elimination (CSE), Dead Code Elimination (DCE), device-independent operator fusion, and buffer analysis for allocating runtime memory for computation. Among these, the JIT compilation module provides various device-dependent analysis and optimization processes, including operator fusion that benefits GPU computing, computational flow partitioning, and operation matching suitable for calling optimization libraries.

[0085] The automatic parallelization module 202 provided by this system offers the capability for single-instruction-stream multiple-data-stream (SIMD) data parallel processing across multiple devices. The compilation process on each device is consistent with the just-in-time (JIT) compilation process on a single device.

[0086] The automatic vectorization module 203 provided by this system offers the capability for single-instruction-stream, multi-data-stream parallel data processing on a single device. It identifies the vector-executable portions of intermediate expressions and automatically converts scalar statements into corresponding SIMD vector statements. Therefore, data that previously required multiple loading operations is now loaded into the vector register at once, thereby improving throughput.

[0087] In one embodiment, the backend compilation layer 20 further includes a computation graph conversion module 204. The computation graph conversion module 204 converts the computation graph corresponding to the brain dynamics model into a programming language-independent intermediate expression. The code compilation module invoked then compiles the code based on the intermediate expression to obtain the code for the brain dynamics model. In other words, after the backend compilation layer of this system obtains the computation graph, the computation graph conversion module 204 first converts the computation graph into an intermediate expression. The intermediate expression is a low-level form independent of programming languages, close to machine code. It has a compact structure, contains control flow information, and is more suitable for static analysis. The intermediate expressions provided by this system support control flow information.

[0088] The backend compilation layer 20 provided by this embodiment offers just-in-time (JIT) compilation on a single device, parallel computation compilation across multiple devices, and automatic vectorization compilation on a single device. In backend compilation, for user-specified code requiring JIT compilation, the model computation graph is first converted into a programming language-independent intermediate expression. Then, the intermediate representation undergoes multiple optimization passes, specifically including device-independent analysis and optimization, and device-dependent analysis and optimization. For user-specified loop code requiring automatic vectorization, the model computation graph is first converted into a programming language-independent intermediate expression. Then, scalar statements are automatically converted into corresponding SIMD vector statements. For user-specified code requiring automatic parallelization, the model computation flow graph is first converted into a programming language-independent intermediate expression. Then, optimization and analysis consistent with the JIT compilation described above are performed on each device.

[0089] The code generation provided by this system uses LLVM (Architectural Compiler) to generate low-level intermediate representations. On devices such as CPUs, GPUs, and TPUs, the code generation layer emits an LLVM IR (Intermediate Representation) that has undergone efficient computation and optimization, and then calls LLVM to emit the native code from the LLVM IR.

[0090] Compared with existing solutions, the programming system of this embodiment has the following main advantages:

[0091] 1. Based on different brain dynamics models to be constructed, different computational graph construction modules are called to construct the corresponding computational graphs. Then, based on different compilation requirements, the corresponding code compilation modules are called to quickly generate the code for the brain dynamics model, making the programming system of this invention more versatile.

[0092] 2. During the computation graph construction and code compilation processes, the corresponding modules can be executed according to the instructions. All models defined in the system can be compiled in real time to achieve high-performance running speed and improve the generation efficiency of brain dynamics model code.

[0093] 3. It has operator customization interface module and model customization interface module, that is, many core tool modules and brain dynamics model modules in the system front-end programming layer can be directly customized by inheriting the base class, which has strong extensibility and reduces the workload of programming.

[0094] Example 2:

[0095] This embodiment provides a programming method based on a general brain dynamics programming system. The general brain dynamics programming system includes a front-end programming layer 10 and a back-end compilation layer 20. The front-end programming layer 10 includes multiple preset computation graph construction modules, and the back-end compilation layer 20 includes preset code compilation modules with different functions.

[0096] Among them, such as Figure 7 The programming methods based on the general programming system for brain dynamics include:

[0097] Step 701: The front-end programming layer receives the computational graph construction instruction corresponding to the brain dynamics model to be constructed, and calls at least one of the preset multiple computational graph construction modules according to the computational graph construction instruction, and runs the called computational graph construction module to obtain the computational graph corresponding to the brain dynamics model.

[0098] Step 702: The backend compilation layer receives the compilation instructions corresponding to the input brain dynamics model, and calls at least one of the preset code compilation modules with different functions. The called code compilation module is used to compile the code according to the computation graph to obtain the binary machine code of the brain dynamics model on the target device.

[0099] The programming method in this embodiment can be understood by comparing it with the programming system in Embodiment 1 above, and will not be repeated here.

[0100] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.

[0101] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments.

[0102] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A general-purpose programming system for brain dynamics based on just-in-time compilation, characterized in that, include: The system comprises a front-end programming layer and a back-end compilation layer. The front-end programming layer includes multiple preset computation graph construction modules, and the back-end compilation layer includes preset code compilation modules with different functions. The front-end programming layer is used to receive the input computational graph construction instructions corresponding to the brain dynamics model to be constructed, and to call at least one of the preset multiple computational graph construction modules according to the computational graph construction instructions, and to run the called computational graph construction module to obtain the computational graph corresponding to the brain dynamics model. The backend compilation layer is used to receive the compilation instructions corresponding to the input brain dynamics model, and to call at least one of the preset code compilation modules with different functions. The called code compilation module is used to compile the code according to the computation graph to obtain the binary machine code of the brain dynamics model on the target device. The computational graph construction module includes an operator module, a tool module, and a brain dynamics model module; each of the operator module, tool module, and brain dynamics model module has different preset computational graph construction operators; The computation graph construction instructions include computation graph construction module selection instructions and model construction parameters; The front-end programming layer is used to call the operator module, tool module and brain dynamics model module according to the selection instruction of the computation graph construction module. The called module is used to construct operators according to the model construction parameters and the computation graph to obtain the computation graph corresponding to the brain dynamics model. The operator module includes a sparse matrix operator module and an event-driven operator module.

2. The general-purpose brain dynamics programming system based on just-in-time compilation according to claim 1, characterized in that, A computation graph is a directed graph composed of operators, whose nodes are input values ​​or correspond to mathematical operations defined by the operators.

3. The general-purpose brain dynamics programming system based on just-in-time compilation according to claim 1, characterized in that, The operator module further includes at least one of the following: a dense matrix operator module and an automatic differentiation module.

4. The general-purpose brain dynamics programming system based on just-in-time compilation according to claim 1, characterized in that, The tool module includes at least one of the following: The system includes modules for solving Ordinary Differential Equations (ODE), Stochastic Differential Equations (SDE), Delayed Differential Equations (DDE), Fractional Differential Equations (FDE), synaptic connections, and weight initialization.

5. The general-purpose brain dynamics programming system based on just-in-time compilation according to claim 1, characterized in that, The brain dynamics model module includes at least one of a computational neuroscience model module and a brain-like intelligent computing model module.

6. The general-purpose brain dynamics programming system based on just-in-time compilation according to claim 1, characterized in that, The front-end programming layer also includes an operator custom interface module and a model custom interface module; The operator customization interface module is used to receive input customized operator information in order to generate the corresponding operator module; The model customization interface module is used to receive input customized model information to generate the corresponding brain dynamics model module.

7. The general-purpose brain dynamics programming system based on just-in-time compilation according to claim 1, characterized in that, The code compilation module includes at least one of a just-in-time compilation module, an automatic parallelization module, and an automatic vectorization module; The compilation instructions include compilation method selection instructions and the target device for applying the brain dynamics model; The backend compilation layer is used to select at least one of the just-in-time compilation module, automatic parallelization module, and automatic vectorization module according to the selected compilation method; the selected module is used to generate binary machine code for the brain dynamics model applicable to the target device according to the target device to which the brain dynamics model is applied.

8. The general-purpose brain dynamics programming system based on just-in-time compilation according to claim 7, characterized in that, The just-in-time compilation module is used to perform target device-independent compilation analysis and optimization on the brain dynamics model according to a preset optimization strategy, and to perform device-dependent compilation analysis and optimization according to the target device, and generate binary machine code suitable for the target device. The automatic parallelization module is used to simultaneously generate binary machine code for brain dynamics models applicable to multiple target devices based on the target devices to which the brain dynamics model is applied. The automatic vectorization module is used to generate binary machine code suitable for the brain dynamics model of the target device using a single instruction stream and multiple data streams in parallel.

9. The general-purpose brain dynamics programming system based on just-in-time compilation according to claim 7, characterized in that, The backend compilation layer also includes a computation graph transformation module; The computation graph conversion module is used to convert the computation graph corresponding to the brain dynamics model into an intermediate expression that is independent of programming language. The called code compilation module is used to compile the code according to the intermediate expression to obtain the binary machine code of the brain dynamics model.

10. A programming method based on a general programming system for brain dynamics, characterized in that, The general programming system for brain dynamics includes a front-end programming layer and a back-end compilation layer. The front-end programming layer includes multiple preset computation graph construction modules, and the back-end compilation layer includes preset code compilation modules with different functions. The programming method includes: The front-end programming layer receives the computational graph construction instruction corresponding to the brain dynamics model to be constructed, and calls at least one of the preset multiple computational graph construction modules according to the computational graph construction instruction, and runs the called computational graph construction module to obtain the computational graph corresponding to the brain dynamics model. The backend compilation layer receives the compilation instructions corresponding to the input brain dynamics model, and calls at least one of the preset code compilation modules with different functions. The called code compilation module is used to compile the code according to the computation graph to obtain the binary machine code of the brain dynamics model. The computational graph construction module includes an operator module, a tool module, and a brain dynamics model module; each of the operator module, tool module, and brain dynamics model module has different preset computational graph construction operators. The computation graph construction instructions include computation graph construction module selection instructions and model construction parameters; The front-end programming layer is used to call the operator module, tool module and brain dynamics model module according to the selection instruction of the computation graph construction module. The called module is used to construct operators according to the model construction parameters and the computation graph to obtain the computation graph corresponding to the brain dynamics model. The operator module includes a sparse matrix operator module and an event-driven operator module.

Citation Information

Patent Citations

  • Neural network compiler architecture and compiling method

    CN110766147A

  • Neurodynamics simulation method and device based on just-in-time compiling

    CN112966433A