Pulse neural network weight gradient calculation method and related device

By using selectors to control the accumulator array in the spiking neural network for gradient accumulation calculation, the problem of high energy consumption and low efficiency in weight gradient updates is solved, achieving sparsity optimization and improved computational efficiency.

CN119358606BActive Publication Date: 2025-11-04PENG CHENG LAB
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411346108.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-09-25
Publication Date
2025-11-04
Estimated Expiration
2044-09-25

AI Technical Summary

Technical Problem

In the existing training process of spiking neural networks, weight gradient updates account for one-third of the total training computation, and there are problems of high energy consumption and low efficiency, especially when dealing with sparse data, a large amount of invalid computation is performed.

Method used

By inputting multiple pulse signal values ​​into a preset selector, the accumulator array is controlled to perform gradient accumulation calculation. The sparsity of the pulse signals is used to optimize the weight gradient data and avoid invalid calculations.

Benefits of technology

It effectively reduces energy consumption during the weight gradient calculation process of spiking neural networks and improves computational efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119358606B_ABST
    Figure CN119358606B_ABST
Patent Text Reader

Abstract

The application provides a pulse neural network weight gradient calculation method, comprising: obtaining a pulse change signal of each channel dimension in a target pulse neural network and membrane potential gradient change information corresponding to each convolution kernel; for each pulse change signal, corresponding pulse signal values are read in a plurality of clock sliding windows according to a clock period; in the case that the plurality of pulse signal values read in the current clock period are not all 0, gradient change values in the plurality of membrane potential gradient change information are read, the plurality of gradient change values are input to a preset accumulator array in rows, and the plurality of pulse signal values are input to a plurality of selectors, so that the plurality of selectors control the plurality of accumulators in the accumulator array to accumulate the gradient change values on the gradient accumulation results of the last clock period according to columns, to obtain a plurality of gradient accumulation results of the current clock period, and then obtain the weight gradient information of each convolution kernel, which can effectively avoid invalid calculation and improve the calculation efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] Embodiments of the present application relate to the technical field of neural network training, and particularly to a spiking neural network weight gradient calculation method and related equipment. BACKGROUND

[0002] As a new type of neural network model, spiking neural networks (SNNs) can improve energy efficiency and computing efficiency by simulating the spiking mechanism of biological neurons and using event-driven computing methods, and perform well in processing sparse and asynchronous data, and are suitable for low-power and high-performance computing requirements.

[0003] However, the current training process of spiking neural networks is relatively complex, involving three stages of forward propagation (FF), back propagation (BP) and weight gradient (WG) update, wherein the weight gradient update accounts for about one-third of the total training computation, and the existing accelerator training process often performs a large amount of invalid computation based on sparse data when processing the weight gradient update, resulting in waste of computing resources and causing the current weight gradient update and spiking neural network training process to have high energy consumption and low efficiency. SUMMARY

[0004] Embodiments of the present application provide a spiking neural network weight gradient calculation method and related equipment, which can input multiple pulse signal values to multiple selectors to enable the multiple selectors to control the accumulator array to perform gradient accumulation calculation, thereby realizing the sparsity optimization of weight gradient data, effectively avoiding invalid computation, reducing energy consumption in the spiking neural network weight gradient calculation process, and improving computing efficiency.

[0005] To achieve the above object, a first aspect of an embodiment of the present application provides a pulse neural network weight gradient calculation method, comprising: obtaining a pulse change signal of each channel dimension in a target pulse neural network and membrane potential gradient change information corresponding to each convolution kernel; for each pulse change signal, reading corresponding pulse signal values in a plurality of clock sliding windows according to clock periods respectively; in the case that the plurality of pulse signal values read in the current clock period are not all 0, reading a gradient change value from each membrane potential gradient change information, inputting the plurality of gradient change values read to a preset accumulator array by row, and inputting the plurality of pulse signal values read to a plurality of preset selectors, so as to control the accumulator array to perform accumulation processing between the plurality of gradient change values and the gradient accumulation result of the last historical clock period according to the plurality of pulse signal values through the plurality of selectors, and obtain a plurality of gradient accumulation results of the current clock period; obtaining a weight gradient accumulation result of a plurality of convolution kernels in a target clock step according to each gradient accumulation result of each clock sliding window of each pulse change signal; after traversing the membrane potential gradient change information corresponding to each convolution kernel in the target pulse neural network, obtaining weight gradient information of each convolution kernel according to a plurality of weight gradient accumulation results corresponding to the plurality of convolution kernels.

[0006] In some embodiments, the reading, for each pulse change signal, of corresponding pulse signal values in a plurality of clock sliding windows according to clock periods comprises: obtaining configuration information of the target pulse neural network; determining, according to the configuration information, that the reading number of the pulse change signals is N, and that the reading number of the membrane potential gradient change information corresponding to the convolution kernel is M; selecting N pulse change signals, and reading, for each pulse change signal in the N pulse change signals, corresponding pulse signal values in a plurality of clock sliding windows according to clock periods.

[0007] In some embodiments, the accumulator array comprises N columns and M rows of accumulators, and the reading of a gradient change value from each membrane potential gradient change information, the inputting of the plurality of gradient change values read to a preset accumulator array by row, and the inputting of the plurality of pulse signal values read to a plurality of preset selectors comprise: reading gradient change values of the current clock period from M membrane potential gradient change information, and inputting the M gradient change values to N accumulators in each row of the accumulator array by row respectively; inputting N pulse signal values to N preset selectors, and the N selectors are connected to input ends of M accumulators in each column of the accumulator array by column respectively.

[0008] In some embodiments, the accumulating the plurality of gradient change values and the gradient accumulation results of the previous historical clock cycle by the plurality of selectors according to the plurality of pulse signal values to obtain the plurality of gradient accumulation results of the current clock cycle comprises: inputting the gradient accumulation results of the previous clock cycle output by each accumulator in the accumulator array into the accumulator; accumulating the plurality of gradient change values and the gradient accumulation results of the previous historical clock cycle by the plurality of accumulators in the corresponding column controlled by the plurality of selectors whose pulse signal values are not 0 to obtain the plurality of gradient accumulation results of the current clock cycle; determining the gradient accumulation results of the previous clock cycle as the gradient accumulation results of the corresponding accumulator in the current clock cycle by the plurality of accumulators in the corresponding column controlled by the plurality of selectors whose pulse signal values are 0.

[0009] In some embodiments, the obtaining the weight gradient accumulation results of the plurality of convolution kernels in the target clock step according to each of the gradient accumulation results of each of the pulse change signals in each of the clock sliding windows comprises: storing the gradient accumulation results of the N pulse change signals in the plurality of clock sliding windows into a preset data storage unit; after traversing each of the clock sliding windows corresponding to the target clock step, if the N is less than the total number of channel dimensions of the target pulse neural network, storing the gradient accumulation results of a plurality of groups of N pulse change signals in the target clock step into the data storage unit according to the N and the total number of channel dimensions; and obtaining the weight gradient accumulation results of each of the channel dimensions of the M convolution kernels in the target clock step according to the gradient accumulation results stored in the data storage unit.

[0010] In some embodiments, the obtaining the weight gradient information of each of the convolution kernels according to a plurality of groups of the weight gradient accumulation results of the plurality of convolution kernels after traversing the membrane potential gradient change information corresponding to each of the convolution kernels in the target pulse neural network comprises: in the case that the M is less than the total number of convolution kernels of the target pulse neural network, storing the weight gradient accumulation results of a plurality of groups of M convolution kernels in the target clock step into the data storage unit according to the M and the total number of convolution kernels; and obtaining the weight gradient information of each of the channel dimensions of each of the convolution kernels in the target clock step of the target pulse neural network according to the weight gradient accumulation results stored in the data storage unit.

[0011] In some embodiments, after the pulse change signals of each channel dimension and the membrane potential gradient change information corresponding to each convolution kernel in the target pulse neural network are obtained, the method further comprises: in the case that all the pulse signal values read in the current clock cycle are 0, skipping reading of the gradient change values in the membrane potential gradient change information in the current clock cycle.

[0012] In some embodiments, the obtaining of the pulse change signals of each channel dimension and the membrane potential gradient change information corresponding to each convolution kernel in the target pulse neural network comprises: obtaining forward calculation data and back propagation data in a training process of the target pulse neural network; obtaining the pulse change signals of each channel dimension according to the forward calculation data, and obtaining the membrane potential gradient change information corresponding to each convolution kernel according to the back propagation data.

[0013] In some embodiments, after the weight gradient information of each convolution kernel is obtained, the method further comprises: obtaining corresponding weight gradient information in multiple clock steps, and obtaining the weight gradient of the target pulse neural network according to the weight gradient information corresponding to the multiple clock steps.

[0014] To achieve the above object, a second aspect of the embodiments of the present application provides a pulse neural network weight gradient calculation device, comprising: a first data storage unit configured to obtain pulse change signals of each channel dimension and membrane potential gradient change information corresponding to each convolution kernel in a target pulse neural network; and configured to read corresponding pulse signal values in multiple clock sliding windows according to clock cycles for each pulse change signal, and in the case that the pulse signal values read in the current clock cycle are not all 0, read gradient change values from each membrane potential gradient change information; a weight gradient calculation unit configured to, in the case that the pulse signal values read in the current clock cycle are not all 0, input the read multiple gradient change values to a preset accumulator array and input the read multiple pulse signal values to a plurality of preset selectors, so that the accumulator array performs accumulation processing between the multiple gradient change values and the gradient accumulation results of the last historical clock cycle according to the multiple pulse signal values controlled by the plurality of selectors through the plurality of selectors, to obtain multiple gradient accumulation results in the current clock cycle; a second data storage unit configured to obtain weight gradient accumulation results of multiple convolution kernels in a target clock step according to each gradient accumulation result of each clock sliding window of each pulse change signal, and configured to, after traversing the membrane potential gradient change information corresponding to each convolution kernel in the target pulse neural network, obtain weight gradient information of each convolution kernel according to multiple sets of the weight gradient accumulation results corresponding to the multiple convolution kernels.

[0015] To achieve the above object, a third aspect of the embodiments of the present application provides an electronic device, comprising: at least one processor; at least one memory for storing at least one program; and when the at least one program is executed by the at least one processor, the method for calculating the weight gradient of the spiking neural network according to any one of the first aspect is implemented.

[0016] To achieve the above object, a fourth aspect of the embodiments of the present application provides a computer-readable storage medium, which stores computer-executable instructions for executing the method for calculating the weight gradient of the spiking neural network according to any one of the fourth aspect.

[0017] The embodiments of the present application provide a method and device for calculating the weight gradient of a spiking neural network, and a storage medium. The method comprises the following steps: obtaining a pulse change signal of each channel dimension in a target spiking neural network and membrane potential gradient change information corresponding to each convolution kernel, wherein the pulse change signal indicates whether a neuron fires a pulse in a forward propagation process, and the membrane potential gradient change information indicates a membrane potential gradient of each neuron in a backward propagation process; dividing data into a plurality of clock sliding windows when calculating the weight gradient, each clock sliding window containing a certain number of time points; reading pulse signal values in the plurality of pulse change signals according to a clock period in each clock sliding window; reading gradient change values in the membrane potential gradient change information only when the plurality of pulse signal values read in the current clock period are not all 0, and inputting the read gradient change values to a preset accumulator array by row and inputting the pulse signal values to a plurality of selectors; using the sparsity of the pulse change signal to control the calculation of the accumulators by the plurality of selectors, such as ignoring the corresponding gradient change value and not performing an accumulation operation when the gradient change value of a certain time point is 0, so that the selectors can control the plurality of accumulators in the accumulator array to accumulate the gradient change values to the gradient accumulation results of the previous clock period by column, thereby obtaining a plurality of gradient accumulation results of the current clock period; and obtaining a weight gradient accumulation result of the plurality of convolution kernels in a target clock step according to the gradient accumulation results of each pulse change signal in each clock sliding window in the current clock period, and obtaining the weight gradient information of each convolution kernel by accumulating the gradient accumulation results in each clock sliding window. It can be understood that there is no valid calculation result when the pulse signal value is 0, so the present application only reads the gradient change value when the pulse signal value is not all 0, and controls the calculation of the accumulators by the selectors when reading, and ignores the read gradient change value when the pulse signal value is 0, which can effectively skip the reading operation of the read gradient change value corresponding to the pulse signal value of 0, reduce unnecessary memory access, effectively avoid invalid calculation, reduce energy consumption in the process of calculating the weight gradient of the spiking neural network, and improve the calculation efficiency. BRIEF DESCRIPTION OF DRAWINGS

[0018] Figure 1 A flowchart of the pulse neural network weight gradient calculation method provided by an embodiment of the present application is shown in FIG. 1.

[0019] Figure 2 A schematic diagram of the device corresponding to the pulse neural network weight gradient calculation method provided by an embodiment of the present application is shown in FIG. 2.

[0020] Figure 3 A flowchart of reading the corresponding pulse signal value in the pulse neural network weight gradient calculation method provided by an embodiment of the present application is shown in FIG. 3.

[0021] Figure 4 A flowchart of inputting to the preset plurality of selectors in the pulse neural network weight gradient calculation method provided by an embodiment of the present application is shown in FIG. 4.

[0022] Figure 5 A flowchart of obtaining a plurality of gradient accumulation results in the pulse neural network weight gradient calculation method provided by an embodiment of the present application is shown in FIG. 5.

[0023] Figure 6 A flowchart of obtaining a weight gradient accumulation result in the pulse neural network weight gradient calculation method provided by an embodiment of the present application is shown in FIG. 6.

[0024] Figure 7 A flowchart of obtaining weight gradient information of each of the convolution kernels in the pulse neural network weight gradient calculation method provided by an embodiment of the present application is shown in FIG. 7.

[0025] Figure 8 A schematic diagram corresponding to the pulse neural network weight gradient calculation method provided by an embodiment of the present application is shown in FIG. 8.

[0026] Figure 9 Another schematic diagram corresponding to the pulse neural network weight gradient calculation method provided by an embodiment of the present application is shown in FIG. 9.

[0027] Figure 10 A structural schematic diagram of the electronic device provided by an embodiment of the present application is shown in FIG. 10. DETAILED DESCRIPTION

[0028] In order to make the objectives, technical solutions and advantages of the present application clearer, the present application is further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and do not limit the present application.

[0029] In some embodiments, although the functional module division is made in the system schematic diagram, and the logical sequence is shown in the flowchart, in some cases, the steps shown or described can be performed in a different order from the module division in the system or the sequence in the flowchart. The terms first, second, etc. in the specification and claims and the above-described drawings are used to distinguish similar objects, and do not necessarily describe a specific order or sequence.

[0030] In addition, unless otherwise explicitly specified and limited, the term "connection / connection" should be understood broadly, for example, it can be a fixed connection or a movable connection, or a detachable connection or a non-detachable connection, or an integral connection; it can be a mechanical connection, or an electrical connection or can communicate with each other; it can be directly connected, or indirectly connected through an intermediate medium.

[0031] In the description of the embodiments of the present application, the description of the terms "one embodiment / implementation", "another embodiment / implementation" or "some embodiments / implementation", "in the above-described embodiment / implementation" and the like means that the specific features, structures, materials or characteristics described in conjunction with the embodiments or examples are contained in at least two embodiments or implementations of the present disclosure. In the present disclosure, the illustrative description of the above terms does not necessarily refer to the same embodiment or implementation. It should be noted that although the logical sequence is shown in the flowchart, in some cases, the steps shown or described can be performed in a different order from the sequence in the flowchart.

[0032] Spiking Neural Networks (SNNs) as a new type of neural network model, by simulating the pulse firing mechanism of biological neurons, and using event-driven computing, can improve energy efficiency and computing efficiency, and perform well in processing sparse and asynchronous data, suitable for low-power and high-performance computing needs.

[0033] However, the current training process of the spiking neural network is relatively complex, involving three stages of forward propagation (FF), back propagation (BP) and weight gradient (WG) update, wherein the weight gradient update accounts for about one third of the total training computation, and the existing accelerator training process often performs a large amount of invalid computation based on sparse data when processing the weight gradient update, causing waste of computing resources, resulting in high energy consumption and low efficiency of the current weight gradient update and spiking neural network training process.

[0034] It can be understood that, in order to overcome the limitations in the prior art, the embodiments of the present application provide a pulse neural network weight gradient calculation method and related equipment, which can input multiple pulse signal values to multiple selectors, so that the multiple selectors control the accumulator array to perform gradient accumulation calculation, realize the sparsity optimization of weight gradient data, and effectively avoid invalid calculation, reduce the energy consumption in the pulse neural network weight gradient calculation process, and improve the calculation efficiency.

[0035] The embodiments of the present application will be further described below with reference to the drawings.

[0036] Reference Figure 1 , Figure 1 The flowchart of the pulse neural network weight gradient calculation method provided by an embodiment of the present application; in some embodiments, the present application provides a pulse neural network weight gradient calculation method, which includes but is not limited to the following steps:

[0037] Step S110, obtaining the pulse change signal of each channel dimension in the target pulse neural network and the membrane potential gradient change information corresponding to each convolution kernel;

[0038] Step S120, for each pulse change signal, reading the corresponding pulse signal value in multiple clock sliding windows according to the clock period, to obtain multiple pulse signal values;

[0039] Step S130, in the case that the multiple pulse signal values read in the current clock period are not all 0, reading the gradient change value from each membrane potential gradient change information, inputting the multiple gradient change values read to the preset accumulator array according to the row, and inputting the multiple pulse signal values read to the preset multiple selectors, to control the accumulator array to perform accumulation processing between the multiple gradient change values and the gradient accumulation result of the last historical clock period according to the multiple pulse signal values, to obtain the multiple gradient accumulation results in the current clock period through the multiple selectors;

[0040] Step S140, obtaining the weight gradient accumulation result of the multiple convolution kernels in the target clock step according to each gradient accumulation result of each clock sliding window of each pulse change signal;

[0041] Step S150, after traversing the membrane potential gradient change information corresponding to each convolution kernel in the target pulse neural network, obtaining the weight gradient information of each convolution kernel according to the multiple weight gradient accumulation results corresponding to the multiple convolution kernels.

[0042] In some embodiments, corresponding to step S110, data changes of all channels involved in the spiking neural network (SNN) are obtained, including spike and membrane potential gradient (▽U), where spike represents the activation state of neurons, and membrane potential gradient is information used to update weights in the backpropagation process.

[0043] In some embodiments, corresponding to step S120, for the spike change signal of each channel, the application can read the value of the spike signal according to a certain clock sliding window in each clock cycle. This helps to capture the spike activity at different time points.

[0044] In some embodiments, corresponding to step S130, when the read spike signal value is not all 0, it means that there is valid spike activity, at this time the corresponding membrane potential gradient change value is read and input into the adder array for accumulation operation, at the same time, the spike signal value is used to control the selector to determine which gradient change value should be accumulated to the previous result, so as to obtain the gradient accumulation result in the current clock cycle.

[0045] In some embodiments, corresponding to step S140, for each spike change signal, the gradient accumulation result obtained in each clock cycle is combined in a given clock sliding window to form the weight gradient accumulation result for multiple convolution kernels.

[0046] In some embodiments, corresponding to step S150, after traversing all the membrane potential gradient change information, the weight gradient accumulation result of each convolution kernel is summarized to obtain the final weight gradient information. The convolution kernel here can be understood as the weight matrix in the neural network, and the weight gradient information is used to guide the subsequent weight update operation to improve the performance of the network.

[0047] In some embodiments, according to the steps S110-S150 described above, the embodiments of the present application can obtain the pulse change signal of each channel dimension in the target spiking neural network and the membrane potential gradient change information corresponding to each convolution kernel, the pulse change signal represents whether the neuron fires a pulse in the forward propagation process, and the membrane potential gradient change information represents the membrane potential gradient of each neuron in the backward propagation process. Then, when calculating the weight gradient, the data can be divided into multiple clock sliding window processes, each clock sliding window contains a certain number of time points, and in each clock sliding window, the pulse signal values in the multiple pulse change signals are read according to the clock period. Further, in the case that the multiple pulse signal values read in the current clock period are not all 0, the gradient change value in the membrane potential gradient change information is read, and the read gradient change value is input to the preset accumulator array by row, and the pulse signal value is input to the preset multiple selectors. By using the sparsity of the pulse change signal, the calculation of the accumulators is controlled by the multiple selectors. For example, if the gradient change value of a certain time point is 0, the corresponding gradient change value is ignored and no accumulation operation is performed, so that the selector can control the multiple accumulators in the accumulator array to accumulate the gradient change value to the gradient accumulation result of the previous clock period, and obtain the multiple gradient accumulation results of the current clock period. Further, according to the gradient accumulation result of each pulse change signal in each clock sliding window in the current clock period, the weight gradient accumulation result of the multiple convolution kernels in the target clock step is obtained, and by accumulating the gradient accumulation result in each clock sliding window, the weight gradient information of each convolution kernel is obtained. It can be understood that when the pulse signal value is 0, there is no effective calculation result, so the present application only reads the gradient change value when the pulse signal value is not all 0, and controls the calculation of the accumulators by the selector when reading. When the pulse signal value is 0, the read gradient change value is ignored, which can effectively skip the reading operation of the read gradient change value corresponding to the pulse signal value of 0, reduce unnecessary memory access, and effectively avoid invalid calculation, reduce the energy consumption in the process of calculating the weight gradient of the spiking neural network, and improve the calculation efficiency.

[0048] Reference Figure 2 , Figure 2 The device schematic diagram corresponding to the pulse neural network weight gradient calculation method provided by an embodiment of the present application; Figure 2The pulse neural network weight gradient calculation engine of the present application is shown, which is composed of a weight gradient calculation engine array and a corresponding SRAM. The weight gradient calculation engine array is composed of an NxM adder array and a selector, and its input includes spike signals generated in the forward calculation process, which are spread horizontally on the array and distributed along the channel dimension; and membrane potential gradient (▽U) generated in the back propagation process, which are spread vertically on the array and also distributed along the channel dimension. The spike signals of N channels are broadcast vertically to N columns of the weight gradient calculation engine array, while the △U signals of M channels are broadcast horizontally to M rows of the weight gradient calculation engine array. Each column of the weight gradient calculation engine array shares a selector, and the N input spike signals are the selection signals of the corresponding column selector. When the spike value is 1, the adder of the corresponding column performs the addition operation on the input membrane potential gradient; when the spike value is 0, the adder of the corresponding column ignores the input membrane potential gradient. The M rows of the weight gradient calculation engine array first calculate the weight gradient information of M kernels in a single clock step, and finally obtain the weight gradient by accumulating the gradient information of different clock steps. The specific calculation formula is as follows:

[0049] Wherein, SRAM is a semiconductor random access memory, used for storing membrane potential gradient, spike and weight; spike is a pulse signal generated by a neuron, which can usually only be 0 or 1, corresponding to the pulse change signal of each channel dimension; S l and the formula represent the pulse signal value of the pulse change signal, and represent the membrane potential gradient change information corresponding to each convolution kernel, kernel is a convolution kernel, and

[0050] It can be understood that the above Figure 2 corresponds to the matrix multiplication calculation process in the present application. Based on the above matrix multiplication calculation process, the present application ignores the cumulative calculation corresponding to the spike value of 0 through the selector, thereby realizing the sparsity optimization of the weight gradient data, thereby effectively avoiding invalid calculation, reducing the energy consumption in the pulse neural network weight gradient calculation process, and improving the calculation efficiency.

[0051] Referring to Figure 3 , Figure 3 In the pulse neural network weight gradient calculation method provided by an embodiment of the present application, the flowchart of reading the corresponding pulse signal value is shown; in some embodiments, for each pulse change signal, the corresponding pulse signal value is read in a plurality of clock sliding windows according to the clock period, including but not limited to the following steps:

[0052] Step S310, obtain configuration information of the target spiking neural network;

[0053] Step S320, determine, according to the configuration information, that the reading number of the pulse change signal is N, and determine that the reading number of the membrane potential gradient change information corresponding to the convolution kernel is M;

[0054] Step S330, select N pulse change signals, and for each pulse change signal in the N pulse change signals, read the corresponding pulse signal value in the multiple clock sliding windows according to the clock period.

[0055] In some embodiments, the configuration information refers to the basic parameter setting of the spiking neural network, including but not limited to the basic information such as network structure, number of layers, number of neurons in each layer, and training parameters that may be involved, such as learning rate, weight decay coefficient, etc.; further, according to the configuration information, it is determined that the reading number of the pulse change signal is N, and it is determined that the reading number of the membrane potential gradient change information corresponding to the convolution kernel is M, it can be understood that in the process of weight gradient calculation, the channel number N of the pulse signal (i.e. the activation state of the neuron) to be processed and the number M of the corresponding convolution kernel (or filter) need to be known, which determines the input size of the weight gradient calculation engine; further, select N pulse change signals, and for each pulse change signal in the N pulse change signals, read the corresponding pulse signal value in the multiple clock sliding windows according to the clock period. This means that in the actual calculation, the change values of N pulse signals will be read from the storage according to the pre-defined clock period (i.e. the time unit of calculation), and the clock sliding window here refers to the clock sliding window used to accumulate the influence of pulse activity in a period of time during weight gradient calculation. The activity pattern of the neuron can be captured at different time points, and the weight gradient can be calculated accordingly for subsequent weight update.

[0056] Reference Figure 4 , Figure 4 In the spiking neural network weight gradient calculation method provided by an embodiment of the present application, the flowchart input to the preset selectors; in some embodiments, the accumulator array includes N columns and M rows of accumulators, the gradient change values are read from each membrane potential gradient change information, the read multiple gradient change values are input to the preset accumulator array by row, and the read multiple pulse signal values are input to the preset multiple selectors, including but not limited to the following steps:

[0057] Step S410, read the gradient change values of the current clock period from the M membrane potential gradient change information, and input the read M gradient change values to the N accumulators of each row of the accumulator array by row respectively;

[0058] Step S420, input the read N pulse signal values to the preset N selectors, and the N selectors are respectively connected with the input ends of the M accumulators in each column of the accumulator array.

[0059] In some embodiments, in the current clock cycle, the gradient change values of the M membrane potential gradient change information (▽U) are read from the memory, the gradient change values represent the errors generated in the forward propagation process, which are needed to update the weights, so each gradient change value is allocated to a row of the accumulator array, and there are M rows, each row has N accumulators; further, input the N spike signal values into the preset N selectors, each selector is responsible for controlling whether the M accumulators in the corresponding column perform addition operation or not, it can be understood that when the spike signal value received by a certain selector is 1, the accumulators in the column will receive and accumulate the gradient change values from the same row; if the spike signal value is 0, the accumulators in the column will ignore the gradient change values from the same row and will not perform the accumulation operation, so that the sparsity of the spike signal can be used to reduce unnecessary calculation and SRAM access, thereby reducing power consumption.

[0060] Reference Figure 5 , Figure 5 In the pulse neural network weight gradient calculation method provided by an embodiment of the application, a flowchart for obtaining multiple gradient accumulation results is provided; in some embodiments, multiple selectors are used to control the accumulator array to perform accumulation processing between the multiple gradient change values and the gradient accumulation results in the last historical clock cycle, so as to obtain the multiple gradient accumulation results in the current clock cycle, including but not limited to the following steps:

[0061] Step S510, input the gradient accumulation results in the last clock cycle output by each accumulator in the accumulator array to the accumulator;

[0062] Step S520, control the multiple accumulators in the corresponding column by using the selectors in the N selectors whose spike signal values are not 0, to perform accumulation processing between the multiple gradient change values and the gradient accumulation results in the last historical clock cycle, so as to obtain the multiple gradient accumulation results in the current clock cycle;

[0063] Step S530, control the multiple accumulators in the corresponding column by using the selectors in the N selectors whose spike signal values are 0, to determine the gradient accumulation results in the last clock cycle as the gradient accumulation results of the corresponding accumulators in the current clock cycle.

[0064] In some embodiments, since the present application will continue to accumulate new results based on the previous gradient accumulation results to obtain the gradient accumulation results of the current clock cycle, the gradient accumulation results calculated by each accumulator in the accumulator array in the last clock cycle need to be input again into the respective accumulators as inputs; further, the accumulators in the corresponding column are controlled to calculate by the selector receiving the non-zero pulse signal value, for example, when a certain selector detects that the corresponding pulse signal value is not 0, it allows the input of all accumulators in the column (i.e. the current read gradient change value) to be added to the gradient accumulation results saved in the last clock cycle, thereby obtaining the new gradient accumulation results in the current clock cycle.

[0065] In addition, it can be understood that the selector receiving the zero pulse signal value will control the accumulators in the corresponding column to directly take the gradient accumulation results of the last clock cycle as the results of the current clock cycle, which means that if no new pulse signal occurs, the gradient accumulation results will remain unchanged, which can enable the present application to effectively utilize the sparsity characteristics in the spiking neural network, i.e. most of the time points neurons do not generate pulses (i.e. are not active), so there is no need to update the weight gradient. Only when a valid pulse is detected, the accumulation operation will be performed to reduce unnecessary calculations, reduce energy consumption, and improve computational efficiency.

[0066] Reference Figure 6 , Figure 6 In the pulse neural network weight gradient calculation method provided by an embodiment of the present application, a flowchart for obtaining the weight gradient accumulation results; in some embodiments, according to each gradient accumulation result of each pulse change signal in each clock sliding window, the weight gradient accumulation results of a plurality of convolution kernels in a target clock step are obtained, including but not limited to the following steps:

[0067] Step S610, storing the gradient accumulation results of the N pulse change signals in the plurality of clock sliding windows into a preset data storage unit;

[0068] Step S620, after traversing each clock sliding window corresponding to the target clock step, if N is less than the total number of channel dimensions of the target spiking neural network, then according to N and the total number of channel dimensions, the gradient accumulation results of a plurality of groups of N pulse change signals in the target clock step are stored into the data storage unit;

[0069] Step S630, according to the gradient accumulation results stored in the data storage unit, obtaining the weight gradient accumulation results of M convolution kernels in each channel dimension in the target clock step.

[0070] In some embodiments, the gradient accumulation results calculated for the N pulse change signals in each clock sliding window are stored in a preset data storage unit, which can be a specially designed hardware register or memory area, for temporarily saving the intermediate results of the calculation. After all the clock sliding windows contained in the target clock step are traversed, if the number of the N pulse change signals currently processed is less than the total channel dimension number of the pulse neural network, the gradient accumulation results of these N pulse change signals in the entire target clock step need to be summarized and stored. After the above storage is completed, the weight gradient accumulation results of each channel dimension of the M convolution kernels during the entire target clock step are calculated based on all the gradient accumulation results saved in the storage unit, so as to obtain the complete weight gradient information of each convolution kernel in the entire considered time period.

[0071] Reference Figure 7 , Figure 7 In the pulse neural network weight gradient calculation method provided by an embodiment of the present application, the flowchart of obtaining the weight gradient information of each convolution kernel; in some embodiments, after the membrane potential gradient change information corresponding to each convolution kernel in the target pulse neural network is traversed, the weight gradient information of each convolution kernel is obtained based on the weight gradient accumulation results of multiple groups of multiple convolution kernels, including but not limited to the following steps:

[0072] Step S710, in the case where M is less than the total number of convolution kernels of the target pulse neural network, the weight gradient accumulation results of the multiple groups of M convolution kernels in the target clock step are stored in the data storage unit according to M and the total number of convolution kernels.

[0073] Step S720, the weight gradient information of each channel dimension of each convolution kernel in the target pulse neural network in the target clock step is obtained based on the weight gradient accumulation results stored in the data storage unit.

[0074] Among them, the weight gradient accumulation results of these M convolution kernels in each clock sliding window are stored in the data storage unit, in order to ensure the recording of the weight gradient information of all convolution kernels, and then all the stored gradient accumulation results are comprehensively processed to obtain the complete weight gradient information of each convolution kernel in the entire considered time period.

[0075] In some embodiments, after obtaining the plurality of pulse signal values by reading the corresponding pulse signal values in the clock cycles in the plurality of clock sliding windows respectively for each pulse change signal, the method further comprises: in the case that the plurality of pulse signal values read in the current clock cycle are all 0, skipping the reading of the gradient change value in the plurality of membrane potential gradient change information in the current clock cycle. It can be understood that if all the pulse signal values read in the current clock cycle are 0, it means that no pulse activity occurs, so the reading of the membrane potential gradient change information can be skipped.

[0076] In some embodiments, obtaining the pulse change signal of each channel dimension and the membrane potential gradient change information corresponding to each convolution kernel in the target spiking neural network comprises: obtaining the forward calculation data and the back propagation data in the training process of the target spiking neural network; obtaining the pulse change signal of each channel dimension according to the forward calculation data, and obtaining the membrane potential gradient change information corresponding to each convolution kernel according to the back propagation data.

[0077] In some embodiments, after obtaining the weight gradient information of each convolution kernel, the method further comprises: obtaining the corresponding weight gradient information in a plurality of clock steps, and obtaining the weight gradient of the target spiking neural network according to the weight gradient information corresponding to the plurality of clock steps, that is, accumulating the gradient information of different time steps to obtain the weight gradient information of the spiking neural network.

[0078] Reference Figure 8 , Figure 8The schematic diagram corresponding to the pulse neural network weight gradient calculation method provided by an embodiment of the present application; wherein, PE represents an accumulator, concat represents a signal merging module for merging two or more data streams into a single data stream, and the weight gradient calculation process of the present application involves accumulating the weight gradient in the time dimension. Specifically, the calculation first operates the last layer membrane potential gradient and the pulse tensor of the current layer at time T to obtain the weight gradient value at this time. Then, the weight gradient value is accumulated with the weight gradient value at the previous time. In this way, the gradient information at different clock steps is accumulated, and the final weight gradient is obtained. In each calculation process, the Spike values of N channels are taken out from the input SRAM and broadcast to the array; at the same time, the M channel values of △U are broadcast to the array. NxM accumulators perform calculation synchronously and return the results to the accumulators. In the next clock cycle, the N channel values of the next point of Spike and the M channel values of △U are broadcast to the array and accumulated with the results of the last clock cycle. Each accumulator adopts an Output stationary design to realize the convolution accumulation function. Once all Spike and △U points in a sliding window are accumulated, the calculation result is output to the array and written to the output SRAM. Then, the convolution calculation of the next sliding window will begin.

[0079] Reference Figure 9 , Figure 9 Another schematic diagram corresponding to the pulse neural network weight gradient calculation method provided by an embodiment of the present application is provided. Figure 9 The sparse design of the weight gradient calculation engine in the present application is shown. The engine array is composed of an NxM adder array and a selector. By utilizing the sparsity of spike, the present application controls the calculation of the accumulator through the gating1 signal. When a spike is 0, the accumulation operation of the corresponding M accumulators is ignored. If all N spikes are 0, the SRAM reading of △U is skipped through the gating2 signal. The sparse design of the present application utilizes the sparsity of spike and △U signals, reduces redundant calculation and related SRAM reading and writing, and thus reduces the power consumption of the engine.

[0080] In some embodiments, the present application can actively perform the following steps:

[0081] S01: Write spike and △U at time T into the on-chip input SRAM;

[0082] S02: Software configures the size of spike and △U and the kernel size of △W, and issues a convolution calculation start signal after the configuration is completed;

[0083] S03: Take N channel values from the input SRAM, judge whether these values are all zeros;

[0084] S04: If N spikes are all zeros, do not start the read data operation of △U, the accumulator gating is valid, and no accumulation is performed;

[0085] S05: If N spikes are not all zeros, start the read data operation of △U, and broadcast the values of S and △U to the accumulator array;

[0086] S06: The adder performs accumulation judgment, when the spike value is 1, the adder of the corresponding column performs addition operation on the input membrane potential gradient; when the spike value is 0, the adder of the corresponding column ignores the input membrane potential gradient;

[0087] S07: The output result of the adder returns to the adder as input until the multiplication and addition calculation of S and △U of a clock sliding window is completed;

[0088] S08: After the calculation of a clock sliding window is completed, the weight gradient result of the last clock sliding window is accumulated, and the calculation result is output to the array and written into the output SRAM;

[0089] S09: S03 to S08 are executed in a loop, the clock sliding window loop is completed first, and N channel weight gradient information of M kernels in one time step is obtained;

[0090] S10: Take the next group of N channel values of S, execute S03 to S09 in a loop, and obtain the next group of N channel weight gradient information of M kernels in one time step. After N cycles of S channels, the weight gradient information of all channels of M kernels in one time step is obtained;

[0091] S11: Take the next group of M channel values of △U, execute S03 to S10 in a loop, and obtain the next group of M kernel weight gradient information of all channels in one time step. After M cycles of △U channels, the weight gradient information of all channels of all kernels in one time step is obtained. In this way, the read operation of the gradient change value corresponding to the pulse signal value of 0 can be effectively skipped, unnecessary memory access can be reduced, invalid calculation can be effectively avoided, energy consumption in the process of pulse neural network weight gradient calculation can be reduced, and calculation efficiency can be improved.

[0092] Some embodiments of the present application provide a pulse neural network weight gradient calculation device, comprising: a first data storage unit configured to obtain a pulse change signal of each channel dimension in a target pulse neural network and membrane potential gradient change information corresponding to each convolution kernel; and configured to read a corresponding pulse signal value in a plurality of clock sliding windows according to a clock period for each pulse change signal, and read a gradient change value in the plurality of membrane potential gradient change information in a case that the plurality of pulse signal values read in the current clock period are not all 0; a weight gradient calculation unit configured to input the plurality of gradient change values to a preset accumulator array by row in a case that the plurality of pulse signal values read in the current clock period are not all 0, and input the plurality of pulse signal values to a plurality of selectors, so as to control the plurality of accumulators in the accumulator array to accumulate the gradient change values to the gradient accumulation result of the last clock period by column through the plurality of selectors, to obtain a plurality of gradient accumulation results of the current clock period; a second data storage unit configured to obtain a weight gradient accumulation result of the plurality of convolution kernels in a target clock step according to each gradient accumulation result of each clock sliding window of each pulse change signal; and configured to obtain weight gradient information of each convolution kernel according to a plurality of weight gradient accumulation results corresponding to the plurality of convolution kernels after traversing the membrane potential gradient change information corresponding to each convolution kernel in the target pulse neural network.

[0093] In the present application, the first data storage unit can be a semiconductor random access memory configured to store the pulse change signal of each channel dimension in the target pulse neural network and the membrane potential gradient change information corresponding to each convolution kernel, the weight gradient calculation unit can be an accumulator array configured to perform matrix calculation and comprising a plurality of accumulators and a plurality of selectors, the second data storage unit can be a semiconductor random access memory configured to store the gradient accumulation result, the weight gradient accumulation result and the weight gradient information, the input end of the plurality of accumulators in the accumulator array is connected to the first data storage unit through the plurality of selectors in column, the output end of the plurality of accumulators in the accumulator array is connected to the first data storage unit, the corresponding pulse signal value and the gradient change value are input to the weight gradient calculation unit through the first data storage unit, and then the plurality of gradient accumulation results of the current clock period output by the weight gradient calculation unit can be obtained, the plurality of gradient accumulation results are stored in the second data storage unit for accumulation and summation, so as to obtain the weight gradient information of each convolution kernel, and invalid calculation can be effectively avoided and the calculation efficiency can be improved.

[0094] In some embodiments, the first data storage unit is configured to obtain configuration information of the target spiking neural network in a process of reading, for each pulse change signal, a corresponding pulse signal value in a plurality of clock sliding windows according to a clock period; determine, according to the configuration information, that the reading number of the pulse change signal is N, and the reading number of the membrane potential gradient change information corresponding to the convolution kernel is M; and select N pulse change signals, and read, for each pulse change signal in the N pulse change signals, a corresponding pulse signal value in a plurality of clock sliding windows according to a clock period.

[0095] In some embodiments, the accumulator array includes N columns and M rows of accumulators, and the weight gradient calculation unit is configured to read gradient change values in the M membrane potential gradient change information in a current clock period, and input the M gradient change values into N accumulators in each row of the accumulator array row by row in a process of reading the gradient change values in the plurality of membrane potential gradient change information, and inputting the plurality of pulse signal values into the plurality of selectors.

[0096] In some embodiments, the weight gradient calculation unit is configured to input, into each accumulator in the accumulator array, a gradient accumulation result of a previous clock period output by the accumulator in a process of controlling, by the plurality of selectors, the plurality of accumulators in the accumulator array to accumulate the gradient change values on the gradient accumulation result of the previous clock period to obtain a plurality of gradient accumulation results of a current clock period; control, by a plurality of selectors in which the pulse signal values are not 0, the plurality of accumulators in the corresponding column to calculate a sum of the gradient change value and the gradient accumulation result of the previous clock period, and determine the sum as the gradient accumulation result of the corresponding accumulator in the current clock period; and control, by a plurality of selectors in which the pulse signal values are 0, the plurality of accumulators in the corresponding column to determine the gradient accumulation result of the previous clock period as the gradient accumulation result of the corresponding accumulator in the current clock period.

[0097] In some embodiments, the second data storage unit is configured to store the gradient accumulation results of the N pulse change signals in the plurality of clock sliding windows to the preset data storage unit in a process of accumulating the gradient of each gradient of each pulse change signal in each clock sliding window to obtain the weight gradient accumulation results of the plurality of convolution kernels in the target clock step; after traversing each clock sliding window corresponding to the target clock step, if N is less than the total number of channel dimensions of the target pulse neural network, the second data storage unit is configured to store the gradient accumulation results of the plurality of groups of N pulse change signals in the target clock step to the data storage unit according to N and the total number of channel dimensions; and the second data storage unit is configured to obtain the weight gradient accumulation results of each channel dimension of each convolution kernel in the target clock step according to the gradient accumulation results stored in the data storage unit.

[0098] In some embodiments, the second data storage unit is configured to store the gradient accumulation results of the M convolution kernels in the target clock step to the data storage unit according to M and the total number of convolution kernels in a process of obtaining the weight gradient information of each convolution kernel according to the plurality of groups of weight gradient accumulation results corresponding to the plurality of convolution kernels after traversing the membrane potential gradient change information corresponding to each convolution kernel in the target pulse neural network; and the second data storage unit is configured to obtain the weight gradient information of each channel dimension of each convolution kernel in the target pulse neural network in the target clock step according to the weight gradient accumulation results stored in the data storage unit.

[0099] In some embodiments, after reading the pulse signal values corresponding to each pulse change signal in the plurality of clock sliding windows according to the clock period respectively, the first data storage unit is further configured to skip reading the gradient change values in the plurality of membrane potential gradient change information in the current clock period if the plurality of pulse signal values read in the current clock period are all 0.

[0100] In some embodiments, the first data storage unit is configured to obtain the forward calculation data and the back propagation data in the training process of the target pulse neural network in a process of obtaining the pulse change signals of each channel dimension and the membrane potential gradient change information corresponding to each convolution kernel in the target pulse neural network; and the first data storage unit is configured to obtain the pulse change signals of each channel dimension according to the forward calculation data and obtain the membrane potential gradient change information corresponding to each convolution kernel according to the back propagation data.

[0101] In some embodiments, after obtaining the weight gradient information of each convolution kernel, the second data storage unit is further configured to obtain the corresponding weight gradient information in the plurality of clock steps, and obtain the weight gradient of the target pulse neural network according to the weight gradient information corresponding to the plurality of clock steps.

[0102] It is understood that the spiking neural network weight gradient calculation device in the above embodiments can implement the spiking neural network weight gradient calculation method in any of the above embodiments to achieve the corresponding technical effect, so it will not be described in detail here.

[0103] Some embodiments of this application provide an electronic device. Figure 10 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application, with reference to... Figure 10 The electronic device includes a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements the spiking neural network weight gradient calculation method of any of the above embodiments, for example, performing the above-described... Figure 1 Method steps S110 to S150, Figure 3 Method steps S310 to S330, Figure 4 Method steps S410 to S420, Figure 5 Method steps S510 to S530, Figure 6 Method steps S610 to S630, Figure 7 Method steps S710 to S720.

[0104] The electronic device 1000 of this application embodiment includes one or more processors 1010 and memory 1020. Figure 10 The example uses a processor 1010 and a memory 1020.

[0105] The processor 1010 and the memory 1020 can be connected via a bus or other means. Figure 10 Taking the example of a connection between China and Israel via a bus.

[0106] Memory 1020, as a non-transitory computer-readable storage medium, can be used to store non-transitory software programs and non-transitory computer-executable programs. Furthermore, memory 1020 may include high-speed random access memory, and may also include non-transitory memory, such as at least one disk storage device, flash memory device, or other non-transitory solid-state storage device. In some embodiments, memory 1020 may optionally include memory 1020 remotely located relative to processor 1010. These remote memories can be connected to electronic device 1000 via a network, and examples of such networks include, but are not limited to, the Internet, intranets, local area networks, mobile communication networks, and combinations thereof.

[0107] In some embodiments, when the processor executes a computer program, it executes the spiking neural network weight gradient calculation method of any of the above embodiments at preset intervals.

[0108] Those skilled in the art will understand thatFigure 10 The device structure shown does not constitute a limitation on the electronic device 1000, and may include more or fewer components than shown, or combine certain components, or have different component arrangements.

[0109] exist Figure 10 In the electronic device 1000 shown, the processor 1010 can be used to call the spiking neural network weight gradient calculation method stored in the memory 1020, thereby realizing the spiking neural network weight gradient calculation method.

[0110] Based on the hardware structure of the above-mentioned electronic device 1000, various embodiments of the spiking neural network weight gradient calculation device of this application are proposed. At the same time, the non-transient software program and instructions required to implement the spiking neural network weight gradient calculation method of the above embodiments are stored in the memory. When executed by the processor, the spiking neural network weight gradient calculation method of the above embodiments is executed.

[0111] This application also provides a computer-readable storage medium storing computer-executable instructions for executing the above-described spiking neural network weight gradient calculation method. These instructions enable one or more processors to execute the spiking neural network weight gradient calculation method of any of the above embodiments, for example, to execute the methods described above. Figure 1 Method steps S110 to S150, Figure 3 Method steps S310 to S330, Figure 4 Method steps S410 to S420, Figure 5 Method steps S510 to S530, Figure 6 Method steps S610 to S630, Figure 7 Method steps S710 to S720.

[0112] This application also provides a computer program product, which includes a computer program stored in a computer-readable storage medium. A processor of a computer device reads the computer program from the computer-readable storage medium and executes the computer program, causing the computer device to perform a spiking neural network weight gradient calculation method implementing any of the above embodiments, for example, performing the above-described method. Figure 1 Method steps S110 to S150, Figure 3 Method steps S310 to S330, Figure 4 Method steps S410 to S420, Figure 5 Method steps S510 to S530, Figure 6 Method steps S610 to S630,Figure 7 The method steps S710-S720 in the method can be implemented by using the apparatus described above. The apparatus described above is only illustrative, and the units described as separate components can or can not be physically separate, i.e., can be located in one place or distributed over multiple network nodes. Some or all of the modules can be selected according to actual needs to achieve the purpose of the embodiment.

[0113] Those skilled in the art can understand that all or some of the steps in the method disclosed above can be implemented as software, firmware, hardware, and appropriate combinations thereof. Some or all of the physical components can be implemented as software executed by a processor, such as a central processing unit, a digital signal processor, or a microprocessor, or as hardware, or as an integrated circuit, such as an application-specific integrated circuit. Such software can be distributed on a computer-readable medium, which can include computer-readable storage media (or non-transitory media) and communication media (or transitory media). As known to those skilled in the art, the term computer-readable storage media includes volatile and non-volatile, removable and non-removable media implemented in any method or technology for storage of information such as computer-readable instructions, data structures, program modules, or other data. Computer-readable storage media include, but are not limited to, RAM, ROM, EEPROM, flash memory or other memory technology, CD-ROM, digital versatile disks (DVD) or other optical disk storage, magnetic cassettes, magnetic tapes, magnetic disk storage, or other magnetic storage devices, or any other medium that can be used to store the desired information and can be accessed by a computer. Furthermore, as known to those skilled in the art, communication media typically include computer-readable instructions, data structures, program modules, or other data in modulated data signals such as carrier waves or other transport mechanisms, and can include any information delivery medium, which has been specifically described above in detail for the preferred implementation of the present application, but the present application is not limited to the above implementation. Those skilled in the art can make various equivalent modifications or replacements without departing from the spirit of the present application, and these equivalent modifications or replacements are all included in the scope defined by the claims of the present application.

Claims

1. A method for calculating the weight gradient of a spiking neural network, characterized in that, include: Acquire the pulse change signal of each channel dimension in the target spiking neural network and the membrane potential gradient change information corresponding to each convolution kernel; For each pulse change signal, the corresponding pulse signal value is read according to the clock cycle within multiple clock sliding windows to obtain multiple pulse signal values; When the multiple pulse signal values ​​read in the current clock cycle are not all 0, the gradient change value of the current clock cycle is read from M membrane potential gradient change information, and the read M gradient change values ​​are respectively input into N accumulators in each row of the accumulator array; the read N pulse signal values ​​are input into N preset selectors, and the N selectors are respectively connected to the input terminals of M accumulators in each column of the accumulator array, so that the accumulator array is controlled by the N selectors to perform accumulation processing between the multiple gradient change values ​​and the gradient accumulation result of the previous historical clock cycle according to the multiple pulse signal values, so as to obtain the multiple gradient accumulation results of the current clock cycle. The accumulator array includes N columns and M rows of accumulators. Based on the gradient accumulation result of each pulse change signal within each clock sliding window, the weight gradient accumulation result of multiple convolutional kernels in the target clock step is obtained. After traversing the membrane potential gradient change information corresponding to each convolutional kernel in the target spiking neural network, the weight gradient information of each convolutional kernel is obtained based on the cumulative results of the weight gradients corresponding to the multiple convolutional kernels. The step of reading the corresponding pulse signal value within multiple clock windows according to the clock cycle for each pulse change signal to obtain multiple pulse signal values ​​includes: acquiring the configuration information of the target spiking neural network; determining the number of pulse change signals to be read as N and the number of membrane potential gradient change information read corresponding to the convolution kernel to be M based on the configuration information; selecting N pulse change signals, and for each of the N pulse change signals, reading the corresponding pulse signal value within multiple clock windows according to the clock cycle.

2. The method for calculating the weight gradient of a spiking neural network according to claim 1, characterized in that, The process involves using the N selectors to control the accumulator array based on multiple pulse signal values ​​to accumulate multiple gradient change values ​​with the gradient accumulation result of the previous historical clock cycle, thereby obtaining multiple gradient accumulation results for the current clock cycle, including: The gradient accumulation result of the previous clock cycle output by each accumulator in the accumulator array is input into the accumulator respectively; By controlling several selectors among the N selectors whose pulse signal values ​​are not 0, multiple accumulators in the corresponding columns are used to accumulate the multiple gradient change values ​​with the gradient accumulation result of the previous historical clock cycle to obtain the multiple gradient accumulation results of the current clock cycle. By controlling a plurality of the accumulators in the corresponding column through a plurality of selectors whose pulse signal values ​​are 0 among the N selectors, the gradient accumulation result of the previous clock cycle is determined as the gradient accumulation result of the corresponding accumulator in the current clock cycle.

3. The method for calculating the weight gradient of a spiking neural network according to claim 1, characterized in that, The step of obtaining the weight gradient accumulation results of multiple convolutional kernels in the target clock step based on the gradient accumulation results of each gradient accumulation result within each clock sliding window for each pulse change signal includes: The gradient accumulation results of N pulse change signals within the multiple clock sliding windows are stored in a preset data storage unit; After traversing each of the clock windows corresponding to the target clock step, if N is less than the total number of channel dimensions of the target spiking neural network, then the gradient accumulation results of multiple sets of N pulse change signals within the target clock step are stored in the data storage unit according to N and the total number of channel dimensions. Based on the gradient accumulation results stored in the data storage unit, the weight gradient accumulation results of the M convolutional kernels in each channel dimension in the target clock step are obtained.

4. The method for calculating the weight gradient of a spiking neural network according to claim 3, characterized in that, After traversing the membrane potential gradient change information corresponding to each convolutional kernel in the target spiking neural network, the weight gradient information of each convolutional kernel is obtained based on the cumulative results of the weight gradients corresponding to the multiple convolutional kernels, including: If M is less than the total number of convolutional kernels of the target spiking neural network, the weight gradient accumulation results of multiple sets of M convolutional kernels within the target clock step are stored in the data storage unit according to M and the total number of convolutional kernels. Based on the weight gradient accumulation result stored in the data storage unit, the weight gradient information of each convolutional kernel in the target spiking neural network for each channel dimension in the target clock step is obtained.

5. The method for calculating the weight gradient of a spiking neural network according to claim 1, characterized in that, After obtaining multiple pulse signal values ​​by reading the corresponding pulse signal value according to the clock cycle within multiple clock sliding windows for each pulse change signal, the method further includes: If all of the pulse signal values ​​read in the current clock cycle are 0, the reading of gradient change values ​​in the multiple membrane potential gradient change information is skipped in the current clock cycle.

6. The method for calculating the weight gradient of a spiking neural network according to claim 1, characterized in that, The acquisition of pulse change signals in each channel dimension of the target spiking neural network and membrane potential gradient change information corresponding to each convolutional kernel includes: Acquire the forward computation data and backpropagation data during the training process of the target spiking neural network; Based on the forward computation data, the pulse change signal of each channel dimension is obtained, and based on the backpropagation data, the membrane potential gradient change information corresponding to each convolution kernel is obtained.

7. The method for calculating the weight gradient of a spiking neural network according to claim 1, characterized in that, After obtaining the weight gradient information of each convolutional kernel, the method further includes: The corresponding weight gradient information is obtained within multiple clock steps, and the weight gradient of the target spiking neural network is obtained based on the weight gradient information corresponding to the multiple clock steps.

8. A device for calculating the weight gradient of a spiking neural network, characterized in that, include: The first data storage unit is used to acquire the pulse change signal of each channel dimension in the target spiking neural network and the membrane potential gradient change information corresponding to each convolution kernel; And for each pulse change signal, read the corresponding pulse signal value according to the clock cycle in multiple clock sliding windows to obtain multiple pulse signal values, and when the multiple pulse signal values ​​read in the current clock cycle are not all 0, read the gradient change value of the current clock cycle from M membrane potential gradient change information; A weighted gradient calculation unit is used to, when the multiple pulse signal values ​​read in the current clock cycle are not all 0, input the read M gradient change values ​​into N accumulators in each row of the accumulator array, and input the read N pulse signal values ​​into N preset selectors. The N selectors are connected to the input terminals of the M accumulators in each column of the accumulator array, so that the N selectors control the accumulator array to perform accumulation processing between the multiple gradient change values ​​and the gradient accumulation result of the previous historical clock cycle according to the multiple pulse signal values, so as to obtain the multiple gradient accumulation results of the current clock cycle. The accumulator array includes N columns and M rows of accumulators. The second data storage unit is used to obtain the weight gradient accumulation result of multiple convolutional kernels in the target clock step based on the gradient accumulation result of each gradient accumulation result in each clock sliding window for each pulse change signal. And, after traversing through the membrane potential gradient change information corresponding to each convolutional kernel in the target spiking neural network, to obtain the weight gradient information of each convolutional kernel based on the cumulative results of the weight gradients corresponding to the multiple convolutional kernels; The step of reading the corresponding pulse signal value within multiple clock windows according to the clock cycle for each pulse change signal to obtain multiple pulse signal values ​​includes: acquiring the configuration information of the target spiking neural network; determining the number of pulse change signals to be read as N and the number of membrane potential gradient change information read corresponding to the convolution kernel to be M based on the configuration information; selecting N pulse change signals, and for each of the N pulse change signals, reading the corresponding pulse signal value within multiple clock windows according to the clock cycle.

9. An electronic device, characterized in that, include: At least one processor; At least one memory for storing at least one program; The spiking neural network weight gradient calculation method as described in any one of claims 1 to 7 is implemented when at least one of the programs is executed by at least one of the processors.

10. A computer-readable storage medium storing computer-executable instructions for performing the spiking neural network weight gradient calculation method as described in any one of claims 1 to 7.

Citation Information

Patent Citations

  • Prefetching weights for use in a neural network processor

    CN107454966A

  • Sparse pulse neural network accelerator based on ping-pong architecture

    CN116663626A