Data transformation method, apparatus, and storage medium
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- HUAWEI TECH CO LTD
- Filing Date
- 2021-11-26
- Publication Date
- 2026-06-26
AI Technical Summary
而在采用NTT对输入数据进行变换时,需要根据变换矩阵的每一行中每个矩阵元对对应的输入数据移位后取余,之后再累加取余,从而得到相应行对应的输出数据,运算复杂度较高
[0019]第五方面,提供了一种计算机可读存储介质,所述计算机可读存储介质中存储有指令,当其在计算机上运行时,使得计算机执行上述第一方面或第二方面所述的数据变换方法。
Smart Images

Figure CN116186473B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of data processing, and in particular to a data transformation method, apparatus and storage medium. Background Technology
[0002] In data processing, number theory transform (NTT) can be used to transform multiple input data into the transform domain, resulting in multiple output data within the transform domain. After processing the data in this transform domain, the processed data is then inversely transformed to obtain the final output data. However, when using NTT to transform the input data, it is necessary to shift the corresponding input data for each element in each row of the transform matrix, take the remainder, and then accumulate and take the remainder again to obtain the output data for the corresponding row. This process has high computational complexity. Summary of the Invention
[0003] This application provides a data transformation method, apparatus, and storage medium, which can reduce the complexity of data transformation and improve transformation efficiency. The technical solution is as follows:
[0004] In a first aspect, a data transformation method is provided, the method comprising: obtaining a first transformation matrix, wherein the first transformation matrix is obtained by transforming an original transformation matrix based on the symmetry of the rotation factor in the number-theoretic transformation NTT, the first transformation matrix comprising M matrix elements, and some of the M matrix elements having symmetry; obtaining data processing results corresponding to m matrix elements in the first transformation matrix according to the first transformation matrix and multiple input data, wherein m is less than M; and using the data processing results corresponding to the m matrix elements in the first transformation matrix as the transformation result.
[0005] In this embodiment, the first transformation matrix is obtained by transforming the original transformation matrix based on the symmetry of the rotation factor in the NTT. Thus, some of the M matrix elements of the first transformation matrix possess symmetry. Therefore, by obtaining the data processing results corresponding to some matrix elements of the first transformation matrix, the data processing results corresponding to the other matrix elements can be recovered, thereby obtaining the various output data. In other words, in this embodiment, only the data processing results corresponding to some matrix elements are needed to characterize all transformation information, reducing the complexity of data transformation and accelerating the transformation speed.
[0006] In one possible implementation, the process of obtaining the first transformation matrix is as follows: obtaining the original transformation matrix, which includes N*N original matrix elements, each original matrix element being a rotation factor, and the exponent of each original matrix element being equal to the remainder of the product of the row number and column number of the corresponding original matrix element divided by N, where N is equal to the number of the plurality of input data; processing the original transformation matrix according to the original transformation matrix and the symmetric rotation factor of each original matrix element to obtain the first transformation matrix.
[0007] In this embodiment, the rotation factors in the original transformation matrix are transformed based on the symmetry of the rotation factors to obtain a first transformation matrix with symmetric matrix elements. Since the matrix elements of the first transformation matrix are symmetric, only the data processing results corresponding to a portion of the matrix elements are needed to characterize all the transformation information, thereby reducing the transformation complexity.
[0008] In one possible implementation, the process of obtaining the data processing results corresponding to the m matrix elements in the first transformation matrix based on the first transformation matrix and multiple input data can be as follows: Select the i-th row and the j-th row from the first transformation matrix, where i is any odd number, j is any even number other than 0 and N / 2, and N is equal to the number of multiple input data; add or subtract the input data corresponding to the matrix elements with the same absolute value in each selected row to obtain the data processing results corresponding to the corresponding matrix elements in the corresponding row, where the input data corresponding to each matrix element refers to the data indexed as the column number of the column where the corresponding matrix element is located.
[0009] In this embodiment, the matrix elements in each odd row of the first transformation matrix are symmetric, and the matrix elements in each even row are symmetric. Thus, by outputting the data processing results corresponding to the matrix elements in one odd row and one even row, all the transformation information can be obtained.
[0010] Secondly, a data transformation method is provided, the method comprising: obtaining a number-theoretical transformation matrix; determining, based on the number-theoretical transformation matrix and multiple input data, the data processing result corresponding to the matrix element in each row of the number-theoretical transformation matrix; performing a cyclic carry-over on the data processing result corresponding to the matrix element in each row of the number-theoretical transformation matrix in ascending order according to the matrix element, to obtain the updated data processing result for each row; and obtaining the output data corresponding to each row based on the updated data processing result for each row.
[0011] In this embodiment, the data processing result corresponding to each row of matrix elements in the number theory transformation matrix is obtained, and the automatic modulo operation of the data processing result corresponding to each row of matrix elements is achieved by cyclically carrying over the corresponding matrix elements in ascending order. This eliminates the need for a large number of modulo operations based on the reference transformation parameters during the transformation process, reduces the transformation complexity, thereby reducing resource consumption and improving the transformation speed.
[0012] In one possible implementation, the process of determining the data processing result corresponding to the matrix element in each row of the number-theoretical transformation matrix based on the number-theoretical transformation matrix and multiple input data is as follows: add or subtract the input data corresponding to the matrix elements with the same absolute value in the i-th row of the number-theoretical transformation matrix to obtain the data processing result corresponding to the corresponding matrix element in the i-th row. The input data corresponding to each matrix element refers to the data whose index is the column number of the column where the corresponding matrix element is located.
[0013] In one possible implementation, each row of the number-theoretical transformation matrix corresponds to N registers, which are concatenated in ascending order of their indices. The most significant bit of the j-th register is connected to the least significant bit of the (j+1)-th register. The process of cyclically carrying over the data processing results corresponding to the matrix elements in each row of the number-theoretical transformation matrix in ascending order of the corresponding matrix elements can be as follows: according to the ascending order of the matrix elements in the i-th row, and based on the set bit width of the registers, the data processing results corresponding to each matrix element are sequentially filled into the registers corresponding to the corresponding matrix elements. The register corresponding to each matrix element is the register whose index is equal to that of the corresponding matrix element.
[0014] In this embodiment, the data processing results corresponding to the matrix elements are filled into the corresponding registers, and automatic cyclic carry is achieved by concatenating the beginning and end of the registers. This replaces the remainder operation in the traditional transformation process, reduces the transformation complexity, thereby reducing resource consumption and improving the transformation speed.
[0015] In one possible implementation, the process of obtaining the output data corresponding to each row based on the updated data processing results of each row is as follows: shift the corresponding data processing results according to the rotation factor corresponding to the matrix element of each data processing result of the updated i-th row; add the shifted data processing results to obtain a first result; and take the remainder of the first result based on the reference transformation parameter to obtain the i-th output data corresponding to the i-th row.
[0016] In this embodiment of the application, for any row, after performing a cyclic carry operation on the data processing results of this row, only the corresponding shift and one modulo operation are needed to obtain the final output data. Compared with the traditional transformation process, the number of modulo operations is greatly reduced, the transformation complexity is reduced, thereby reducing resource consumption and improving the transformation speed.
[0017] Thirdly, a data transformation apparatus is provided, which has the function of implementing the data transformation method behavior described in the first or second aspect above. The data transformation apparatus includes at least one module for implementing the data transformation method provided in the first or second aspect above.
[0018] Fourthly, a data transformation apparatus is provided, comprising a processor and a memory. The memory stores programs that support the data transformation apparatus in executing the data transformation methods provided in the first or second aspect, and stores data related to implementing the data transformation methods provided in the first or second aspect. The processor is configured to execute the programs stored in the memory.
[0019] Fifthly, a computer-readable storage medium is provided, wherein instructions are stored therein, which, when executed on a computer, cause the computer to perform the data transformation method described in the first or second aspect above.
[0020] In a sixth aspect, a computer program product containing instructions is provided, which, when run on a computer, causes the computer to perform the data transformation method described in the first or second aspect above.
[0021] The technical effects achieved by the third, fourth, fifth, and sixth aspects mentioned above are similar to those achieved by the corresponding technical means in the first or second aspects, and will not be repeated here.
[0022] The beneficial effects of the technical solutions provided in this application include at least the following:
[0023] In this embodiment, the first transformation matrix is obtained by transforming the original transformation matrix based on the symmetry of the rotation factor in the NTT. Thus, some of the M matrix elements of the first transformation matrix possess symmetry. Therefore, by obtaining the data processing results corresponding to some matrix elements in the first transformation matrix, the data processing results corresponding to the other matrix elements can be recovered, thereby obtaining the various output data. That is, in this embodiment, only the data processing results corresponding to some matrix elements are needed to characterize all transformation information, reducing the complexity of data transformation and accelerating the transformation speed. Alternatively, in this embodiment, automatic modulo operation of the data processing results corresponding to each row of matrix elements in the number theory transformation matrix is achieved by cyclically carrying over the corresponding matrix elements in ascending order. This eliminates the need for numerous modulo operations based on reference transformation parameters during the transformation process, reducing transformation complexity, thereby reducing resource consumption and improving transformation speed. Attached Figure Description
[0024] Figure 1 This is a schematic diagram of the structure of a computing device provided in an embodiment of this application;
[0025] Figure 2 This is a flowchart of a data transformation method provided in an embodiment of this application;
[0026] Figure 3 This is a schematic diagram illustrating the symmetry of matrix elements in a first transformation matrix provided in an embodiment of this application;
[0027] Figure 4 This is a flowchart of another data transformation method provided in the embodiments of this application;
[0028] Figure 5 This is a schematic diagram illustrating how multiple registers can be cascaded together to achieve automatic cyclic carry, as provided in an embodiment of this application.
[0029] Figure 6 This is a schematic diagram of a data transformation device provided in an embodiment of this application;
[0030] Figure 7 This is a schematic diagram of another data transformation device structure provided in the embodiments of this application. Detailed Implementation
[0031] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the implementation methods of this application will be further described in detail below with reference to the accompanying drawings.
[0032] Before providing a detailed explanation of the embodiments of this application, the application scenarios involved in the embodiments of this application will be introduced first.
[0033] Currently, in the fields of communication, artificial intelligence (AI), and image processing, data is often transformed to the transform domain using NTT (Network Transformation) to reduce computational complexity. For example, in the filtering process of digital signals, the core processing method is to perform a circular convolution of the input signal with the filter taps in the time domain to obtain the output signal. Since the circular convolution process is relatively complex, the input signal can first be transformed to the transform domain using number theory to obtain the output signal in the transform domain. The output signal in the transform domain is then multiplied by the corresponding filter coefficients in the transform domain, and finally, the signal obtained from the dot product is inversely transformed to obtain the final output signal. Similarly, in the fields of AI and image processing, various convolution operations on input data are frequently involved. In such cases, to reduce computational complexity, NTT can also be used to transform the data to the transform domain for processing, and then the final output data is obtained through inverse transformation. The data transformation method provided in this application can be applied to the above-mentioned scenarios to perform NTT on the data.
[0034] Figure 1 This is a schematic diagram of a computing device provided in an embodiment of this application. This computing device can be used to perform the data transformation methods described below. For example, the computing device can be a filter for filtering digital signals, or a computer device for image processing or running AI algorithms. Figure 1 As shown, the computing device includes one or more processors 101, a communication bus 102, a memory 103, and one or more communication interfaces 104.
[0035] Processor 101 can be a general-purpose central processing unit (CPU), a network processor (NP), a microprocessor, or one or more integrated circuits for implementing the scheme of this application, such as application-specific integrated circuits (ASICs), programmable logic devices (PLDs), or combinations thereof. The aforementioned PLD can be a complex programmable logic device (CPLD), a field-programmable gate array (FPGA), a generic array logic (GAL), or any combination thereof. Optionally, in some possible implementations, processor 101 includes multiple registers, and these multiple registers can be concatenated in ascending order of their indices.
[0036] The communication bus 102 is used to transmit information between the aforementioned components. The communication bus 102 can be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, it is represented by only one thick line in the figure, but this does not mean that there is only one bus or one type of bus.
[0037] The memory 103 may be a read-only memory (ROM), a random access memory (RAM), an electrically erasable programmable read-only memory (EEPROM), an optical disc (including a compact disc read-only memory (CD-ROM), a compressed optical disc, a laser disc, a digital versatile optical disc, a Blu-ray disc, etc.), a magnetic disk storage medium, or other magnetic storage device, or any other medium capable of carrying or storing desired program code in the form of instructions or data structures that can be accessed by a computer, but not limited thereto. The memory 103 may exist independently and be connected to the processor 101 via the communication bus 102. The memory 103 may also be integrated with the processor 101.
[0038] Communication interface 104 uses any transceiver-like device for communicating with other devices or communication networks. Communication interface 104 includes a wired communication interface and may also include a wireless communication interface. The wired communication interface may be, for example, an Ethernet interface. The Ethernet interface may be an optical interface, an electrical interface, or a combination thereof. The wireless communication interface may be a wireless local area network (WLAN) interface, a cellular network communication interface, or a combination thereof.
[0039] In some embodiments, the computing device may include multiple processors, such as Figure 2 The processors 101 and 105 shown are illustrated. Each of these processors may be a single-core processor or a multi-core processor. Here, "processor" may refer to one or more devices, circuits, and / or processing cores used to process data (such as computer program instructions).
[0040] In a specific implementation, as one embodiment, the computing device may further include an output device 106 and an input device 107. The output device 106 communicates with the processor 101 and can display information in various ways. For example, the output device 106 may be a liquid crystal display (LCD), a light-emitting diode (LED) display device, a cathode ray tube (CRT) display device, or a projector, etc. The input device 107 communicates with the processor 101 and can receive user input in various ways. For example, the input device 107 may be a mouse, keyboard, touchscreen device, or sensing device, etc.
[0041] In some embodiments, memory 103 stores program code 108 for executing the scheme of this application, and processor 101 can execute the program code 108 stored in memory 103. The program code may include one or more software modules, and the computing device can implement the following by using processor 101 and the program code 108 in memory 103. Figure 2 Or the data transformation method shown in Figure 4.
[0042] Before providing a detailed explanation of the data transformation method provided in the embodiments of this application, the principle of NTT will be introduced first.
[0043] The transformation formula for NTT is shown in equation (1) below:
[0044]
[0045] Where X(k) is the kth output data; mod F() denotes the modulo operation. In the modulo operation, F is the dividend, F is the reference transformation parameter in number theory transformation, and when the number theory transformation is Fermat number theory transformation, F is the Fermat number; x(n) is the nth input data among multiple input data, that is, the index of this input data is n; N is the number of input data; α nk Let be the rotation factor, where α is the basis of the rotation factor, and its commonly used value is 2 or a power of 2.
[0046] From the above formula (1), we can see that the multiplication operation between the input data and the rotation factor can be expressed as the multiplication operation between the transformation matrix and N input data, as shown in the following formula (2):
[0047]
[0048] The transformation matrix mentioned above is the original transformation matrix of NTT. Each matrix element in the original transformation matrix is a rotation factor, and the exponent of each matrix element is equal to the remainder obtained by dividing the product of the number of rows and columns of the matrix element by N.
[0049] Therefore, when α is 2 or a power of 2, the multiplication operation between the input data and the rotation factor in the above formula can be simplified to shifting the corresponding x(n) according to the power of the rotation factor. However, it can also be seen from the above formula (1) that after shifting the corresponding input data according to each rotation factor, a remainder operation is also required. Since the dividend is F, the range of the remainder is [0, F). In this case, in order to ensure that the hardware can continue to operate on the remainder data, it is necessary to ensure that the set bit width of the hardware is equal to the bit width of the dividend F. That is, the remainder operation in the transformation process causes the bit width of the hardware to be locked. Since the bit width of the hardware is locked to the bit width of the dividend, even if the input data is small, the remainder data still needs to be represented as data with a bit width equal to the bit width of the dividend, which will lead to a large resource consumption in the subsequent data processing process. In addition, shifting each input data according to each rotation factor in the transformation matrix and then performing a remainder operation, followed by accumulation and then a remainder operation, will also lead to a high computational complexity.
[0050] Based on this, this application provides a data transformation method that utilizes the symmetry of the rotation factor in NTT to transform the original transformation matrix, obtaining a first transformation matrix with symmetric matrix elements. Then, by determining the data processing results corresponding to some matrix elements in the first transformation matrix, all transformation information is obtained, thereby reducing computational complexity and accelerating the transformation speed. This data transformation method can be applied to... Figure 1 In the computing device shown, see Figure 2 The data transformation method includes the following steps:
[0051] Step 201: Obtain the first transformation matrix. The first transformation matrix is obtained by transforming the original transformation matrix based on the symmetry of the rotation factor in NTT. The first transformation matrix includes M matrix elements, and some of the M matrix elements have symmetry.
[0052] In this embodiment of the application, the computing device first obtains the original transformation matrix, and then transforms the original transformation matrix based on the symmetry of the rotation factor to obtain the first transformation matrix.
[0053] For example, the computing device generates an original transformation matrix comprising N*N original matrix elements based on the number N of input data. Each original matrix element in this original transformation matrix is a rotation factor, and the exponent of each original matrix element is equal to the remainder of the product of the row number and column number of the corresponding original matrix element, divided by N. It should be noted that, in this embodiment, the row number of the original matrix element refers to the index value of the row, and the column number refers to the index value of the column. Furthermore, the row and column indices in the original transformation matrix range from [0, N-1]. In the following text, the row with index value n is called the nth row, and the column with index value n is called the nth column.
[0054] For example, when there are 8 input data points, the computing device generates an 8x8 original transformation matrix. For each element in the 0th row of the original matrix, since the product of the row number and column number of each element is 0, and 0 divided by 8 leaves a remainder of 0, each element in the 0th row is a rotation factor with a power of 0, i.e., α. 0 Similarly, each element of the original matrix in column 0 is also α. 0 For example, for the original matrix element in the 2nd row and 6th column, since the product of the row number and the column number is 12, and the remainder of 12 divided by 8 is 4, the original matrix element in the 2nd row and 6th column is a rotation factor with a power of 4, i.e., α. 4 Based on this, when there are 8 input data, the generated 8*8 original transformation matrix A is shown in equation (3) below:
[0055]
[0056] After obtaining the original transformation matrix, the computing device can process the original transformation matrix according to the symmetry rotation factor of each original matrix element in the original transformation matrix to obtain the first transformation matrix.
[0057] For example, the computing device determines the symmetry rotation factor of each original matrix element in the original transformation matrix based on the symmetry between rotation factors in the NTT, and then replaces some original matrix elements in the odd-numbered rows of the original transformation matrix with the corresponding symmetry rotation factors to obtain the second transformation matrix. Then, based on the exponent of each matrix element in the second transformation matrix, the first transformation matrix is determined.
[0058] The symmetry of the rotation factor in NTT can be expressed by the following formula (4):
[0059]
[0060] Where k = 0, 1, 2, ... N / 2-1. Based on the above formula (4), the computing device can determine the symmetry rotation factor of each original matrix element in the original transformation matrix.
[0061] Taking the case where N is 8 as an example, we can obtain α from the above formula (4). 4 =-α 0 α 5 =-α 1 α 6 =-α 2 α 7 =-α 3 Based on this, the α in the odd-numbered rows of equation (3) above... 4 α 5 α 6 and α 7 By replacing the corresponding symmetric rotation factor, the second transformation matrix B can be obtained, as shown in equation (5) below:
[0062]
[0063] After obtaining the second transformation matrix, the computing device replaces the positive matrix elements in the second transformation matrix with their exponents, and the negative matrix elements with their negative exponents. Thus, the first transformation matrix C obtained from the second transformation matrix according to equation (5) is shown in equation (6) below:
[0064]
[0065] From the first transformation matrix obtained above, it can be seen that, except for the 0th row, the N / 2th row, and the 0th column, the matrix elements of the remaining rows and columns have certain symmetric relationships without considering the signs of the matrix elements. For example, in the first transformation matrix shown in equation (6) above, the symmetric relationships between the 1st to 3rd columns of the 1st row and the 1st to 3rd columns of the 7th row, and the symmetric relationships between the 5th to 7th columns of the 1st row and the 5th to 7th columns of the 7th row are as follows: Figure 3As shown, similarly, there is a similar symmetry between rows 2 and 6, and a similar symmetry between any two odd-numbered rows. Furthermore, there is also a symmetry between columns 0 to 3 and columns 4 to 7 of each row in this first transformation matrix.
[0066] Optionally, in some possible implementations, the computing device may pre-store first transformation matrices corresponding to different quantities of input data. For example, it may store first transformation matrices corresponding to T = 4, 8, 16, ... In this case, the computing device can directly obtain the first transformation matrix corresponding to N based on the number of input data N from the stored mapping relationship between the number of input data and the first transformation matrix. The stored first transformation matrices can be pre-obtained using the methods described above.
[0067] Step 202: Based on the first transformation matrix and multiple input data, obtain the data processing results corresponding to the m matrix elements in the first transformation matrix, where m is less than M.
[0068] As described above, except for rows 0 and N / 2, the remaining even-numbered rows in the first transformation matrix exhibit symmetry, and the odd-numbered rows also exhibit symmetry. Based on this, after obtaining the first transformation matrix, the computing device can select, according to the symmetry between the rows, a subset of matrix elements (i.e., m matrix elements) from the M matrix elements included in the first transformation matrix, whose processing results can contain all the transformation information. This subset of m matrix elements then represents the transformation result. The statement that the data processing results corresponding to these m matrix elements can contain all the transformation information actually means that the data processing results corresponding to the remaining matrix elements can be recovered from the data processing results corresponding to these m matrix elements.
[0069] For example, the computing device selects the i-th and j-th rows from the first transformation matrix, where i is any odd number and j is any even number other than 0 and N / 2. The input data corresponding to the matrix elements with the same absolute value in each selected row are added or subtracted to obtain the data processing result corresponding to the corresponding matrix element in the corresponding row. The input data corresponding to each matrix element refers to the data indexed as the column number of the column containing the corresponding matrix element. Since there is symmetry between odd-numbered rows and even-numbered rows, the data processing results corresponding to the matrix elements in other odd-numbered rows can be recovered from the i-th row, and the data processing results corresponding to the matrix elements in other even-numbered rows can be recovered from the j-th row. Therefore, the data processing results corresponding to the matrix elements in the i-th and j-th rows contain all the transformation information.
[0070] Taking any selected row as an example, the computing device first determines the matrix elements with the same absolute value from that row. For at least two matrix elements with the same absolute value, if both of these matrix elements have positive signs (i.e., their values are equal), then the input data corresponding to these two matrix elements are added together to obtain the data processing result for these two matrix elements. If there is a matrix element with a negative sign among these at least two matrix elements, then the input data corresponding to the negative matrix element is inverted. Then, the inverted input data is added together with the input data corresponding to the other positive matrix elements to obtain the data processing result for these at least two matrix elements.
[0071] For example, taking the first transformation matrix shown in equation (6) above as an example, assuming that an odd-numbered row is selected as the first row and an even-numbered row as the second row, then in the first row, the 0th matrix element is 0 and the 4th matrix element is -0, that is, these two matrix elements are two matrix elements with the same absolute value. Among them, the input data corresponding to the 0th matrix element is x(0), and the input data corresponding to the 4th matrix element is x(4). Since the sign of the 4th matrix element is negative, the corresponding input data is inverted to obtain -x(4). Thus, the data processing result corresponding to these two matrix elements can be obtained as x(0)-x(4). At this time, the data processing result can also be directly used as the processing result corresponding to the matrix element with a positive sign. By the same method, the data processing result corresponding to the matrix element with an absolute value of 1 is x(1)-x(5), the data processing result corresponding to the matrix element with an absolute value of 2 is x(2)-x(6), and the data processing result corresponding to the matrix element with an absolute value of 3 is x(3)-x(7). In the second row, the data processing result corresponding to the matrix element with an absolute value of 0 is x(0)+x(4), the data processing result corresponding to the matrix element with an absolute value of 2 is x(1)+x(5), the data processing result corresponding to the matrix element with an absolute value of 4 is x(2)+x(6), and the data processing result corresponding to the matrix element with an absolute value of 6 is x(3)+x(7).
[0072] Based on this, and according to the symmetry between rows 1 and 7, in row 1, each matrix element with an absolute value of 1 is replaced with a matrix element of the opposite sign and an absolute value of 3; each matrix element with an absolute value of 2 is inverted; and each matrix element with an absolute value of 3 is replaced with a matrix element of the opposite sign and an absolute value of 1. This yields row 7. Therefore, the inverted result of the data processing corresponding to the matrix element with an absolute value of 1 in row 1 is the data processing result corresponding to the matrix element with an absolute value of 3 in row 7; the inverted result of the data processing corresponding to the matrix element with an absolute value of 2 in row 1 is the data processing result corresponding to the matrix element with an absolute value of 2 in row 7; and the inverted result of the data processing corresponding to the data element with an absolute value of 3 in row 1 is the data processing result corresponding to the matrix element with an absolute value of 3 in row 7. Since the column numbers of matrix elements 0 and -0 are exactly the same in rows 1 and 7, the data processing result of the matrix element with an absolute value of 0 in row 1 is the data processing result of the matrix element with an absolute value of 0 in row 7.
[0073] Furthermore, based on the symmetry between rows 2 and 6, in row 2, replacing matrix elements with values of 2 with values of 6 and vice versa yields row 6. Therefore, swapping the processing results for the matrix elements with values of 2 and 6 in row 1 results in the processing results for the matrix elements with values of 2 and 6 in row 6. Similarly, since the columns containing matrix elements with values of 0 and 4 are the same in rows 2 and 6, the processing results for the matrix elements with values of 0 and 4 in row 6 are the same as in row 2.
[0074] For the 0th row of the first transformation matrix, regardless of the value of N, the matrix elements in the 0th row are all 0. Therefore, the data processing result corresponding to the matrix elements in the 0th row is equal to the sum of all the input data.
[0075] For the N / 2th row of the first transformation matrix, which is the 4th row, replace the matrix elements with a value of 4 in the 2nd row with a value of 0, and replace the matrix elements with values of 2 and 6 in the 2nd row with a value of 4. This gives us the 4th row. Therefore, adding the data processing results corresponding to the matrix elements with values of 4 and 0 in the 2nd row gives us the data processing result corresponding to the matrix elements with a value of 0 in the 4th row, and adding the data processing results corresponding to the matrix elements with values of 2 and 6 in the 2nd row gives us the data processing result corresponding to the matrix elements with a value of 4 in the 4th row.
[0076] In summary, the data processing results corresponding to the matrix elements in the first and second rows of the first transformation matrix shown in equation (6) can be used to recover the data processing results of the matrix elements in all other rows. That is, the data processing results corresponding to the matrix elements in the first and second rows contain all the transformation information. The above explanation uses the first and second rows of the first transformation matrix as an example. When other odd and even rows are selected, such as the second and seventh rows, or the sixth and seventh rows, or the third and second rows, etc., the information of other rows can also be recovered based on the same principle. Therefore, by obtaining the data processing results corresponding to the matrix elements in the odd and even rows of the first transformation matrix, all the transformation information can be obtained.
[0077] Optionally, in one possible implementation, the matrix elements with the same absolute value in each row of the first transformation matrix can correspond to a register in the computing device, and the index value of the corresponding register is the absolute value of the matrix element. For example, in the first transformation matrix shown in equation (6), matrix elements 1 and -1 correspond to a register, and the index of the register is 1. Based on this, the data processing results corresponding to the matrix elements with the same absolute value can be stored in the corresponding register. In this way, after storing the data processing results corresponding to the matrix elements in a certain odd or even row into the corresponding register, when restoring other rows, the data stored in registers with different indices can be directly swapped, inverted, swapped, or added according to the symmetric relationship between the matrix elements in the rows described above, thereby obtaining the data processing results corresponding to the matrix elements in other rows that are equal to the corresponding register indices.
[0078] Step 203: Take the data processing results corresponding to the m matrix elements in the first transformation matrix as the transformation result.
[0079] As described in step 202, the data processing results corresponding to the m matrix elements in the first transformation matrix are actually the data processing results corresponding to the matrix elements in one odd row and one even row of the first transformation matrix. These m matrix elements contain all the transformation information. Therefore, the computing device can directly use the data processing results corresponding to these m matrix elements as the final transformation result.
[0080] For example, regarding the above Figure 6 The first transformation matrix shown below yields the final transformation results, as shown in Table 1 below:
[0081] Table 1 Transformation Results
[0082] Matrix element 0 1 2 3 4 6 Row 1 x(0) - x(4) x(1) - x(5) x(2) - x(6) x(3) - x(7) Row 2 x(0) + x(4) x(1) + x(5) x(2) + x(6) x(3) + x(7)
[0083] In this embodiment, based on the symmetry between rotation factors in NTT, the rotation factors included in the original transformation matrix are transformed to obtain a first transformation matrix in which the matrix elements between rows and columns have symmetric relationships. Based on this, the computing device only needs to obtain the data processing results corresponding to a portion of the matrix elements in the first transformation matrix to obtain all the transformation information, without needing to obtain the data processing results corresponding to all matrix elements, thus accelerating the transformation speed and improving transformation efficiency.
[0084] Furthermore, in this embodiment, the data processing result can be obtained by adding and subtracting the input data corresponding to matrix elements with the same absolute value, and then used as the final transformation result. The entire process does not require multiplication, modulo, or other operations, reducing the transformation complexity. Moreover, in this embodiment, since no modulo operation is involved in the entire transformation process, there is no hardware bit-width locking, i.e., the bit width is unlocked. Furthermore, because no modulo operation is performed, the transformation result can be truncated from the least significant bit to the most significant bit during subsequent signal processing, thereby flexibly setting the data bit width and reducing the consumption of computational resources.
[0085] It should be noted that the above mainly describes the process of performing a forward transformation on the input data when the input data is untransformed. Optionally, when the input data has been processed in the transform domain after a forward transformation, the inverse transformation matrix can be obtained by applying the orthogonality and uniqueness between the forward and inverse transformations. Then, referring to the method described in the above embodiments, this inverse transformation matrix can be used as the first transformation matrix to obtain the data processing results corresponding to m matrix elements. Finally, dividing the obtained data processing results by N yields the inverse transformation result.
[0086] Optionally, in some possible implementations, when the number of input data is N, the split basis algorithm can be used to arrange the input data into a matrix. Then, each row of input data in the input data matrix is transformed using the method described in the above embodiments to obtain the transformation result.
[0087] For example, when the number of input data is N, the input data is divided into two rows, each row containing N / 2 input data. In this case, the first transformation matrix corresponding to N / 2 can be used to transform each row of input data to obtain the transformation result of each row.
[0088] Taking N=8 as an example, the 8 input data are arranged into a 2*4 matrix D, as shown in equation (7):
[0089]
[0090] Next, for each row of the matrix D containing four input data points, the indices of these four input data points are set to 0, 1, 2, and 3 in ascending order. Then, the transformation of each row's four data points can be performed using the 4x4 first transformation matrix as described in the previous embodiment, thus obtaining the transformation result for each row. The process of transforming the four input data points using the 4x4 transformation matrix can also be called a 4-point transformation. Therefore, in this implementation, splitting the eight input data points into two groups for separate transformations effectively breaks down the eight-point transformation into two 4-point transformations.
[0091] For example, taking the first row of input data in matrix D as an example, let h(0) = x(0), h(1) = x(2), h(2) = x(4), h(3) = x(6). As can be seen from the above introduction, the first transformation matrix E of 4*4 is as shown in equation (8):
[0092]
[0093] It is worth noting that since the even-numbered rows of the 4*4 first transformation matrix are rows 0 and 2, and row 2 is exactly row N / 2, when selecting an odd-numbered row and an even-numbered row, the even-numbered row is row 2, and the odd-numbered row can be row 1 or row 3. Based on this, the transformation result corresponding to the first row of input data obtained by the computing device can be shown in Table 2 or 3.
[0094] Table 2 Transformation Results
[0095] Matrix element 0 1 2 Row 1 x(0) - x(2) x(1) - x(3) Row 2 x(0) + x(2) x(1) + x(3)
[0096] Table 3 Transformation Results
[0097] Matrix element 0 1 2 Row 2 x(0) + x(2) x(1) + x(3) Row 3 x(0) - x(2) x(3) - x(1)
[0098] Therefore, after transforming the four input data in each row, the transformation result corresponding to each row of input data will be the data processing result corresponding to the matrix elements of the first row and the second row of the first transformation matrix obtained according to the corresponding row of input data, or the data processing result corresponding to the matrix elements of the second row and the third row.
[0099] It should be noted that the above example using N=8 is merely for illustration and does not constitute a limitation on the embodiments of this application. For example, when N=16, the input data can also be arranged into a 2*8 or 4*4 matrix, and the input data in each row can be transformed accordingly according to the 8*8 or 4*4 first transformation matrix. This will not be elaborated further in the embodiments of this application.
[0100] Furthermore, addressing the issues of bit width locking and high computational complexity caused by the modulo operation in current NTT implementations, this application provides another data transformation method. This method can also be applied to... Figure 1 In the computing device shown, such as Figure 4 As shown, the method includes the following steps:
[0101] Step 401: Obtain the number theory transformation matrix.
[0102] The number-theoretical transformation matrix is either the first transformation matrix obtained in step 201 based on the original transformation matrix, or the third transformation matrix obtained by replacing each matrix element in the original transformation matrix with the power of the corresponding matrix element. The method by which the computing device obtains the number-theoretical transformation matrix can refer to the relevant implementation method of step 201, which will not be elaborated further in this embodiment.
[0103] Step 402: Based on the number theory transformation matrix and multiple input data, determine the data processing result corresponding to the matrix element in each row of the number theory transformation matrix.
[0104] When the number theory transformation matrix is the first transformation matrix mentioned in step 201, in this step, the computing device can refer to the method described in step 202 for determining the data processing result corresponding to the matrix element in each row of the number theory transformation matrix.
[0105] For example, taking the first transformation matrix shown in the aforementioned equation (6) as an example, the data processing results corresponding to the matrix elements in each row obtained from the 8 input data and the 8*8 first transformation matrix are shown in Table 4.
[0106] Table 4 shows the data processing results corresponding to the matrix elements in each row of the first transformation matrix.
[0107]
[0108]
[0109] Optionally, when the number theory transformation matrix is the third transformation matrix obtained from the original transformation matrix as described above, in this step, for each row of matrix elements in the third transformation matrix, if there are identical matrix elements in that row, the input data corresponding to the identical matrix elements are added together and used as the data processing result corresponding to the corresponding matrix element. For other identical matrix elements, the input data corresponding to the matrix element is directly used as the data processing result corresponding to that matrix element.
[0110] For example, taking the original transformation matrix shown in equation (3) above as an example, by replacing each matrix element in the original transformation matrix with the power exponent of the corresponding matrix element, the resulting third transformation matrix G is shown in equation (9) below:
[0111]
[0112] The data processing results corresponding to each matrix element obtained based on the third transformation matrix and the 8 input data are shown in Table 5 below.
[0113] Table 5 shows the data processing results for each matrix element in the third transformation matrix.
[0114]
[0115] Step 403: Perform a cyclic carry-over of the data processing results corresponding to the matrix elements in each row of the number theory transformation matrix in ascending order of the corresponding matrix elements to obtain the updated data processing results for each row.
[0116] After obtaining the data processing results corresponding to the matrix elements in each row of the number-theoretical transformation matrix, the computing device performs a cyclic carry-over on the data processing results corresponding to the matrix elements in each row of the number-theoretical transformation matrix in ascending order of the corresponding matrix elements, thereby achieving automatic modulo and obtaining the updated data processing results for each row.
[0117] For example, in one possible implementation, each row of the number-theoretic transformation matrix corresponds to N registers, and these N registers are concatenated in ascending order of their indices. For any row of the number-theoretic transformation matrix, such as the i-th row, the computing device can fill the data processing result corresponding to each matrix element in the i-th row into the register with the corresponding matrix element index, thereby achieving cyclic carry.
[0118] It should be noted that the index values of the N registers corresponding to each row range from 0 to N-1. In this embodiment, the j-th register refers to the register with index j. When the N registers are cascaded, the most significant bit of the j-th register is connected to the least significant bit of the (j+1)-th register, and the most significant bit of the last register is connected to the least significant bit of the 0th register. Furthermore, in this embodiment, the bit width of each register is a set bit width. For example, the set bit width of each register is 2b / N, where b is the bit width determined according to the reference transformation parameter in number theory transformation. This reference transformation parameter is the dividend in the modulo operation of number theory transformation; for example, this reference transformation parameter can be a Fermat number.
[0119] Based on this, taking the i-th row as an example, the computing device fills the data processing results corresponding to each matrix element in the i-th row into the register corresponding to the corresponding matrix element in order from smallest to largest according to the set bit width of the register. The register corresponding to each matrix element is the register whose index is equal to that of the corresponding matrix element.
[0120] The computing device first sorts the matrix elements in the i-th row in ascending order. Then, it obtains the data processing result corresponding to the first matrix element after sorting. If the bit width of the data processing result corresponding to the first matrix element is greater than the set bit width of the register, then bits of the data processing result corresponding to the first matrix element, starting from the least significant bit, are truncated to the set bit width and filled into the register corresponding to that matrix element. Then, the remaining bits are carried over to the next register connected to that register. The next register is the register where the least significant bit is connected to the most significant bit of the first register. If the bit width of the data processing result corresponding to the first matrix element is not greater than the set bit width of the register, then the data processing result corresponding to the first matrix element is directly filled into the corresponding register.
[0121] Next, the computing device obtains the data processing result corresponding to the second matrix element. If the register corresponding to the second matrix element contains the carry data from the previous register, the data processing result of the second matrix element is added to the carry data stored in the second register. The added data is then filled into the register corresponding to the second matrix element. If the bit width of the added data is greater than the set bit width, the carry can be added to the next register in the same way as described above. If the register corresponding to the second matrix element does not contain the carry data from the previous register, the data processing result of the first matrix element can be filled into the register corresponding to the second matrix element, following the method described above. This process continues, allowing the computing device to automatically cycle and carry over data from each matrix element in the i-th row, in ascending order, according to the set bit width of the register. After completing the automatic cyclic carry, the computing device can use the data stored in each register as the updated data processing result of the matrix element corresponding to that register.
[0122] Here, the register with index j among the N registers is called register R(j), and the carry relationship between the N registers in each row is as follows: Figure 5 As shown, according to the register index in ascending order, the data is carried over sequentially. If the bit width of the data to be stored in the last register R(N-1) exceeds the set bit width, then the data is carried over to R(0).
[0123] For example, suppose there are 8 registers R(0) to R(7), each with a set bit width of 2 bits. Suppose the data processing result corresponding to matrix element 0 in the i-th row is 11011, which exceeds the set bit width. In this case, the lower two bits of the data processing result of matrix element 0, i.e., 11, are filled into R(0), and the remaining 3 bits are carried over to R(1). Suppose there is no matrix element 1 in the i-th row, but since 110 still exceeds the set bit width of the register, the lower two bits of 110, i.e., 10, can be filled into R(1), and the higher 1 bit is carried over to R(2). Of course, if there is matrix element 1 in the i-th row, the computing device adds the 3 bits of data that need to be carried over to R(1) with the data processing result corresponding to matrix element 1. Then, the lower 2 bits of the added data are filled into R(1), and the remaining bits are carried over to R(2) in the same way. If there is still data that needs to be carried over to the next register up to R(7), then carry over to R(0).
[0124] As can be seen from the above introduction, for the i-th row, the updated data processing result of the i-th row may contain the data processing result corresponding to the matrix element that does not exist in the i-th row. For example, in the above example, although the i-th row does not contain matrix element 1, the carry data of matrix element 0 will cause the updated data processing result of the i-th row to contain the data processing result corresponding to matrix element 1.
[0125] For each row in the number theory transformation matrix, the above method can be used to perform a cyclic carry-over of the data processing results of the matrix elements in each row, thereby completing the automatic remainder and obtaining the updated data processing results for each row.
[0126] Optionally, the above description is based on the example of a computing device implementing cyclic carry using its own registers. In other possible implementations, the computing device may also implement cyclic carry for each row using other hardware or software methods. Regardless of whether it is hardware or software, the principle of cyclic carry is the same or similar, and this application embodiment will not elaborate further.
[0127] Step 404: Based on the updated data processing results for each row, obtain the corresponding output data for each row.
[0128] Taking the i-th row as an example, the computing device shifts the corresponding data processing results according to the rotation factor corresponding to the matrix element of each data processing result in the updated i-th row; the shifted data processing results are added together to obtain the first result; the first result is moduloed based on the reference transformation parameter to obtain the i-th output data corresponding to the i-th row.
[0129] As described in step 403 above, the updated data processing result of row i may contain data processing results corresponding to matrix elements that were not originally present in row i. Therefore, in this step, the computing device first determines the matrix elements corresponding to each data processing result in the updated row i. For example, the matrix elements corresponding to each data processing result can be determined based on the index of the register storing each data processing result. That is, for any data processing result, if the index of the register storing that data processing result is j, then that data processing result is the data processing result corresponding to matrix element j. Afterward, the computing device obtains the rotation factor corresponding to each matrix element, where the rotation factor corresponding to a matrix element is the rotation factor whose exponent is equal to that of the matrix element.
[0130] After obtaining the rotation factor corresponding to each matrix element, the computing device shifts the data processing result corresponding to the corresponding matrix element according to the rotation factor.
[0131] In this system, the basis of the twitch factor corresponding to each matrix element is the same. If the basis is 2, then the number of bits shifted in the corresponding data processing result corresponds to the power of the twitch factor. Of course, if the basis is not 2, but 2 to the power of P, then the product of P and the power of the twitch factor, Q, is calculated, and then the corresponding data processing result is shifted by Q bits.
[0132] For example, for matrix element 1, the power of the rotation factor is 1. Assuming the data processing result corresponding to matrix element 1 is 11, and the basis of the rotation factor is 2 to the power of 2, then shifting the data processing result of matrix element by two bits will result in 1100.
[0133] After obtaining the processed data after shifting, the shifted data results are added together to obtain the first result. Then, the first result is moduloed by the reference transformation parameter as the dividend to obtain the output data corresponding to the i-th row, that is, the i-th output data.
[0134] The updated data for each row can be processed using the same method described above to obtain the corresponding output data for each row. The resulting N rows of output data represent the transformation result.
[0135] In this embodiment, the data processing result corresponding to each row of matrix elements in the number theory transformation matrix is obtained, and the automatic modulo operation of the data processing result is achieved by cyclically carrying over the corresponding matrix elements in ascending order. This eliminates the need for a large number of modulo operations based on the reference transformation parameters during the transformation process, reduces the transformation complexity, thereby reducing resource consumption and improving the transformation speed.
[0136] Alternatively, in some possible implementations,Figure 4 The illustrated embodiment can also be combined with the split-basis algorithm. That is, when the number of input data is N, the split-basis algorithm can be used to arrange the N input data into a matrix. Then, for each row of the input data matrix, the split-basis algorithm can be used... Figure 4 The method described in the illustrated embodiment performs transformations to obtain an intermediate transformation result matrix composed of the transformation results of each row of input data. A portion of the transformation results in the intermediate transformation result matrix is shifted according to the corresponding rotation factor, and then each column of the intermediate transformation result matrix is transformed again using the method described above to obtain the final transformation result.
[0137] For example, taking N equal to 8 as an example, the 8 input data are arranged into matrix D as shown in equation (7), and then... Figure 4 The method described in the embodiment transforms the two rows of input data respectively. After the transformation of each row of input data, four intermediate output data can be obtained, that is, four intermediate transformation results. Thus, after transforming the two rows of input data of matrix D, a 2*4 intermediate transformation result matrix H can be obtained, as shown in the following equation (10):
[0138]
[0139] In the above formula, F(a,b) refers to the b-th intermediate output data obtained by transforming the input data in the a-th row.
[0140] As described above, splitting the 8 input data points into two groups for transformation can also be described as splitting the 8-point transformation into two 4-point transformations. And through... Figure 4 The result of performing two 4-point transformations in the illustrated embodiment is the intermediate transformation result matrix of equation (10) above. Then, the computing device can combine the results of the two 4-point transformations to obtain the final transformation result. Specifically, when combining the results of the two 4-point transformations, the computing device multiplies each intermediate input data in the second row of matrix H by its corresponding rotation factor, i.e., performs a shift, to obtain the updated H. Then, through... Figure 4 In the illustrated embodiment, the two input data in each column are treated as a set of input data and subjected to a two-point transformation to obtain the final transformation result.
[0141] See Figure 6 This application provides a data transformation device 600, which includes: a first acquisition module 601, a second acquisition module 602, and a determination module 603;
[0142] The first acquisition module 601 is used to execute step 201 in the foregoing embodiment;
[0143] The second acquisition module 602 is used to execute step 202 in the foregoing embodiment;
[0144] The determination module 603 is used to execute step 203 in the foregoing embodiments.
[0145] The various modules in the device 600 can be accessed through the aforementioned Figure 1 The processor of the computing device shown is used to implement this.
[0146] Optionally, the first acquisition module 601 is mainly used for:
[0147] Obtain the original transformation matrix, which consists of N*N original matrix elements. Each original matrix element is a rotation factor, and the exponent of each original matrix element is equal to the remainder of the product of the row number and column number of the corresponding original matrix element divided by N. N is equal to the number of multiple input data.
[0148] The original transformation matrix is processed based on the original transformation matrix and the symmetry rotation factor of each original matrix element to obtain the first transformation matrix.
[0149] Optionally, the second acquisition module 602 is mainly used for:
[0150] Select the i-th and j-th rows from the first transformation matrix, where i is any odd number and j is any even number except 0 and N / 2, and N is equal to the number of multiple input data.
[0151] Add or subtract the input data corresponding to the matrix elements with the same absolute value in each selected row to obtain the data processing result corresponding to the matrix element in the corresponding row. The input data corresponding to each matrix element refers to the data whose index is the column number of the column where the corresponding matrix element is located.
[0152] In summary, in this embodiment, the first transformation matrix is obtained by transforming the original transformation matrix based on the symmetry of the rotation factor in NTT. Thus, some of the M matrix elements of the first transformation matrix possess symmetry. Therefore, by obtaining the data processing results corresponding to some matrix elements of the first transformation matrix, the data processing results corresponding to the other matrix elements can be recovered, thereby obtaining the various output data. That is, in this embodiment, only the data processing results corresponding to some matrix elements are needed to characterize all transformation information, reducing the complexity of data transformation and accelerating the transformation speed.
[0153] See Figure 7 This application embodiment also provides another data conversion device 700, which includes: a first acquisition module 701, a determination module 702, a cyclic carry module 703, and a second acquisition module 704.
[0154] The first acquisition module 701 is used to execute step 401 in the foregoing embodiment;
[0155] The determination module 702 is used to execute step 402 in the foregoing embodiments;
[0156] The cyclic carry module 703 is used to execute step 403 in the aforementioned embodiment;
[0157] The second acquisition module 704 is used to execute step 404 in the foregoing embodiment.
[0158] Optionally, the determining module 702 is mainly used for:
[0159] Add or subtract the input data corresponding to the matrix elements with the same absolute value in the i-th row of the number theory transformation matrix to obtain the data processing result corresponding to the matrix element in the i-th row. The input data corresponding to each matrix element refers to the data whose index is the column number of the column where the corresponding matrix element is located.
[0160] Optionally, each row of the number theory transformation matrix corresponds to N registers, which are concatenated in ascending order of their indices. The most significant bit of the j-th register is connected to the least significant bit of the (j+1)-th register. The cyclic carry module 703 is mainly used for:
[0161] Following the ascending order of the matrix elements in the i-th row, and according to the set bit width of the register, the data processing results corresponding to each matrix element are sequentially filled into the register corresponding to the corresponding matrix element. The register corresponding to each matrix element is the register whose index is equal to that of the corresponding matrix element.
[0162] Optionally, the second acquisition module 704 is mainly used for:
[0163] Based on the rotation factor corresponding to the matrix element of each data processing result in the updated i-th row, shift the corresponding data processing result.
[0164] Add the processed data after shifting to obtain the first result;
[0165] The first result is moduloed based on the reference transformation parameters to obtain the i-th output data corresponding to the i-th row.
[0166] In this embodiment, the data processing result corresponding to each row of matrix elements in the number theory transformation matrix is obtained, and the automatic modulo operation of the data processing result is achieved by cyclically carrying over the corresponding matrix elements in ascending order. This eliminates the need for a large number of modulo operations based on the reference transformation parameters during the transformation process, reduces the transformation complexity, thereby reducing resource consumption and improving the transformation speed.
[0167] It should be noted that the data transformation device provided in the above embodiments is only illustrated by the division of the above functional modules when transforming input data. In practical applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above. In addition, the data transformation device and the data transformation method embodiments provided in the above embodiments belong to the same concept, and the specific implementation process can be found in the method embodiments, which will not be repeated here.
[0168] In the above embodiments, implementation can be achieved entirely or partially through software, hardware, firmware, or any combination thereof. When implemented using software, it can be implemented entirely or partially as a computer program product. The computer program product includes one or more computer instructions. When the computer instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of this application are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, Digital Subscriber Line, DSL) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that integrates one or more available media. The available media can be magnetic media (e.g., floppy disks, hard disks, magnetic tapes), optical media (e.g., Digital Versatile Discs (DVDs)), or semiconductor media (e.g., Solid State Disks (SSDs)).
[0169] Those skilled in the art will understand that all or part of the steps of the above embodiments can be implemented by hardware or by a program instructing related hardware. The program can be stored in a computer-readable storage medium, such as a read-only memory, a disk, or an optical disk.
[0170] The above description is not intended to limit the embodiments of this application. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the embodiments of this application should be included within the protection scope of the embodiments of this application.
Claims
1. A data transformation method, characterized in that, The method includes: Obtain the number theory transformation matrix; Based on the number theory transformation matrix and multiple input data, determine the data processing result corresponding to the matrix element in each row of the number theory transformation matrix; The data processing results corresponding to the matrix elements in each row of the number theory transformation matrix are cyclically carried over according to the order of the corresponding matrix elements from smallest to largest, so as to obtain the updated data processing results for each row. Based on the updated data processing results for each row, obtain the corresponding output data for each row; The step of obtaining the output data corresponding to each row based on the data processing result of each updated row includes: Based on the rotation factor corresponding to the matrix element of each data processing result in the updated i-th row, shift the corresponding data processing result. Add the processed data after shifting to obtain the first result; The first result is moduloed based on the reference transformation parameters to obtain the i-th output data corresponding to the i-th row.
2. The method according to claim 1, characterized in that, The step of determining the data processing result corresponding to the matrix element in each row of the number-theoretical transformation matrix based on the number-theoretical transformation matrix and multiple input data includes: The input data corresponding to the matrix elements with the same absolute value in the i-th row of the number theory transformation matrix are added or subtracted to obtain the data processing result corresponding to the matrix element in the i-th row. The input data corresponding to each matrix element refers to the data whose index is the column number of the column where the corresponding matrix element is located.
3. The method according to claim 1, characterized in that, Each row of the number-theoretic transformation matrix corresponds to N registers, which are concatenated in ascending order of their indices. The most significant bit of the j-th register is connected to the least significant bit of the (j+1)-th register. The step of cyclically carrying over the data processing results corresponding to the matrix elements in each row of the number-theoretic transformation matrix according to the ascending order of the corresponding matrix elements includes: According to the ascending order of the matrix elements in the i-th row, and based on the set bit width of the register, the data processing results corresponding to each matrix element are sequentially filled into the register corresponding to the corresponding matrix element. The register corresponding to each matrix element is the register whose index is equal to that of the corresponding matrix element.
4. The method according to claim 1, characterized in that, The acquisition of the number theory transformation matrix includes: A first transformation matrix is obtained as the number theory transformation matrix. The first transformation matrix is obtained by transforming the original transformation matrix based on the symmetry of the rotation factor in the number theory transformation NTT. The first transformation matrix includes M matrix elements, and some of the M matrix elements have symmetry. The step of determining the data processing result corresponding to the matrix element in each row of the number-theoretical transformation matrix based on the number-theoretical transformation matrix and multiple input data includes: Based on the first transformation matrix and multiple input data, obtain the data processing results corresponding to m matrix elements in the first transformation matrix, where m is less than M; The data processing results corresponding to the m matrix elements in the first transformation matrix are taken as the transformation result; The step of obtaining the first transformation matrix includes: Obtain the original transformation matrix, which includes N. There are N original matrix elements, each of which is a rotation factor. The power of each original matrix element is equal to the remainder of the product of the row number and column number of the corresponding original matrix element divided by N. The number of N is equal to the number of input data. The original transformation matrix is processed based on the original transformation matrix and the symmetry rotation factor of each original matrix element to obtain the first transformation matrix.
5. The method according to claim 4, characterized in that, The step of obtaining the data processing results corresponding to the m matrix elements in the first transformation matrix based on the first transformation matrix and multiple input data includes: Select the i-th row and the j-th row from the first transformation matrix, where i is any odd number, j is any even number other than 0 and N / 2, and N is equal to the number of the plurality of input data. Add or subtract the input data corresponding to the matrix elements with the same absolute value in each selected row to obtain the data processing result corresponding to the matrix element in the corresponding row. The input data corresponding to each matrix element refers to the data whose index is the column number of the column where the corresponding matrix element is located.
6. A data conversion device, characterized in that, The device includes: The first acquisition module is used to acquire the number theory transformation matrix; The determination module is used to determine the data processing result corresponding to the matrix element in each row of the number theory transformation matrix based on the number theory transformation matrix and multiple input data. The cyclic carry module is used to cyclically carry over the data processing results corresponding to the matrix elements in each row of the number theory transformation matrix in ascending order of the corresponding matrix elements to obtain the updated data processing results for each row. The second acquisition module is used to acquire the corresponding output data for each row based on the data processing results of each row after the update. The second acquisition module is mainly used for: Based on the rotation factor corresponding to the matrix element of each data processing result in the updated i-th row, shift the corresponding data processing result. Add the processed data after shifting to obtain the first result; The first result is moduloed based on the reference transformation parameters to obtain the i-th output data corresponding to the i-th row.
7. The apparatus according to claim 6, characterized in that, The determining module is mainly used for: The input data corresponding to the matrix elements with the same absolute value in the i-th row of the number theory transformation matrix are added or subtracted to obtain the data processing result corresponding to the matrix element in the i-th row. The input data corresponding to each matrix element refers to the data whose index is the column number of the column where the corresponding matrix element is located.
8. The apparatus according to claim 6, characterized in that, Each row of the number theory transformation matrix corresponds to N registers, which are concatenated in ascending order of their indices. The most significant bit of the j-th register is connected to the least significant bit of the (j+1)-th register. The cyclic carry module is mainly used for: According to the ascending order of the matrix elements in the i-th row, and based on the set bit width of the register, the data processing results corresponding to each matrix element are sequentially filled into the register corresponding to the corresponding matrix element. The register corresponding to each matrix element is the register whose index is equal to that of the corresponding matrix element.
9. The apparatus according to claim 6, characterized in that, The first acquisition module is used to acquire a first transformation matrix as the number theory transformation matrix. The first transformation matrix is obtained by transforming the original transformation matrix based on the symmetry of the rotation factor in the number theory transformation NTT. The first transformation matrix includes M matrix elements, and some of the M matrix elements have symmetry. The determining module is used to: obtain the data processing results corresponding to m matrix elements in the first transformation matrix based on the first transformation matrix and multiple input data, where m is less than M; and take the data processing results corresponding to the m matrix elements in the first transformation matrix as the transformation result; The first acquisition module is mainly used for: Obtain the original transformation matrix, which includes N. There are N original matrix elements, each of which is a rotation factor. The power of each original matrix element is equal to the remainder of the product of the row number and column number of the corresponding original matrix element divided by N. The number of N is equal to the number of input data. The original transformation matrix is processed based on the original transformation matrix and the symmetry rotation factor of each original matrix element to obtain the first transformation matrix.
10. The apparatus according to claim 9, characterized in that, The determining module is mainly used for: Select the i-th row and the j-th row from the first transformation matrix, where i is any odd number, j is any even number other than 0 and N / 2, and N is equal to the number of the plurality of input data. Add or subtract the input data corresponding to the matrix elements with the same absolute value in each selected row to obtain the data processing result corresponding to the matrix element in the corresponding row. The input data corresponding to each matrix element refers to the data whose index is the column number of the column where the corresponding matrix element is located.
11. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores instructions that, when executed on a computer, cause the computer to perform the data transformation method according to any one of claims 1-5.