Weight mapping method and apparatus based on memristor array

By using a method of splitting the memristor array based on the row containing the maximum element value and mapping by column, the problem of computational accuracy being affected by traditional full matrix mapping is solved, achieving higher computational accuracy and conductivity utilization.

CN118035622BActive Publication Date: 2026-11-17TSINGHUA UNIVERSITY
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410064031.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-01-16
Publication Date
2026-11-17
Estimated Expiration
2044-01-16

AI Technical Summary

Technical Problem

In traditional full matrix mapping methods, if the matrix elements involved in matrix-vector multiplication differ significantly, matrix elements with small absolute values ​​will be mapped to very small memristor conductance values. These values ​​are easily overwhelmed by the intrinsic noise of the memristor, resulting in the weight mapping failing to effectively utilize the device's resistance window and affecting computational accuracy.

Method used

The initial weight matrix is ​​split into a target weight matrix by a splitting strategy based on the row containing the maximum element value, and the maximum column element value of all columns is recorded. The target scaling factor is calculated based on the column mapping strategy to determine the target mapping matrix. After the mapping is completed, the memristor array calculation results are processed by the coefficient restoration method to obtain the actual matrix-vector multiplication result.

Benefits of technology

It effectively reduces the average dynamic range of the matrix, improves the utilization rate of device conductivity states, and enhances calculation accuracy.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118035622B_ABST
    Figure CN118035622B_ABST
Patent Text Reader

Abstract

This application relates to the field of memristor technology, and particularly to a weight mapping method and apparatus based on a memristor array. The method includes: splitting an initial weight matrix into target weight matrices based on a preset row-splitting strategy where the maximum element value is located, and recording the maximum column element value of all columns in the target weight matrix; calculating target scaling factors for all columns of the target weight matrix based on a preset column-mapping strategy; determining the target mapping matrix of the initial weight matrix based on the target scaling factors of all columns, and mapping the target mapping matrix to the memristor array column by column; after mapping is completed and matrix-vector multiplication of the memristor array is completed, processing the calculation results of the memristor array using a coefficient restoration method to obtain the actual matrix-vector multiplication result of the initial weight matrix. This effectively reduces the average dynamic range of the matrix, improves the utilization rate of device conductivity states, and enhances calculation accuracy.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of memristor technology, and in particular to a weight mapping method and apparatus based on memristor arrays. Background Technology

[0002] In in-memory computing systems based on memristor arrays, matrix-vector multiplication (MVM) is the primary computational method. The matrices involved in the computation need to be mapped onto the memristor array first. Traditional matrix mapping methods are full matrix mapping (or full-weighted matrix mapping), such as... Figure 1 As shown, the entire matrix is ​​mapped to the memristor array using a uniform scaling factor. This scaling factor is determined by the memristor's resistance window and the absolute value of the largest element in the entire matrix. The larger the absolute value of the largest element, the smaller the scaling factor. In some applications, if the matrix elements involved in matrix-vector multiplication differ significantly, the memristor conductance value corresponding to a given matrix element mapped to the memristor array will be smaller. Therefore, in the traditional full-matrix mapping method, matrix elements with small absolute values ​​will be mapped to very small memristor conductance values, which are easily overwhelmed by the intrinsic noise of the memristor. Figure 2 As shown, the weight mapping cannot effectively utilize the resistive switching window of the device, thus degrading the calculation accuracy, which urgently needs to be addressed. Summary of the Invention

[0003] This application provides a weighting mapping method and apparatus based on memristor arrays to solve the problem that in traditional full matrix mapping methods, if the matrix elements in the matrix-vector multiplication operation have large differences, the matrix elements with small absolute values ​​in the matrix will be mapped to very small memristor conductance values, which are easily submerged by the intrinsic noise of the memristor. This results in the weighting mapping not being able to effectively utilize the resistance window of the device, thus affecting the calculation accuracy.

[0004] The first aspect of this application provides a weight mapping method based on a memristor array, comprising the following steps: splitting an initial weight matrix into a target weight matrix based on a preset row splitting strategy where the maximum element value is located, and recording the maximum column element value of all columns in the target weight matrix; calculating the target scaling factor of all columns of the target weight matrix based on a preset column-by-column mapping strategy, determining the target mapping matrix of the initial weight matrix based on the target scaling factor of all columns, and mapping the target mapping matrix to the memristor array column by column; after the mapping is completed and the matrix-vector multiplication operation of the memristor array is completed, processing the calculation result of the memristor array using the coefficient restoration method to obtain the actual matrix-vector multiplication result of the initial weight matrix.

[0005] Optionally, the initial weight matrix is ​​split into a target weight matrix based on a preset splitting strategy for the row containing the maximum element value. This includes: obtaining the absolute value of the maximum element value and the absolute value of the second maximum element value in the initial weight matrix; determining whether the row containing the maximum element value satisfies a preset splitting condition based on the absolute values ​​of the maximum and second maximum element values; if the row containing the maximum element value satisfies the preset splitting condition, then splitting the row containing the maximum element value into a target number of split rows, and adjusting the initial matrix element values ​​of the target number of split rows to a preset multiple multiplied by the initial matrix element values ​​to obtain the target weight matrix.

[0006] Optionally, calculating the target scaling factor for all columns of the target weight matrix includes: calculating the target scaling factor for all columns of the target weight matrix based on a preset first scaling factor calculation formula and the absolute value of the largest column element value of all columns, wherein the preset first scaling factor calculation formula is:

[0007]

[0008] Where, α i The target scaling factor is `window`, which represents the size of the memristor's variable resistor window. It is the absolute value of the largest column element in the target weight matrix.

[0009] Optionally, the step of processing the calculation result of the memristor array using the coefficient restoration method to obtain the actual matrix-vector multiplication result of the initial weight matrix after the mapping is completed and the memristor array has completed the matrix-vector multiplication operation includes: performing a matrix-vector multiplication operation based on the target mapping matrix and the input voltage of the memristor array to output a current signal to the TIA; converting the output current signal into a voltage signal based on a preset TIA current-to-voltage conversion formula and sending it to the analog-to-digital converter (ADC) to obtain the actual matrix-vector multiplication result of the initial weight matrix, wherein the formula for calculating the output current is:

[0010]

[0011] in, Let G be the input voltage and G be the target mapping matrix.

[0012] The preset TIA current-voltage conversion formula is as follows:

[0013] V out =RI;

[0014] Among them, V out R is the output voltage of the transimpedance amplifier TIA, I is the adjustable resistor, R is proportional to the reciprocal of the target scaling factor, and I is the output current value.

[0015] Optionally, the step of processing the calculation results of the memristor array using the coefficient restoration method to obtain the actual matrix-vector multiplication result of the initial weight matrix after the mapping is completed and the memristor array has completed the matrix-vector multiplication operation further includes: correcting the target scaling factor of all columns to obtain the actual scaling factor of all columns, and determining the target mapping matrix of the initial weight matrix based on the actual scaling factor; mapping the target mapping matrix to the memristor array column by column, and outputting a current signal to a TIA to convert it into a voltage signal after performing the matrix-vector multiplication operation, and converting the voltage signal into a digital signal using an analog-to-digital converter (ADC); performing a shift operation on the digital signal according to the actual scaling factor, wherein when the actual scaling factor is greater than a first preset threshold, the digital signal is shifted in a first shift direction, and when the actual scaling factor is less than the first preset threshold, the digital signal is shifted in a second shift direction to obtain the actual matrix-vector multiplication result of the initial weight matrix.

[0016] Optionally, calculating the actual scaling factor of all columns based on the target scaling factor of all columns includes: calculating the actual scaling factor of all columns based on a preset second scaling factor calculation formula and the target scaling factor, wherein the preset second scaling factor calculation formula is:

[0017]

[0018] Where, α′ i α represents the actual scaling factor, [] is the rounding symbol, and α is the actual scaling factor. i The target scaling factor.

[0019] A second aspect of this application provides a weight mapping device based on a memristor array, comprising: a generation module, configured to split an initial weight matrix into a target weight matrix based on a preset row splitting strategy where the maximum element value is located, and record the maximum column element value of all columns in the target weight matrix; a calculation module, configured to calculate the target scaling factor of all columns of the target weight matrix based on a preset column-mapping strategy, determine the target mapping matrix of the initial weight matrix based on the target scaling factor of all columns, and map the target mapping matrix to the memristor array column by column; and a restoration module, configured to process the calculation result of the memristor array using a coefficient restoration method after the mapping is completed and the matrix-vector multiplication operation of the memristor array is completed, to obtain the actual matrix-vector multiplication result of the initial weight matrix.

[0020] Optionally, the generation module is further configured to: obtain the absolute value of the largest element value and the absolute value of the second largest element value in the initial weight matrix; determine whether the row containing the largest element value satisfies a preset splitting condition based on the absolute value of the largest element value and the absolute value of the second largest element value; if the row containing the largest element value satisfies the preset splitting condition, split the row containing the largest element value into a target number of splitting rows, and adjust the initial matrix element values ​​of the target number of splitting rows to a preset multiple multiplied by the initial matrix element values ​​to obtain the target weight matrix.

[0021] Optionally, the calculation module is further configured to: calculate the target scaling factor of all columns of the target weight matrix based on a preset first scaling factor calculation formula and the absolute value of the maximum column element value of all columns, wherein the preset first scaling factor calculation formula is:

[0022]

[0023] Where, α i The target scaling factor is `window`, which represents the size of the memristor's variable resistor window. It is the absolute value of the largest column element in the target weight matrix.

[0024] Optionally, the restoration module is further configured to: perform a matrix-vector multiplication operation based on the target mapping matrix and the input voltage of the memristor array, outputting a current signal to the TIA; convert the output current signal into a voltage signal based on a preset TIA current-to-voltage conversion formula, and send it to the analog-to-digital converter (ADC) to obtain the actual matrix-vector multiplication result of the initial weight matrix, wherein the formula for calculating the output current is:

[0025]

[0026] in, Let G be the input voltage and G be the target mapping matrix.

[0027] The preset TIA current-voltage conversion formula is as follows:

[0028] V out =RI;

[0029] Among them, V out R is the output voltage of the transimpedance amplifier TIA, R is an adjustable resistor that is proportional to the reciprocal of the target scaling factor, and I is the output current value.

[0030] Optionally, the restoration module is further configured to: correct the target scaling factor of all columns to obtain the actual scaling factor of all columns, and determine the target mapping matrix of the initial weight matrix based on the actual scaling factor; map the target mapping matrix to the memristor array column by column, and output a current signal to the TIA to convert it into a voltage signal after performing the matrix-vector multiplication operation, and convert the voltage signal into a digital signal using an analog-to-digital converter (ADC); perform a shift operation on the digital signal according to the actual scaling factor, wherein when the actual scaling factor is greater than a first preset threshold, the digital signal is shifted in a first shift direction, and when the actual scaling factor is less than the first preset threshold, the digital signal is shifted in a second shift direction to obtain the actual matrix-vector multiplication result of the initial weight matrix.

[0031] Optionally, the restoration module is further configured to: calculate the actual scaling factor of all columns based on a preset second scaling factor calculation formula and the target scaling factor, wherein the preset second scaling factor calculation formula is:

[0032]

[0033] Where, α' i α represents the actual scaling factor, [] is the rounding symbol, and α is the actual scaling factor. i The target scaling factor.

[0034] This application uses a pre-defined row-splitting strategy based on the maximum element value to split the initial weight matrix into a target weight matrix. It records the maximum column element value in all columns of the target weight matrix and calculates the target scaling factor for all columns of the target weight matrix based on a pre-defined column-mapping strategy. The target mapping matrix of the initial weight matrix is ​​determined based on the target scaling factors of all columns, and then mapped to the memristor array column by column. After mapping and matrix-vector multiplication of the memristor array, the calculation results are processed using a coefficient restoration method to obtain the actual matrix-vector multiplication result of the initial weight matrix. This solves the problem in traditional full-matrix mapping methods where large differences between matrix elements in matrix-vector multiplication can cause small absolute values ​​to be mapped to very small memristor conductance values, easily overwhelmed by the intrinsic noise of the memristor. This results in ineffective utilization of the device's resistance window, affecting calculation accuracy. This approach effectively reduces the average dynamic range of the matrix, improves the utilization rate of the device's conductance state, and enhances calculation accuracy.

[0035] Additional aspects and advantages of this application will be set forth in part in the description which follows, and in part will be obvious from the description, or may be learned by practice of this application. Attached Figure Description

[0036] The above and / or additional aspects and advantages of this application will become apparent and readily understood from the following description of the embodiments taken in conjunction with the accompanying drawings, wherein:

[0037] Figure 1 This is a schematic diagram of full matrix mapping in related technologies;

[0038] Figure 2 This is a comparative diagram of full matrix mapping in related technologies and embodiments of this application;

[0039] Figure 3 This is a flowchart of a weight mapping method based on a memristor array provided according to an embodiment of this application;

[0040] Figure 4 This is a schematic diagram of a weight mapping method based on a memristor array according to an embodiment of this application;

[0041] Figure 5 This is a schematic diagram of the split mapping of the row containing the maximum value according to one embodiment of this application;

[0042] Figure 6 This is a schematic diagram of the hardware implementation of the split mapping of the row containing the maximum value according to one embodiment of this application;

[0043] Figure 7 This is a schematic diagram of column mapping according to an embodiment of this application;

[0044] Figure 8 This is a schematic diagram of the reconstruction of analog coefficients according to an embodiment of this application;

[0045] Figure 9 This is a schematic diagram illustrating the restoration of digital coefficients according to an embodiment of this application;

[0046] Figure 10 This is an example diagram of a weight mapping device based on a memristor array according to an embodiment of this application. Detailed Implementation

[0047] The embodiments of this application are described in detail below. Examples of these embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals denote the same or similar elements or elements having the same or similar functions throughout. The embodiments described below with reference to the accompanying drawings are exemplary and intended to explain this application, and should not be construed as limiting this application.

[0048] The following describes a weight mapping method and apparatus based on a memristor array according to embodiments of this application, with reference to the accompanying drawings. Addressing the problem mentioned in the background art that in traditional full-matrix mapping methods, if the matrix elements in the matrix-vector multiplication operation differ significantly, matrix elements with small absolute values ​​will be mapped to very small memristor conductance values, easily overwhelmed by the intrinsic noise of the memristor. This results in the weight mapping failing to effectively utilize the device's resistance window, affecting calculation accuracy. This application provides a weight mapping method based on a memristor array. In this method, the initial weight matrix is ​​split at the location of the maximum element value based on a preset row splitting strategy, yielding a target weight matrix. The maximum column element value of all columns in the target weight matrix is ​​recorded. The target scaling factor for all columns of the target weight matrix is ​​calculated based on a preset column-by-column mapping strategy. The target mapping matrix of the initial weight matrix is ​​determined based on the target scaling factors of all columns, and the target mapping matrix is ​​mapped to the memristor array column by column. After mapping is completed and the memristor array has undergone matrix-vector multiplication, the calculation results on the memristor array are processed using a coefficient restoration method to obtain the actual matrix-vector multiplication result of the initial weight matrix. This solves the problem in traditional full matrix mapping methods where, if the matrix elements involved in matrix-vector multiplication differ significantly, matrix elements with small absolute values ​​are mapped to very small memristor conductance values. These values ​​are easily overwhelmed by the intrinsic noise of the memristor, leading to ineffective utilization of the device's resistance window and affecting computational accuracy. This method effectively reduces the average dynamic range of the matrix, improves the utilization rate of device conductance states, and enhances computational accuracy.

[0049] Specifically, Figure 3 This is a flowchart illustrating a weight mapping method based on a memristor array provided in an embodiment of this application.

[0050] In this embodiment, the matrix weight values ​​are mapped onto the memristor array using a row-by-row splitting mapping strategy and column-by-column mapping. The input voltage is calculated on the memristor array and then converted into current. The column-by-column mapping method requires a coefficient restoration step, and the current signal is then converted into a digital signal output by a coefficient restoration readout module. Coefficient restoration includes both analog and digital methods, as detailed below. Figure 4 As shown in the embodiments below, the specific implementation of the row-based splitting and mapping strategy and the column-based mapping strategy is described in detail. The row-based splitting and mapping strategy and the column-based mapping strategy can be used together or independently.

[0051] like Figure 3 As shown, the weight mapping method based on memristor arrays includes the following steps:

[0052] In step S301, the initial weight matrix is ​​split into a target weight matrix based on a preset splitting strategy for the row containing the maximum element value, and the maximum column element value of all columns in the target weight matrix is ​​recorded.

[0053] Optionally, in some embodiments, the initial weight matrix is ​​split into a target weight matrix based on a preset splitting strategy for the row containing the maximum element value. This includes: obtaining the absolute value of the maximum element value and the absolute value of the second maximum element value in the initial weight matrix; determining whether the row containing the maximum element value satisfies a preset splitting condition based on the absolute values ​​of the maximum and second maximum element values; if the row containing the maximum element value satisfies the preset splitting condition, then splitting the row containing the maximum element value into a target number of splitting rows, and adjusting the initial matrix element values ​​of the target number of splitting rows to a preset multiple multiplied by the initial matrix element values ​​to obtain the target weight matrix.

[0054] The preset splitting condition is that the absolute value of the largest element is not equal to the absolute value of the second largest element. The number of rows to be split is determined by the ratio of the absolute value of the largest element to the absolute value of the second largest element.

[0055] Specifically, the initial weight matrix is ​​first split using a pre-defined splitting strategy based on the row containing the maximum element value to generate the target weight matrix, such as... Figure 5 and Figure 6 As shown:

[0056] For an m×n initial weight matrix A, first find the maximum element value (a) of the initial weight matrix A. ij ) max The row containing the largest element value is split into k rows, with the parameter value of k rows being 1 / k of the original value, resulting in a target weight matrix A' with (m+k-1) rows and n columns. Alternatively, multiple rows containing the largest elements of the initial weight matrix A can be split. The number of rows k depends on the difference between the absolute value of the largest element and the absolute value of the second largest element; the larger the difference, the more rows are split. For example, if k=2 rows are split, and the absolute value of the largest element in the initial weight matrix A is (a... ij ) max The absolute value of the second largest element of the initial weight matrix A (a) ij ) 2nd If the initial weight matrix A is twice the size of the target weight matrix A, then the target splitting row number is 2 rows, and the target scaling factor is set to 1 / 2 of the original value. 1 / 2 is a preset multiple. Then the initial matrix element values ​​in the 2 split rows are adjusted to 1 / 2 times the initial matrix element values, thus obtaining the target weight matrix A'.

[0057] For example, if the absolute value of the largest element in the initial weight matrix A is less than twice the absolute value of the second largest element in the initial weight matrix A, then the scaling factor after splitting is set to (a) of the original weight matrix A. ij ) 2nd / (a ij ) max This is the ratio of the absolute value of the second-largest element to the absolute value of the largest element. If the absolute value of the second-largest element is a fractional multiple of the absolute value of the largest element, or the absolute value of the largest element is a fractional multiple of the absolute value of the second-largest element (e.g., the absolute value of the largest element is 1.5 times the absolute value of the second-largest element), then we can round it to the right, multiplying 1.5 by 2. This results in the target number of rows to be split in the row containing the largest element, making the second-largest element the largest element, and reducing the scaling factor in the split rows to 2 / 3 of the original.

[0058] In step S302, the target scaling factor of all columns of the target weight matrix is ​​calculated based on the preset column mapping strategy. The target mapping matrix of the initial weight matrix is ​​determined according to the target scaling factor of all columns, and the target mapping matrix is ​​mapped to the memristor array column by column.

[0059] In some embodiments, calculating the target scaling factor for all columns of the target weight matrix includes: calculating the target scaling factor for all columns of the target weight matrix based on a preset first scaling factor calculation formula and the absolute value of the largest column element value of all columns, wherein the preset first scaling factor calculation formula is:

[0060]

[0061] Where, α i The target scaling factor is `window`, which represents the size of the memristor's variable resistor window. It is the absolute value of the largest column element in the target weight matrix.

[0062] Specifically, such as Figure 7 As shown, in the preset column-mapping strategy, the maximum column element value of each column in the target weight matrix is ​​first found by mapping on a column-by-column basis, and the absolute value of the maximum column element value of all columns is obtained. Assume the target weight matrix consists of column vectors... If the vectors are composed of elements, then the absolute value of the largest element in each column vector is... Next, all matrix element values ​​in the target weight matrix are mapped to the corresponding conductance values ​​of the memristor array, column by column. For example, the i-th column vector... Its mapped conductance vector value is This yields the target scaling factor for the element in column i. That is, a preset scaling factor calculation formula is further extended to all column vectors in the target weight matrix according to the preset first scaling factor calculation formula to obtain the target scaling factor of all columns, and thus obtain the target scaling factor matrix B.

[0063] In step S303, after the mapping is completed and the matrix-vector multiplication operation of the memristor array is completed, the calculation result of the memristor array is processed by the coefficient restoration method to obtain the actual matrix-vector multiplication result of the initial weight matrix.

[0064] Specifically, the target mapping matrix G of the initial weight matrix A is obtained according to the formula G = AB, and the target mapping matrix G is mapped to the memristor array column by column.

[0065] Further, in some embodiments, after the mapping is completed and the memristor array has completed the matrix-vector multiplication operation, the calculation result of the memristor array is processed by the coefficient restoration method to obtain the actual matrix-vector multiplication result of the initial weight matrix. This includes: performing a matrix-vector multiplication operation based on the target mapping matrix and the input voltage of the memristor array to output a current signal to the TIA; converting the output current signal into a voltage signal based on a preset TIA current-to-voltage conversion formula and sending it to the analog-to-digital converter (ADC) to obtain the actual matrix-vector multiplication result of the initial weight matrix, wherein the formula for calculating the output current is:

[0066]

[0067] in, Let G be the input voltage and G be the target mapping matrix.

[0068] The preset TIA current-to-voltage conversion formula is:

[0069] V out =RI;

[0070] Among them, V out R is the output voltage of the transimpedance amplifier TIA, R is an adjustable resistor that is proportional to the reciprocal of the target scaling factor, and I is the output current value.

[0071] It should be understood that, based on the input voltage vector of the memristor array... The target mapping matrix G is simulated by matrix-vector multiplication using Kirchhoff's laws, and the result is expressed as current. Output in the following format: The output current signal needs to be further converted to voltage by current to restore the scaling factor, meaning each output value is restored to its original value.

[0072] The traditional approach to coefficient restoration involves first converting the current into a voltage signal via a transimpedance amplifier (TIA), then converting it into a digital signal via an ADC, and finally outputting the digital signal to a host computer for coefficient restoration. However, this embodiment proposes two scaling coefficient restoration methods: a digital coefficient restoration method and an analog coefficient restoration method. These methods can be processed directly on-chip, eliminating the need for a host computer.

[0073] Specifically, the analog coefficient restoration method integrates the coefficient restoration step into the TIA current-to-voltage conversion process. For example... Figure 8 As shown, the basic structure of a TIA involves connecting a resistor across the output stage and one input stage of an operational amplifier to form negative feedback. In the preset TIA current-voltage conversion formula, the bridging resistor R is replaced by a memristor with a variable resistance value, i.e. Figure 4 The ReTIA in the database allows for arbitrary changes to the bridging resistor R value, achieved by setting the memristor resistance value in each TIA column in relation to the reciprocal of the target scaling factor. Proportional (which can be understood as the value of R representing the target scaling factor).

[0074] The current signal is output after matrix-vector multiplication based on the target mapping matrix and the input voltage of the memristor array. The TIA then converts the current signal into a voltage signal according to a preset TIA current-to-voltage conversion formula. The ADC then converts the current signal into a digital signal, which is output as a voltage V by the TIA. out The target scaling factor has been restored, due to the output voltage V. out It is an analog quantity, and TIA needs to output the voltage V. out The ADC converts the output voltage into a digital signal, which is the result of the actual matrix-vector multiplication of the initial weight matrix.

[0075] Optionally, in some embodiments, after the mapping is completed and the memristor array has completed the matrix-vector multiplication operation, the actual matrix-vector multiplication result of the initial weight matrix is ​​obtained by processing the calculation result of the memristor array using the coefficient restoration method. This further includes: correcting the target scaling factor of all columns to obtain the actual scaling factor of all columns, and determining the target mapping matrix of the initial weight matrix based on the actual scaling factor; mapping the target mapping matrix to the memristor array column by column, and after performing matrix-vector multiplication, outputting a current signal to a TIA to convert it into a voltage signal, and using an analog-to-digital converter (ADC) to convert the voltage signal into a digital signal; performing a shift operation on the digital signal according to the actual scaling factor, wherein when the actual scaling factor is greater than a first preset threshold, the digital signal is shifted in a first shift direction, and when the actual scaling factor is less than the first preset threshold, the digital signal is shifted in a second shift direction to obtain the actual matrix-vector multiplication result of the initial weight matrix.

[0076] In this embodiment, the first preset threshold is 1, the first shift direction is to the right, and the second shift direction is to the left.

[0077] Optionally, in some embodiments, calculating the actual scaling factor of all columns based on the target scaling factor of all columns includes: calculating the actual scaling factor of all columns based on a preset second scaling factor calculation formula and the target scaling factor, wherein the preset second scaling factor calculation formula is:

[0078]

[0079] Where, α′ i α represents the actual scaling factor, [] is the rounding symbol, and α is the actual scaling factor. i The target scaling factor.

[0080] Specifically, the digital coefficient restoration method requires first limiting the target scaling factor α. i The value of α′ makes the actual scaling factor α′ i Only powers of 2 can be used, meaning the actual scaling factor α′ is calculated using the preset second scaling factor calculation formula. i We get x = [log2α] i ], in α′ i The target mapping matrix is ​​used to calculate the initial weight matrix as the actual scaling factor. This target mapping matrix is ​​then mapped column-wise to a memristor array. After matrix-vector multiplication using Kirchhoff's laws, a current signal is output to the TIA to obtain a voltage signal. An analog-to-digital converter (ADC) converts the voltage signal into a digital signal for output. A shift register is then used to quickly restore the coefficients. Figure 9 As shown, when x is positive (i.e., the actual scaling factor α′), i When x is greater than 1, the digital signal is shifted right by x bits. When x is negative (i.e., the actual scaling factor α′), the signal is shifted right by x bits. i When the value is less than 1, the digital signal is shifted left by x bits to obtain the actual matrix-vector multiplication result of the initial weight matrix. Since the hardware overhead of the shift register is extremely small, it can be almost ignored.

[0081] In the embodiments of this application, different types of memristors (such as resistive random access memory, phase-change memory, magnetic random access memory, etc.) and different in-memory computing architectures or units (such as 1T1R, 2T2R, 2T1R, etc.) can be used.

[0082] According to the weight mapping method based on memristor arrays proposed in this application, the initial weight matrix is ​​split at the location of the maximum element value based on a preset row splitting strategy to obtain the target weight matrix. The maximum column element value of all columns in the target weight matrix is ​​recorded. The target scaling factor of all columns of the target weight matrix is ​​calculated based on a preset column-by-column mapping strategy. The target mapping matrix of the initial weight matrix is ​​determined based on the target scaling factors of all columns, and the target mapping matrix is ​​mapped to the memristor array column by column. After the mapping is completed and the matrix-vector multiplication operation of the memristor array is completed, the calculation result of the memristor array is processed by the coefficient restoration method to obtain the actual matrix-vector multiplication result of the initial weight matrix. This solves the problem in traditional full-matrix mapping methods where, if the matrix elements in the matrix-vector multiplication operation differ greatly, matrix elements with small absolute values ​​are mapped to very small memristor conductance values, which are easily submerged by the intrinsic noise of the memristor. This results in the weight mapping not effectively utilizing the resistive switching window of the device, affecting the calculation accuracy. This method effectively reduces the average dynamic range of the matrix, improves the utilization rate of the device conductance state, and improves the calculation accuracy.

[0083] Secondly, 10 is a block diagram of a weight mapping device based on a memristor array according to an embodiment of this application.

[0084] like Figure 10 As shown, the weight mapping device 10 based on memristor array includes: a generation module 100, a calculation module 200, and a restoration module 300.

[0085] The generation module 100 is used to split the initial weight matrix into a target weight matrix based on a preset splitting strategy for the row containing the maximum element value, and to record the maximum column element value of all columns in the target weight matrix; the calculation module 200 is used to calculate the target scaling factor of all columns of the target weight matrix based on a preset column mapping strategy, determine the target mapping matrix of the initial weight matrix based on the target scaling factor of all columns, and map the target mapping matrix to the memristor array column by column; the restoration module 300 is used to process the calculation result of the memristor array to obtain the actual matrix-vector multiplication result of the initial weight matrix after the mapping is completed and the matrix-vector multiplication operation of the memristor array is completed by the coefficient restoration method.

[0086] Optionally, in some embodiments, the generation module 100 is further configured to: obtain the absolute value of the maximum element value and the absolute value of the second maximum element value in the initial weight matrix; determine whether the row containing the maximum element value satisfies the preset splitting condition based on the absolute value of the maximum element value and the absolute value of the second maximum element value; if the row containing the maximum element value satisfies the preset splitting condition, split the row containing the maximum element value into a target number of splitting rows, and adjust the initial matrix element values ​​of the target number of splitting rows to a preset multiple multiplied by the initial matrix element values ​​to obtain the target weight matrix.

[0087] Optionally, in some embodiments, the calculation module 200 is further configured to: calculate the target scaling factor of all columns of the target weight matrix based on a preset first scaling factor calculation formula and the absolute value of the maximum column element value of all columns, wherein the preset first scaling factor calculation formula is:

[0088]

[0089] Where, α i The target scaling factor is `window`, which represents the size of the memristor's variable resistor window. It is the absolute value of the largest column element in the target weight matrix.

[0090] Optionally, in some embodiments, the restoration module 300 is further configured to: perform matrix-vector multiplication based on the target mapping matrix and the input voltage of the memristor array to output a current signal to the TIA; convert the output current signal into a voltage signal based on a preset TIA current-to-voltage conversion formula and send it to the analog-to-digital converter (ADC) to obtain the actual matrix-vector multiplication result of the initial weight matrix, wherein the formula for calculating the output current is:

[0091]

[0092] in, Let G be the input voltage and G be the target mapping matrix.

[0093] The preset TIA current-to-voltage conversion formula is:

[0094] V out =RI;

[0095] Among them, V out R is the output voltage of the transimpedance amplifier TIA, R is an adjustable resistor that is proportional to the reciprocal of the target scaling factor, and I is the output current value.

[0096] Optionally, in some embodiments, the restoration module 300 is further configured to: correct the target scaling factor of all columns to obtain the actual scaling factor of all columns, and determine the target mapping matrix of the initial weight matrix based on the actual scaling factor; map the target mapping matrix to the memristor array column by column, and output a current signal to the TIA to convert it into a voltage signal after performing matrix-vector multiplication, and use the analog-to-digital converter (ADC) to convert the voltage signal into a digital signal; perform a shift operation on the digital signal according to the actual scaling factor, wherein when the actual scaling factor is greater than a first preset threshold, the digital signal is shifted in a first shift direction, and when the actual scaling factor is less than the first preset threshold, the digital signal is shifted in a second shift direction to obtain the actual matrix-vector multiplication result of the initial weight matrix.

[0097] Optionally, in some embodiments, the restoration module 300 is further configured to: calculate the actual scaling factor of all columns based on a preset second scaling factor calculation formula and a target scaling factor, wherein the preset second scaling factor calculation formula is:

[0098]

[0099] Where, α′ i α represents the actual scaling factor, [] is the rounding symbol, and α is the actual scaling factor. i The target scaling factor.

[0100] It should be noted that the foregoing explanation of the weight mapping method embodiment based on memristor array also applies to the weight mapping device based on memristor array in this embodiment, and will not be repeated here.

[0101] According to the weight mapping device based on a memristor array proposed in this application, the target weight matrix is ​​obtained by splitting the initial weight matrix at the row partitioning point where the maximum element value is located based on a preset row partitioning strategy. The maximum column element value of all columns in the target weight matrix is ​​recorded. The target scaling factor of all columns of the target weight matrix is ​​calculated based on a preset column mapping strategy. The target mapping matrix of the initial weight matrix is ​​determined based on the target scaling factor of all columns. The target mapping matrix is ​​then mapped to the memristor array column by column. After the mapping is completed and the matrix-vector multiplication operation of the memristor array is completed, the actual matrix-vector multiplication result of the initial weight matrix is ​​obtained by processing the calculation result of the memristor array through the coefficient restoration method. Thus, the problem of traditional full matrix mapping methods, where large differences between the matrix elements in the matrix-vector multiplication operation will cause matrix elements with small absolute values ​​to be mapped to very small memristor conductance values, which are easily submerged by the intrinsic noise of the memristor. This results in the weight mapping not being able to effectively utilize the resistive switching window of the device, affecting the calculation accuracy. This method can effectively reduce the average dynamic range of the matrix, improve the utilization rate of the device conductance state, and improve the calculation accuracy.

[0102] In the description of this specification, the references to terms such as "one embodiment," "some embodiments," "example," "specific example," or "some examples," etc., indicate that a specific feature, structure, material, or characteristic described in connection with that embodiment or example is included in at least one embodiment or example of this application. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples. Moreover, without contradiction, those skilled in the art can combine and integrate the different embodiments or examples described in this specification, as well as the features of different embodiments or examples.

[0103] Furthermore, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include at least one of that feature. In the description of this application, "N" means at least two, such as two, three, etc., unless otherwise explicitly specified.

[0104] Any process or method described in the flowchart or otherwise herein can be understood as representing a module, segment, or portion of code comprising one or more N executable instructions for implementing custom logic functions or processes, and the scope of the preferred embodiments of this application includes additional implementations in which functions may be performed not in the order shown or discussed, including substantially simultaneously or in reverse order depending on the functions involved, as should be understood by those skilled in the art to which embodiments of this application pertain.

[0105] It should be understood that the various parts of this application can be implemented using hardware, software, firmware, or a combination thereof. In the above embodiments, the N steps or methods can be implemented using software or firmware stored in memory and executed by a suitable instruction execution system. For example, if implemented in hardware as in another embodiment, it can be implemented using any one or a combination of the following techniques known in the art: discrete logic circuits having logic gates for implementing logical functions on data signals, application-specific integrated circuits (ASICs) having suitable combinational logic gates, programmable gate arrays (PGAs), field-programmable gate arrays (FPGAs), etc.

Claims

1. A weight mapping method based on memristor arrays, characterized in that, Includes the following steps: The initial weight matrix is ​​split into a target weight matrix based on a preset splitting strategy for the row containing the maximum element value, and the maximum column element value of all columns in the target weight matrix is ​​recorded. The method of splitting the initial weight matrix based on the preset splitting strategy of the row containing the maximum element value to generate a target weight matrix includes: obtaining the absolute value of the maximum element value and the absolute value of the second maximum element value in the initial weight matrix; determining whether the row containing the maximum element value satisfies a preset splitting condition based on the absolute values ​​of the maximum and second maximum element values; if the row containing the maximum element value satisfies the preset splitting condition, splitting the row containing the maximum element value into a target number of splitting rows, and adjusting the initial matrix element values ​​of the target number of splitting rows to a preset multiple multiplied by the initial matrix element values ​​to obtain the target weight matrix, wherein the preset splitting condition is that the absolute value of the maximum element value and the absolute value of the second maximum element value are not equal; The target scaling factor of all columns of the target weight matrix is ​​calculated based on the preset column mapping strategy. The target mapping matrix of the initial weight matrix is ​​determined according to the target scaling factor of all columns. The target mapping matrix is ​​then mapped to the memristor array column by column. The step of calculating the target scaling factor for all columns of the target weight matrix based on a preset column-wise mapping strategy includes: calculating the target scaling factor for all columns of the target weight matrix based on a preset first scaling factor calculation formula and the absolute value of the largest column element value of all columns, wherein the preset first scaling factor calculation formula is: ; in, The target scaling factor. window The size of the memristor resistive variable window. It is the absolute value of the largest column element in the target weight matrix; After the mapping is completed and the matrix-vector multiplication operation of the memristor array is completed, the calculation result of the memristor array is processed by the coefficient restoration method to obtain the actual matrix-vector multiplication result of the initial weight matrix.

2. The method according to claim 1, wherein after the mapping is completed and the memristor array has completed the matrix-vector multiplication operation, the actual matrix-vector multiplication result of the initial weight matrix is ​​obtained by processing the calculation result of the memristor array using the coefficient restoration method, includes: A matrix-vector multiplication operation is performed based on the target mapping matrix and the input voltage of the memristor array to output a current signal to the transimpedance amplifier TIA; Based on the preset TIA current-to-voltage conversion formula, the output current signal is converted into a voltage signal and sent to the analog-to-digital converter (ADC) to obtain the actual matrix-vector multiplication result of the initial weight matrix. The formula for calculating the output current is: ; in, Input voltage, The target mapping matrix; The preset TIA current-voltage conversion formula is as follows: ; in, The output voltage of the transimpedance amplifier TIA. The resistor R is adjustable and is proportional to the reciprocal of the target scaling factor. This is the output current value.

3. The method according to claim 1, characterized in that, The step of processing the calculation results of the memristor array using the coefficient restoration method to obtain the actual matrix-vector multiplication result of the initial weight matrix after the mapping is completed and the matrix-vector multiplication operation of the memristor array is completed also includes: The target scaling factor of all columns is corrected to obtain the actual scaling factor of all columns, and the target mapping matrix of the initial weight matrix is ​​determined based on the actual scaling factor; The target mapping matrix is ​​mapped to the memristor array column by column, and after performing the matrix-vector multiplication operation, the current signal is output to the TIA to be converted into a voltage signal, and the voltage signal is converted into a digital signal using an analog-to-digital converter (ADC). The digital signal is shifted according to the actual scaling factor, wherein when the actual scaling factor is greater than a first preset threshold, the digital signal is shifted in a first shift direction, and when the actual scaling factor is less than the first preset threshold, the digital signal is shifted in a second shift direction to obtain the actual matrix-vector multiplication result of the initial weight matrix.

4. The method according to claim 3, characterized in that, The step of correcting the target scaling factor for all columns to obtain the actual scaling factor for all columns includes: The actual scaling factor of all columns is calculated based on a preset second scaling factor calculation formula, wherein the preset second scaling factor calculation formula is: in, The scaling factor is [ ], and the square brackets [ ] represent the integer part. The target scaling factor.

5. A weight mapping device based on a memristor array, characterized in that, include: The generation module is used to split the initial weight matrix into a target weight matrix based on a preset splitting strategy for the row containing the maximum element value, and to record the maximum column element value of all columns in the target weight matrix. The generation module is further configured to: obtain the absolute value of the maximum element value and the absolute value of the second largest element value in the initial weight matrix; and determine whether the row containing the maximum element value satisfies a preset splitting condition based on the absolute value of the maximum element value and the absolute value of the second largest element value. If the row containing the maximum element value satisfies the preset splitting condition, then the row containing the maximum element value is split into a target number of splitting rows, and the initial matrix element values ​​of the target number of splitting rows are adjusted to a preset multiple multiplied by the initial matrix element values ​​to obtain the target weight matrix. The preset splitting condition is that the absolute value of the maximum element value is not equal to the absolute value of the second maximum element value. The calculation module is used to calculate the target scaling factor of all columns of the target weight matrix based on a preset column mapping strategy, determine the target mapping matrix of the initial weight matrix according to the target scaling factor of all columns, and map the target mapping matrix to the memristor array column by column. The calculation module is further configured to: calculate the target scaling factor of all columns of the target weight matrix based on a preset first scaling factor calculation formula and the absolute value of the maximum column element value of all columns, wherein the preset first scaling factor calculation formula is: ; in, The target scaling factor. window The size of the memristor resistive variable window. It is the absolute value of the largest column element in the target weight matrix; The restoration module is used to process the calculation results of the memristor array using the coefficient restoration method after the mapping is completed and the matrix-vector multiplication operation of the memristor array is completed, so as to obtain the actual matrix-vector multiplication result of the initial weight matrix.

6. The apparatus according to claim 5, characterized in that, The restoration module is also used for: A matrix-vector multiplication operation is performed based on the target mapping matrix and the input voltage of the memristor array to output a current signal to the transimpedance amplifier TIA; Based on the preset TIA current-to-voltage conversion formula, the output current signal is converted into a voltage signal and sent to the analog-to-digital converter (ADC) to obtain the actual matrix-vector multiplication result of the initial weight matrix. The formula for calculating the output current is: ; in, Input voltage, The target mapping matrix; The preset TIA current-voltage conversion formula is as follows: ; in, The output voltage of the transimpedance amplifier TIA. The resistor R is adjustable and is proportional to the reciprocal of the target scaling factor. This is the output current value.

7. The apparatus according to claim 5, characterized in that, The restoration module is also used for: The target scaling factor of all columns is corrected to obtain the actual scaling factor of all columns, and the target mapping matrix of the initial weight matrix is ​​determined based on the actual scaling factor; The target mapping matrix is ​​mapped to the memristor array column by column, and after performing the matrix-vector multiplication operation, the current signal is output to the TIA to be converted into a voltage signal, and the voltage signal is converted into a digital signal using an analog-to-digital converter (ADC). The digital signal is shifted according to the actual scaling factor, wherein when the actual scaling factor is greater than a first preset threshold, the digital signal is shifted in a first shift direction, and when the actual scaling factor is less than the first preset threshold, the digital signal is shifted in a second shift direction to obtain the actual matrix-vector multiplication result of the initial weight matrix.