Pulse neural network weight gradient calculation method and related equipment
By using a selector to control the accumulator array in the spiking neural network for gradient accumulation calculations, the problems of high energy consumption and low efficiency in the weight gradient update process are solved, and more efficient calculations are achieved.
Patent Information
- Application Number
- CN202411346108.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-25
- Publication Date
- 2025-01-24
- Estimated Expiration
- 2044-09-25
AI Technical Summary
There are problems of high energy consumption and low efficiency in the weight gradient update process of existing pulsed neural networks, mainly due to the invalid calculation of sparse data.
By input multiple pulse signals to the preset selector, the accumulator array is controlled for gradient cumulative calculation, and the sparseness of the gradient data is optimized to avoid invalid calculations.
Effectively reduce the energy consumption during the weight gradient calculation process of pulse neural network rights, and improve the calculation efficiency.
Smart Images

Figure CN119358606A_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present application relate to the field of neural network training technology, and in particular to a pulse neural network weight gradient calculation method and related equipment. Background Art
[0002] Spiking Neural Networks (SNNs), as a new type of neural network model, can improve energy efficiency and computing efficiency by imitating the pulse emission mechanism of biological neurons and adopting event-driven computing methods. It performs well in processing sparse and asynchronous data and is suitable for low-power and high-performance computing needs.
[0003] However, the current training process of pulse neural networks is relatively complex, involving three stages: forward propagation (FF), back propagation (BP) and weight gradient (WG) update. Among them, the weight gradient update accounts for about one-third of the total training computation. When processing weight gradient updates, the existing accelerator training process often performs a large number of invalid calculations based on sparse data, resulting in a waste of computing resources, leading to high energy consumption and low efficiency in the current weight gradient update and pulse neural network training process. Summary of the invention
[0004] The embodiment of the present application provides a pulse neural network weight gradient calculation method and related equipment, which can optimize the sparsity of weight gradient data by inputting multiple pulse signal values into multiple preset selectors so that the multiple selectors control the accumulator array to perform gradient accumulation calculation, thereby effectively avoiding invalid calculations, reducing energy consumption in the pulse neural network weight gradient calculation process, and improving computing efficiency.
[0005] To achieve the above-mentioned purpose, the first aspect of the embodiment of the present application provides a method for calculating the weight gradient of a pulse neural network, including: 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 the corresponding pulse signal value in a plurality of clock sliding windows according to the clock cycle; when the plurality of pulse signal values read in the current clock cycle are not all 0, reading the gradient change value from each membrane potential gradient change information, inputting the plurality of gradient change values read into a preset accumulator array row by row, and inputting the plurality of pulse signal values read into a preset plurality of A selector is used to control the accumulator array through the multiple selectors according to the multiple pulse signal values to perform accumulation processing between the multiple gradient change values and the gradient accumulation results of the previous historical clock cycle, so as to obtain multiple gradient accumulation results of the current clock cycle; according to each gradient accumulation result of each pulse change signal in each clock sliding window, the weight gradient accumulation results of multiple convolution kernels in the target clock step are obtained; after traversing the membrane potential gradient change information corresponding to each convolution kernel in the target pulse neural network, the weight gradient information of each convolution kernel is obtained according to the weight gradient accumulation results corresponding to multiple groups of the multiple convolution kernels.
[0006] In some embodiments, for each pulse change signal, the corresponding pulse signal value is read in multiple clock sliding windows according to the clock cycle, including: obtaining the configuration information of the target pulse neural network; determining the number of readings of the pulse change signal as N according to the configuration information, and determining the number of readings of the membrane potential gradient change information corresponding to the convolution kernel as M; selecting N of the pulse change signals, and for each of the N pulse change signals, reading the corresponding pulse signal value in multiple clock sliding windows according to the clock cycle.
[0007] In some embodiments, the accumulator array includes N columns and M rows of accumulators, and the gradient change value is read from each membrane potential gradient change information, and the multiple gradient change values read are input into a preset accumulator array by row, and the multiple pulse signal values read are input into a preset multiple selectors, including: reading the gradient change value of the current clock cycle from M membrane potential gradient change information, and inputting the M gradient change values into the N accumulators in each row of the accumulator array by row; inputting the N pulse signal values into the preset N selectors, and the N selectors are connected to the input ends of the M accumulators in each column of the accumulator array by column.
[0008] In some embodiments, the control of the accumulator array by the multiple selectors according to the multiple pulse signal values to perform accumulation processing between the multiple gradient change values and the gradient accumulation results of the previous historical clock cycle to obtain multiple gradient accumulation results of the current clock cycle includes: inputting the gradient accumulation result of the previous clock cycle output by each accumulator in the accumulator array into the accumulator respectively; controlling the multiple accumulators of the corresponding column by the selectors whose pulse signal values are not 0 among the N selectors, performing accumulation processing between the multiple gradient change values and the gradient accumulation results of the previous historical clock cycle to obtain multiple gradient accumulation results of the current clock cycle; controlling the multiple accumulators of the corresponding column by the selectors whose pulse signal values are 0 among the N selectors, determining the gradient accumulation result of the previous clock cycle as the gradient accumulation result of the corresponding accumulator in the current clock cycle.
[0009] In some embodiments, the weight gradient accumulation results of multiple convolution kernels in the target clock step are obtained according to each gradient accumulation result of each pulse change signal in each clock sliding window, including: storing the gradient accumulation results of N pulse change signals in multiple clock sliding windows into a preset data storage unit; 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, storing multiple groups of N pulse change signals in the target clock step into the data storage unit according to N and the total number of channel dimensions; and obtaining the weight gradient accumulation results of each channel dimension of M convolution kernels in the target clock step according to the gradient accumulation results stored in the data storage unit.
[0010] In some embodiments, after traversing the membrane potential gradient change information corresponding to each convolution kernel in the target pulse neural network, the weight gradient information of each convolution kernel is obtained according to the weight gradient accumulation results corresponding to multiple groups of the multiple convolution kernels, including: when M is less than the total number of convolution kernels of the target pulse neural network, the weight gradient accumulation results of multiple groups of M convolution kernels within the target clock step are stored in the data storage unit according to M and the total number of convolution kernels; according to the weight gradient accumulation results stored in the data storage unit, the weight gradient information of each channel dimension of each convolution kernel in the target pulse neural network is obtained.
[0011] In some embodiments, after reading the corresponding pulse signal values in multiple clock sliding windows according to the clock cycle for each pulse change signal to obtain multiple pulse signal values, the method also includes: when the multiple pulse signal values read in the current clock cycle are all 0, skipping the reading of the gradient change values in the multiple membrane potential gradient change information in the current clock cycle.
[0012] In some embodiments, the method of 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 includes: obtaining forward calculation data and back propagation data during the training process of the target pulse 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.
[0013] In some embodiments, after obtaining the weight gradient information of each of the convolution kernels, the method further includes: acquiring corresponding weight gradient information within 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-mentioned purpose, the second aspect of the embodiment of the present application provides a pulse neural network weight gradient calculation device, including: a first data storage unit, used to obtain 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; and for each pulse change signal, reading the corresponding pulse signal value in multiple clock sliding windows according to the clock cycle, and when the multiple pulse signal values read in the current clock cycle are not all 0, reading the gradient change value from each membrane potential gradient change information; a weight gradient calculation unit, used to input the read multiple gradient change values into a preset accumulator array by row when the multiple pulse signal values read in the current clock cycle are not all 0, And the read multiple pulse signal values are input into the preset multiple selectors, so that the accumulator array is controlled by the multiple selectors according to the multiple pulse signal values to perform accumulation processing between the multiple gradient change values and the gradient accumulation results of the previous historical clock cycle, so as to obtain multiple gradient accumulation results of the current clock cycle; the second data storage unit is used to obtain the weight gradient accumulation results of multiple convolution kernels in the target clock step according to each gradient accumulation result of each pulse change signal in each clock sliding window; and after traversing the membrane potential gradient change information corresponding to each convolution kernel in the target pulse neural network, according to the weight gradient accumulation results corresponding to multiple groups of the multiple convolution kernels, obtain the weight gradient information of each convolution kernel.
[0015] To achieve the above-mentioned purpose, the third aspect of an embodiment of the present application provides an electronic device, comprising: at least one processor; at least one memory for storing at least one program; when at least one of the programs is executed by at least one of the processors, a pulse neural network weight gradient calculation method as described in any one of the first aspects is implemented.
[0016] To achieve the above-mentioned purpose, the fourth aspect of an embodiment of the present application provides a computer-readable storage medium storing computer-executable instructions, wherein the computer-executable instructions are used to execute the pulse neural network weight gradient calculation method as described in any one of the fourth aspects.
[0017] The embodiments of the present application provide a pulse neural network weight gradient calculation method, apparatus, device and storage medium. The method can obtain 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 pulse change signal indicates whether the neuron emits a pulse during the forward propagation process, and the membrane potential gradient change information indicates the membrane potential gradient of each neuron during the reverse propagation process. When calculating the weight gradient, the data can be divided into multiple clock sliding windows for processing. Each clock sliding window contains a certain number of time points. In each clock sliding window, the pulse signal values in the multiple pulse change signals are read according to the clock cycle. Furthermore, when the multiple pulse signal values read in the current clock cycle 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 into a preset accumulator array by row, and the pulse signal value is input into a preset multiple selectors. The sparsity of the pulse change signal is used to control the calculation of the accumulator through multiple selectors. For example, when the gradient change value at 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 multiple accumulators in the accumulator array by column to accumulate the gradient change value to the gradient accumulation result of the previous clock cycle, and obtain multiple gradient accumulation results of the current clock cycle; further, according to the gradient accumulation result of the current clock cycle of each pulse change signal in each clock sliding window, the weight gradient accumulation results of multiple convolution kernels in the target clock step are obtained, and the weight gradient information of each convolution kernel is obtained by accumulating the gradient accumulation results in each clock sliding window; it can be understood that when the pulse signal value is 0, there is no valid calculation result, so the present application only reads the gradient change value when the pulse signal value is not all 0, and the calculation of the accumulator is controlled by the selector during reading, and the read gradient change value is ignored when the pulse signal value is 0, which can effectively skip the reading operation of reading the gradient change value corresponding to the pulse signal value of 0, reduce unnecessary memory access, and can effectively avoid invalid calculation, reduce energy consumption in the pulse neural network weight gradient calculation process, and improve calculation efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] Figure 1 A flowchart of a pulse neural network weight gradient calculation method provided in one embodiment of the present application;
[0019] Figure 2 A schematic diagram of a device corresponding to the pulse neural network weight gradient calculation method provided in one embodiment of the present application;
[0020] Figure 3 A flowchart of reading the corresponding pulse signal value in the pulse neural network weight gradient calculation method provided in one embodiment of the present application;
[0021] Figure 4 A flowchart of inputting into a plurality of preset selectors in a pulse neural network weight gradient calculation method provided in an embodiment of the present application;
[0022] Figure 5 A flow chart of obtaining multiple gradient accumulation results in a pulse neural network weight gradient calculation method provided in an embodiment of the present application;
[0023] Figure 6 A flow chart of obtaining a weight gradient accumulation result in a pulse neural network weight gradient calculation method provided in an embodiment of the present application;
[0024] Figure 7 A flowchart of obtaining weight gradient information of each convolution kernel in a pulse neural network weight gradient calculation method provided in an embodiment of the present application;
[0025] Figure 8 A schematic diagram corresponding to a method for calculating a weight gradient of a spiking neural network provided in one embodiment of the present application;
[0026] Fig. 9 Another schematic diagram corresponding to the pulse neural network weight gradient calculation method provided in one embodiment of the present application;
[0027] Fig.10 A schematic diagram of the structure of an electronic device provided in one embodiment of the present application. DETAILED DESCRIPTION
[0028] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0029] In some embodiments, although the functional modules are divided in the system schematic diagram and the logical order is shown in the flowchart, in some cases, the steps shown or described may be performed in a different order than the module division in the system or the order in the flowchart. The terms first, second, etc. in the specification, claims and the above drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence.
[0030] In addition, unless otherwise clearly specified and limited, the term "connected" should be understood in a broad sense. For example, it can be a fixed connection or a movable connection, a detachable connection or a non-detachable connection, or an integral connection; it can be a mechanical connection, an electrical connection, or the two can communicate with each other; it can be a direct connection or an indirect connection through an intermediate medium.
[0031] In the description of the embodiments of the present application, the description of reference terms "one embodiment / implementation", "another embodiment / implementation" or "certain embodiments / implementations", "in the above embodiments / implementations", etc. means that the specific features, structures, materials or characteristics described in combination with the implementation or example are included in at least two embodiments or implementations disclosed in the present application. In the disclosure of this application, the schematic representation of the above terms does not necessarily refer to the same embodiment or implementation. It should be noted that although the logical order is shown in the flowchart, in some cases, the steps shown or described may be performed in an order different from that in the flowchart.
[0032] Spiking Neural Networks (SNNs), as a new type of neural network model, can improve energy efficiency and computing efficiency by imitating the pulse emission mechanism of biological neurons and adopting event-driven computing methods. It performs well in processing sparse and asynchronous data and is suitable for low-power and high-performance computing needs.
[0033] However, the current training process of pulse neural networks is relatively complex, involving three stages: forward propagation (FF), back propagation (BP) and weight gradient (WG) update. Among them, the weight gradient update accounts for about one-third of the total training computation. When processing weight gradient updates, the existing accelerator training process often performs a large number of invalid calculations based on sparse data, resulting in a waste of computing resources, leading to high energy consumption and low efficiency in the current weight gradient update and pulse neural network training process.
[0034] It can be understood that in order to overcome the limitations of the prior art, the embodiments of the present application provide a pulse neural network weight gradient calculation method and related equipment, which can optimize the sparsity of weight gradient data by inputting multiple pulse signal values into multiple preset selectors so that multiple selectors control the accumulator array to perform gradient accumulation calculation, thereby effectively avoiding invalid calculations, reducing energy consumption in the pulse neural network weight gradient calculation process, and improving computing efficiency.
[0035] The embodiments of the present application are further described below in conjunction with the accompanying drawings.
[0036] refer to Figure 1 , Figure 1 A flowchart of a pulse neural network weight gradient calculation method provided in an embodiment of the present application; in some embodiments, the present application provides a pulse neural network weight gradient calculation method, including but 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 a plurality of clock sliding windows according to the clock cycle, to obtain a plurality of pulse signal values;
[0039] Step S130, when the multiple pulse signal values read in the current clock cycle are not all 0, read the gradient change value from each membrane potential gradient change information, input the read multiple gradient change values into a preset accumulator array by row, and input the read multiple pulse signal values into a preset multiple selectors, so as to 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 through the multiple selectors according to the multiple pulse signal values, so as to obtain multiple gradient accumulation results of the current clock cycle;
[0040] Step S140, obtaining weighted gradient accumulation results of multiple convolution kernels in a target clock step according to each gradient accumulation result of each pulse change signal in each clock sliding window;
[0041] Step S150, after traversing the membrane potential gradient change information corresponding to each convolution kernel in the target pulse neural network, the weight gradient information of each convolution kernel is obtained according to the weight gradient accumulation results corresponding to multiple groups of 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 pulse signals (spike) and membrane potential gradients (▽U), where the pulse signals represent the activation state of the neurons, and the membrane potential gradients are information used to update weights during back propagation.
[0043] In some embodiments, corresponding to step S120, for the pulse change signal of each channel, the present application can read the value of the pulse signal clock cycle by clock cycle according to a certain clock sliding window, which helps to capture the pulse activity at different time points.
[0044] In some embodiments, corresponding to step S130, when the read pulse signal values are not all 0, it means that there is effective pulse activity. At this time, the corresponding membrane potential gradient change values are read and input into the adder array for accumulation. At the same time, the pulse signal value is used to control the selector to determine which gradient change values should be added to the previous results, thereby obtaining the gradient accumulation result in the current clock cycle.
[0045] In some embodiments, corresponding to step S140, for each pulse change signal, within a given clock sliding window, the gradient accumulation results obtained in each clock cycle are combined to form weight gradient accumulation results for multiple convolution kernels.
[0046] In some embodiments, corresponding to step S150, after traversing all membrane potential gradient change information, the weight gradient accumulation results of each convolution kernel are 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 subsequent weight update operations to improve the performance of the network.
[0047] In some embodiments, according to the above steps S110 to S150, the embodiments of the present application can obtain 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 pulse change signal indicates whether the neuron emits a pulse during the forward propagation process, and the membrane potential gradient change information indicates the membrane potential gradient of each neuron during the reverse propagation process, and then when calculating the weight gradient, the data can be divided into multiple clock sliding windows for processing, 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 cycle; further, when the multiple pulse signal values read in the current clock cycle 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 into the preset accumulator array by row, and the pulse signal value is input into the preset multiple selectors, and the sparsity of the pulse change signal is used to control the calculation of the accumulator through multiple selectors. If the gradient change value at a certain time point is 0, then the gradient change value is ignored. The corresponding gradient change value is not accumulated, so that the selector can control multiple accumulators in the accumulator array by column to accumulate the gradient change value to the gradient accumulation result of the previous clock cycle, and obtain multiple gradient accumulation results of the current clock cycle; further, according to the gradient accumulation result of the current clock cycle of each pulse change signal in each clock sliding window, the weight gradient accumulation results of multiple convolution kernels in the target clock step are obtained, and the weight gradient information of each convolution kernel is obtained 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 reads the gradient change value only when the pulse signal value is not all 0, and the calculation of the accumulator is controlled by the selector during reading, and the gradient change value read is ignored when the pulse signal value is 0, which can effectively skip the reading operation of reading the gradient change value corresponding to the pulse signal value of 0, reduce unnecessary memory access, and can effectively avoid invalid calculation, reduce energy consumption in the weight gradient calculation process of the pulse neural network, and improve calculation efficiency.
[0048] refer to Figure 2 , Figure 2 A schematic diagram of a device corresponding to the pulse neural network weight gradient calculation method provided in one embodiment of the present application; Figure 2The present invention shows a pulse neural network weight gradient calculation engine, which consists of a weight gradient calculation engine array and a corresponding SRAM. The weight gradient calculation engine array consists of an NxM adder array and a selector, and its input includes spike signals generated during the forward calculation process, which are horizontally expanded on the array and distributed along the channel dimension; and the membrane potential gradient (▽U) generated during the back propagation process, which are vertically expanded on the array and also distributed along the channel dimension. The Spike signals of N channels are broadcast vertically to the N columns of the weight gradient calculation engine array, while the ▽U signals of M channels are broadcast horizontally to the 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 serve as the selection signal of the corresponding column selector. When the Spike value is 1, the adder of the corresponding column performs an 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 the 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 shown as follows:
[0049] Among them, SRAM is a semiconductor random access memory, which is used to store membrane potential gradient, spike and weight; spike is the pulse signal generated by neurons, which can usually only be 0 or 1, corresponding to the pulse change signal of each channel dimension mentioned above; l And the formula Both represent the pulse signal value of the pulse change signal, ▽U and They all represent the membrane potential gradient change information corresponding to each convolution kernel, kernel l is the convolution kernel, and ▽w represents the weight gradient information of each convolution kernel obtained.
[0050] It is understandable that the above Figure 2 To correspond to the matrix multiplication calculation process in this application, on the basis of the above-mentioned matrix multiplication calculation process, this application ignores the cumulative calculation corresponding to the Spike value of 0 through a selector, thereby realizing the sparsity optimization of the weight gradient data, thereby effectively avoiding invalid calculations, reducing energy consumption in the pulse neural network weight gradient calculation process, and improving calculation efficiency.
[0051] refer to Figure 3 , Figure 3 A flowchart of reading the corresponding pulse signal value in the pulse neural network weight gradient calculation method provided in an embodiment of the present application; in some embodiments, for each pulse change signal, the corresponding pulse signal value is read in multiple clock sliding windows according to the clock cycle, including but not limited to the following steps:
[0052] Step S310, obtaining configuration information of the target spiking neural network;
[0053] Step S320, determining the number of pulse change signals to be read as N according to the configuration information, and determining the number of membrane potential gradient change information to be read corresponding to the convolution kernel as M;
[0054] Step S330 , selecting N pulse change signals, and for each of the N pulse change signals, reading the corresponding pulse signal value in a plurality of clock sliding windows according to the clock cycle.
[0055] In some embodiments, configuration information refers to the basic parameter settings of the pulse neural network, including but not limited to basic information such as network structure, number of layers, number of neurons in each layer, and possible training parameters such as learning rate, weight decay coefficient, etc.; further, according to the configuration information, the number of pulse change signals to be read is determined to be N, and the number of membrane potential gradient change information corresponding to the convolution kernel is determined to be M. It can be understood that in the process of weight gradient calculation, it is necessary to know the number of channels N of the pulse signal to be processed (i.e., the activation state of the neuron) and the number M of convolution kernels (or filters) corresponding thereto, which determines the input scale of the weight gradient calculation engine; further, N pulse change signals are selected, and for each of the N pulse change signals, the corresponding pulse signal value is read in multiple clock sliding windows according to the clock cycle. This means that in actual calculation, the change values of N pulse signals will be read from the storage according to the predefined clock cycle (i.e., the time unit of calculation). The clock sliding window here refers to the clock sliding window used to accumulate the influence of pulse activity over a period of time when calculating the weight gradient. The activity pattern of the neuron can be captured at different time points through this method, and the weight gradient is calculated accordingly for subsequent weight update.
[0056] refer to Figure 4 , Figure 4 A flowchart of a pulse neural network weight gradient calculation method provided in an embodiment of the present application, inputted into a preset multiple selectors; in some embodiments, the accumulator array includes N columns and M rows of accumulators, reads the gradient change value from each membrane potential gradient change information, inputs the read multiple gradient change values into the preset accumulator array by row, and inputs the read multiple pulse signal values into the preset multiple selectors, including but not limited to the following steps:
[0057] Step S410, reading the gradient change value of the current clock cycle from the M membrane potential gradient change information, and inputting the read M gradient change values into the N accumulators of each row of the accumulator array in rows;
[0058] Step S420: input the read N pulse signal values into preset N selectors, and the N selectors are connected to the input ends of the M accumulators in each column of the accumulator array respectively in columns.
[0059] In some embodiments, in the current clock cycle, the gradient change values of M membrane potential gradient change information (▽U) are read from the memory. The gradient change value represents the error generated during the forward propagation process and is needed to update the weight. Therefore, each gradient change value is assigned to a row of the accumulator array. There are M rows in total, and each row has N accumulators; further, N pulse signal values (spike) are input into the preset N selectors, and each selector is responsible for controlling whether the M accumulators of its corresponding column perform addition operations. It can be understood that when the spike signal value received by a selector is 1, the accumulator of the column will receive and accumulate the gradient change values from the same row; if the spike signal value is 0, the accumulator of the column will ignore the gradient change value from the same row and will not perform the accumulation operation, so that the present application can utilize the sparsity of the spike signal to reduce unnecessary calculations and SRAM accesses, thereby reducing power consumption.
[0060] refer to Figure 5 , Figure 5 In the pulse neural network weight gradient calculation method provided in one embodiment of the present application, a flowchart of obtaining multiple gradient accumulation results is provided; in some embodiments, multiple selectors are used to control the accumulator array according to multiple pulse signal values to perform accumulation processing between multiple gradient change values and the gradient accumulation results of the previous historical clock cycle to obtain multiple gradient accumulation results of the current clock cycle, including but not limited to the following steps:
[0061] Step S510, inputting the gradient accumulation result of the previous clock cycle output by each accumulator in the accumulator array into the accumulator respectively;
[0062] Step S520, controlling multiple accumulators of corresponding columns by using selectors whose pulse signal values are not 0 among the N selectors, performing accumulation processing between multiple gradient change values and the gradient accumulation results of the previous historical clock cycle, and obtaining multiple gradient accumulation results of the current clock cycle;
[0063] Step S530 , controlling multiple accumulators of corresponding columns by using selectors whose pulse signal values are 0 among the N selectors, and determining the gradient accumulation result of the previous clock cycle as the gradient accumulation result of the corresponding accumulator in the current clock cycle.
[0064] In some embodiments, since the present application continues to perform new accumulation based on the previous gradient accumulation result to obtain the gradient accumulation result of the current clock cycle, it is necessary to use the gradient accumulation result calculated by each accumulator in the accumulator array in the previous clock cycle as input and input it into the respective accumulators again; further, the accumulators in the corresponding column are controlled to perform calculations by the selector that receives the non-zero pulse signal value. For example, when a selector detects that the corresponding pulse signal value is not 0, it allows the inputs of all accumulators in the column (i.e., the gradient change value currently read) to be added to the gradient accumulation result saved in the previous clock cycle, thereby obtaining a new gradient accumulation result of the current clock cycle.
[0065] In addition, it can be understood that the selector that receives the zero pulse signal value will control the accumulator in the corresponding column to directly use the gradient accumulation result of the previous clock cycle as the result of the current clock cycle, which means that if no new pulse signal occurs, the gradient accumulation result will remain unchanged, which can enable the present application to effectively utilize the sparsity characteristics of the pulse neural network, that is, most of the time points neurons do not generate pulses (ie, inactive), so there is no need to update the weight gradient. Only when a valid pulse is detected will the accumulation operation be performed to reduce unnecessary calculations, reduce energy consumption, and improve computing efficiency.
[0066] refer to Figure 6 , Figure 6 In the pulse neural network weight gradient calculation method provided in an embodiment of the present application, a flowchart of obtaining the weight gradient accumulation result is provided; 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 multiple convolution kernels in the target clock step are obtained, including but not limited to the following steps:
[0067] Step S610, storing the gradient accumulation results of N pulse change signals in multiple 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 pulse neural network, the gradient accumulation results of multiple groups 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;
[0069] Step S630, according to the gradient accumulation results stored in the data storage unit, obtain the weight gradient accumulation results of the 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 may be a specially designed hardware register or memory area for temporarily storing intermediate calculation results; after traversing all clock sliding windows contained in the target clock step, if the number of N pulse change signals currently being processed is less than the total number of channel dimensions of the pulse neural network, then 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 the M convolution kernels on each channel dimension during the entire target clock step are calculated based on all the gradient accumulation results stored in the storage unit, so as to obtain the complete weight gradient information of each convolution kernel in the entire considered time period.
[0071] refer to Figure 7 , Figure 7 In the pulse neural network weight gradient calculation method provided in an embodiment of the present application, a flowchart of obtaining the weight gradient information of each convolution kernel is provided; in some embodiments, after traversing the membrane potential gradient change information corresponding to each convolution kernel in the target pulse neural network, the weight gradient information of each convolution kernel is obtained according to the weight gradient accumulation results corresponding to multiple groups of multiple convolution kernels, including but not limited to the following steps:
[0072] Step S710, when M is less than the total number of convolution kernels of the target spiking neural network, the weight gradient accumulation results of the multiple groups of M convolution kernels within the target clock step are stored in a data storage unit according to M and the total number of convolution kernels;
[0073] Step S720, according to the weight gradient accumulation result stored in the data storage unit, obtain the weight gradient information of each convolution kernel in the target pulse neural network in each channel dimension in the target clock step.
[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 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, for each pulse change signal, the corresponding pulse signal value is read in a plurality of clock sliding windows according to the clock cycle to obtain a plurality of pulse signal values, and the method further includes: when the plurality of pulse signal values read in the current clock cycle are all 0, the reading of the gradient change values in the plurality of membrane potential gradient change information is skipped in the current clock cycle. It can be understood that if all the pulse signal values read in the current clock cycle are 0, this means that no pulse activity occurs, so the reading of the membrane potential gradient change information can be skipped.
[0076] In some embodiments, obtaining a pulse change signal for each channel dimension in a target pulse neural network and membrane potential gradient change information corresponding to each convolution kernel includes: obtaining forward calculation data and back propagation data during the training process of the target pulse neural network; obtaining a pulse change signal for each channel dimension based on the forward calculation data, and obtaining membrane potential gradient change information corresponding to each convolution kernel based on the back propagation data.
[0077] In some embodiments, after obtaining the weight gradient information of each convolution kernel, the method also includes: acquiring the corresponding weight gradient information within 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, that is, accumulating the gradient information of different time steps to obtain the weight gradient information of the pulse neural network.
[0078] refer to Figure 8 , Figure 8A schematic diagram corresponding to a pulse neural network weight gradient calculation method provided in 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 weight gradients in the time dimension. Specifically, the calculation first operates the membrane potential gradient of the previous layer and the pulse tensor of the current layer at time T to obtain the weight gradient value at that moment. Subsequently, this weight gradient value is accumulated with the weight gradient value of the previous moment. In this way, the gradient information of different clock steps is accumulated, and the final weight gradient is finally obtained. In each calculation process, the Spike values of N channels are taken 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 calculations 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 previous clock cycle. Each accumulator uses an output stat ionary design to implement the convolution accumulation function. Once all the Spike and ▽U points in a sliding window are accumulated, the calculation results will be output to the array and written to the output SRAM. After that, the convolution calculation of the next sliding window will start.
[0079] refer to Fig. 9 , Fig. 9 Another schematic diagram corresponding to the pulse neural network weight gradient calculation method provided in one embodiment of the present application; Fig. 9 The sparse design of the weight gradient calculation engine in this application is demonstrated. The engine array consists of an NxM adder array and a selector. By utilizing the sparsity of spikes, this 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 read of ▽U is skipped through the gating2 signal. The sparse design of this application utilizes the sparsity of spike and ▽U signals, reduces redundant calculations and related SRAM reading and writing, and thus reduces the power consumption of the engine.
[0080] In some embodiments, the present application may proactively perform the following steps:
[0081] S01: write the spike and ▽U at time T into the on-chip input SRAM;
[0082] S02: The software configures the size of spike and ▽U and the kernel size of ▽W. After the configuration is completed, a convolution calculation start signal is issued;
[0083] S03: Take out N channel values from the input SRAM and determine whether these values are all zero;
[0084] S04: If all N spikes are 0, the read data operation of ▽U is not started, the accumulator gate is valid, and no accumulation is performed;
[0085] S05: If N spikes are not all 0, 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 an 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 is returned to the adder as input again 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, it is accumulated with the weight gradient result of the previous clock sliding window, and the calculation result is output to the array and written into the output SRAM;
[0089] S09: Execute S03 to S08 in a loop, first complete the loop value acquisition of the clock sliding window, and obtain the weight gradient information of N channels in one time step of M kernels;
[0090] S10: Get the next group of N channel values of S, and execute S03 to S09 repeatedly to obtain the weight gradient information of the next group of N channels of M kernels in one time step. After the number of channels of S / N cycles, the weight gradient information of all channels of M kernels in one time step is obtained.
[0091] S11: Get the next group of M channel values of ▽U, and execute S03 to S10 in a loop to obtain the weight gradient information of all channels of the next group of M kernels in one time step. After the number of channels of ▽U / M cycles, the weight gradient information of all channels of all kernels in one time step is obtained. This can effectively skip the reading operation of reading the gradient change value corresponding to the pulse signal value of 0, reduce unnecessary memory access, and effectively avoid invalid calculations, reduce energy consumption in the process of calculating the weight gradient of the pulse neural network, and improve calculation efficiency.
[0092] Some embodiments of the present application provide a pulse neural network weight gradient calculation device, including: a first data storage unit, used to obtain 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; and for each pulse change signal, respectively reading the corresponding pulse signal value in a plurality of clock sliding windows according to the clock cycle, and when the values of the plurality of pulse signals read in the current clock cycle are not all 0, reading the gradient change values in the plurality of membrane potential gradient change information; a weight gradient calculation unit, used to input the plurality of gradient change values into the pre-processed data by row when the values of the plurality of pulse signals read in the current clock cycle are not all 0. An accumulator array is set, and multiple pulse signal values are input into multiple preset selectors, so as to control multiple accumulators in the accumulator array by column through multiple selectors to accumulate the gradient change value to the gradient accumulation result of the previous clock cycle, so as to obtain multiple gradient accumulation results of the current clock cycle; a second data storage unit is used to obtain the weight gradient accumulation results of multiple convolution kernels in the target clock step according to each gradient accumulation result of each pulse change signal in each clock sliding window; and after traversing the membrane potential gradient change information corresponding to each convolution kernel in the target pulse neural network, according to the weight gradient accumulation results corresponding to multiple groups of multiple convolution kernels, obtain the weight gradient information of each convolution kernel.
[0093] Among them, the first data storage unit can be a semiconductor random access memory for storing 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 for matrix calculation, including multiple accumulators and multiple selectors, and the second data storage unit can be a semiconductor random access memory for storing gradient accumulation results, weight gradient accumulation results and weight gradient information. The first data storage unit is connected to the input ends of multiple accumulators in the accumulator array by column through multiple selectors, and the first data storage unit is connected to the output ends of multiple accumulators in the accumulator array. The corresponding pulse signal value and gradient change value are input to the weight gradient calculation unit through the first data storage unit, and then multiple gradient accumulation results of the current clock cycle output by the weight gradient calculation unit can be obtained. The multiple gradient accumulation results are stored in the second data storage unit for accumulation and summation to obtain the weight gradient information of each convolution kernel, which can effectively avoid invalid calculations and improve calculation efficiency.
[0094] In some embodiments, the first data storage unit is used to obtain configuration information of the target pulse neural network in the process of reading the corresponding pulse signal value according to the clock cycle in multiple clock sliding windows for each pulse change signal; determining the number of reads of the pulse change signal as N according to the configuration information, and determining the number of reads of the membrane potential gradient change information corresponding to the convolution kernel as M; selecting N pulse change signals, and for each of the N pulse change signals, reading the corresponding pulse signal value according to the clock cycle in multiple clock sliding windows.
[0095] In some embodiments, the accumulator array includes N columns and M rows of accumulators. The weight gradient calculation unit is used to read the gradient change values of M membrane potential gradient change information in the current clock cycle, input the multiple gradient change values into a preset accumulator array by row, and input the multiple pulse signal values into a preset multiple selectors, and input the M gradient change values into the N accumulators in each row of the accumulator array by row; input the N pulse signal values into the preset N selectors, and the N selectors are connected to the input ends of the M accumulators in each column of the accumulator array by column.
[0096] In some embodiments, in the process of controlling multiple accumulators in the accumulator array by columns through multiple selectors to accumulate the gradient change value onto the gradient accumulation result of the previous clock cycle to obtain multiple gradient accumulation results of the current clock cycle, the weight gradient calculation unit is used to input the gradient accumulation result of the previous clock cycle output by each accumulator in the accumulator array into the accumulator respectively; control the multiple accumulators in the corresponding columns through selectors whose pulse signal values are not 0 among the N selectors, calculate the sum of the gradient change value and the gradient accumulation result of the previous clock cycle, and determine it as the gradient accumulation result of the corresponding accumulator in the current clock cycle; control the multiple accumulators in the corresponding columns through selectors whose pulse signal values are 0 among the N selectors, and determine the gradient accumulation result of the previous clock cycle as the gradient accumulation result of the corresponding accumulator in the current clock cycle.
[0097] In some embodiments, the second data storage unit is used to store the gradient accumulation results of N pulse change signals in multiple clock sliding windows in a preset data storage unit in the process of obtaining the weight gradient accumulation results of multiple convolution kernels in the target clock step according to each gradient accumulation result of each pulse change signal in each clock sliding window; 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, then the gradient accumulation results of multiple groups of N pulse change signals in the target clock step are stored in the data storage unit according to N and the total number of channel dimensions; according to the gradient accumulation results stored in the data storage unit, the weight gradient accumulation results of the M convolution kernels in each channel dimension in the target clock step are obtained.
[0098] In some embodiments, after traversing the membrane potential gradient change information corresponding to each convolution kernel in the target pulse neural network, the second data storage unit obtains the weight gradient information of each convolution kernel according to the weight gradient accumulation results corresponding to multiple groups of multiple convolution kernels. In the process, when M is less than the total number of convolution kernels of the target pulse neural network, the weight gradient accumulation results of multiple groups of M convolution kernels within the target clock step are stored in the data storage unit according to M and the total number of convolution kernels; and 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 according to the weight gradient accumulation results stored in the data storage unit.
[0099] In some embodiments, after reading the corresponding pulse signal value in multiple clock sliding windows according to the clock cycle for each pulse change signal, the first data storage unit is also used to skip reading the gradient change values in multiple membrane potential gradient change information in the current clock cycle when the multiple pulse signal values read in the current clock cycle are all 0.
[0100] In some embodiments, the first data storage unit is used to obtain forward calculation data and back propagation data during the training process of the target pulse neural network in the process of 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; the pulse change signal of each channel dimension is obtained according to the forward calculation data, and the membrane potential gradient change information corresponding to each convolution kernel is obtained 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 also used to obtain the corresponding weight gradient information within multiple clock steps, and obtain the weight gradient of the target pulse neural network according to the weight gradient information corresponding to the multiple clock steps.
[0102] It can be understood that the pulse neural network weight gradient calculation device in the above embodiment can implement the pulse neural network weight gradient calculation method in any of the above embodiments to achieve the corresponding technical effect, so it will not be repeated here.
[0103] Some embodiments of the present application provide an electronic device, Fig.10 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application, referring to Fig.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, the pulse neural network weight gradient calculation method of any of the above embodiments is implemented, for example, the above described Figure 1 Steps S110 to S150 of the method, Figure 3 Steps S310 to S330 of the method, Figure 4 Steps S410 to S420 of the method, Figure 5 Steps S510 to S530 of the method, Figure 6 Steps S610 to S630 of the method, Figure 7 Method steps S710 to S720.
[0104] The electronic device 1000 of the embodiment of the present application includes one or more processors 1010 and a memory 1020. Fig.10 In the figure, a processor 1010 and a memory 1020 are taken as an example.
[0105] The processor 1010 and the memory 1020 may be connected via a bus or other means. Fig.10 The example of connecting through bus is taken in the following.
[0106] The 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. In addition, the memory 1020 may include a high-speed random access memory, and may also include a non-transitory memory, such as at least one disk storage device, a flash memory device, or other non-transitory solid-state storage device. In some embodiments, the memory 1020 may optionally include a memory 1020 remotely disposed relative to the processor 1010, and these remote memories may be connected to the electronic device 1000 via a network. At the same time, examples of the above-mentioned network include but are not limited to the Internet, an intranet, a local area network, a mobile communication network, and a combination thereof.
[0107] In some embodiments, when the processor executes the computer program, the pulse neural network weight gradient calculation method of any of the above embodiments is performed at a preset interval.
[0108] Those skilled in the art will understand that Fig.10 The device structure shown in the figure does not constitute a limitation on the electronic device 1000, and may include more or less components than shown in the figure, or combine certain components, or arrange the components differently.
[0109] exist Fig.10 In the electronic device 1000 shown, the processor 1010 can be used to call the pulse neural network weight gradient calculation method stored in the memory 1020, so as to implement the pulse neural network weight gradient calculation method.
[0110] Based on the hardware structure of the above-mentioned electronic device 1000, various embodiments of the pulse neural network weight gradient calculation device of the present application are proposed. At the same time, the non-transient software program and instructions required to implement the pulse neural network weight gradient calculation method of the above-mentioned embodiment are stored in the memory. When executed by the processor, the pulse neural network weight gradient calculation method of the above-mentioned embodiment is executed.
[0111] The present application also provides a computer-readable storage medium storing computer-executable instructions, which are used to execute the above-mentioned pulse neural network weight gradient calculation method, so that the above-mentioned one or more processors can execute the pulse neural network weight gradient calculation method of any of the above-mentioned embodiments, for example, to execute the above-mentioned Figure 1 Steps S110 to S150 of the method, Figure 3 Steps S310 to S330 of the method, Figure 4 Steps S410 to S420 of the method, Figure 5 Steps S510 to S530 of the method, Figure 6 Steps S610 to S630 of the method, Figure 7 Method steps S710 to S720.
[0112] The present application also provides a computer program product, which includes a computer program stored in a computer-readable storage medium. The processor of the computer device reads the computer program from the computer-readable storage medium, and the processor executes the computer program, so that the computer device executes the pulse neural network weight gradient calculation method implementing any one of the above embodiments, for example, executing the above described Figure 1 Steps S110 to S150 of the method, Figure 3 Steps S310 to S330 of the method, Figure 4 Steps S410 to S420 of the method, Figure 5 Steps S510 to S530 of the method, Figure 6 Steps S610 to S630 of the method, Figure 7 The method steps S710 to S720 in the above device embodiment are merely illustrative, and the units described as separate components may or may not be physically separated, that is, they may be located in one place or distributed on multiple network nodes. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0113] It will be appreciated by those skilled in the art that all or some of the steps and systems in the disclosed method above may be implemented as software, firmware, hardware and appropriate combinations thereof. Some physical components or all physical components may be implemented as software executed by a processor, such as a central processing unit, a digital signal processor or a microprocessor, or may be implemented as hardware, or may be implemented as an integrated circuit, such as an application specific integrated circuit. Such software may be distributed on a computer-readable medium, which may include a computer-readable storage medium (or a non-transitory medium) and a communication medium (or a temporary medium). As known to those skilled in the art, the term computer-readable storage medium includes volatile and non-volatile, removable and non-removable media implemented in any method or technology for storing 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 technologies, CD to ROM, digital versatile disk (DVD) or other optical disk storage, magnetic cassettes, magnetic tapes, disk storage or other magnetic storage devices, or any other medium that may be used to store desired information and may be accessed by a computer. In addition, it is well known to those skilled in the art that communication media typically include computer-readable instructions, data structures, program modules, or other data in modulated data signals such as carrier waves or other transmission mechanisms, and may include any information delivery media. The above is a specific description of the preferred implementation of the present application, but the present application is not limited to the above implementation mode. Those skilled in the art may make various equivalent modifications or substitutions without violating the spirit of the present application, and these equivalent modifications or substitutions are all included in the scope defined by the claims of the present application.
Claims
1. A method for calculating weight gradient of a pulse neural network, characterized in that: include: Obtain 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; For each pulse change signal, the corresponding pulse signal value is read in a plurality of clock sliding windows according to the clock cycle to obtain a plurality of pulse signal values; In the case that the multiple pulse signal values read in the current clock cycle are not all 0, the gradient change value is read from each membrane potential gradient change information, the multiple gradient change values read are input into a preset accumulator array by row, and the multiple pulse signal values read are input into a preset multiple selectors, so that the accumulator array is controlled by the multiple selectors according to the multiple pulse signal values to perform accumulation processing between the multiple gradient change values and the gradient accumulation results of the previous historical clock cycle, so as to obtain multiple gradient accumulation results of the current clock cycle; Obtain weighted gradient accumulation results of multiple convolution kernels in a 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; After traversing the membrane potential gradient change information corresponding to each convolution kernel in the target pulse neural network, the weight gradient information of each convolution kernel is obtained according to the weight gradient accumulation results corresponding to multiple groups of the multiple convolution kernels.
2. The pulse neural network weight gradient calculation method according to claim 1, characterized in that: For each pulse change signal, reading the corresponding pulse signal value in a plurality of clock sliding windows according to the clock cycle respectively includes: Acquiring configuration information of the target spiking neural network; Determine, according to the configuration information, the number of reads of the pulse change signal as N, and determine the number of reads of the membrane potential gradient change information corresponding to the convolution kernel as M; N pulse change signals are selected, and for each of the N pulse change signals, corresponding pulse signal values are read in a plurality of clock sliding windows according to clock cycles.
3. The pulse neural network weight gradient calculation method according to claim 2, characterized in that: The accumulator array includes N columns and M rows of accumulators, and the gradient change value is read from each membrane potential gradient change information, and the multiple gradient change values read are input into the preset accumulator array by row, and the multiple pulse signal values read are input into the preset multiple selectors, including: Reading the gradient change value of the current clock cycle from the M membrane potential gradient change information, and inputting the read M gradient change values into the N accumulators of each row of the accumulator array in rows respectively; The read N pulse signal values are input into preset N selectors, and the N selectors are connected to the input ends of the M accumulators in each column of the accumulator array in columns respectively.
4. The pulse neural network weight gradient calculation method according to claim 3 is characterized in that: The multiple selectors are used to control the accumulator array according to the multiple pulse signal values to perform accumulation processing between the multiple gradient change values and the gradient accumulation results of the previous historical clock cycle to obtain multiple gradient accumulation results of the current clock cycle, including: Inputting the gradient accumulation result of the previous clock cycle output by each accumulator in the accumulator array into the accumulator respectively; Controlling the plurality of accumulators of the corresponding column by using a plurality of selectors whose pulse signal values are not 0 among the N selectors, performing accumulation processing between the plurality of gradient change values and the gradient accumulation results of the previous historical clock cycle, to obtain a plurality of gradient accumulation results of the current clock cycle; The plurality of accumulators in the corresponding column are controlled by selectors whose pulse signal values are 0 among the N selectors, and 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.
5. The pulse neural network weight gradient calculation method according to claim 2, characterized in that: The step of obtaining weighted gradient accumulation results of multiple convolution kernels in a target clock step according to each gradient accumulation result of each pulse change signal in each clock sliding window includes: 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 N is less than the total number of channel dimensions of the target pulse neural network, then storing the gradient accumulation results of multiple groups of N pulse change signals within the target clock step in the data storage unit according to N and the total number of channel dimensions; According to the gradient accumulation results stored in the data storage unit, the weight gradient accumulation results of the M convolution kernels in each channel dimension in the target clock step are obtained.
6. The method for calculating the weight gradient of a spiking neural network according to claim 5, characterized in that: After traversing the membrane potential gradient change information corresponding to each convolution kernel in the target spiking neural network, the weight gradient information of each convolution kernel is obtained according to the weight gradient accumulation results corresponding to multiple groups of the multiple convolution kernels, including: In the case where M is less than the total number of convolution kernels of the target spiking neural network, storing the weight gradient accumulation results of multiple groups of M convolution kernels within the target clock step in the data storage unit according to M and the total number of convolution kernels; According to the weight gradient accumulation result stored in the data storage unit, the weight gradient information of each convolution kernel in the target pulse neural network in each channel dimension in the target clock step is obtained.
7. The pulse neural network weight gradient calculation method according to claim 1, characterized in that: After reading the corresponding pulse signal value in a plurality of clock sliding windows according to the clock cycle for each pulse change signal to obtain a plurality of pulse signal values, the method further includes: When the values of the plurality of pulse signals read in the current clock cycle are all 0, the reading of the gradient change values in the plurality of membrane potential gradient change information is skipped in the current clock cycle.
8. The method for calculating weight gradient of a spiking neural network according to claim 1, characterized in that: The step of 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 includes: Obtain forward computation data and back propagation data during the training process of the target spiking neural network; The pulse change signal of each channel dimension is obtained according to the forward calculation data, and the membrane potential gradient change information corresponding to each convolution kernel is obtained according to the back propagation data.
9. The pulse neural network weight gradient calculation method according to claim 1, characterized in that: After obtaining the weight gradient information of each convolution kernel, the method further includes: The corresponding weight gradient information is obtained within a plurality of clock steps, and the weight gradient of the target pulse neural network is obtained according to the weight gradient information corresponding to the plurality of clock steps.
10. A pulse neural network weight gradient calculation device, characterized in that: include: A first data storage unit is used to obtain 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; and for reading the corresponding pulse signal value in a plurality of clock sliding windows according to the clock cycle for each pulse change signal, respectively, to obtain a plurality of pulse signal values, and for reading the gradient change value from each membrane potential gradient change information when the plurality of pulse signal values read in the current clock cycle are not all 0; a weight gradient calculation unit, configured to input the multiple gradient change values read into a preset accumulator array row by row, and input the multiple pulse signal values read into a preset multiple selectors, so as to control the accumulator array to perform accumulation processing between the multiple gradient change values and the gradient accumulation results of the previous historical clock cycle through the multiple selectors according to the multiple pulse signal values, in the case that the multiple pulse signal values read in the current clock cycle are not all 0, to obtain multiple gradient accumulation results of the current clock cycle; A second data storage unit is used to obtain weight gradient accumulation results of multiple convolution kernels in a target clock step according to each gradient accumulation result of each pulse change signal in each clock sliding window; And it is used to obtain the weight gradient information of each convolution kernel according to the weight gradient accumulation results corresponding to multiple groups of the multiple convolution kernels after traversing the membrane potential gradient change information corresponding to each convolution kernel in the target pulse neural network.
11. An electronic device, characterized in that: include: at least one processor; at least one memory for storing at least one program; When at least one of the programs is executed by at least one of the processors, the pulse neural network weight gradient calculation method as described in any one of claims 1 to 9 is implemented.
12. A computer-readable storage medium storing computer-executable instructions, wherein the computer-executable instructions are used to execute the pulse neural network weight gradient calculation method as described in any one of claims 1 to 9.
Citation Information
Patent Citations
Prefetching weights for use in a neural network processor
CN107454966A
Pulse neural network accelerator learning method and device, terminal and storage medium
CN115456149A
Sparse pulse neural network accelerator based on ping-pong architecture
CN116663626A
Methods and systems for generating the gradients of a loss function with respect to the weights of a convolution layer
US20220351036A1