CN116186473A - Data conversion method, device and storage medium - Google Patents

Data conversion method, device and storage medium Download PDF

Info

Publication number
CN116186473A
CN116186473A CN202111422020.4A CN202111422020A CN116186473A CN 116186473 A CN116186473 A CN 116186473A CN 202111422020 A CN202111422020 A CN 202111422020A CN 116186473 A CN116186473 A CN 116186473A
Authority
CN
China
Prior art keywords
matrix
transformation
row
data processing
data
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202111422020.4A
Other languages
Chinese (zh)
Inventor
方啸天
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Huawei Technologies Co Ltd
Original Assignee
Huawei Technologies Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Huawei Technologies Co Ltd filed Critical Huawei Technologies Co Ltd
Priority to CN202111422020.4A priority Critical patent/CN116186473A/en
Priority to PCT/CN2022/134349 priority patent/WO2023093849A1/en
Publication of CN116186473A publication Critical patent/CN116186473A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F17/00Digital computing or data processing equipment or methods, specially adapted for specific functions
    • G06F17/10Complex mathematical operations
    • G06F17/14Fourier, Walsh or analogous domain transformations, e.g. Laplace, Hilbert, Karhunen-Loeve, transforms
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F17/00Digital computing or data processing equipment or methods, specially adapted for specific functions
    • G06F17/10Complex mathematical operations
    • G06F17/16Matrix or vector computation, e.g. matrix-matrix or matrix-vector multiplication, matrix factorization
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Mathematical Physics (AREA)
  • Theoretical Computer Science (AREA)
  • Computational Mathematics (AREA)
  • Mathematical Analysis (AREA)
  • Mathematical Optimization (AREA)
  • Pure & Applied Mathematics (AREA)
  • Data Mining & Analysis (AREA)
  • Algebra (AREA)
  • Software Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Computing Systems (AREA)
  • Complex Calculations (AREA)
  • Image Processing (AREA)
  • Compression, Expansion, Code Conversion, And Decoders (AREA)
  • Compression Or Coding Systems Of Tv Signals (AREA)

Abstract

The embodiment of the application discloses a data transformation method, a data transformation device and a storage medium, and belongs to the field of data processing. In this embodiment of the present application, the first transformation matrix is obtained by transforming the original transformation matrix according to symmetry of the rotation factor in the NTT, so that some matrix elements in M matrix elements of the first transformation matrix have symmetry, so that by obtaining the data processing results corresponding to some matrix elements in the first transformation matrix, the data processing results corresponding to other matrix elements can be recovered, and further, each output data is obtained. That is, in the embodiment of the application, all transformation information can be represented only by acquiring the data processing results corresponding to part of matrix elements, so that the complexity of data transformation is reduced, and the transformation speed is increased.

Description

Data conversion method, device and storage medium
Technical Field
The present invention relates to the field of data processing, and in particular, to a data transformation method, apparatus, and storage medium.
Background
In the data processing process, a number theory transformation (number theory transform, NTT) mode can be adopted to convert a plurality of input data into a transformation domain, so as to obtain a plurality of output data in the transformation domain. After the data is processed in the transformation domain, the processed data is subjected to inverse transformation to obtain final output data. When the NTT is adopted to transform the input data, the corresponding input data is required to be shifted according to each matrix element in each row of the transformation matrix and then the remainder is added, so that the output data corresponding to the corresponding row is obtained, and the operation complexity is high.
Disclosure of Invention
The embodiment of the application provides a data conversion method, a data conversion device and a storage medium, which can reduce the complexity of data conversion and improve the conversion efficiency. The technical scheme is as follows:
in a first aspect, a data transformation method is provided, the method comprising: acquiring a first transformation matrix, wherein the first transformation matrix is obtained by converting an original transformation matrix based on symmetry of rotation factors in Number Theory Transformation (NTT), the first transformation matrix comprises M matrix elements, and part of the M matrix elements have symmetry; according to the first transformation matrix and a plurality of input data, data processing results corresponding to M matrix elements in the first transformation matrix are obtained, wherein M is smaller than M; and taking data processing results corresponding to m matrix elements in the first transformation matrix as transformation results.
In this embodiment of the present application, the first transformation matrix is obtained by transforming the original transformation matrix according to symmetry of the rotation factor in the NTT, so that some matrix elements in M matrix elements of the first transformation matrix have symmetry, so that by obtaining the data processing results corresponding to some matrix elements in the first transformation matrix, the data processing results corresponding to other matrix elements can be recovered, and further, each output data is obtained. That is, in the embodiment of the application, all transformation information can be represented only by acquiring the data processing results corresponding to part of matrix elements, so that the complexity of data transformation is reduced, and the transformation speed is increased.
In one possible implementation manner, the implementation process of obtaining the first transformation matrix is as follows: the original transformation matrix is obtained, the original transformation matrix comprises N original matrix elements, each original matrix element is a twiddle factor, the power exponent of each original matrix element is equal to the remainder of dividing the product of the number of rows of the row where the corresponding original matrix element is located and the number of columns where the corresponding original matrix element is located by N, and the number of N and the number of the plurality of input data are equal; and processing the original transformation matrix according to the original transformation matrix and the symmetrical rotation factors of each original matrix element to obtain the first transformation matrix.
In the embodiment of the present application, according to the symmetry of the twiddle factors, the twiddle factors in the original transformation matrix are converted, so as to obtain a first transformation matrix with symmetry matrix elements. Because the matrix elements of the first transformation matrix have symmetry, all transformation information can be represented only by acquiring data processing results corresponding to part of the matrix elements, so that transformation complexity is reduced.
In one possible implementation manner, according to the first transformation matrix and the plurality of input data, an implementation process of obtaining data processing results corresponding to m matrix elements in the first transformation matrix may be: selecting an ith row and a jth row from the first transformation matrix, wherein i is any odd number, j is any even number except 0 and N/2, and the number of the N and the plurality of input data is equal; and adding or subtracting the input data corresponding to the matrix elements with the same absolute value in each selected row to obtain a data processing result corresponding to the corresponding matrix element in the corresponding row, wherein the input data corresponding to each matrix element refers to the data with the index of the column number of the column in which the corresponding matrix element is positioned.
In this embodiment of the present application, the matrix elements in each odd-numbered row of the first transformation matrix have symmetry, and the matrix elements in each even-numbered row have symmetry, so that all transformation information can be obtained only by outputting the data processing results corresponding to the matrix elements in one odd-numbered row and one even-numbered row.
In a second aspect, there is provided a data transformation method, the method comprising: acquiring a number theory transformation matrix; determining a data processing result corresponding to matrix elements in each row of the number-theory transformation matrix according to the number-theory transformation matrix and a plurality of input data; carrying out cyclic carry on the data processing results corresponding to the matrix elements in each row of the number theory transformation matrix according to the sequence from the smaller matrix elements to the larger matrix elements, and obtaining updated data processing results of each row; and acquiring output data corresponding to each row according to the updated data processing result of each row.
In the embodiment of the application, the data processing result corresponding to each row of matrix elements in the number theory transformation matrix is obtained, and the automatic remainder of the data processing result is realized by carrying out cyclic carry on the data processing result corresponding to each row of matrix elements according to the sequence from small to large of the corresponding matrix elements, so that a large amount of remainder calculation based on reference transformation parameters in the transformation process is omitted, the transformation complexity is reduced, the resource consumption is reduced, and the transformation speed is improved.
In one possible implementation manner, the determining, according to the number-theory transformation matrix and the plurality of input data, the data processing result corresponding to the matrix element in each row of the number-theory transformation matrix includes: and adding or subtracting input data corresponding to the matrix elements with the same absolute value in the ith row of the number theory transformation matrix to obtain a data processing result corresponding to the corresponding matrix elements in the ith row, wherein the input data corresponding to each matrix element refers to data with the index of the column number of the column where the corresponding matrix element is located.
In one possible implementation manner, each row of the number theory transformation matrix corresponds to N registers, the N registers are connected in series according to the order from small to large of indexes of the registers, wherein the most significant bit of the jth register is connected with the least significant bit of the jth+1th register, and the implementation process of circularly carrying out the data processing result corresponding to the matrix elements in each row of the number theory transformation matrix according to the order from small to large of the corresponding matrix elements may be: according to the order from small to large of each matrix element in the ith row, according to the set bit width of the register, sequentially filling the data processing results corresponding to each matrix element into the register corresponding to the corresponding matrix element, wherein the register corresponding to each matrix element refers to a register with the index equal to that of the corresponding matrix element.
In the embodiment of the application, the data processing results corresponding to the matrix elements are filled into the corresponding registers, and automatic cyclic carry is realized through the head-tail serial connection of the registers, so that the residual operation in the traditional conversion process is replaced, the conversion complexity is reduced, the resource consumption is reduced, and the conversion speed is improved.
In one possible implementation manner, the implementation process of obtaining the output data corresponding to each row according to the updated data processing result of each row is: shifting the corresponding data processing results according to the twiddle factors corresponding to the matrix elements corresponding to the updated data processing results of the ith row; adding the shifted data processing results to obtain a first result; and taking the remainder of the first result based on the reference transformation parameters to obtain the ith output data corresponding to the ith row.
In the embodiment of the application, for any row, after each data processing result of the row is circularly carried, the final output data can be obtained only by carrying out corresponding shift and one-time remainder taking operation, and compared with the traditional conversion process, the number of remainder taking operations is greatly reduced, the conversion complexity is reduced, so that the resource consumption is reduced, and the conversion speed is improved.
In a third aspect, there is provided a data conversion apparatus having a function of realizing the data conversion method behavior in the first or second aspect described above. The data transformation device comprises at least one module for implementing the data transformation method provided in the first aspect or the second aspect.
In a fourth aspect, there is provided a data conversion apparatus comprising in its structure a processor and a memory for storing a program supporting the data conversion apparatus to perform the data conversion method provided in the first or second aspect described above, and for storing data involved in implementing the data conversion method provided in the first or second aspect described above. The processor is configured to execute a program stored in the memory.
In a fifth aspect, there is provided a computer readable storage medium having instructions stored therein which, when run on a computer, cause the computer to perform the data transformation method of the first or second aspect described above.
In a sixth aspect, there is provided a computer program product comprising instructions which, when run on a computer, cause the computer to perform the data transformation method of the first or second aspect described above.
The technical effects obtained by the third aspect, the fourth aspect, the fifth aspect and the sixth aspect are similar to the technical effects obtained by the corresponding technical means in the first aspect or the second aspect, and are not described in detail herein.
The beneficial effects that technical scheme that this application embodiment provided include at least:
in this embodiment of the present application, the first transformation matrix is obtained by transforming the original transformation matrix according to symmetry of the rotation factor in the NTT, so that some matrix elements in M matrix elements of the first transformation matrix have symmetry, so that by obtaining the data processing results corresponding to some matrix elements in the first transformation matrix, the data processing results corresponding to other matrix elements can be recovered, and further, each output data is obtained. That is, in the embodiment of the application, all transformation information can be represented only by acquiring the data processing results corresponding to part of matrix elements, so that the complexity of data transformation is reduced, and the transformation speed is increased. Or in the embodiment of the application, the automatic remainder of the data processing result is realized by circularly carrying out carry on the data processing result corresponding to each row of matrix elements in the number theory transformation matrix according to the sequence from small to large of the corresponding matrix elements, so that a large amount of remainder calculation based on reference transformation parameters in the transformation process is omitted, the transformation complexity is reduced, the resource consumption is reduced, and the transformation speed is improved.
Drawings
FIG. 1 is a schematic diagram of a computing device provided in an embodiment of the present application;
FIG. 2 is a flow chart of a data transformation method provided in an embodiment of the present application;
fig. 3 is a schematic diagram of symmetry of matrix elements in a first transformation matrix according to an embodiment of the present application;
FIG. 4 is a flow chart of another method of data transformation provided by an embodiment of the present application;
FIG. 5 is a schematic diagram of a plurality of registers connected in series to implement auto-loop carry according to an embodiment of the present application;
fig. 6 is a schematic structural diagram of a data conversion device according to an embodiment of the present application;
fig. 7 is a schematic structural diagram of another data conversion device according to an embodiment of the present application.
Detailed Description
For the purposes of making the objects, technical solutions and advantages of the embodiments of the present application more apparent, the embodiments of the present application will be described in further detail below with reference to the accompanying drawings.
Before explaining the embodiment of the present application in detail, an application scenario related to the embodiment of the present application is first described.
Currently, in the communication field, the artificial intelligence (artificial intelligence, AI) field, and the image processing field, during the process of processing data, the data is often transformed into the transform domain through NTT for processing, so as to reduce the computational complexity. For example, in the filtering process of a digital signal, the core processing is to circularly convolve an input signal with taps of a filter in the time domain, so as to obtain an output signal. Because the cyclic convolution process is complex, the input signal can be firstly transformed into the transform domain in a number theory transformation mode to obtain an output signal in the transform domain, the output signal in the transform domain and the corresponding filter coefficient in the transform domain are subjected to dot product, and then the signal obtained by the dot product is subjected to inverse transformation to obtain a final output signal. Similarly, in the AI field and the image processing field, various convolution operations on input data are often involved, in this case, in order to reduce the complexity of the operations, the data may be transformed into the transform domain by adopting the NTT method to perform processing, and then the final output data is obtained through inverse transformation. The data transformation method provided by the embodiment of the application can be applied to various scenes to perform NTT on the data.
Fig. 1 is a schematic structural diagram of a computing device according to an embodiment of the present application. The computing device may be used to perform the data transformation methods described below. For example, the computing device may be a filter for filtering digital signals, or a computer device for image processing or running AI algorithms. As shown in fig. 1, the computing device includes one or more processors 101, a communication bus 102, a memory 103, and one or more communication interfaces 104.
The processor 101 may be a general purpose central processing unit (central processing unit, CPU), network processor (network processor, NP), microprocessor, or may be one or more integrated circuits for implementing aspects of the present application, such as application-specific integrated circuits (ASIC), programmable logic devices (programmable logic device, PLD), or a combination thereof. The PLD may be a complex programmable logic device (complex programmable logic device, CPLD), a field-programmable gate array (field-programmable gate array, FPGA), general-purpose array logic (generic array logic, GAL), or any combination thereof. Alternatively, in some possible implementations, the processor 101 includes a plurality of registers, and the plurality of registers may be concatenated in order of index from small to large.
Communication bus 102 is used to transfer information between the above-described components. The communication bus 102 may be classified as an address bus, a data bus, a control bus, or the like. For ease of illustration, the figures are shown with only one bold line, but not with only one bus or one type of bus.
The memory 103 may be, but is not limited to, a read-only memory (ROM), a random-access memory (random access memory, RAM), an electrically erasable programmable read-only memory (electrically erasable programmable read-only memory, EEPROM), an optical disk (including a compact disk, a laser disk, a digital versatile disk, 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 and capable of being accessed by a computer. The memory 103 may be stand-alone and may be coupled to the processor 101 via the communication bus 102. Memory 103 may also be integrated with processor 101.
The communication interface 104 uses any transceiver-like device for communicating with other devices or communication networks. The 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 (wireless local area networks, WLAN) interface, a cellular network communication interface, a combination thereof, or the like.
In some embodiments, the computing device may include multiple processors, such as processor 101 and processor 105 shown in fig. 2. Each of these processors may be a single-core processor or a multi-core processor. A processor herein may refer to one or more devices, circuits, and/or processing cores for processing data (e.g., computer program instructions).
In a particular implementation, the computing device may also include an output device 106 and an input device 107, as one embodiment. The output device 106 communicates with the processor 101 and may display information in a variety of ways. For example, the output device 106 may be a liquid crystal display (liquid crystal display, LCD), a light emitting diode (light emitting diode, LED) display device, a Cathode Ray Tube (CRT) display device, or a projector (projector), or the like. The input device 107 communicates with the processor 101 and may receive user input in a variety of ways. For example, the input device 107 may be a mouse, a keyboard, a touch screen device, a sensing device, or the like.
In some embodiments, the memory 103 is used to store program code 108 that executes aspects of the present application, and the processor 101 may execute the program code 108 stored in the memory 103. One or more software modules may be included in the program code that may be executed by the computing device to implement the data transformation methods illustrated in figures 2 or 4 below via the processor 101 and the program code 108 in the memory 103.
Before explaining the data transformation method provided in the embodiment of the present application in detail, the principle of NTT will be described first.
The transformation formula of NTT is shown in the following formula (1):
Figure BDA0003377853800000051
wherein X (k) is kth output data; mod F () Representing a remainder operation in which F is a dividend, F being a reference transformation parameter in a digital-to-analogue transformation, F being a fermat number when the digital-to-analogue transformation is a fermat number-to-analogue transformation; x (n) is the nth input data of the plurality of input data, that is, the index of the input data is n; n is the number of input data; alpha nk Is a twiddle factor, where α is the base of the twiddle factor, and the common value is 2 or the power of 2.
As can be obtained from the above formula (1), the multiplication operation between the input data and the twiddle factor can be expressed as a multiplication operation of a transformation matrix with N input data, as shown in the following formula (2):
Figure BDA0003377853800000052
the transformation matrix is an original transformation matrix of the NTT, each element in the original transformation matrix is a twiddle factor, and the exponent of each element is equal to the remainder obtained by dividing the product of the number of rows and the number of columns where the element is located by N.
It can be seen that when α takes a value of 2 or a power of 2, the multiplication operation between the input data and the twiddle factor in the above formula can be simplified to an operation of shifting the corresponding x (n) according to the power exponent of the twiddle factor. However, as can be seen from the above formula (1), the remainder operation is performed after the corresponding input data is shifted according to each twiddle factor. Since the dividend is F, the range of the value of the data obtained by taking the remainder is [0,F ]. In this case, in order to ensure that the hardware can continue to operate on the data after the remainder, 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 bit width lock of hardware is caused by the remainder operation existing in the conversion process, and since the bit width of hardware is locked to the bit width of the dividend, even if the input data is small, the remainder data needs to be represented as the data of the bit width of the dividend, which results in a larger resource consumption in the subsequent data processing process. In addition, in the transformation process, each input data is shifted according to each rotation factor in the transformation matrix, and then is subjected to remainder taking, and then the remainder taking is accumulated, so that the complexity of operation is high.
Based on this, the embodiment of the application provides a data transformation method, which can utilize symmetry of rotation factors in NTT to transform an original transformation matrix to obtain a first transformation matrix with symmetrical partial matrix elements, and further obtain all transformation information by determining data processing results corresponding to the partial matrix elements in the first transformation matrix, so as to reduce operation complexity and accelerate transformation speed. Wherein, the data transformation method can be applied to the computing device shown in fig. 1, referring to fig. 2, the data transformation method comprises the following steps:
step 201: and acquiring a first transformation matrix, wherein the first transformation matrix is obtained by converting an original transformation matrix based on symmetry of rotation factors in NTT, the first transformation matrix comprises M matrix elements, and part of the M matrix elements have symmetry.
In the embodiment of the application, the computing device first acquires the original transformation matrix, and then converts the original transformation matrix based on symmetry of the twiddle factors, so as to obtain a first transformation matrix.
Illustratively, the computing device generates an original transformation matrix comprising N x N original matrix elements from the number N of input data. Wherein each original matrix element in the original transformation matrix is a twiddle factor, and the power exponent of each original matrix element is equal to the remainder of the product of the number of rows in which the corresponding original matrix element is located and the number of columns in which the corresponding original matrix element is located divided by N. In the embodiment of the present application, the number of rows of the row of the original matrix element refers to the index value of the row of the original matrix element, and the number of columns refers to the index value of the column of the original matrix element. And the range of the index values of the rows and the index values of the columns in the original transformation matrix is [0, N-1]. Hereinafter, for a row having an index value of n, referred to as an nth row, a column having an index value of n is referred to as an nth column.
For example, when there are 8 input data, then the computing deviceAn original transformation matrix of 8 x 8 is generated. Wherein, for each original matrix element of the 0 th row, since the product of the number of rows and columns of each original matrix element is 0 and the remainder obtained by dividing 0 by 8 is 0, each original matrix element of the 0 th row is a twiddle factor with a power exponent of 0, namely alpha 0 . Similarly, each original matrix element in column 0 is alpha 0 . For another example, for the original matrix elements of row 2 and column 6, since the product of the number of rows and the number of columns is 12 and the remainder of division of 12 by 8 is 4, the original matrix elements of row 2 and column 6 are twiddle factors with a power exponent equal to 4, i.e., α 4 . Based on this, when the input data is 8, the generated 8×8 original transformation matrix a is represented by the following formula (3):
Figure BDA0003377853800000061
after obtaining the original transformation matrix, the computing device may process the original transformation matrix to obtain a first transformation matrix based on the symmetric rotation factor of each original matrix element in the original transformation matrix.
Illustratively, the computing device determines a symmetric rotation factor for each original matrix element in the original transformation matrix according to symmetry between rotation factors in the NTT, and further replaces a portion of the original matrix elements in odd rows in the original transformation matrix with the corresponding symmetric rotation factors, thereby obtaining the second transformation matrix. And then, determining and obtaining a first transformation matrix according to the power exponent of each matrix element in the second transformation matrix.
Wherein symmetry of the rotation factor in NTT can be expressed by the following formula (4):
Figure BDA0003377853800000062
where k=0, 1,2, … N/2-1. Based on equation (4) above, the computing device can determine a symmetric rotation factor for each original matrix element in the original transformation matrix.
Taking the case where N is 8 as an exampleIt is clear that from the above formula (4), alpha can be obtained 4 =-α 0 ,α 5 =-α 1 ,α 6 =-α 2 ,α 7 =-α 3 . Based on this, α in the odd-numbered row in the above formula (3) 4 、α 5 、α 6 And alpha 7 The second transformation matrix B can be obtained by replacing the corresponding symmetric rotation factor, as shown in the following formula (5):
Figure BDA0003377853800000071
after deriving the second transformation matrix, the computing device replaces a positive element in the second transformation matrix with a power exponent of the element, and a negative element with a negative power exponent of the element. Thus, the first transformation matrix C obtained from the second transformation matrix of the expression (5) is represented by the following expression (6):
Figure BDA0003377853800000072
as is clear from the first transformation matrix obtained as described above, the first transformation matrix has a certain symmetrical relationship between the matrix elements of the remaining rows and columns, except for the 0 th row, the N/2 th row, and the 0 th column, without considering the signs of the matrix elements. For example, in the first transformation matrix shown in the above formula (6), the symmetrical relation between the 1 st to 3 rd columns of the 1 st row and the 1 st to 3 rd columns of the 7 th row, and the symmetrical relation between the 5 th to 7 th columns of the 1 st row and the 5 th to 7 th columns of the 7 th row are as shown in fig. 3, and similarly, the similar symmetrical relation is also present between the 2 nd row and the 6 th row, and similarly, the similar symmetrical relation is also present between any two odd rows. In addition, the first transformation matrix has a symmetrical relationship between the 0 th column to the 3 rd column and the 4 th column to the 7 th column of each row.
Alternatively, in some possible implementations, the computing device may have pre-stored therein a first transformation matrix corresponding to the amount of different input data, e.g., a first transformation matrix corresponding to when t=4, 8,16, in this case, the computing device may directly obtain the first transformation matrix corresponding to N from the mapping relationship between the stored number of input data and the first transformation matrix according to the number of input data N. Wherein the stored respective first transformation matrices may be obtained in advance by the method described above.
Step 202: and acquiring data processing results corresponding to M matrix elements in the first transformation matrix according to the first transformation matrix and the plurality of input data, wherein M is smaller than M.
From the above description, it is clear that, in the first transformation matrix, there is a symmetrical relationship between the remaining even rows except for the 0 th row and the N/2 th row, and there is a symmetrical relationship between the odd rows. Based on this, after the first transformation matrix is obtained, the computing device may select, according to the symmetrical relationship between the rows of the first transformation matrix, from M matrix elements included in the first transformation matrix, a part of matrix elements, that is, M matrix elements, whose corresponding processing results can include all transformation information, so as to obtain data processing results corresponding to the M matrix elements to characterize the transformation results. The fact that the data processing results corresponding to the m matrix elements can include all the transformation information means that the data processing results corresponding to the m matrix elements can be recovered from the data processing results corresponding to the remaining matrix elements.
Illustratively, the computing device selects an ith row and a jth row from the first transformation matrix, where i is any odd number and j is any even number other than 0 and N/2; and adding or subtracting the input data corresponding to the matrix elements with the same absolute value in each selected row to obtain a data processing result corresponding to the corresponding matrix element in the corresponding row, wherein the input data corresponding to each matrix element refers to the data with the index of the column number of the column in which the corresponding matrix element is positioned. At this time, because symmetry exists between the odd lines and symmetry exists between the even lines, the data processing results corresponding to the matrix elements of other odd lines can be restored according to the ith line, and the data processing results corresponding to the matrix elements of other even lines can be restored according to the jth line, so that the data processing results corresponding to the matrix elements in the ith line and the jth line comprise all transformation information.
With any selected row example, the computing device first determines the matrix elements with the same absolute value from the row, and for at least two matrix elements with the same absolute value, if the signs of the at least two matrix elements are positive, that is, the values of the at least two matrix elements are equal, at this time, the input data corresponding to the at least two matrix elements are added as the data processing results corresponding to the at least two matrix elements. And if the matrix elements with negative signs exist in the at least two matrix elements, inverting the input data corresponding to the matrix elements with negative signs, and adding the inverted input data and the input data corresponding to other matrix elements with positive signs to obtain the data processing results corresponding to the at least two matrix elements.
For example, taking the first transformation matrix shown in the above formula (6) as an example, assuming that one odd row is selected as row 1 and one even row is selected as row 2, in row 1, the 0 th element is 0 and the 4 th element is-0, that is, the two elements are two elements with the same absolute value. The input data corresponding to the 0 th element is x (0), the input data corresponding to the 4 th element is x (4), and the sign of the 4 th element is negative, so that the corresponding input data is inverted to obtain-x (4), and the data processing results corresponding to the two elements are x (0) -x (4). In this case, the data processing result may be directly used as a processing result corresponding to a matrix element having a positive sign. The data processing results corresponding to the matrix elements with the absolute value of 1 are x (1) -x (5), the data processing results corresponding to the matrix elements with the absolute value of 2 are x (2) -x (6), and the data processing results corresponding to the matrix elements with the absolute value of 3 are x (3) -x (7) which can be obtained through the same method. In row 2, the data processing result corresponding to the matrix element with the absolute value of 0 is x (0) +x (4), the data processing result corresponding to the matrix element with the absolute value of 2 is x (1) +x (5), the data processing result corresponding to the matrix element with the absolute value of 4 is x (2) +x (6), and the data processing result corresponding to the matrix element with the absolute value of 6 is x (3) +x (7).
On the basis of the symmetrical relation between the 1 st row and the 7 th row, in the 1 st row, each element with the absolute value of 1 is replaced with an element with the opposite sign and the absolute value of 3, each element with the absolute value of 2 is inverted, and each element with the absolute value of 3 is replaced with an element with the opposite sign and the absolute value of 1, so that the 7 th row is obtained. Based on the above, the data processing result corresponding to the matrix element with the absolute value of 1 in the 1 st row is the data processing result corresponding to the matrix element with the absolute value of 3 in the 7 th row, the data processing result corresponding to the matrix element with the absolute value of 2 in the 1 st row is the data processing result corresponding to the matrix element with the absolute value of 2 in the 7 th row, and the data processing result with the absolute value of 3 in the 1 st row is the data processing result with the absolute value of 3 in the 7 th row. In the 1 st row and the 7 th row, the columns of the matrix elements 0 and-0 are identical, so that the data processing result of the matrix element with the absolute value of 0 in the 1 st row is the data processing result of the matrix element with the absolute value of 0 in the 7 th row.
In addition, according to the symmetrical relation between the 2 nd and 6 th rows, in the 2 nd row, the matrix element with the value of 2 is replaced by the matrix element with the value of 6, and the matrix element with the value of 6 is replaced by the matrix element with the value of 2, so that the 6 th row can be obtained. Based on the above, the data processing results corresponding to the matrix elements with the median value of 2 in the 1 st row and the data processing results corresponding to the matrix elements with the value of 6 are interchanged, so that the data processing results corresponding to the matrix elements with the median value of 2 and the value of 6 in the 6 th row are obtained, and similarly, the columns where the matrix elements with the median value of 0 and the value of 4 in the 2 nd row and the 6 th row are located are identical, so that the data processing results corresponding to the matrix elements with the median value of 0 and the 4 in the 6 th row are identical to those in the 2 nd row.
For the 0 th row in the first transformation matrix, no matter the value of N, the matrix element of the 0 th row is 0, so the data processing result corresponding to the matrix element of the 0 th row is equal to the sum of all input data.
For the N/2 th row, namely the 4 th row, in the first transformation matrix, the matrix element with the value of 4 in the 2 nd row is replaced by the matrix element with the value of 0, and the matrix elements with the values of 2 and 6 in the 2 nd row are replaced by the matrix element with the value of 4, so that the 4 th row can be obtained. Therefore, the data processing result corresponding to the matrix element with the median value of 4 in the 2 nd row and the matrix element with the value of 0 is added to obtain the data processing result corresponding to the matrix element with the median value of 0 in the 4 th row, and the data processing result corresponding to the matrix elements with the median values of 2 and 6 in the 2 nd row is added to obtain the data processing result of the matrix element with the median value of 4 in the 4 th row.
In summary, the data processing results of the matrix elements in all other rows can be recovered by the data processing results corresponding to the matrix elements in the 1 st row and the 2 nd row in the first transformation matrix shown in the formula (6), that is, the data processing results corresponding to the matrix elements in the 1 st row and the 2 nd row contain all transformation information. The above description is given by taking the 1 st row and the 2 nd row in the first transformation matrix as examples, and when other odd rows and even rows are selected, for example, the 2 nd row and the 7 th row, or the 6 th row and the 7 th row, or the 3 rd row and the 2 nd row, etc., the information of other rows can be recovered based on the same principle. Thus, by acquiring the data processing results corresponding to the matrix elements of the odd-numbered rows and the even-numbered rows in the first transformation matrix, the entire transformation information can be obtained.
Alternatively, in one possible implementation manner, the matrix elements with the same absolute value in each row of the first transformation matrix may correspond to one 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), element 1 and element-1 correspond to a register, and the index of the register is 1. On the basis, the data processing results corresponding to the matrix elements with the same absolute value can be stored in the corresponding registers. In this way, after the data processing results corresponding to the matrix elements in a certain odd-numbered row or even-numbered row are stored in the corresponding registers, when other rows are restored, the data stored in the registers with different indexes can be directly exchanged or added after being inverted according to the symmetrical relation of the matrix elements between the rows, so that the data processing results corresponding to the matrix elements with the same indexes as the corresponding registers in other rows are obtained.
Step 203: and taking the data processing results corresponding to m matrix elements in the first transformation matrix as transformation results.
Based on the description in step 202, the obtained 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 an odd row and an even row in the first transformation matrix. The m matrix elements contain all the transformation information. Therefore, the computing device can directly take the data processing results corresponding to the m matrix elements as the final transformation results.
For example, for the first transformation matrix shown in fig. 6 described above, the final transformation results obtained may be as shown in table 1 below:
table 1 conversion results table
Matrix element 0 1 2 3 4 6
Line 1 x(0)-x(4) x(1)-x(5) x(2)-x(6) x(3)-x(7)
Line 2 x(0)+x(4) x(1)+x(5) x(2)+x(6) x(3)+x(7)
In the embodiment of the present application, the rotation factors included in the original transformation matrix are converted based on symmetry between the rotation factors in the NTT, so as to obtain a first transformation matrix with symmetric relations between matrix elements between rows and between columns. On the basis, the computing equipment can obtain all the transformation information only by acquiring the data processing results corresponding to part of matrix elements in the first transformation matrix, and the data processing results corresponding to all the matrix elements are not required to be acquired, so that the transformation speed is increased, and the transformation efficiency is improved.
In addition, in the embodiment of the application, the data processing result can be obtained by adding and subtracting the input data corresponding to the matrix elements with the same absolute value, and then the input data is used as the final conversion result, so that various operations such as multiplication, remainder and the like are not needed in the whole process, and the conversion complexity is reduced. In addition, in the embodiment of the application, since the remainder operation is not involved in the whole transformation process, the bit width locking of hardware does not exist, namely, the bit width is unlocked. In addition, since the remainder operation is not performed, the bit interception from the low order to the high order can be performed on the conversion result during the subsequent signal processing, so that the data bit width can be flexibly set, and the consumption of calculation resources can be reduced.
The above mainly describes a process of performing a forward conversion on input data when the input data is untransformed data. Alternatively, when the input data is data processed in the transform domain after the forward transform, an inverse transform matrix of the forward transform matrix may be obtained according to the orthogonal uniqueness between the forward transforms when the inverse transform is performed. Then, the method described in the above embodiment may be referred to, where the inverse transformation matrix is used as a first transformation matrix to obtain data processing results corresponding to m matrix elements, and then the obtained data processing results are divided by N to obtain the inverse transformation result.
Alternatively, in some possible implementations, when the number of input data is N, a split-base algorithm may be further used to arrange the input data into a matrix, and then, each line of input data in the input data matrix is transformed by the method described in the foregoing embodiments, so as to obtain a transformation result.
For example, when the number of input data is N, the input data is divided into two rows each including N/2 input data, in which case each row of input data may be transformed according to a first transformation matrix corresponding to N/2, thereby obtaining a transformation result for each row.
Still taking N as 8 as an example, 8 input data are arranged into a matrix D of 2×4, as shown in the following formula (7):
Figure BDA0003377853800000101
then, for the 4 input data of each row in the matrix D, the indexes of the 4 input data are sequentially set to 0, 1, 2 and 3 from small to large, and then the 4 data of each row can be transformed according to the first transformation matrix of 4*4 by the method described in the above embodiment, so as to obtain a transformation result of each row. The process of transforming 4 input data according to the transformation matrix of 4*4 may also be referred to as 4-point transformation. It follows that in this implementation, splitting 8 input data into two separate transforms actually splits the 8-point transform into two 4-point transforms.
Illustratively, taking the first row of input data in the matrix D as an example, let h (0) =x (0), h (1) =x (2), h (2) =x (4), h (3) =x (6), the first transformation matrix E of 4*4 is shown in the following formula (8):
Figure BDA0003377853800000102
notably, since the even rows of the first transformation matrix of 4*4 are row 0 and row 2, and row 2 is exactly row N/2, when an odd row and an even row are selected, row 2 is selected for the even row, and row 1 or row 3 can be selected for the odd row. Based on this, the transformation result corresponding to the first line of input data obtained by the computing device may be as shown in table 2 or 3.
Table 2 conversion result table
Matrix element 0 1 2
Line 1 x(0)-x(2) x(1)-x(3)
Line 2 x(0)+x(2) x(1)+x(3)
Table 3 conversion result table
Matrix element 0 1 2
Line 2 x(0)+x(2) x(1)+x(3)
Line 3 x(0)-x(2) x(3)-x(1)
It can be seen that after the 4 input data of each row are transformed, the transformation result corresponding to each row of input data will be the data processing result corresponding to the matrix elements of the 1 st row and the 2 nd 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 2 nd row and the 3 rd row.
The foregoing is merely illustrative with N being 8, and is not to be construed as limiting the embodiments of the present application. For example, when N is 16, the input data may be arranged as a matrix of 2*8 or 4*4, and the input data of each row may be correspondingly transformed according to the first transformation matrix of 8×8 or 4*4, which is not described herein in detail.
In addition, the embodiment of the application also provides another data transformation method aiming at the problems of high bit width locking and operation complexity caused by residual operation in the current NTT. The method is equally applicable to the computing device shown in fig. 1, as shown in fig. 4, and comprises the steps of:
step 401: a number theory transformation matrix is obtained.
The number-theory transformation matrix is the first transformation matrix obtained based on the original transformation matrix in the step 201, or the number-theory transformation matrix is the third transformation matrix obtained by replacing each matrix element in the original transformation matrix with the power exponent of the corresponding matrix element. The implementation manner of the computing device to obtain the number-theory transformation matrix may refer to the related implementation manner of step 201, which is not described in detail in the embodiment of the present application.
Step 402: and determining a data processing result corresponding to the matrix elements in each row of the number-theory transformation matrix according to the number-theory transformation matrix and the plurality of input data.
When the number-base transformation matrix is the first transformation matrix in step 201, in this step, the computing device may refer to the method of determining the data processing result corresponding to the selected matrix element in each row in step 202 to determine the data processing result corresponding to each row of matrix elements in the number-base transformation matrix.
For example, taking the first transformation matrix shown in the above formula (6) as an example, the data processing results corresponding to the matrix elements in each row obtained from 8 pieces of input data and the 8×8 first transformation matrix are shown in table 4.
Table 4 data processing result table corresponding to matrix elements in each row of the first transformation matrix
Figure BDA0003377853800000111
/>
Figure BDA0003377853800000121
Optionally, when the number theory transformation matrix is the third transformation matrix obtained according to the original transformation matrix, in this step, for each row of matrix elements in the third transformation matrix, if the same matrix element exists in the row, input data corresponding to the same matrix element is added as a data processing result corresponding to the corresponding matrix element, and for other matrix elements not existing the same matrix element, input data corresponding to the matrix element is directly used as a data processing result corresponding to the matrix element.
For example, taking the original transformation matrix shown in the foregoing formula (3) as an example, each element in the original transformation matrix is replaced by a power exponent of a corresponding element, and the third transformation matrix G is obtained as shown in the following formula (9):
Figure BDA0003377853800000122
the data processing results corresponding to the respective matrix elements obtained based on the third transformation matrix and 8 pieces of input data are shown in table 5 below.
Table 5 data processing results for each element in the third transformation matrix
Figure BDA0003377853800000123
Step 403: and carrying out cyclic carry on the data processing results corresponding to the matrix elements in each row of the number theory transformation matrix according to the sequence from the smaller matrix elements to the larger matrix elements, and obtaining updated data processing results of each row.
After the data processing results corresponding to the matrix elements in each row of the number theory transformation matrix are obtained, the computing equipment carries out cyclic carry on the data processing results corresponding to the matrix elements in each row of the number theory transformation matrix according to the sequence from the smaller to the larger of the corresponding matrix elements, so that automatic remainder taking is realized, and the updated data processing results of each row are obtained.
Illustratively, in one possible implementation, each row of matrix elements of the number theory transformation matrix corresponds to N registers, and the N registers are serially connected in order of the index of the registers from small to large. For any row in the number theory transformation matrix, for example, the ith row, the computing device may fill the data processing result corresponding to each matrix element in the ith row into the register indexed as the corresponding matrix element, so as to implement cyclic carry.
It should be noted that, in the embodiment of the present application, the jth register refers to a register with an index of j, when the N registers are connected in series, the highest bit of the jth register is connected with the lowest bit of the jth+1th register, and the highest bit of the last register is connected with the lowest bit of the 0 th register. Also, in the embodiment of the present application, 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 a reference transformation parameter in the number theory transformation, and the reference transformation parameter may be a fermat number, for example, when the reference transformation parameter is a dividend in the remainder operation in the number theory transformation.
Based on this, with the ith row example, the computing device sequentially fills the data processing results corresponding to each element in the ith row into the registers corresponding to the corresponding elements according to the order from small to large of each element in the ith row and the set bit width of the registers, where each register corresponding to each element refers to a register with an index equal to that of the corresponding element.
The computing device firstly sorts all matrix elements in an ith row from small to large, then obtains a data processing result corresponding to a first matrix element after sorting, intercepts bit data with a set bit width from the lowest bit of the data processing result corresponding to the first matrix element and fills the bit data with the set bit width into a register corresponding to the matrix element if the bit width of the data processing result corresponding to the first matrix element is larger than the set bit width of the register, and then carries the rest bit data into a next register connected with the register. The next register of the register refers to a register with the lowest bit connected with the highest bit of the register. If the bit width of the data processing result corresponding to the first matrix element is not larger than the set bit width of the register, the data processing result corresponding to the first matrix element is directly filled into the corresponding register.
And then, the computing equipment acquires a data processing result corresponding to the second matrix element, if the register corresponding to the second matrix element stores carry data of the last register, the data processing result corresponding to the second matrix element is added with the carry data stored in the second register, and then, the added data is filled into the register corresponding to the second matrix element. And filling the added data into the register corresponding to the second matrix element, and if the bit width of the added data is larger than the set bit width, carrying out the method to the next register of the register corresponding to the second matrix element. If the carry data of the previous register is not stored in the register corresponding to the second element, the method of filling the data processing result corresponding to the first element into the corresponding register can be referred to, and the data processing result corresponding to the second element can be filled into the register corresponding to the second element. And so on, the computing device can sequentially fill the data processing results of the matrix elements into the corresponding registers according to the setting bit width of the registers according to the order from small to large of the matrix elements of the ith row so as to realize automatic cyclic carry. After completing the automatic cyclic carry, the computing device may use the data stored in each register as the updated data processing result of the matrix element corresponding to the register.
The register with index j in the N registers is referred to as a register R (j), and the carry relation among the N registers in each row is as shown in fig. 5, that is, the registers carry sequentially according to the order of the register indexes from small to large, and if the bit width of the data to be stored in the last register R (N-1) exceeds the set bit width, the data is carried to R (0).
For example, let 8 registers R (0) to R (7) be provided, the set bit width of each register is 2 bits, and let the data processing result 11011 corresponding to the element 0 in the i-th row exceed the set bit width, at this time, the lower two bits of data, that is, 11, in the data processing result of the element 0 are filled into R (0), and the remaining 3 bits of data are carried into R (1). Assuming that matrix element 1 is not present in row i, however, since 110 still exceeds the set bit width of the register, the lower two bits of data 10 of 110 can be stuffed into R (1), and the upper 1 bit of data can be carried into R (2). Of course, if matrix element 1 exists in the i-th row, the computing device adds 3-bit data that needs to be carried into R (1) to the data processing result corresponding to matrix element 1, then fills the low 2-bit data in the added data into R (1), carries R (2) by the above method on the remaining bit data, and so on. If there is more data to carry to the next register until R (7), then carry to R (0).
As can be seen from the above description, for the ith row, the updated data processing result of the ith row may include the data processing result corresponding to the matrix element that does not exist in the ith row, for example, in the above example, although the matrix element 1 does not exist in the ith row, the updated data processing result of the ith row may include the data processing result corresponding to the matrix element 1 due to the carry data of the matrix element 0.
For each row in the number theory transformation matrix, the method can be referred to realize the cyclic carry of the data processing result of the matrix element of each row, so as to finish automatic remainder taking, and obtain the updated data processing result of each row.
Optionally, the foregoing description is given by taking the example that the computing device depends on its own register to implement the cyclic carry, and in other possible implementations, the computing device may also depend on other hardware or software methods to implement the cyclic carry of each row, and the principles of the cyclic carry are the same or similar no matter depending on hardware or software, which is not repeated in this embodiment of the present application.
Step 404: and acquiring output data corresponding to each row according to the updated data processing result of each row.
Still taking the ith row example, the computing equipment shifts the corresponding data processing results according to the twiddle factors corresponding to the matrix elements corresponding to the updated data processing results of the ith row; adding the shifted data processing results to obtain a first result; and taking the remainder of the first result based on the reference transformation parameters to obtain the ith output data corresponding to the ith row.
As can be seen from the description in step 403, the updated data processing result of the ith row may include the data processing result corresponding to the matrix element that the ith row does not originally have. Based on this, in this step, the computing device first determines the matrix element corresponding to each data processing result of the i-th row after updating. For example, the matrix element corresponding to each data processing result may be determined according to the index of the register storing each data processing result. That is, for any data processing result, if the index of the register storing the data processing result is j, the data processing result is the data processing result corresponding to the matrix element j. The computing device then obtains twiddle factors corresponding to each element, where twiddle factors corresponding to an element are twiddle factors with a power exponent equal to the element.
After the twiddle factors corresponding to the matrix elements are obtained, the computing equipment shifts the data processing results corresponding to the matrix elements according to the twiddle factors corresponding to the matrix elements.
Wherein the substrates of the twiddle factors corresponding to the matrix elements are the same. If the base is 2, the exponent of the twiddle factor is several, and the corresponding data processing result is shifted by several bits. Of course, if the base is not 2, but is to the power of 2, the product Q of P and the power exponent of the twiddle factor is calculated, after which the corresponding data processing result is shifted by Q bits.
For example, for element 1, the exponent of the twiddle factor is 1, and assuming that the data processing result corresponding to element 1 is 11 and the base of twiddle factor is 2 to the power of 2, the data processing result for element is shifted by two bits, and the shifted data processing result is 1100.
After the shifted data processing results are obtained, the shifted data processing results are added to obtain a first result. And then taking the reference transformation parameter as a divisor to remainder the first result, thereby obtaining output data corresponding to the ith row, namely the ith output data.
The updated data processing result of each row can be processed by referring to the method, so that output data corresponding to each row is obtained. At this time, the obtained N lines of output data are the conversion results.
In the embodiment of the application, the data processing result corresponding to each row of matrix elements in the number theory transformation matrix is obtained, and the automatic remainder of the data processing result is realized by carrying out cyclic carry on the data processing result according to the sequence from small to large of the corresponding matrix elements, so that a large amount of remainder calculation based on reference transformation parameters in the transformation process is omitted, the transformation complexity is reduced, the resource consumption is reduced, and the transformation speed is improved.
Alternatively, in some possible implementations, the embodiment shown in fig. 4 may also be combined with a split-base algorithm. That is, when the number of input data is N, the N input data may be arranged into a matrix by using a split-base algorithm, and then each line of input data in the input data matrix is transformed by the method described in the embodiment shown in fig. 4, respectively, to obtain an intermediate transformation result matrix composed of transformation results of each line of input data. And shifting part of the transformation results in the intermediate transformation result matrix according to the corresponding twiddle factors, and then transforming each column in the intermediate transformation result matrix again by the method so as to obtain a final transformation result.
For example, taking N equal to 8 as an example, 8 input data are arranged into a matrix D as shown in formula (7), then, two rows of input data are transformed by the method described in the embodiment of fig. 4, and four intermediate output data, that is, four intermediate transformation results, can be obtained after each row of input data is transformed, so that an intermediate transformation result matrix H of 2×4 can be obtained after two rows of input data of the matrix D are transformed, as shown in the following formula (10):
Figure BDA0003377853800000151
wherein, F (a, b) in the above formula refers to the b-th intermediate output data obtained by converting the a-th line input data.
As can be seen from the foregoing description, splitting 8 input data into two sets of transforms may also be referred to as splitting an 8-point transform into two 4-point transforms. The result obtained by performing 4-point transformation twice in the embodiment shown in fig. 4 is the intermediate transformation result matrix of the above formula (10). The computing device may then combine the results of the two 4-point transformations to obtain a final transformation result. When combining the results of the two 4-point transforms, the computing device multiplies each intermediate input data of the 2 nd row of the matrix H by a corresponding twiddle factor, that is, shifts, to obtain an updated H. Then, in the embodiment shown in fig. 4, two-point transformation is performed by using two input data of each column as a group of input data, so as to obtain a final transformation result.
Referring to fig. 6, an embodiment of the present application provides a data conversion apparatus 600, where the apparatus 600 includes: a first acquisition module 601, a second acquisition module 602, and a determination module 603;
a first obtaining module 601, configured to perform step 201 in the foregoing embodiment;
a second obtaining module 602, configured to perform step 202 in the foregoing embodiment;
a determining module 603, configured to perform step 203 in the foregoing embodiment.
Wherein the various modules in the apparatus 600 may be implemented by the processor of the computing device shown in fig. 1, described above.
Optionally, the first acquisition module 601 is mainly configured to:
obtaining an original transformation matrix, wherein the original transformation matrix comprises N x N original matrix elements, each original matrix element is a twiddle factor, the power exponent of each original matrix element is equal to the remainder of dividing the product of the number of rows of the corresponding original matrix element and the number of columns of the corresponding original matrix element by N, and the number of N and a plurality of input data are equal;
and processing the original transformation matrix according to the original transformation matrix and the symmetrical rotation factors of each original matrix element to obtain a first transformation matrix.
Optionally, the second acquisition module 602 is mainly configured to:
selecting an ith row and a jth row from the first transformation matrix, wherein i is any odd number, j is any even number except 0 and N/2, and the number of N and a plurality of input data is equal;
And adding or subtracting the input data corresponding to the matrix elements with the same absolute value in each selected row to obtain a data processing result corresponding to the corresponding matrix element in the corresponding row, wherein the input data corresponding to each matrix element refers to the data with the index of the column number of the column in which the corresponding matrix element is positioned.
In summary, in this embodiment of the present application, the first transformation matrix is obtained by transforming the original transformation matrix according to symmetry of the rotation factor in the NTT, so that some matrix elements in M matrix elements of the first transformation matrix have symmetry, so that by obtaining the data processing result corresponding to some matrix elements in the first transformation matrix, the data processing result corresponding to other matrix elements can be recovered, and further, each output data is obtained. That is, in the embodiment of the application, all transformation information can be represented only by acquiring the data processing results corresponding to part of matrix elements, so that the complexity of data transformation is reduced, and the transformation speed is increased.
Referring to fig. 7, another data conversion device 700 is provided in an embodiment of the present application, where the data conversion device 700 includes: a first acquisition module 701, a determination module 702, a cyclic carry module 703 and a second acquisition module 704.
A first obtaining module 701, configured to perform step 401 in the foregoing embodiment;
a determining module 702, configured to perform step 402 in the foregoing embodiment;
a carry-in-loop module 703 for performing step 403 in the foregoing embodiment;
a second obtaining module 704, configured to perform step 404 in the foregoing embodiment.
Alternatively, the determining module 702 is mainly configured to:
and adding or subtracting input data corresponding to the matrix elements with the same absolute value in the ith row of the number theory transformation matrix to obtain a data processing result corresponding to the corresponding matrix elements in the ith row, wherein the input data corresponding to each matrix element refers to data with the index of the column number of the column where the corresponding matrix element is located.
Optionally, each row of the number theory transformation matrix corresponds to N registers, where the N registers are serially connected in order from small to large according to indexes of the registers, and a most significant bit of a j register is connected to a least significant bit of a j+1th register, and the cyclic carry module 703 is mainly configured to:
according to the order from small to large of each matrix element in the ith row, according to the set bit width of the register, sequentially filling the data processing results corresponding to each matrix element into the register corresponding to the corresponding matrix element, wherein the register corresponding to each matrix element refers to a register with index equal to that of the corresponding matrix element.
Optionally, the second acquisition module 704 is mainly configured to:
shifting the corresponding data processing results according to the twiddle factors corresponding to the matrix elements corresponding to the updated data processing results of the ith row;
adding the shifted data processing results to obtain a first result;
and taking the remainder of the first result based on the reference transformation parameters to obtain the ith output data corresponding to the ith row.
In the embodiment of the application, the data processing result corresponding to each row of matrix elements in the number theory transformation matrix is obtained, and the automatic remainder of the data processing result is realized by carrying out cyclic carry on the data processing result according to the sequence from small to large of the corresponding matrix elements, so that a large amount of remainder calculation based on reference transformation parameters in the transformation process is omitted, the transformation complexity is reduced, the resource consumption is reduced, and the transformation speed is improved.
It should be noted that: in the data conversion device provided in the above embodiment, when converting input data, only the division of the above functional modules is used for illustration, in practical application, the above functional allocation may be performed by different functional modules according to needs, that is, the internal structure of the device is divided into different functional modules, so as to complete all or part of the functions described above. In addition, the data conversion device and the data conversion method provided in the foregoing embodiments belong to the same concept, and specific implementation processes thereof are detailed in the method embodiments and are not described herein again.
In the above embodiments, it may be implemented in whole or in part by software, hardware, firmware, or any combination thereof. When implemented in software, may be implemented in whole or in part in the form of 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, the processes or functions described in accordance with embodiments of the present application are produced in whole or in part. The computer may be a general purpose computer, a special purpose computer, a computer network, or other programmable apparatus. The computer instructions may be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another computer-readable storage medium, for example, the computer instructions may be transmitted from one website, computer, server, or data center to another website, computer, server, or data center by a wired (e.g., coaxial cable, fiber optic, data subscriber line (Digital Subscriber Line, DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer readable storage medium may be any available medium that can be accessed by a computer or a data storage device such as a server, data center, etc. that contains an integration of one or more available media. The usable medium may be a magnetic medium (e.g., floppy Disk, hard Disk, magnetic tape), an optical medium (e.g., digital versatile Disk (Digital Versatile Disc, DVD)), or a semiconductor medium (e.g., solid State Disk (SSD)), etc.
It will be understood by those skilled in the art that all or part of the steps for implementing the above embodiments may be implemented by hardware, or may be implemented by a program for instructing relevant hardware, where the program may be stored in a computer readable storage medium, and the storage medium may be a read-only memory, a magnetic disk or an optical disk, etc.
The foregoing description is not intended to limit the embodiments of the present application, and any modifications, equivalents, improvements, etc. that fall within the spirit and principles of the embodiments of the present application are intended to be included within the scope of the embodiments of the present application.

Claims (15)

1. A method of data transformation, the method comprising:
acquiring a first transformation matrix, wherein the first transformation matrix is obtained by converting an original transformation matrix based on symmetry of rotation factors in Number Theory Transformation (NTT), the first transformation matrix comprises M matrix elements, and part of the M matrix elements have symmetry;
according to the first transformation matrix and a plurality of input data, data processing results corresponding to M matrix elements in the first transformation matrix are obtained, wherein M is smaller than M;
and taking data processing results corresponding to m matrix elements in the first transformation matrix as transformation results.
2. The method of claim 1, wherein the obtaining a first transformation matrix comprises:
the original transformation matrix is obtained, the original transformation matrix comprises N original matrix elements, each original matrix element is a twiddle factor, the power exponent of each original matrix element is equal to the remainder of dividing the product of the number of rows of the row where the corresponding original matrix element is located and the number of columns where the corresponding original matrix element is located by N, and the number of N and the number of the plurality of input data are equal;
and processing the original transformation matrix according to the original transformation matrix and the symmetrical rotation factors of each original matrix element to obtain the first transformation matrix.
3. The method according to claim 1 or 2, wherein the obtaining, according to the first transformation matrix and the plurality of input data, data processing results corresponding to m matrix elements in the first transformation matrix includes:
selecting an ith row and a jth row from the first transformation matrix, wherein i is any odd number, j is any even number except 0 and N/2, and the number of the N and the plurality of input data is equal;
and adding or subtracting the input data corresponding to the matrix elements with the same absolute value in each selected row to obtain a data processing result corresponding to the corresponding matrix element in the corresponding row, wherein the input data corresponding to each matrix element refers to the data with the index of the column number of the column in which the corresponding matrix element is positioned.
4. A method of data transformation, the method comprising:
acquiring a number theory transformation matrix;
determining a data processing result corresponding to matrix elements in each row of the number-theory transformation matrix according to the number-theory transformation matrix and a plurality of input data;
carrying out cyclic carry on the data processing results corresponding to the matrix elements in each row of the number theory transformation matrix according to the sequence from the smaller matrix elements to the larger matrix elements, and obtaining updated data processing results of each row;
and acquiring output data corresponding to each row according to the updated data processing result of each row.
5. The method of claim 4, wherein determining the data processing results corresponding to the matrix elements in each row of the number-wise transformation matrix based on the number-wise transformation matrix and the plurality of input data comprises:
and adding or subtracting input data corresponding to the matrix elements with the same absolute value in the ith row of the number theory transformation matrix to obtain a data processing result corresponding to the corresponding matrix elements in the ith row, wherein the input data corresponding to each matrix element refers to data with the index of the column number of the column where the corresponding matrix element is located.
6. The method according to claim 5, wherein each row of the number theory transformation matrix corresponds to N registers, the N registers are connected in series in order of descending index of the registers, wherein the most significant bit of the jth register is connected with the least significant bit of the (j+1) th register, and the circularly carrying out the data processing results corresponding to the matrix elements in each row of the number theory transformation matrix in order of descending index of the corresponding matrix elements comprises:
According to the order from small to large of each matrix element in the ith row, according to the set bit width of the register, sequentially filling the data processing results corresponding to each matrix element into the register corresponding to the corresponding matrix element, wherein the register corresponding to each matrix element refers to a register with the index equal to that of the corresponding matrix element.
7. The method according to any one of claims 4-6, wherein the obtaining the output data corresponding to each row according to the updated data processing result of each row includes:
shifting the corresponding data processing results according to the twiddle factors corresponding to the matrix elements corresponding to the updated data processing results of the ith row;
adding the shifted data processing results to obtain a first result;
and taking the remainder of the first result based on the reference transformation parameters to obtain the ith output data corresponding to the ith row.
8. A data conversion device, the device comprising:
the first acquisition module is used for acquiring a first transformation matrix, the first transformation matrix is obtained by converting an original transformation matrix based on symmetry of rotation factors in the number theory transformation NTT, the first transformation matrix comprises M matrix elements, and part of the M matrix elements have symmetry;
The second acquisition module is used for acquiring data processing results corresponding to M matrix elements in the first transformation matrix according to the first transformation matrix and the plurality of input data, wherein M is smaller than M;
and the determining module is used for taking the data processing results corresponding to the m matrix elements in the first transformation matrix as transformation results.
9. The apparatus of claim 8, wherein the first acquisition module is configured to:
the original transformation matrix is obtained, the original transformation matrix comprises N original matrix elements, each original matrix element is a twiddle factor, the power exponent of each original matrix element is equal to the remainder of dividing the product of the number of rows of the row where the corresponding original matrix element is located and the number of columns where the corresponding original matrix element is located by N, and the number of N and the number of the plurality of input data are equal;
and processing the original transformation matrix according to the original transformation matrix and the symmetrical rotation factors of each original matrix element to obtain the first transformation matrix.
10. The apparatus according to claim 8 or 9, wherein the second acquisition module is mainly configured to:
selecting an ith row and a jth row from the first transformation matrix, wherein i is any odd number, j is any even number except 0 and N/2, and the number of the N and the plurality of input data is equal;
And adding or subtracting the input data corresponding to the matrix elements with the same absolute value in each selected row to obtain a data processing result corresponding to the corresponding matrix element in the corresponding row, wherein the input data corresponding to each matrix element refers to the data with the index of the column number of the column in which the corresponding matrix element is positioned.
11. A data conversion device, the device comprising:
the first acquisition module is used for acquiring the number theory transformation matrix;
the determining module is used for determining a data processing result corresponding to the matrix elements in each row of the number-theory transformation matrix according to the number-theory transformation matrix and the plurality of input data;
the cyclic carry module is used for carrying out cyclic carry on the data processing results corresponding to the matrix elements in each row of the number theory transformation matrix according to the sequence from the smaller matrix elements to the larger matrix elements, so as to obtain updated data processing results of each row;
and the second acquisition module is used for acquiring the output data corresponding to each row according to the updated data processing result of each row.
12. The apparatus of claim 11, wherein the determining module is configured to:
and adding or subtracting input data corresponding to the matrix elements with the same absolute value in the ith row of the number theory transformation matrix to obtain a data processing result corresponding to the corresponding matrix elements in the ith row, wherein the input data corresponding to each matrix element refers to data with the index of the column number of the column where the corresponding matrix element is located.
13. The apparatus of claim 12, wherein each row of the number theory transformation matrix corresponds to N registers, the N registers are serially connected in order of indexes of the registers from small to large, wherein a most significant bit of a j-th register is connected to a least significant bit of a j+1th register, and the circular carry module is mainly configured to:
according to the order from small to large of each matrix element in the ith row, according to the set bit width of the register, sequentially filling the data processing results corresponding to each matrix element into the register corresponding to the corresponding matrix element, wherein the register corresponding to each matrix element refers to a register with the index equal to that of the corresponding matrix element.
14. The apparatus according to any one of claims 11-13, wherein the second acquisition module is configured to:
shifting the corresponding data processing results according to the twiddle factors corresponding to the matrix elements corresponding to the updated data processing results of the ith row;
adding the shifted data processing results to obtain a first result;
and taking the remainder of the first result based on the reference transformation parameters to obtain the ith output data corresponding to the ith row.
15. A computer readable storage medium having instructions stored therein which, when executed on a computer, cause the computer to perform the data transformation method of any one of claims 1-3 or 4-7.
CN202111422020.4A 2021-11-26 2021-11-26 Data conversion method, device and storage medium Pending CN116186473A (en)

Priority Applications (2)

Application Number Priority Date Filing Date Title
CN202111422020.4A CN116186473A (en) 2021-11-26 2021-11-26 Data conversion method, device and storage medium
PCT/CN2022/134349 WO2023093849A1 (en) 2021-11-26 2022-11-25 Data transformation method and device and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111422020.4A CN116186473A (en) 2021-11-26 2021-11-26 Data conversion method, device and storage medium

Publications (1)

Publication Number Publication Date
CN116186473A true CN116186473A (en) 2023-05-30

Family

ID=86435014

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111422020.4A Pending CN116186473A (en) 2021-11-26 2021-11-26 Data conversion method, device and storage medium

Country Status (2)

Country Link
CN (1) CN116186473A (en)
WO (1) WO2023093849A1 (en)

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2010032763A1 (en) * 2008-09-16 2010-03-25 日本電気株式会社 Data numerical transformation processing method and receiver using data numerical transformation processing
FR3083885B1 (en) * 2018-07-10 2020-10-02 Commissariat Energie Atomique ROTATION FACTOR GENERATION CIRCUIT FOR NTT PROCESSOR
CN111221501B (en) * 2020-01-07 2021-11-26 常熟理工学院 Number theory conversion circuit for large number multiplication

Also Published As

Publication number Publication date
WO2023093849A1 (en) 2023-06-01

Similar Documents

Publication Publication Date Title
CN109063825B (en) Convolutional neural network accelerator
US7305507B2 (en) Multi-stage round robin arbitration system
Manz A sequency-ordered fast Walsh transform
KR100253987B1 (en) Fast hadamard transform method
US20210349692A1 (en) Multiplier and multiplication method
CN101847986B (en) Circuit and method for realizing FFT/IFFT conversion
JPH05113930A (en) Flexible n-way-memory interleaving method
US11860970B2 (en) Method, circuit, and SOC for performing matrix multiplication operation
CN112506880B (en) Data processing method and related equipment
CN111008691B (en) Convolutional neural network accelerator architecture with weight and activation value both binarized
CN112380004B (en) Memory management method, memory management device, computer readable storage medium and electronic equipment
CN116186473A (en) Data conversion method, device and storage medium
CN109379191B (en) Dot multiplication operation circuit and method based on elliptic curve base point
US11165615B2 (en) Data shifting operation apparatus and method having multiple operation modes
CN105930521A (en) Database management device and method
CN113988279A (en) Output current reading method and system of storage array supporting negative value excitation
CN111615700B (en) Arithmetic circuit
CN115658730B (en) Sparse data query method, apparatus, device and computer readable storage medium
CN113434811B (en) IP core of 2048-point FFT (fast Fourier transform) processor
CN109816110B (en) Scrypt algorithm workload proving method and Scrypt algorithm workload proving device
CN112269806B (en) Data query method, device, equipment and computer storage medium
CN116301712A (en) BCD code processing method, device, equipment and medium based on decimal multiplication
CN117215519A (en) Data processing method and device, electronic equipment and storage medium
CN117391207A (en) Method, device, electronic equipment and storage medium for determining quantum probability distribution
CN117251133A (en) Design method of subtractor-free rapid three-dividing circuit

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination