A method and device for realizing brain-like computing based on vector instruction set

Through the method based on vector instruction set and the design of Buffets data buffer, the problem of insufficient programmability and performance of existing brain-like computing chips is solved, and an efficient and programmable brain-like processor is realized, supporting complex neuron models. High-precision calculation and efficient memory access overlap with calculation.

CN114816067BActive Publication Date: 2024-12-03TSINGHUA UNIVERSITY
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210489441.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-05-06
Publication Date
2024-12-03
Estimated Expiration
2042-05-06

AI Technical Summary

Technical Problem

The existing brain-like computing chips have lost programmability and design flexibility while pursuing performance, and cannot effectively support complex neuronal models and high-precision computing. The implementation performance based on the general instruction set is poor, so it is impossible to accurately simulate complexity. neuronal model.

Method used

Using a method based on vector instruction set, the pulse neural network model is compiled through custom vector instruction sets, vector instructions and configuration instructions are generated, and the memory access and calculation of the brain-like computing vector processor is realized simultaneously, and the data is used to use the Buffets data buffer. Storage and switching, combined with RISC-V CPU for task allocation and simulation calculation of control cores.

Benefits of technology

It realizes an efficient and programmable brain-like processor, supports high-precision computing of complex neuron models, simplifies the process of users establishing pulsed neural network models, improves work efficiency, and realizes time between memory fetching and calculation Efficient overlap.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114816067B_ABST
    Figure CN114816067B_ABST
Patent Text Reader

Abstract

The embodiment of the present invention discloses a method and device for implementing brain-like computing based on a vector instruction set, the method comprising: compiling a pulse neural network model according to a custom vector instruction set to generate vector instructions and configuration instructions; the memory access unit of the brain-like computing vector processor performs memory access operations according to the configuration instructions; at the same time, the computing unit performs calculations according to the vector instructions. Through the above-mentioned method, the embodiment of the present invention adopts a custom vector instruction set and a vector processor to optimize the sparse calculations involved in the pulse neural network simulation; provides a user-friendly front end, which is conducive to the user to transplant code from other pulse neural network simulators that support Python; realizes the separation of the memory access step and the calculation step in the computing core, and allows the memory access step and the calculation step to be performed simultaneously, so as to achieve efficient overlap of memory access and calculation in time.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] Embodiments of the present invention relate to the field of brain-inspired computing technology, and specifically to a method and device for implementing brain-inspired computing based on a vector instruction set. Background Art

[0002] In the field of neuroscience, brain-like computing, as the main means of numerical simulation, is regarded as the most important research method besides theoretical and experimental research. From the perspective of computer architecture, the event-driven and integrated storage and computing characteristics of brain-like computing have the potential to inspire the design of new processor architectures; brain-like computing is also regarded as one of the important evolutionary paths for the next generation of artificial intelligence. As the main computing model in the field of brain-like computing, the Spiking Neural Network (SNN) introduces more biological realities, such as neural pulses and membrane potential, on the basis of the traditional spiking neural network model, which makes it have the characteristics of event-driven, irregular memory access, and sparse computing. General-purpose processors (including general-purpose graphics processors GPGPU) and deep learning acceleration chips are basically optimized for intensive computing and continuous memory access. Therefore, high-performance SNN computing needs to rely on specific chips, which are called brain-like computing chips. At present, the SNN model has put forward new requirements for brain-like computing chips: First, the function needs to support the integration of DNN / SNN and the increasingly complex network structure; second, the performance needs to take into account the requirements of flexible programmability and multi-precision computing (various floating point and fixed point) while ensuring high efficiency. At present, the implementation of brain-like chips can be divided into the following categories: First, custom structure chips based on data flow calculations, such as IBM's truenorth, which is characterized by the use of custom hardware to implement structures such as neuron models and synapses. This existing design method is efficient, but it also lacks programmability and has some design limitations; second, implementation based on general instruction sets, such as the spinnaker chip of the University of Manchester, which implements the SNN computing body based on the ARM core, and hardware modifications are mainly concentrated at the interconnection level; the third is the implementation of general processors + custom acceleration hardware, such as Intel's loihi. However, there is no brain-like computing instruction set based on vector computing and the corresponding brain-like chip design. The three types of current brain-like chips mentioned above have the following main limitations: First, customized structure chips lose programmability and design flexibility while pursuing performance, and have some design limitations. They usually only support simple neuron models, or use fixed-point numbers and low-precision floating-point numbers to implement some complex neuron models, but accurate and load-intensive neuron models are not supported because they require a large number of floating-point calculations and complex calculation processes; second, the implementation based on the general instruction set is not optimized for the SNN calculation process, and the performance is poor; third, the combination of general-purpose processors and customized acceleration hardware, its optimization idea is mainly for the hardware pipeline design of the SNN cyclic calculation process, but the current design only supports fixed-point calculations, with poor accuracy, and cannot accurately simulate complex neuron models. Summary of the invention

[0003] The technical problem to be solved by the present invention is to address the deficiencies of the above-mentioned prior art and to provide a method and device for realizing brain-like computing based on a vector instruction set, which can provide users with an easy-to-use front end and enable memory access steps and calculation steps to be performed simultaneously.

[0004] To achieve the above technical objectives, the technical solution adopted by the present invention is: a method for implementing brain-like computing based on a vector instruction set, comprising:

[0005] Compile the spiking neural network model according to the custom vector instruction set to generate vector instructions and configuration instructions;

[0006] The memory access unit of the brain-inspired computing vector processor performs a memory access operation according to the configuration instruction;

[0007] At the same time, the computing unit performs calculations according to the vector instructions.

[0008] Preferably, compiling the spiking neural network model according to the custom vector instruction set to generate vector instructions and configuration instructions includes:

[0009] Compile the pulse neural network model according to the custom vector instruction set to form an intermediate code;

[0010] Vector instructions and configuration instructions are generated according to the intermediate code.

[0011] Preferably, the step of generating vector instructions and configuration instructions according to the intermediate code specifically comprises the following steps:

[0012] Map the operation to the expression in the intermediate code;

[0013] Optimizing the intermediate code;

[0014] Mapping virtual registers in the intermediate code to architectural registers through an allocation algorithm, and mapping intermediate code operations to vector instructions;

[0015] Map access to variables from memory to the index of the Buffets asynchronous buffer and generate configuration instructions for the memory access unit.

[0016] Preferably, the optimization of the intermediate code includes: multiplication-addition fusion, common expression elimination and redundant instruction elimination.

[0017] Preferably, the intermediate code is in the form of SSA.

[0018] Preferably, it also includes:

[0019] A pulse neural network model is established, wherein the pulse neural network model includes a neuron model and a synapse model.

[0020] Preferably, the spiking neural network model is established by Python.

[0021] Preferably, the establishing of the pulse neural network model specifically includes:

[0022] Declare the input, output and intermediate variables involved in the neuron model and the synapse model;

[0023] Describe the calculation process of the neuron model and the synapse model.

[0024] Preferably, the memory access unit and the computing unit in the brain-like computing vector processor are connected through the Buffets data buffer to perform data storage and exchange;

[0025] The memory access unit performs memory access and writes the read data into the Buffets data buffer;

[0026] At the same time, the computing unit reads data from the Buffets data buffer and performs calculations according to a custom vector instruction set.

[0027] Preferably, the memory access unit performs memory access specifically including:

[0028] Extract the memory access process separately, encode the memory access process, and generate configuration instructions;

[0029] According to the configuration instruction, memory access is performed by a separate address generation unit.

[0030] Preferably, it also includes:

[0031] Write the computation results of the computation unit back to the memory asynchronously.

[0032] Preferably, the method further comprises the steps of:

[0033] Start the control core;

[0034] The control core distributes tasks to the computing cores, and performs simulation calculations in a cycle.

[0035] Preferably, the control core adopts RISC-V CPU.

[0036] Preferably, the startup control core specifically includes the steps of:

[0037] Prepare initial data for the control core;

[0038] Configuring the instruction cache of a brain-inspired processor.

[0039] The present invention discloses a device for implementing brain-like computing based on a vector instruction set, comprising:

[0040] A compilation unit, used to compile the pulse neural network model according to a custom vector instruction set and generate vector instructions and configuration instructions;

[0041] A plurality of computing cores, each of which includes a brain-like computing vector processor, and the brain-like computing vector processor includes a memory access unit and a computing unit;

[0042] The memory access unit is used to perform memory access operations according to the configuration instruction;

[0043] Meanwhile, the computing unit is used to perform computing according to vector instructions.

[0044] Preferably, the compilation unit comprises:

[0045] An intermediate code generation module, used for compiling the pulse neural network model according to a custom vector instruction set to form an intermediate code, wherein the intermediate code is in the form of SSA;

[0046] An instruction generation module is used to generate vector instructions and configuration instructions according to the intermediate code.

[0047] Preferably, the compilation unit further includes:

[0048] The corresponding module is used to map Python operations to expressions in the intermediate code;

[0049] An optimization module, used for optimizing the intermediate code, wherein the optimization includes multiplication-addition fusion, general expression elimination, and redundant instruction elimination;

[0050] A first mapping unit, configured to map virtual registers in the intermediate code to architectural registers by using an allocation algorithm;

[0051] The second mapping unit is used to map the access to the variable from the memory to the index of the Buffets asynchronous buffer.

[0052] Preferably, it also includes:

[0053] An establishing unit, used for establishing a pulse neural network model, wherein the pulse neural network model includes a neuron model and a synapse model;

[0054] The establishing unit comprises:

[0055] A declaration module, used to declare the input, output and intermediate variables involved in the neuron model and the synapse model;

[0056] The description module is used to describe the calculation process of the neuron model and the synapse model.

[0057] Preferably, the memory access unit comprises:

[0058] The encoding module is used to extract the memory access process separately, encode the memory access process, and generate configuration instructions.

[0059] Preferably, it also includes:

[0060] Buffets data cache is used to connect the memory access unit and computing unit in the brain-like computing vector processor for data storage and exchange.

[0061] Preferably, it also includes:

[0062] A write-back unit is used to asynchronously write the calculation results of the calculation unit back to the memory;

[0063] A startup unit, used for starting a control core, wherein the control core adopts a RISC-V CPU;

[0064] A control core, used for allocating tasks to the computing cores to perform simulation calculations cyclically;

[0065] The startup unit comprises:

[0066] A preparation module, used for preparing initial data of the control core;

[0067] A configuration module is used to configure the instruction cache of the brain-like processor.

[0068] Compared with the prior art, the present invention has the following beneficial effects:

[0069] 1. The present invention adopts a customized vector instruction set and vector processor to optimize the sparse computing involved in the pulse neural network simulation, designs a brain-like computing instruction set, and realizes an efficient and programmable brain-like processor.

[0070] 2. The present invention is based on Python language and realizes modeling of neuron model and synapse model in a user-friendly way, providing users with a convenient front end, which is conducive to users porting codes from other pulse neural network simulators that support Python, greatly reducing the time spent by users on establishing pulse neural network models, simplifying work steps and improving work efficiency.

[0071] 3. The present invention uses Buffets data cache as a buffer between the memory access unit and the computing unit to store and exchange data, thereby separating the memory access step from the computing step in the computing core, and allowing the memory access step and the computing step to be performed simultaneously, thereby achieving efficient temporal overlap of memory access and computing. BRIEF DESCRIPTION OF THE DRAWINGS

[0072] Figure 1 It is a structural block diagram of a device for realizing brain-like computing based on a vector instruction set according to the present invention;

[0073] Figure 2 It is a flow chart of a method for realizing brain-like computing based on a vector instruction set according to the present invention. DETAILED DESCRIPTION

[0074] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0075] The present invention designs a vector instruction set optimized for brain-like computing and a general-purpose, flexible and programmable brain-like processor, such as Figure 1 As shown, the brain-like processor is mainly composed of a control core (RISC-V CPU), a memory (Memory) and several computing cores (GaBAN core). The control core (RISC-V CPU), the memory (Memory) and several computing cores (GaBAN core) are connected through a bus (Bus), and data exchange is carried out through the bus (Bus).

[0076] Among them, each computing core (GaBAN core) mainly includes a memory access unit, a computing unit and a Buffets data buffer. The memory access unit and the computing unit in each computing core (GaBAN core) are connected through the Buffets data buffer. The memory access unit mainly includes an address generation unit (AddrGen), and the computing unit mainly includes a vector processor (VPU). The memory access unit is used to access the memory (Memory) and write the read data into the Buffets data buffer; at the same time, the computing unit is used to read data from the Buffets data buffer and perform calculations according to vector instructions. The Buffets data buffer is used as a buffer between memory access and calculation, and the memory access and calculation in the computing core (GaBAN core) are separated. The Buffets data buffer is used for data storage and exchange in the middle, so as to achieve efficient overlap in memory access and calculation time. By using the mechanism of a separate memory access unit and a Buffets data buffer, the calculation time and memory access time can be well covered, thereby improving performance.

[0077] It is worth noting that the brain-like processor may include one or more computing cores (GaBAN cores). Preferably, the brain-like processor includes a first computing core to an nth computing core, wherein the number of computing cores (GaBAN cores) n may represent any desired number of cores. Typically, the number of cores ranges from one to about several hundred, and often ranges from one to about several dozen. Exemplarily, the number of computing cores (GaBAN cores) n=3, then the brain-like processor includes a control core (RISC-V CPU), a memory (Memory), and a first computing core, a second computing core, and a third computing core, wherein the control core (RISC-V CPU) is connected to the memory (Memory), the first computing core, the second computing core, and the third computing core through a bus (Bus), and the instructions, data, etc. on the memory (Memory) are read into registers through the control core (RISC-V CPU), and the first computing core, the second computing core, and the third computing core perform calculations according to the instructions and data read into the registers from the memory (Memory).

[0078] like Figure 2 As shown, Figure 2 A schematic flow chart of a method for implementing brain-like computing based on a vector instruction set of the present invention is shown, and the method comprises the following steps:

[0079] A pulse neural network model is established through Python. The data corresponding to the pulse neural network model will be stored in memory. The pulse neural network model includes a neuron model and a synapse model. The neuron models are coupled to each other through synapses. The neuron model can be understood as a series of differential equations, that is, the way the internal state of the neuron changes with the input and output; the synapse model refers to the way the synaptic weight changes with the firing of the neuron. Building a model means re-implementing these equations in code.

[0080] The specific steps of establishing a pulse neural network model include: declaring the input, output and intermediate variables involved in the neuron model and the synapse model; describing the calculation process of the neuron model and the synapse model.

[0081] It is worth noting that the neuron model in this embodiment adopts the LIF (leaky integrate-and-fire) model, where Leaky refers to leakage, indicating that if there is only one neuron input, it is not enough to make the membrane potential exceed the threshold. Due to the continuous ion exchange between the cell membrane and the membrane, the membrane potential will automatically leak and gradually fall back to the resting state; Integrate refers to integration, indicating that the neuron will receive all pulses from the axon terminals (previous neuron) connected to the neuron; Fire refers to excitation, indicating that when the membrane potential exceeds the threshold, the neuron will send a pulse. After sending a pulse, the neuron will enter a hyperpolarized state, followed by a refractory period. During the refractory period, even if stimulated, it will not respond, that is, the neuron will no longer receive stimulation and maintain the resting potential. For the LIF neuron model, the input signal directly affects the state of the neuron, that is, the membrane potential. Only when the membrane potential rises to the threshold potential will the output pulse signal be generated. The LIF neuron model uses the fact that the neuron action potential of a given neuron always has roughly the same form. If the shape of the action potential is always the same, then this shape cannot be used to transmit information, but is contained in the presence or absence of spikes. Therefore, the action potential is reduced to an "event" that occurs at a precise moment, so the task of the LIF neuron model is to model the changes in membrane potential over time and external input. The LIF neuron model is a basic simplification of the HH model. But it is not a simple omission of variables. The model does not deliberately describe the shape of the action potential. A sample Python script is as follows, showing the variables and calculation process of the LIF neuron model:

[0082]

[0083]

[0084] The following is one of the examples of establishing a spiking neural network model: input the training data set and the initial synaptic weight matrix, establish each neuron model and each synapse model, dynamically use multiple threads to pre-divide the neuron group according to computer resources, and then establish a local spiking neural network within the thread, initialize the neuron group, synaptic connection relationship and synaptic weight in each independent thread, and after the initialization is completed, all threads are trained in parallel according to the set number of rounds. The neural network consists of three layers: input layer, hidden layer and output layer. Each layer has multiple neurons, and the layers use a fully connected structure, which can be a feedforward network or a feedback network. When the neural network performs reasoning operations, when image, voice, text and other data enter the input layer neurons, the data is first input into the weight matrix, and then the row vectors in the result matrix are added in sequence to generate the calculation result of the layer, and used as the input of the next layer, and forwarded in sequence to finally obtain the calculation result.

[0085] In this embodiment, the modeling of the neuron model and the synapse model is implemented in a user-friendly manner based on the Python language. This design provides a front end that is convenient for users to use. Since some existing SNN simulators also provide a Python front end, this embodiment uses the Python language to establish the SNN, which is conducive to porting codes from other spiking neural network simulators that support Python, thereby saving modeling time.

[0086] After the pulse neural network model is established, the model is compiled by the compiler to obtain vector processor assembly instructions, and the assembly instructions are stored in the memory. Specifically, the compiler compiles the pulse neural network model according to the custom vector instruction set to generate vector instructions and configuration instructions.

[0087] Specifically, you first need to run the compiler for the instruction set of the vector processor. The compiler will perform lexical analysis, syntax analysis, semantic analysis, etc. on the source code of the neuron model and synapse model algorithms to obtain the intermediate code of the vector processor converted in program organization units, and then generate the final assembly instructions of the vector processor. The following is an example of the generated assembly code:

[0088]

[0089] Specifically, the intermediate code has multiple implementation forms. In this embodiment, the intermediate code adopts the form of SSA. It is worth noting that SSA stands for static single-assignment, which is an IR (intermediate representation code). SAA is an intermediate code that can ensure that each variable is assigned only once. By adopting SSA, the compiler's optimization algorithm can be simplified.

[0090] After running the compiler for the instruction set of the vector processor, the Python code can be used to overload operators, and the Python operations can be mapped to the expressions in the SSA. After generating the intermediate code, the compiler performs several optimizations on the intermediate code, including multiplication and addition fusion, common expression elimination, and redundant instruction elimination. Specifically, the data dependency is analyzed, and then useless instructions and their dependencies are deleted; because its object is intermediate code, it can support the processing of multiple high-level languages; the intermediate code is analyzed and calculated using the deletion method to obtain the dependency graph; wherein, the dependency analysis includes forward rules and reverse rules; in the dependency query process, a filter function is designed. In addition to being able to immediately obtain the content being accessed, the filter function can also return True to mark the current unsolved object as ignore and stop searching. Since the dependency graph is a tree-like graph, returning True can only reject the search of the current branch, and other branches will continue to go deeper; therefore, it is used The dependency graph is filtered by the filter function of the pruning method to reduce the size of the dependency graph and obtain the pruned dependency graph; the filter functions are specifically: structure filter functions and call filter functions; they can usually make the calculation process faster, the final graph is smaller, and more focused on the content we expect; those pre-designed callback functions are called filters. During the query process, all filter functions are applied first and pruned as early as possible; filter functions usually require some parameters to construct, so they are very convenient to use; the intermediate code is traversed from the bottom to the top according to the call relationship CallGraph; each call relationship node CallGraphNode is traversed from the bottom to the top.

[0091] After several optimizations are performed on the intermediate code SSA, the compiler maps the virtual registers in the intermediate code SSA to the architecture registers through a linear allocation algorithm. At the same time, access to variables from the memory is mapped to the index of the Buffets data buffer. It is worth noting that the virtual registers in the SSA are infinite, while the architecture registers are limited, so it is necessary to make a mapping under the premise of ensuring correctness. In the prior art, if you need to find the required data, you need to find the first address of an array in the memory, and calculate the data to be found based on the first address of the array. In this embodiment, since the data is transferred through the buffer, the array to be found is segmented and stored in the Buffets data buffer. When looking for the required data, you only need to access the index in this segment each time to find the data.

[0092] This embodiment implements a corresponding compiler and software support for a vector instruction set, and implements a hardware prototype on an FPGA.

[0093] After the model is compiled by the compiler to obtain the vector processor assembly instructions, the control core (RISC-V CPU) is started, and the control core (RISC-V CPU) assigns tasks to the computing core (GaBAN core), and the computing core (GaBAN core) performs simulation calculations in a loop.

[0094] This embodiment introduces the RISC-V CPU as the control core, and other cores, such as the ARM core, may also be used.

[0095] Among them, starting the control core (RISC-V CPU) specifically includes the steps of: preparing the initial data of the control core (RISC-V CPU); configuring the instruction cache of the brain-like processor.

[0096] Specifically, the control core (RISC-V CPU) is responsible for preparing the initial data, such as the initial state data of the neuron model and the initial weights of the synaptic model, and configuring the instruction cache of the brain-like processor. During the simulation process, the control core (RISC-V CPU) simulates several time steps under the specified input information to obtain the state change process of the pulse neural network SNN. In each time step, the control core (RISC-V CPU) will allocate a given pulse neural network SNN to each computing core (GaBAN core) for simulation calculation. After the calculation is completed, it will enter the next cycle simulation.

[0097] Furthermore, the control core (RISC-V CPU) writes the instruction sequence into the instruction cache, and configures the program pointer register to control the number of loop executions of the instruction sequence. When the control core (RISC-V CPU) completes the initialization configuration, the control core (RISC-V CPU) sends a start command to control the computing core (GaBAN core) to enter the working state; the program pointer register in the instruction cache is incremented from the starting address in sequence, and the instruction indicated by the program pointer register is taken out as the instruction to be executed currently; the decoder analyzes the instruction to be executed currently and extracts the key field of the instruction to be executed currently; the data preparation module extracts the source operand vector elements stored in the local memory according to the key field and inputs them to the execution module, forwards the arriving real-time stream data to the execution module, and stores the immediate number in the instruction to be executed currently; the execution module performs monocular or binocular operations on the real-time stream data, the immediate number of the instruction to be executed currently or the vector stored in the local memory to obtain the operation result; the data preparation module and the execution module adopt a pipeline working mode, and the execution module processes the previous time When the source operand is pre-fetched in the clock cycle, the data preparation module pre-fetches the source operand of the next clock cycle; when the binary operation is executed, the execution module and the write-back queue adopt the pipeline working mode. When the execution module processes the elements of the current clock cycle, the write-back queue writes the operation result sequence elements output in the previous clock cycle to the destination address of the local memory; when the write-back queue executes the last clock cycle of the previous instruction, the program pointer register value in the instruction cache is increased by 1, and the acquisition of the next instruction is started; when the program pointer register in the instruction cache indicates that the instruction has reached the last instruction, it returns to the starting address, and the loop count counter is increased by 1. When the loop count reaches the set boundary, it is terminated and an interrupt signal is sent to the control core (RISC-VCPU) at the same time.

[0098] The GaBAN core performs simulation calculations in a loop, specifically including: connecting the memory access unit and the computing unit in the GaBAN core through the Buffets data buffer to store and exchange data;

[0099] It is worth noting that each time the computing unit executes an instruction cycle, it needs to read some data; if the data caching method in the prior art is used, it is necessary to wait until all data in this cycle is read into the data cache before performing calculations; and this embodiment uses a Buffets data cache to connect the memory access unit and the computing unit in the computing core (GaBAN core), so the computing unit does not need to wait for all data to arrive at the data cache, but through an internal checking mechanism, when the computing unit reads a data that has not been obtained, it will automatically wait until the data is obtained from the memory. This design is relatively simple and efficient.

[0100] After starting the control core (RISC-V CPU), the memory access unit of the brain-like computing vector processor performs memory access operations according to the configuration instructions and writes the read data into the Buffets data buffer;

[0101] Specifically, the memory access unit accesses the memory (Memory), reads the data corresponding to the pulse neural network model from the memory (Memory), and writes the data into the Buffets data buffer. The memory access unit includes an address generation unit. In order to efficiently realize the simulation of the pulse neural network, it is necessary to implement a more radical memory access optimization. Since the memory access mode is known in advance during the calculation process of the pulse neural network, that is, the memory access mode can be seen from the calculation process of the pulse neural network SNN, the memory access process can be encoded and accessed by a separate address generation unit. The address generation unit supports two access modes, namely continuous access and indirect access. By using the mechanism of a separate memory access unit and a Buffets data buffer, the calculation time and memory access time can be well covered, thereby improving performance.

[0102] Specifically, while compiling the pulse neural network model, combined with the intermediate code SSA, it is possible to obtain the data that needs to be read in each cycle, thereby obtaining information on how the address generation unit is configured.

[0103] The memory access unit performs memory access and writes the read data into the Buffets data buffer including the following steps:

[0104] Extract the memory access process separately, encode the memory access process, and generate configuration instructions;

[0105] According to the configuration instructions, a separate address generation unit performs memory access and writes the read data into the Buffets data buffer. An example of the configuration instruction is as follows:

[0106]

[0107] In order to optimize the simulation calculation process of the pulse neural network (SNN), the memory access process is extracted separately and the address generation unit is programmed using memory access instructions because its memory access mode is highly predictable. The calculation process is highly parallelizable, so vector instructions are used to perform data parallel calculations.

[0108] This embodiment proposes a vector processing instruction set for brain-like computing and corresponding address generation unit configuration instructions, and achieves a high degree of programmability through the instruction set. If you want to implement a new and more complex neuron model and synapse model, you only need to write Python code without modifying the hardware logic, which is highly flexible.

[0109] While the memory access unit is accessing memory and writing the read data into the Buffets data buffer, the computing unit reads data from the Buffets data buffer and performs computing according to vector instructions.

[0110] Specifically, the register pointer variable is used to query the memory address of the current CPU task; the memory address is used as an index. When the instruction is sent to the core, the register will read or write the value of the specific register unit according to the requirements of each instruction; each computing core (GaBAN core) is composed of an instruction fetch module, a decoder, a shift module, an arithmetic logic operation module, a counting module, a data forward module, a data acquisition module, and a data alignment module; wherein: the instruction fetch module determines whether to fetch the next instruction according to the sent instruction, and when the control core (RISC-V CPU) requires inserting an empty instruction or repeating the previous instruction, the instruction fetch module does not accept the next instruction input; when the instruction fetch is completed, the instruction will flow into the decoder; the decoder generates a corresponding control signal according to the instruction encoding; then the instruction will flow into the data operation path, access the register to obtain the operand according to the result generated by the instruction and the decoding signal, or access the memory (Memory) through the data acquisition module to obtain the operand, and then operate on the data through the logic operation module, the shift module, and the counting module; the data operation result is re-stored in a standardized storage format through the data alignment module, and then written into the register or into the memory (Memory) according to the instruction.

[0111] After the GaBAN core performs simulation calculations in a loop, the calculation results are asynchronously written to the memory through the Write-back FIFO write-back queue.

[0112] In summary, the present invention writes a pulse neural network model through Python; starts a compiler, and the compiler compiles the model according to a custom vector instruction set to obtain vector instructions and configuration instructions of a vector processor; the corresponding vector instructions and configuration instructions compiled according to the pulse neural network model are stored in a memory (Memory); starts a control core (RISC-V CPU), and the control core (RISC-V CPU) assigns tasks to a computing core (GaBAN core), and the computing core (GaBAN core) performs simulation calculations in a loop: an address generation unit in the computing core (GaBAN core) is responsible for generating an address request for the memory (Memory); the computing core (GaBAN core) accesses the memory (Memory) through a bus Bus, and writes the data corresponding to the read pulse neural network model into a Buffets data buffer; a vector processor VPU reads data from the Buffets data buffer, and performs calculations according to vector instructions; and the calculation results are asynchronously written into the memory (Memory) through a Write-back FIFO write-back queue.

[0113] The present invention aims at the high-performance computing problem of spiking neural networks, adopts a customized vector instruction set and vector processor method, optimizes the sparse computing involved in the simulation of spiking neural networks, designs a brain-like computing instruction set, and realizes an efficient and programmable brain-like processor.

[0114] Based on Python language, the modeling of neuron model and synapse model is realized in a user-friendly way. This method of using Python to build a pulse neural network model provides users with a convenient front end, which is conducive to users porting codes from other pulse neural network simulators that support Python, reducing users' time spent on building pulse neural network models, simplifying work steps and improving work efficiency.

[0115] Buffets data cache is used as a buffer between the memory access unit and the computing unit to store and exchange data, so that the memory access step and the computing step in the computing core (GaBAN core) are separated and the memory access step and the computing step can be performed simultaneously, achieving efficient time overlap of memory access and computing.

[0116] The above are only preferred embodiments of the present invention, and the protection scope of the present invention is not limited to the above embodiments. All technical solutions under the concept of the present invention belong to the protection scope of the present invention. It should be pointed out that for ordinary technicians in this technical field, some improvements and modifications without departing from the principle of the present invention should be regarded as the protection scope of the present invention.

Claims

1. A method for implementing brain-like computing based on a vector instruction set, characterized in that: include: Compile the spiking neural network model according to the custom vector instruction set to generate vector instructions and configuration instructions; The memory access unit of the brain-inspired computing vector processor performs a memory access operation according to the configuration instruction; At the same time, the computing unit performs calculations based on vector instructions; Compile the spiking neural network model according to the custom vector instruction set, generate vector instructions and configuration instructions including: Compile the pulse neural network model according to the custom vector instruction set to form an intermediate code; Generate vector instructions and configuration instructions according to the intermediate code; The step of generating vector instructions and configuration instructions according to the intermediate code specifically comprises the following steps: Map the operation to the expression in the intermediate code; Optimizing the intermediate code; Mapping virtual registers in the intermediate code to architectural registers through an allocation algorithm, and mapping intermediate code operations to vector instructions; Map access to variables from memory to the index of the Buffets asynchronous buffer and generate configuration instructions for the memory access unit.

2. The method for implementing brain-like computing based on a vector instruction set according to claim 1, characterized in that: The optimization of the intermediate code includes: multiplication-addition fusion, general expression elimination and redundant instruction elimination.

3. The method for implementing brain-like computing based on a vector instruction set according to claim 2, characterized in that: The intermediate code is in the form of SSA.

4. The method for implementing brain-like computing based on a vector instruction set according to any one of claims 1 to 3, characterized in that: Also includes: A pulse neural network model is established, wherein the pulse neural network model includes a neuron model and a synapse model.

5. The method for implementing brain-like computing based on a vector instruction set according to claim 4, characterized in that: Build a spiking neural network model using Python.

6. The method for implementing brain-like computing based on a vector instruction set according to claim 5, characterized in that: The said establishing a pulse neural network model specifically comprises: Declare the input, output and intermediate variables involved in the neuron model and the synapse model; Describe the calculation process of the neuron model and the synapse model.

7. The method for implementing brain-like computing based on a vector instruction set according to any one of claims 1 to 3, characterized in that: The memory access unit and computing unit in the brain-like computing vector processor are connected through the Buffets data buffer for data storage and exchange; The memory access unit performs memory access and writes the read data into the Buffets data buffer; At the same time, the computing unit reads data from the Buffets data buffer and performs calculations according to a custom vector instruction set.

8. The method for implementing brain-like computing based on a vector instruction set according to claim 7, characterized in that: The memory access unit performs memory access specifically including: Extract the memory access process separately, encode the memory access process, and generate configuration instructions; According to the configuration instruction, memory access is performed by a separate address generation unit.

9. The method for implementing brain-like computing based on a vector instruction set according to claim 8, characterized in that: Also includes: Write the computation results of the computation unit back to the memory asynchronously.

10. The method for implementing brain-like computing based on a vector instruction set according to claim 9, characterized in that: Also includes the steps: Start the control core; The control core distributes tasks to the computing cores, and performs simulation calculations in a cycle.

11. The method for implementing brain-like computing based on a vector instruction set according to claim 10, characterized in that: The control core adopts RISC-V CPU.

12. The method for implementing brain-like computing based on a vector instruction set according to claim 10, characterized in that: The startup control core specifically includes the following steps: Prepare initial data for the control core; Configuring the instruction cache of a brain-inspired processor.

13. A device for implementing brain-like computing based on a vector instruction set, characterized in that: include: A compilation unit, used to compile the pulse neural network model according to a custom vector instruction set and generate vector instructions and configuration instructions; A plurality of computing cores, each of which includes a brain-like computing vector processor, and the brain-like computing vector processor includes a memory access unit and a computing unit; The memory access unit is used to perform memory access operations according to the configuration instruction; Meanwhile, the computing unit is used to perform computing according to the vector instruction; The compilation unit comprises: An intermediate code generation module, used for compiling a pulse neural network model according to a custom vector instruction set to form an intermediate code, wherein the intermediate code is in the form of SSA; An instruction generation module, used for generating vector instructions and configuration instructions according to the intermediate code; The compilation unit also includes: The corresponding module is used to map Python operations to expressions in the intermediate code; An optimization module, used for optimizing the intermediate code, wherein the optimization includes multiplication-addition fusion, general expression elimination and redundant instruction elimination; A first mapping unit, used for mapping virtual registers in the intermediate code to architectural registers through an allocation algorithm; The second mapping unit is used to map the access to the variable from the memory to the index of the Buffets asynchronous buffer.

14. The device for implementing brain-like computing based on a vector instruction set according to claim 13, characterized in that: Also includes: An establishing unit, used for establishing a pulse neural network model, wherein the pulse neural network model includes a neuron model and a synapse model; The establishing unit comprises: A declaration module, used to declare the input, output and intermediate variables involved in the neuron model and the synapse model; A description module is used to describe the calculation process of the neuron model and the synapse model.

15. The device for implementing brain-like computing based on a vector instruction set according to claim 13, characterized in that: The memory access unit comprises: The encoding module is used to extract the memory access process separately, encode the memory access process, and generate configuration instructions.

16. The device for implementing brain-like computing based on a vector instruction set according to claim 13, characterized in that: Also includes: Buffets data buffers are used to connect the memory access units and computing units in the brain-like computing vector processor for data storage and exchange; A write-back unit is used to asynchronously write the calculation results of the calculation unit back to the memory; A startup unit, used for starting a control core, wherein the control core adopts a RISC-V CPU; A control core, used for allocating tasks to the computing cores and performing simulation calculations cyclically; The startup unit comprises: A preparation module, used for preparing initial data of the control core; A configuration module is used to configure the instruction cache of the brain-like processor.

Citation Information

Patent Citations

  • Brain-like computing system based on multi-neural network fusion and execution method of instruction set

    CN111325321A

  • Reduced instruction set storage and calculation integrated neural network coprocessor based on resistive memristor

    CN113010213A