Method and device for storing or reading twiddle factors in target transformation

By storing the rotation factor in the processing circuit using a secondary storage method, the problem of high storage cost of rotation factor is solved, and the effect of reducing the processing circuit area and improving efficiency is achieved.

CN119719590AActive Publication Date: 2025-03-28ALIPAY (HANGZHOU) INFORMATION TECH CO LTD

Patent Information

Application Number
CN202411803443.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-09
Publication Date
2025-03-28
Estimated Expiration
2044-12-09

AI Technical Summary

Technical Problem

In the prior art, the rotation factor storage cost is high, which affects the area and efficiency of the processing circuit.

Method used

The rotation factor is stored using the secondary storage method, and the combination of the rotation factor memory and the index memory can effectively save storage costs.

Benefits of technology

The rotation factor storage cost in the processing circuit is reduced, the area of ​​the processing circuit is reduced, and the efficiency of the processing circuit is improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119719590A_ABST
    Figure CN119719590A_ABST
Patent Text Reader

Abstract

Embodiments of the present specification provide methods of storing or reading twiddle factors in a target transformation. The target transform is a discrete transform or an inverse transform thereof that transforms an input coefficient sequence into an output coefficient sequence based on a twiddle factor. The method comprises the following steps: determining a target twiddle factor to be stored, wherein the power of the target twiddle factor is a result of a product modular target value of a first factor of a first digit and a second factor of a second digit; the target twiddle factor is stored in a two-stage storage mode, and the two-stage storage mode comprises the steps that the target twiddle factor is stored at a first address in a twiddle factor storage device, and the twiddle factor storage device comprises a first number of first storage units, the first number is the number of different modular multiplication results generated by the factor of the first digit and the factor of the second digit; storing an index value directed to the first address at a second address in an index memory, where the index memory includes a target number of second memory cells, the second address corresponding to a power of the target twiddle factor; the target value is greater than the first number.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] One or more embodiments of the present specification relate to the optimization of hardware for accelerating polynomial multiplication, and more particularly to the optimization of storage of twiddle factors therein. Background Art

[0002] Fast Fourier Transform (FFT) and Fast Number Theoretic Transform (NTT) are the most critical steps to accelerate polynomial multiplication, and they have a wide range of application scenarios in the fields of communication and encryption. For example, FFT realizes the conversion between time domain and frequency domain in digital signal processing, and NTT and negative wrapping convolution (NWC) using NTT accelerate polynomial multiplication under finite fields in the design of fully homomorphic hardware acceleration chips.

[0003] Currently, many architectures have been proposed to implement FFT, NTT and their variants, which require pre-storage of rotation factors, which greatly affects the memory overhead.

[0004] Therefore, it is expected that there will be an improved solution to reduce the storage cost of the rotation factors. Summary of the invention

[0005] One or more embodiments of the present specification describe a solution for storing or reading rotation factors in a target transformation. The solution uses a secondary storage method to store the rotation factors, effectively saving the storage cost of the rotation factors in the processing circuit, thereby effectively reducing the area of ​​the processing circuit.

[0006] According to a first aspect, a method for storing a rotation factor in a target transform is provided, wherein the target transform is a discrete transform or an inverse transform thereof that transforms an input coefficient sequence into an output coefficient sequence based on the rotation factor; the method comprising:

[0007] Determine a target rotation factor to be stored, where the power of the target rotation factor is a result of multiplying a first factor of a first digit by a second factor of a second digit modulo a target value;

[0008] The target rotation factor is stored in a secondary storage manner, and the secondary storage manner includes:

[0009] Storing the target twiddle factor at a first address in a twiddle factor memory, wherein the twiddle factor memory includes a first number of first storage units, the first number being the number of different modular multiplication results generated by the factors of the first digit and the factors of the second digit;

[0010] An index value pointing to the first address is stored at a second address in an index memory, wherein the index memory includes the target value second storage units, the second address corresponds to a power of the target rotation factor; and the target value is greater than the first number.

[0011] In one embodiment, the bit width of the first storage unit is a first number of bits required for the target rotation factor; the bit width of the second storage unit is a second number of bits required for the index value, and a ratio of the second number of bits to the first number of bits is less than a preset value.

[0012] In one embodiment, the target rotation factor is a rotation factor used for performing inter-combination multiplication when an n-order target transformation is decomposed into a combination of two low-order transformations of (np) order and p order at a decomposition point p, wherein the first factor and the second factor are obtained by performing first and second linear transformations based on p-bit values ​​and (np)-bit values, respectively; and the target value is determined according to the target transformation type.

[0013] Further, in one example, the target transform is a fast Fourier transform FFT, the first and second linear transforms are both identity transforms, and the target value is 2 to the power of n-2.

[0014] Further, in one example, the target transformation is a fast number theoretic transformation NTT, the first and second linear transformations are both identity transformations, and the target value is 2 to the power of n-1.

[0015] Furthermore, in one example, the target transformation is the NTTP transformation obtained by fusing preprocessing with fast number theory transformation NTT in negative wrapping convolution NWC, the first linear transformation is an identity transformation, the second linear transformation defines the second factor as 2*(np) bit value + 1, and the target value is 2 to the power of n.

[0016] Furthermore, in one example, the target transformation is the INTTP transformation obtained by fusing the inverse fast number theory transform INTT with post-processing in the negative wrapping convolution NWC, the first linear transformation defines the first factor as 2*p-bit value + 1, the second linear transformation is an identity transformation, and the target value is 2 to the power of n.

[0017] Further, in one example, the target rotation factor is a rotation factor under a target decomposition method with minimum storage cost for the K-point input coefficient sequence to be processed; the target decomposition method is determined by the following steps:

[0018] Determine a plurality of candidate decomposition points in the k-bit coefficient index corresponding to the K-point input coefficient sequence, where K is 2 raised to the kth power;

[0019] Starting from the low-order decomposition point, for each candidate decomposition point in turn, according to the decomposition cost evaluation function, through recursive decomposition of several levels of index bits, the minimum storage cost under each candidate decomposition point is determined, thereby determining the target decomposition method with the minimum storage cost; wherein the decomposition cost evaluation function defines that for the n-order target transformation, the storage cost under the decomposition point p includes the storage cost of the (np)-order first transformation, the storage cost of the p-order second transformation, and the local storage cost of storing the inter-level rotation factors through the secondary storage method, wherein the first transformation and the second transformation are each the target transformation or its corresponding base transformation, and the local storage cost includes the storage cost of the rotation factor memory and the storage cost of the index memory.

[0020] Furthermore, in one example, the target transform is a fast Fourier transform FFT, the first transform and the second transform are both target transforms; and the storage cost of the first-order target transform is initialized to zero.

[0021] Furthermore, in one example, the target transformation is a fast number theoretic transformation NTT, the first transformation and the second transformation are both target transformations; and the storage cost of the first-order target transformation is initialized to zero.

[0022] Furthermore, in an example, the target transformation is the NTTP transformation obtained by fusing preprocessing with fast number theoretic transformation NTT in negative wrapping convolution NWC; the first transformation is the target transformation, and the second transformation is the NTT transformation; the storage cost of the first-order target transformation is initialized to 1.

[0023] Furthermore, in an example, the target transformation is the INTTP transformation obtained by fusing the inverse fast number theory transform INTT with post-processing in the negative wrapping convolution NWC; the first transformation is the INTT transformation, and the second transformation is the target transformation; the storage cost of the first-order target transformation is initialized to 1.

[0024] According to a second aspect, a method for reading a rotation factor in a target transform is provided, wherein the target transform is a discrete transform or an inverse transform thereof that transforms an input coefficient sequence into an output coefficient sequence based on the rotation factor; the method comprising:

[0025] Determine a target power of the rotation factor to be read, the target power being a result of multiplying a first factor of the first digit by a second factor of the second digit modulo a target value;

[0026] Determine a second address according to the target power; read the index value stored at the second address in the index memory; wherein the index memory has the target value of second storage units;

[0027] A first address is determined according to the index value, and the value of the rotation factor stored at the first address in the rotation factor memory is read; wherein the rotation factor memory includes a first number of first storage units, and the first number is the number of different modular multiplication results generated by the factor of the first digit and the factor of the second digit; and the first number is less than the target value.

[0028] According to a third aspect, a device for storing a rotation factor in a target transform is provided, wherein the target transform is a discrete transform or an inverse transform thereof that transforms an input coefficient sequence into an output coefficient sequence based on the rotation factor; the device comprises:

[0029] a determining unit configured to determine a target rotation factor to be stored, wherein the power of the target rotation factor is a result of multiplying a first factor of a first digit by a second factor of a second digit modulo a target value;

[0030] A storage unit is configured to store the target rotation factor in a secondary storage manner, wherein the secondary storage manner includes:

[0031] Storing the target twiddle factor at a first address in a twiddle factor memory, wherein the twiddle factor memory includes a first number of first storage units, the first number being the number of different modular multiplication results generated by the factors of the first digit and the factors of the second digit;

[0032] An index value pointing to the first address is stored at a second address in an index memory, wherein the index memory includes the target value second storage units, the second address corresponds to a power of the target rotation factor; and the target value is greater than the first number.

[0033] According to a fourth aspect, a device for reading a rotation factor in a target transform is provided, wherein the target transform is a discrete transform or an inverse transform thereof that transforms an input coefficient sequence into an output coefficient sequence based on the rotation factor; the device comprises:

[0034] a determining unit configured to determine a target power of a rotation factor to be read, wherein the target power is a result of multiplying a first factor of a first digit by a second factor of a second digit modulo a target value;

[0035] A first reading unit is configured to: determine a second address according to the target power; read an index value stored at the second address in an index memory; wherein the index memory has the target value of second storage units;

[0036] The second reading unit is configured to: determine the first address according to the index value, and read the value of the rotation factor stored at the first address in the rotation factor memory; wherein the rotation factor memory includes a first number of first storage units, and the first number is the number of different modular multiplication results generated by the factor of the first digit and the factor of the second digit; the first number is less than the target value.

[0037] According to a fifth aspect, a computing device is provided, including a memory and a processor, wherein the memory stores executable code, and when the processor executes the executable code, the method described in the first aspect or the second aspect is implemented.

[0038] In an embodiment of the present specification, a method and device for storing or reading rotation factors in a target transformation are proposed. In this method, by adopting a secondary storage method of a rotation factor memory plus an index memory to store the rotation factors, the storage waste of unnecessary rotation factors is avoided, thereby effectively saving the storage cost of the rotation factors in the processing circuit, and effectively reducing the area of ​​the processing circuit. Furthermore, in the methods of some embodiments, an evaluation function of the storage cost of the rotation factors of the target transformation under various decomposition methods is also defined. According to this function, a target decomposition method with the minimum total storage cost is found through recursive decomposition. Therefore, by combining the target decomposition method with the minimum storage cost with the secondary storage method, the storage cost of the rotation factors in the processing circuit is further effectively saved, thereby further effectively reducing the area of ​​the processing circuit. BRIEF DESCRIPTION OF THE DRAWINGS

[0039] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without paying creative work.

[0040] Figure 1a A schematic diagram showing a radix-2 CT butterfly operation;

[0041] Figure 1b A schematic diagram showing the FFT performed by radix-2 CT butterfly operation in the example of N=8 is shown;

[0042] Figure 2a A schematic diagram showing a general pipeline stage based on SDF;

[0043] Figure 2b A schematic diagram showing a pipeline architecture for implementing a 12th-order CT FFT according to one embodiment;

[0044] Figure 3aAn example of 2-dimensional decomposition of an n-th order FFT at a decomposition point p according to an embodiment is shown;

[0045] Figure 3b According to one embodiment, the corresponding Figure 3a Schematic diagram of storage cost of decomposition method;

[0046] Figure 3c According to one embodiment, Figure 3a A schematic diagram of storage cost obtained by further decomposing the example;

[0047] Figure 4a Algorithm 1 in pseudocode form is shown for searching for the minimum storage cost for k-th order FFT;

[0048] Figure 4b The operation algorithm of NWC described in pseudo code form is shown;

[0049] Figure 4c Algorithm 2 is shown for searching for the minimum storage cost for k-order NTT, NTTP and INTTP;

[0050] Figure 5a A schematic diagram showing a pipeline architecture for implementing a 12th order FFT according to one embodiment;

[0051] Figure 5b A schematic diagram showing a pipeline architecture for implementing a 12-stage NTT according to one embodiment;

[0052] Figure 6 A schematic diagram showing a twiddle factor memory using a one-level storage method according to an embodiment is shown;

[0053] Figure 7 A schematic diagram showing a memory using a secondary storage method to store rotation factors according to an embodiment;

[0054] Figure 8 A flow chart showing a method for storing rotation factors in a target transform according to one embodiment;

[0055] Fig. 9 A flow chart showing a method for executing a secondary storage mode according to an embodiment is shown;

[0056] Fig.10 A flow chart showing a method for determining a target decomposition method according to an embodiment;

[0057] Fig.11 A flow chart of a method for reading rotation factors in a target transform according to one embodiment is shown. DETAILED DESCRIPTION

[0058] The solution provided in this specification will be described below in conjunction with the accompanying drawings.

[0059] FFT (Fast Fourier Transform) is a widely used technique in digital signal processing, which significantly accelerates the calculation of DFT (Discrete Fourier Transform). Its calculation formula is as follows:

[0060]

[0061] Among them, x represents the input coefficient sequence, X o represents the output coefficient sequence, i and o are the coefficient indices of the input coefficient and the output coefficient respectively, and 0 <= i, o <= N - 1.

[0062] The above N is the total number of each of the input and output coefficient sequences. Usually, N is a power of 2, such as 1024 = 2^10.

[0063] The above is called the twiddle factor, where ω N is the Nth root of unity, and the product value of io is its power. ω N is a special number that satisfies where 1 ≤ k < N. In the complex number domain, usually where j is the imaginary unit, that is, j 2 = -1.

[0064] The twiddle factor has the following attractive properties:

[0065] (i) Periodicity: Since Therefore

[0066] (ii) Semi-periodicity: Since ω^2 = -1, therefore

[0067] (iii) 1 / 4-periodicity: Since ω^4 = j, therefore

[0068] The multiplication of

[0069] is usually called a simple multiplication, without actual multiplication operations, but only taking the negative or swapping the real and imaginary parts.

[0070] ​

[0071] Where n is the logarithm of N with base 2, rounded up. For example, when N is 1024, n=10.

[0072] Therefore, the above formula (1) can be rewritten as the following formula (3):

[0073]

[0074] The FFT may be referred to as an N-point FFT, or an n-level or n-order FFT.

[0075] At present, some FFT optimization schemes have been proposed, such as the Cooley-Tukey (CT) algorithm, which converts the N-point FFT transform into an n-level radix-2 butterfly operation, thereby effectively reducing the number of calculations from N to 1. 2 Reduced to N / 2logN.

[0076] In the radix-2 CT algorithm, the input coefficients are decimated based on the least significant bit of index i. It can be rewritten as the following formula (4):

[0077]

[0078] No need to calculate X independently o and X o+N / 2 , you can instead compute the FFT of two N / 2 coefficients: Then through N / 2 Figure 1a The CT butterfly operation shown recovers all N / 2 pairs of X o and X o+N / 2 (0≤o <N / 2)。 Figure 1a The circles marked with "o" represent the rotation factors Multiplication of .

[0079] The above analysis of formula (4) also applies to its sub-problem, that is, the FFT of the two N / 2 coefficients obtained by splitting it: It can also be further split by using formula (4). Based on the divide-and-conquer method, the final split is logN levels, with N / 2 butterfly operations in each level, for example Figure 1b exemplified. Figure 1b A data flow representation of a radix-2 CT FFT is given when N is 8, which shows a total of 3 stages, 4 CT butterfly operations in each stage. Since the butterfly operation consumes 2 inputs and produces 2 outputs, the algorithm is called a radix-2 CT algorithm.

[0080] In order to efficiently run various FFT algorithms, many processing circuit hardware architectures have been proposed, including pipeline architectures, such as the SDF (single-path delay feedback) pipeline architecture. The FFT implementation under the pipeline architecture has the advantage of high throughput, and the SDF pipeline architecture is an implementation method that takes both area and throughput into consideration.

[0081] Figure 2a A general pipeline stage based on SDF is shown, which includes a FIFO (First-In-First-Out) memory for storing data to be delayed or reordered, a basic butterfly operation unit for the current stage, a rotation factor multiplier between each stage, a ROM (Read-Only Memory) for storing the rotation factor, an address generator for generating a read address of the current rotation factor, and a register REG, etc.

[0082] Can be used Figure 2a The SDF general pipeline stage shown is used to construct processing circuits for various FFT algorithms that achieve a target number of points.

[0083] For example, Figure 2b shows the method for implementing 2 12 The SDF pipeline architecture of the processing circuit of the CT FFT transformation of the 12-point (also called 12-stage or 12-order) has 12-stage basic butterfly operation units and 11-stage inter-twiddle factor multiplication operators. In addition, the memory on the basic butterfly operation unit corresponds to Figure 2a The FIFO memory in the multiplier indicated by “*” corresponds to the memory under the multiplier. Figure 2a The ROM in is used to store the pre-calculated values ​​of the required rotation factors.

[0084] For the sake of clarity and simplicity, Figure 2b Not drawn in Figure 2a The register REG and the address generator in the multiplication operator are marked only below the memory below the multiplier for generating the address of the corresponding rotation factor (corresponding to the power of the rotation factor), that is, the product of several bits in the input coefficient index i and several bits in the output coefficient index o.

[0085] like Figure 2b As shown, the corresponding power of the rotation factor is shown below the last (11th) inter-stage rotation factor multiplication operator, that is, the io bit product is i0o 10:0 , that is, the rotation factor required for this multiplication is It usually requires storage of 2 12=4096 rotation factors, that is, 4096 rotation factor storage units are occupied.

[0086] In the embodiments of this specification, in order to reduce the occupied storage space, the characteristics of the aforementioned rotation factors, such as the semi-periodicity and 1 / 4 periodicity brought by w2=-1 and w4=j, can be used to reduce the number of stored rotation factors. as well as Therefore, it is sufficient to store only the values ​​of the rotation factors k∈[0,N / 4). Figure 2b As shown, for the last (11th) inter-level rotation factor multiplication operation, the actual 1024 rotation factor storage units are is enough. Similarly, except for the special cases of the first and second multiplications, for the previous m-th inter-level rotation factor multiplication operations, 2 (m-1) power rotation factor storage units are used. In the first multiplication, since w4 = j, no multiplier is actually used; and in the second multiplication, only the value of ω8 needs to be stored.

[0087] therefore, Figure 2b The pipeline CT FFT processing circuit in the embodiment uses a total of 2045 storage units to store the twiddle factors, but this still requires a huge storage overhead. If the storage cost of the twiddle factors can be further reduced, the area of ​​the processing circuit for implementing FFT can be effectively reduced.

[0088] The above discussion is not only applicable to FFT, but also can be similarly applied to other FFT-like transforms, such as NTT (Number Theoretic Transform) as a variant of FFT in finite fields, and variants NTTP, INTTP, etc. in NWC (negative wrapped convolution). These transforms can be summarized as discrete transforms or their inverse transforms that transform the input coefficient sequence into the output coefficient sequence based on the rotation factor. All the contents discussed for FFT in this specification can be extended to these transforms, but only adaptive modifications can be made in some implementation details.

[0089] In view of this, in the embodiments of this specification, a scheme for storing or reading rotation factors in a target transform is proposed. The target transform is a discrete transform that transforms an input coefficient sequence into an output coefficient sequence based on rotation factors or its inverse transform. When the actual number of rotation factors required for current multiplication is less than the upper limit value, this scheme adopts a two-level storage method to store rotation factors, effectively saving the storage cost of rotation factors in the processing circuit, thereby effectively reducing the area of the processing circuit. Further, in the embodiments of this specification, a scheme for finding a target decomposition method with the minimum storage cost is also proposed. It defines an evaluation function for the storage cost of rotation factors in the target transform under various decomposition methods. According to this function, a target decomposition method with the minimum storage cost is found through recursive decomposition; thus, the storage cost of rotation factors in the processing circuit can be further effectively saved, and the area of the processing circuit can be further effectively reduced.

[0090] To describe the solution of the embodiment more clearly, first, take the FFT as an example to elaborate on the principle, implementation steps, etc. of this solution.

[0091] The FFT represented by the foregoing formula (3) can be decomposed through the following formula (5):

[0092]

[0093] where 1 <= p < n. The three sources of rotation factors in this decomposition method are also marked in formula (5).

[0094] Specifically, in formula (5), the n-order FFT is decomposed into 2 p internal FFTs (which are (n - p)-order FFTs), 2 n-p external FFTs (which are p-order FFTs), and multiplications of 2 n points with a rotation factor respectively between the internal FFT and the external FFT (which can also be called inter-stage rotation factor multiplications).

[0095] As shown in formula (5), in this decomposition method, it can be regarded as decomposing the n-bit coefficient index i at the p-bit, into two index segments of p bits and (n - p) bits, and performing the corresponding external FFT and internal FFT respectively.

[0096] In the embodiments of this specification, this decomposition method shown in formula (5) can be called the decomposition method obtained for the n-order FFT or the n-bit coefficient index at the decomposition point p.

[0097] Figure 3a Use a 2D decomposition diagram to visually represent the decomposition method at the decomposition point p of formula (5).

[0098] In Figure 3aIn the figure, the vertical axis is the n bits of the input coefficient index i from top to bottom, and the horizontal axis is the n bits of the output coefficient index o from right to left, where the n bits of i are decomposed at p bits, and the n bits of o are also decomposed accordingly at (np) bits.

[0099] like Figure 3a As shown, after decomposition, for the highest (np) bit of i, i n-1:p Perform an internal (np)-order FFT, targeting the lowest p bits of i, i p-1:0 An external p-order FFT is performed and the same p-1:0 o n-p-1:0 The multiplication of the twiddle factors of the power is the multiplication of the inter-level twiddle factors.

[0100] As shown in formula (5), the rotation factors of the n-order FFT at the decomposition point p come from three sources: the internal (np)-order FFT, the external p-order FFT, and 2 n Inter-level twiddle factor multiplications.

[0101] The storage cost of the twiddle factors required for an n-th order FFT can be defined as C FFT (n), the local storage cost required for inter-level twiddle factor multiplication is defined as L FFT (p, np). It should be understood that the “cost” or “storage cost” mentioned in this specification refers to the storage cost of the rotation factor, which can be represented by the number of rotation factors that need to be stored in some examples.

[0102] Therefore, the storage cost of the n-order FFT at the decomposition point p can be obtained as:

[0103] C FFT (n) = C FFT (np)+C FFT (p)+L FFT (p,np), (6)

[0104] This may be referred to as a decomposition cost evaluation function.

[0105] Accordingly, Figure 3b Shows Figure 3a The storage cost corresponding to the decomposition method.

[0106] The above formula (5) and Figure 3a The decomposition technique shown is used to decompose the inner and outer FFTs until they are finally decomposed into a 1st-order FFT (i.e., a 2-point FFT, which is a basic butterfly operation). That is, an n-order FFT is finally decomposed into n-level basic butterfly operations and n-1-level inter-level rotation factor multiplication operations.

[0107] Therefore, the above decomposition cost evaluation function can be recursively applied to calculate the storage cost of the n-order FFT under various decomposition methods, so as to find the decomposition method with the minimum storage cost.

[0108] Figure 3c The example shows Figure 3a The storage cost is obtained by further decomposing the internal and external FFTs in the decomposition method.

[0109] like Figure 3c As shown, the inner (np) order FFT is similarly decomposed into the inner (np-q1) order FFT, the outer q1 order FFT and the 2 n-p The multiplication of inter-level twiddle factors, so its storage cost is C FFT (np) becomes C FFT (np-q1)+C FFT (q1)+L FFT (q1,np-q1). Similarly, the outer p-order FFT is decomposed into the inner (p-q2)-order FFT, the outer q2-order FFT, and 2 p The multiplication of inter-level twiddle factors, so its storage cost is C FFT (p) becomes C FFT (p-q2)+C FFT (q2)+L FFT (q2,p-q2).

[0110] By analogy, after recursive decomposition of several levels of index bit numbers, they are finally decomposed into a first-order FFT, so that the final storage cost can be recursively obtained.

[0111] As shown in the previous formula (5), for n-order FFT, the value of the decomposition point p can be in the range of 1 to n-1. In other words, n-order FFT can have n-1 candidate decomposition points, and the storage cost of each candidate decomposition point may be different. The cost evaluation function of the above formula (6) can be used to calculate the cost of each candidate decomposition point, and then find the minimum value as the storage cost C of n-order FFT. FFT (n), the decomposition method corresponding to the minimum value is the target decomposition method of the n-th order FFT.

[0112] Under the above alternative decomposition points, when p or np is 1, since the first-order FFT does not require multiplication, C FFT (1) = 0; and when p or np is not 1, it can be further decomposed to the first-order FFT through several levels of recursion, so as to finally find the decomposition method with the minimum storage cost.

[0113] All minimum costs C for p∈[1,n) can be pre-searched and obtained in a bottom-up manner FFT (p) and its corresponding decomposition method, and then traverse the value of p, for example, scan p from 1 to n-1, calculate the cost of each alternative decomposition point, and find the C with the minimum cost FFT (n) and its corresponding decomposition method.

[0114] Figure 4a Algorithm 1 is written in pseudo code, which gives an example of a method for searching for the minimum storage cost for a k-th order FFT.

[0115] like Figure 4a As shown in the method example of Algorithm 1, a bottom-up approach is adopted, that is, from the low C FFT (2) Start by gradually calculating the storage cost C of the k-th order FFT of the target order FFT (k), where for each n-order FFT, the costs under all decomposition points p are traversed to find the minimum value as its final storage cost C FFT (n).

[0116] In line 1 of Algorithm 1, the storage cost C of the first-order FFT is FFT (1) Initialized to 0.

[0117] In line 5 of Algorithm 1, the above decomposition cost evaluation function (6) is used to calculate the cost TC at the current decomposition point p for each n-order FFT FFT , where the minimum storage costs of each low-order, i.e., each p-order and np-order, have been calculated previously by Algorithm 1, so the calculated minimum storage costs of the p-order and (np)-order FFTs are directly read as the storage costs C of the p-order and (np)-order FFTs in row 5, respectively. FFT (p), C FFT (np) is enough.

[0118] In addition, for the local storage cost L in the decomposition cost evaluation function (6) FFT (p,np), the upper limit of the number of rotation factors that need to be stored for inter-stage multiplication is usually 2 n However, as mentioned above, the half-periodicity and 1 / 4 periodicity of the FFT rotation factor can be used to reduce it to one-fourth, that is, to 2 n-2 The two rotation factors can be stored in the traditional first-level storage method. n-2 twiddle factors; that is, using n-2 The memory of the storage unit is used to directly store these 2 n-2 The address of each storage unit corresponds to the power of the rotation factor stored in the unit.FFT (p,np) are both 2 n-2 .

[0119] In addition, in line 6 of Algorithm 1, the current storage cost TC is FFT With the first variable value C FFT (n) is compared. If it is less than the current first variable value, the first variable value C is FFT (n) Updated to the current storage cost TC FFT ; Otherwise the first variable value C FFT (n) remains unchanged, and the first variable value C is changed in line 3 of Algorithm 1 FFT (n) is initialized to a maximum value. Therefore, the first variable value C can be guaranteed FFT (n) The minimum storage cost of storing the n-th order FFT at each decomposition point p that has been traversed.

[0120] Although the above algorithm 1 only returns the storage cost C of FFT of order 2 to k FFT (2) to C FFT (k), but it should be understood that the values ​​of the decomposition points p corresponding to these minimum storage costs can also be returned at the same time, so as to obtain the decomposition points with the minimum storage cost of each order FFT. Therefore, using these decomposition points, through recursive decomposition of several levels, the target decomposition method with the minimum storage cost of the target k-level FFT can be obtained.

[0121] Table 1 below lists the minimum storage costs of various order FFTs obtained using the above algorithm 1 when using a one-level storage method and the values ​​of their corresponding decomposition points.

[0122] Table 1

[0123]

[0124] In Table 1, “(np)+p” indicates the decomposition method at decomposition point p or np (for FFT, the decomposition point p or np is symmetrical and its cost is the same), and “local cost” indicates the local storage cost L of the first-level storage method for the multiplication of inter-level rotation factors. FFT (p,np), “total cost” represents the storage cost C of the n-order FFT FFT (n).

[0125] For a given n, the storage cost of the twiddle factors of the traditional n-order FFT design is 2 n-1 Taking n=12 as an example, the traditional cost of FFT is 2048, but as shown in Table 1, the optimized cost of the solution in the embodiment of this specification is 1060, and the storage cost is reduced by (2048-1060) / 2048*100%=48.24%.

[0126] In addition, from Table 1, we can obtain the target decomposition method with the minimum storage cost of each order FFT when using the one-level storage method.

[0127] For example, for a 12th-order FFT, the decomposition point 6 can be used to obtain a 6th-order FFT+6th-order FFT, and then the sub-decomposition point 3 can be used for the 6th-order FFT to obtain a 3rd-order FFT+3rd-order FFT, and then the sub-decomposition point 1 or 2 can be used for the 3rd-order FFT to obtain a 1st-order FFT+2nd-order FFT, and then the 2nd-order FFT can be decomposed to obtain a 1st-order FFT+1st-order FFT.

[0128] The entire FFT processing circuit may be designed according to the target decomposition method obtained above, for example, corresponding memories may be allocated to the rotation factors therein.

[0129] For example, the above-mentioned target decomposition method can be used to convert the above-mentioned Figure 2b The SDF pipeline architecture of the 12th-order FFT in becomes Figure 5a An example of the SDF pipeline architecture is shown.

[0130] like Figure 5a As shown, compared to Figure 2b , with the change of decomposition method, the number of rotation factors required to be stored by each level of multipliers also changes, and the corresponding storage space occupied by the memory under each multiplier also changes. It can be seen that Figure 5a Significantly reduces the number of twiddle factors required, from Figure 2b The number of 2,045 was reduced to just 1,060. Figure 5a Each rotation factor memory in the is stored in a first-level manner.

[0131] Figure 5a For the sake of clarity and simplicity, only the change of the memory allocated for the rotation factor is shown, but in fact the data flow of the entire 12-stage basic butterfly operation and the inter-stage rotation factor multiplication has changed, so some of its connection methods and the like also need to be changed accordingly.

[0132] As mentioned above, the principles and solutions proposed for FFT can be extended to other types of FFT transforms, such as NTT, NTTP, INTTP, etc. The following discusses the application of the solutions of the embodiments of this specification in NTT, NTTP, and INTTP.

[0133] NTT is a finite field FFT variant, and its calculation formula is as follows:

[0134]

[0135] Among them, 0<=i, o<=N-1.

[0136] Compared with the FFT, the NTT has one more modular operation. Correspondingly, the twiddle factor ω of the NTT N should satisfy where 1 ≤ k < N. The twiddle factor of the NTT has the periodicity and semi-periodicity of the FFT twiddle factor mentioned above, but since w4 is no longer a special number, it does not have 1 / 4 periodicity.

[0137] Similar to the FFT, the NTT represented by the aforementioned formula (7) can be decomposed by the following formula (8):

[0138]

[0139] where 1 <= p < n. The three sources of the twiddle factor in this decomposition method are also marked in formula (8).

[0140] Similar to the FFT, in formula (8), the n-order NTT is decomposed into 2 p inner NTTs (which are (n - p)-order NTTs), 2 n-p outer NTTs (which are p-order NTTs), and the multiplication of the twiddle factors between the inner NTT and the outer NTT.

[0141] Similarly, the storage cost of the twiddle factor required for the n-order NTT can be defined as C NTT (n), and the local storage cost required for the multiplication of the twiddle factors between levels can be defined as L NTT (p, n - p). Therefore, the storage cost of the n-order NTT at the decomposition point p can be obtained as:

[0142] C NTT (n) = C NTT (n - p) + C NTT (p) + L NTT (p, n - p) (9)

[0143] Since the NTT twiddle factor no longer has 1 / 4 periodicity, the upper limit of the number of twiddle factors that need to be stored for the multiplication between levels can only be reduced to 2 n-1 ones. Therefore, in the case of using the traditional one-level storage method to store the twiddle factor, L NTT (p, n - p) can be uniformly taken as 2 n-1 . C NTT (1) is still 0.

[0144] Similar to FFT, the above formula (8) can be recursively applied to perform several levels of index bit decomposition on the n-order NTT until it is finally decomposed into the 1-order NTT. Therefore, the above decomposition cost evaluation function (9) can be recursively applied to calculate the storage cost of the n-order NTT under various decomposition methods, so as to find the decomposition method with the minimum storage cost.

[0145] In addition to changing the subscripts of the parameters from FFT to NTT, the above algorithm 1 for FFT can also be applied to NTT, and L NTT (p,np) are both 2 n-1 .

[0146] Refer to the following Figure 4b , which introduces the operation of NWC in pseudocode and provides an efficient method for computing polynomial products c(x).

[0147] exist Figure 4b In the calculation process shown, a(x) and b(x) are The polynomials in the equation have coefficients a N-1 to a0 and b N-1 to b0, where a i ,b i ∈[0,q). The polynomial multiplication of a(x) and b(x) is to find a polynomial c(x) with N coefficients such that Where 0≤o <N。

[0148] In addition to the standard operations in line 3, NWC requires an additional preprocessing step, where a(x) and b(x) are compared with Perform coefficient multiplication. In addition, after the inverse NTT (INTT) is a similar post-processing step involving Multiply the coefficients.

[0149] To speed up the operation, the pre-processing steps can be integrated into NTT and the post-processing steps can be integrated into INTT.

[0150] For simplicity, the embodiment of this specification introduces NTTP to represent the transformation obtained by fusing pre-processing with NTT in NWC, and introduces INTTP to represent the transformation obtained by fusing INTT with post-processing in NWC, as shown below:

[0151]

[0152] Substituting into the calculation formulas of NTT and INTT respectively, the NTTP and INTTP transformations can be transformed into the following formulas respectively:

[0153]

[0154] Among them, 0<=i, o<=N-1.

[0155] Without considering the constant 1 / N, the calculation framework of NTTP and INTTP transformations is similar to the calculation framework of FFT and NTT mentioned above.

[0156] Therefore, similar to the aforementioned FFT and NTT, the NTTP represented by the aforementioned formula (10) can be decomposed by the following formula (12):

[0157]

[0158] And the INTTP represented by the above formula (11) is decomposed by the following formula (13) (where the constant 1 / N is omitted):

[0159]

[0160] Among them, 1 <= p <n。

[0161] In formula (12), the n-order NTTP is decomposed into 2 p Internal NTTP (which is (np)-order NTTP), 2 n-p An outer NTT (which is a p-order NTT), and an inter-order twiddle factor multiplication between the inner NTTP and the outer NTT.

[0162] In formula (13), the n-th order INTTP is decomposed into 2 p Internal INTT (which is an (np)-order INTT), 2 n-p There are outer INTTPs (which are p-order INTTPs), and inter-stage rotation factor multiplications between the inner INTT and the outer INTTP.

[0163] The storage cost of the twiddle factors required for n-order INTT, n-order NTTP, and n-order INTTP can be defined as C INTT (n), C NTTP (n) and C INTTP (n), the local storage cost required for the inter-level twiddle factor multiplication of n-order NTTP and n-order INTTP is defined as L NTTP (p,np) and L INTTP (p,np).

[0164] Therefore, the storage costs of n-order NTTP and n-order INTTP at decomposition point p are:

[0165] C NTTP (n) = C NTTP (np)+C NTT(p)+L NTTP (p,np)(14)

[0166] C INTTP (n) = C INTT (np)+C INTTP (p)+L INTTP (p,np)(15)

[0167] Since the base of the rotation factor is 2 in NTTP and INTTP transformations n+1 Instead of the previous 2 in NTT n , so the upper limit of the number of rotation factors that need to be stored for inter-stage multiplication becomes 2 n Therefore, when using the traditional level-1 storage method to store the rotation factors, L NTTP (p,np) and L INTTP (p,np) are both 2 n . And C NTTP (1) and C INTTP (1) also becomes 1 accordingly, that is, a rotation factor needs to be stored in the first-order NTTP and INTTP transformations.

[0168] Similar to FFT, the above formulas (12) and (13) can be recursively applied to perform several levels of index bit decomposition on n-order NTTP and n-order INTTP respectively, until they are finally decomposed into 1-order transformation. Therefore, the above decomposition cost evaluation functions (14) and (15) can be recursively applied to calculate the storage cost of n-order NTTP and n-order INTTP under various decomposition methods, so as to find the decomposition method with the minimum storage cost.

[0169] However, as shown in equations (14) and (15), the decomposition cost functions of n-order NTTP and n-order INTTP also involve the cost of lower-order NTT or INTT. It can be proved that the cost of NTT and INTT is the same, that is, C NTT (n) = C INTT (n), so it is also necessary to use the previous algorithm for NTT to pre-calculate the storage cost of each low-order NTT.

[0170] Therefore, it can be Figure 4a By making some changes to Algorithm 1 for FFT, we get Figure 4c Algorithm 2 shown is used to search for the minimum storage cost for k-order NTT, NTTP and INTTP respectively.

[0171] Similar to Algorithm 1, in the method example of Algorithm 2, a bottom-up approach is adopted, that is, starting from the low C NTT (2) C NTTP (2) and C INTTP(2) Start by gradually calculating the storage cost C of k-order NTT, NTTP, and INTTP to the target order NTT (k), C NTTP (k) and C INTTP (k), where for each n-order NTT, NTTP and INTTP, the costs under all decomposition points p are traversed respectively to find the minimum value as its final storage cost C NTT (n), C NTTP (n) and C INTTP (n).

[0172] The specific steps of Algorithm 2 are similar to those of Algorithm 1, except that the initialization value of the first-order transformation, the decomposition cost evaluation function, and the value of the local cost are adaptively modified according to the previous discussion.

[0173] Similarly, the minimum storage costs of each order of NTT, NTTP and INTTP obtained by Algorithm 2 when using the primary storage method and the values ​​of their corresponding decomposition points are listed in Table 2 below.

[0174] Table 2

[0175]

[0176] "(np)+p" in Table 2 represents the decomposition method of each n-order transformation at the decomposition point p (but for NTT, the decomposition point p or np is symmetric and the cost is the same), "local cost" represents the local storage cost of the inter-level rotation factor multiplication of each n-order transformation using the first-level storage method, and "total cost" represents the total storage cost of each n-order transformation.

[0177] For a given n, the storage costs of each n-order transformation under the traditional design are: (1) NTT needs to store 2 n storage factors; (2) Both NTTP and INTTP need to store 2 n+1 storage factor.

[0178] Take n=12 as an example,

[0179] (1) The traditional cost of NTT is 4096, but as shown in Table 2, the optimized cost of the solution in the embodiment of this specification is 2132, and the storage cost is reduced by (4096-2132) / 4096*100%=47.95%;

[0180] (2) The traditional cost of NTTP and INTTP is 8192, but as shown in Table 2, the cost after optimization of the solution in the embodiment of this specification is 4217, and the storage cost is reduced by (8192-4217) / 8192*100%=48.52%.

[0181] In addition, from Table 2, we can obtain the target decomposition method with the minimum storage cost of each order NTT when using the first-level storage method.

[0182] For example, for the 12th-order NTT, the same decomposition method as the aforementioned 12th-order FFT can be used. Similarly, the entire NTT processing circuit can be designed according to the obtained target decomposition method, for example, corresponding memories are allocated for the rotation factors therein.

[0183] For example, with the above Figure 5a Similar to the SDF FFT pipeline architecture example shown, one can construct Figure 5b The NTT processing circuit shown has an SDF pipeline architecture.

[0184] like Figure 5b As shown, compared to Figure 5a The number of rotation factors stored in the multipliers between each level increases from 2 n-2 becomes 2 n-1 , the corresponding storage space occupied by the memory under each multiplier is also basically increased by 2 times. It can be seen that Figure 5b The architecture requires a total of 2132 storage units to store the rotation factors, which still occupies a large storage area.

[0185] by Figure 5b The memory that occupies the largest storage space is used to store the rotation factors The memory (the memory marked with "2048" in Figure 5) is used as an example to discuss how to further reduce the required storage cost.

[0186] Figure 6 The structure of the twiddle factor memory using a one-level storage method is shown.

[0187] i 5:0 *o 5:0 The product of has 12 bits, but as mentioned before, since the unit root w2 at 2 is a special value -1, based on this semi-periodicity, only half the power (i.e. 2) needs to be stored. 11 The rotation factor of ) is sufficient.

[0188] Because I 5:0 *o 5:0 mod 2 11 The possible range is [0,2 11 ), so all 2 11 The rotation factors of powers are stored in the storage units at the addresses corresponding to their powers.

[0189] like Figure 6 As shown, the depth of the rotation factor memory, that is, the number of storage units B is 211 = 2048, the bit width of each storage unit, that is, the number of bits T required to store the rotation factor is 128, and the storage unit at each address stores the value of the rotation factor of the same power as the address. For example, the rotation factor is stored at address 2047

[0190] When you need to read the required rotation factor, you can 5:0 *o 5:0 The highest 1 bit of the product of is used to determine the semi-periodicity of w2, and the remaining 11 bits are used as the address to read the value of the rotation factor stored at the address in the rotation factor memory, which has the same power as the address, that is, i 5:0 *o 5:0 mod 2 11 .

[0191] therefore, Figure 6 The first-level storage method needs to store B*T=2048*128=262144 bits in total. On average, it is equivalent to storing B*T / T=262144 / 128=2048 data (i.e., rotation factor values).

[0192] However, research has found that 5:0 *o 5:0 mod 2 11 The actual product result has only P = 1073 possibilities, which is far lower than the upper limit of 2048. Figure 6 Of the 2048 rotation factor values ​​stored, only 1073 are actually needed, and the remaining nearly 1,000 storage units are wasted.

[0193] In order to solve this inefficient storage allocation problem, a secondary storage method is proposed to store the rotation factors. Figure 7 As shown, two memories can be set: a rotation factor memory and an index memory, wherein the rotation factor memory only needs to have P storage units, which are the number of io valid modular multiplication results, to store all valid rotation factor values, and the depth of the index memory is an upper limit B, and the address of the rotation factor corresponding to each valid modular multiplication value in the rotation factor memory is stored at the address of the modular multiplication value.

[0194] When storing the rotation factors, all the rotation factors that are raised to the power of the effective modular multiplication value of io can be first stored in the rotation factor memory, and then the corresponding index value is stored at the address of each effective modular multiplication value in the index memory, and the index value points to the address of the rotation factor raised to the power of the effective modular multiplication value in the rotation factor memory.

[0195] Thus, when reading the rotation factor, the modular multiplication value of io can be calculated first, which is the power of the rotation factor to be read. The index memory is read with the modular multiplication value as the address, that is, the index value stored at the address of the modular multiplication value in the index memory is read. Then, the rotation factor memory is read with the index value as the address, that is, the value of the rotation factor stored at the address of the index value in the rotation factor memory is read.

[0196] with i 5:0 =33 and o 5:0 =62 as an example, i 5:0 o 5:0 mod 2 11 =2046. At address 2046 of the index memory, an index value 1072 is stored, which represents the rotation factor The twiddle factor memory is stored at address 1072. For ease of understanding, Figure 7 The values ​​displayed in each storage unit of the rotation factor memory are not the actual stored rotation factor values, but their power values. Figure 7 The secondary storage method shown can also be 5:0 o 5:0 mod 2 11 Directly generate addresses to read the corresponding rotation factor values.

[0197] In addition, if Figure 7 As shown, since 2047 cannot pass i 5:0 o 5:0 mod 2 11 Generated, so the value at address 2047 of the index memory can be any value, such as 0.

[0198] In the above-mentioned secondary storage method, although the cost of the index memory is increased, the increased cost is less than the storage cost saved by the rotation factor memory, so the total storage cost is reduced.

[0199] Specifically, the bit width of the index memory depends only on the depth P of the twiddle factor memory, which is That is, log2P is rounded up. For example, Figure 7 In the example, P is 1073, and the bit width of the index memory is only 11 bits.

[0200] thus, Figure 7 The secondary storage method requires a total of:

[0201] Bit.

[0202] On average, storage data (i.e., rotation factor values).

[0203] Therefore, compared to Figure 6 The primary storage method is to use the secondary storage method, i 5:0 o 5:0 mod 2 11 The required local storage cost is reduced from 2048 to 1249.

[0204] The above secondary storage method can be applied to Figure 5b The memory used by other inter-stage multipliers in the inter-stage multiplication can be used as long as the number of valid rotation factors actually used in the inter-stage multiplication is less than the upper limit of the number of rotation factors, or satisfies a certain relationship, such as the ratio of the bit width of the index memory to the bit width of the rotation factor memory is less than a preset value, so as to achieve the effect of reducing the storage cost.

[0205] Generally speaking, when the following formula (16) is satisfied, the number of bits required by the secondary storage method is equal to or less than that of the primary storage method, so the secondary storage method can be used:

[0206]

[0207] The following formula (17) shows the storage cost saving ratio of the secondary storage method compared to the primary storage method:

[0208]

[0209] It can be seen that when the bit width T of the rotation factor becomes larger, more storage cost can be saved. In addition, when the number P of io effective modular multiplications is much smaller than the upper limit value B, more storage cost can be saved.

[0210] A certain condition can be preset according to the above formula (17), and the secondary storage method is used only when the condition is met, so as to better balance the efficiency and area of ​​the rotation factor storage. For example, the condition can be: the ratio of the bit width of the index memory to the bit width of the rotation factor memory is less than a preset value. The preset value can be determined as needed.

[0211] The minimum storage costs of each order of FFT, NTT, NTTP and INTTP obtained by using Algorithm 1 and Algorithm 2 when using the secondary storage method and the values ​​of their corresponding decomposition points are listed in Table 3 below.

[0212] Table 3

[0213]

[0214] "(np)+p" in Table 3 represents the decomposition method of each n-order transform at the decomposition point p (however, for FFT and NTT, the decomposition point p or np is symmetrical and the cost is the same), "products" represents the number of corresponding io effective modular multiplications under the decomposition method, "local cost" represents the local storage cost of the inter-stage rotation factor multiplication of each n-order transform using the secondary storage method, and "total cost" represents the total storage cost of each n-order transform.

[0215] As mentioned above, for a given n, the storage costs of each n-order transform under the traditional design are: (1) FFT needs to store 2 n-1 storage factor; (2) NTT needs to store 2 n storage factor; (3) Both NTTP and INTTP need to store 2 n+1 storage factor.

[0216] Take n=12 as an example,

[0217] (1) The traditional cost of FFT is 2048, but as shown in Table 3, the optimized cost of the solution in the embodiment of this specification is 908, and the storage cost is reduced by (2048-908) / 2048*100%=55.66%;

[0218] (2) The traditional cost of NTT is 4096, but as shown in Table 3, the optimized cost of the solution in the embodiment of this specification is 1317.5, and the storage cost is reduced by (4096-1317.5) / 4096*100%=67.83%;

[0219] (3) The traditional cost of NTTP and INTTP is 8192, but as shown in Table 3, the optimized cost of the solution in the embodiment of this specification is 2527.625, and the storage cost is reduced by (8192-2527.625) / 8192*100%=69.15%.

[0220] In addition, comparing the data in Table 3 with those in Table 1 and Table 2:

[0221] For FFT, the cost is further reduced from 1060 to 908;

[0222] For NTT, the cost was further reduced from 2132 to 1317.5;

[0223] For NTTP and INTTP, the cost is further reduced from 4217 to 2527.625.

[0224] It can be seen that compared with the primary storage method, the secondary storage method greatly reduces the storage cost, especially in the application scenarios of NTT, NTTP and INTTP.

[0225] Based on the basic principles and inventive concepts of the specific solutions of the embodiments of this specification implemented for FFT, NTT, NTTP and INTTP transformations, a general solution can be obtained, which is generally applicable to similar application scenarios and effectively saves the storage cost of the rotation factors.

[0226] Figure 8 A flow chart of a method for storing rotation factors in a target transform according to an embodiment is shown. The target transform is a discrete transform or an inverse transform thereof that transforms an input coefficient sequence into an output coefficient sequence based on the rotation factors. Figure 8 The method shown includes the following steps:

[0227] Step S81, determining a target rotation factor to be stored, wherein the power of the target rotation factor is a result of multiplying a first factor of a first digit by a second factor of a second digit modulo a target value;

[0228] Step S82: storing the target rotation factor in a secondary storage manner.

[0229] Fig. 9 A flowchart of a method for performing the secondary storage method in step S82 according to an embodiment is shown. Fig. 9 The secondary storage method shown includes the following steps:

[0230] Step S821, storing the target rotation factor at a first address in a rotation factor memory, wherein the rotation factor memory includes a first number of first storage units, and the first number is the number of different modular multiplication results generated by the factor of the first digit and the factor of the second digit;

[0231] Step S822, storing an index value pointing to the first address at a second address in an index memory, wherein the index memory includes the target value second storage unit, the second address corresponds to the power of the target rotation factor; and the target value is greater than the first number.

[0232] The execution of the above steps is described in detail below with reference to specific examples.

[0233] In step S81, in some examples, the target rotation factor to be stored may be a rotation factor used for performing inter-combination multiplication when the n-order target transformation is decomposed into a combination of two low-order transformations of (np) order and p order at the decomposition point p as shown in the above formula (5), (8), (12) or (13), wherein the first factor and the second factor are obtained by performing first and second linear processing based on coefficient indices of p bits and (np) bits, respectively; and the target value is determined according to the target transformation type. It should be understood that the solution of the embodiment of the present specification is not limited to this application scenario, but can be applied to any scenario with similar rotation factor storage requirements.

[0234] Accordingly, as shown in the above formula (5) and its related discussion, when the target transform is FFT, the power of the target rotation factor can be i p-1:0 *o n-p-1:0 mod 2 n-2 The value of; therefore the first factor is i p-1:0 , the second factor is o n-p-1:0 , the first digit and the second digit are p and (np) digits respectively, the first and second linear processing are both identity transformations, and the target value is 2 to the power of n-2.

[0235] As shown in the above formula (8) and its related discussion, when the target transformation is NTT, the power of the target rotation factor can be i p-1:0 *o n-p-1:0 mod 2 n-1 The value of; therefore the first factor is i p-1:0 , the second factor is o n-p-1:0 , the first digit and the second digit are p and (np) digits respectively, the first and second linear processing are both identity transformations, and the target value is 2 to the power of n-1.

[0236] As shown in the above formula (12) and its related discussion, when the target transformation is NTTP, the power of the target rotation factor can be i p-1:0 *(2*o n-p-1:0 +1) mod 2 n The value of; therefore the first factor is i p-1:0 , the second factor is (2*o n-p-1:0 +1), whose first and second digits are p and (n-p+1) bits respectively. This means that the first linear process is an identity transformation, and the second linear process defines the second factor as 2*x+1, where x is a coefficient index of (np) bits, and the target value is 2 to the power of n.

[0237] As shown in the above formula (13) and its related discussion, when the target transformation is INTTP, the power of the target rotation factor can be (2*i p-1:0 +1)*o n-p-1:0 mod 2 n The value of; therefore the first factor is (2*i p-1:0 +1), the second factor is o n-p-1:0 , whose first and second digits are (p+1) and (np) bits respectively. This means that the first linear process defines the first factor as 2*x+1, where x is the p-bit coefficient index, and the second linear process is the identity transformation, with the target value being 2 to the power of n.

[0238] In some examples, the target rotation factors to be stored may be rotation factors of a target decomposition method with minimum storage cost for the K-point input coefficient sequence to be processed. The target decomposition method may be Fig.10 The method shown determines that the target decomposition method aimed at minimizing the storage cost of the entire layout can be combined with the secondary storage method to greatly reduce the storage cost.

[0239] Fig.10 A flow chart of a method for determining a target decomposition method according to an embodiment is shown. Fig.10 The method shown in comprises the following steps:

[0240] Step S101, determining a plurality of candidate decomposition points in the k-bit coefficient index corresponding to the K-point input coefficient sequence, wherein K is 2 raised to the kth power; thus, the target transformation may also be called a k-order target transformation;

[0241] Step S102, starting from the low-order decomposition point, for each candidate decomposition point in turn, according to the decomposition cost evaluation function, by recursively decomposing the number of index bits of several levels, determine the minimum storage cost under each candidate decomposition point, thereby determining the target decomposition method with the minimum storage cost; wherein the decomposition cost evaluation function defines that for the n-order target transformation, the storage cost under the decomposition point p includes the storage cost of the (np)-order first transformation, the storage cost of the p-order second transformation, and the storage cost of the (np)-order second transformation. Fig. 9 The secondary storage method shown stores the local storage cost of the inter-level rotation factors, wherein the first transformation and the second transformation are each the target transformation or its corresponding base transformation, and the local storage cost includes the storage cost of the rotation factor memory and the storage cost of the index memory.

[0242] In some examples, in step S101, for the k-order target transformation, any multiple values ​​in the interval [1, k-1] can be selected as candidate decomposition points. For example, as shown in the aforementioned Algorithms 1 and 2, the interval [1, k-1] can be traversed, that is, the candidate decomposition points include all integer values ​​from 1 to k-1. However, in some examples, due to the symmetry of the decomposition costs of FFT and NTT, that is, the costs at decomposition points p and kp are equal, all integer values ​​from 1 to k / 2 can be taken as candidate decomposition points. In other examples, the values ​​of the candidate decomposition points can also be selected based on other considerations.

[0243] Then, in step S102, the minimum cost of each candidate decomposition point can be calculated in order from small to large according to the decomposition cost evaluation function, and then the minimum value is obtained as the minimum cost of the k-order target transformation. The decomposition method corresponding to the minimum cost is the target decomposition method.

[0244] For example, at the current candidate decomposition point n, the decomposition cost evaluation function defines the current cost as the sum of the cost of the (kn)th order first transformation corresponding to the decomposition, the cost of the nth order second transformation and the local cost for the kth order target transformation.

[0245] As shown in Table 3 above, for some lower-order target transforms, such as 2nd to 5th-order FFT and 2nd to 3rd-order NTT, since the number of rotation factors actually required is equal to their upper limit, there is no need to use secondary storage, and their local cost is still the corresponding upper limit. For higher-order FFT and NTT, as well as NTTP and INTTP of each order, secondary storage can be used to store inter-level rotation factors, and their local cost is the sum of the storage costs of the rotation factor memory and index memory used by the corresponding secondary storage method. The right side of the above formula (16), that is, Calculate the values ​​of these local costs ahead of time.

[0246] Therefore, the local cost may be a pre-calculated value, and to determine the minimum value of the current cost, the minimum value of the cost of the (kn)-order first transformation and the n-order second transformation must be determined first.

[0247] When the target transform is FFT or NTT, the first and second transforms are both the target transforms themselves. When (kn) or n is 1, the initialized value can be directly obtained, that is, C FFT (1) or C NTT (1) = 0; and when (kn) or n is not 1, since the minimum cost value is not known, the minimum storage cost can be determined by recursively decomposing the number of index bits at several levels until it is decomposed to the first-order FFT or NTT.

[0248] For example, for the n-order target transformation corresponding to the current candidate decomposition point, similar to the aforementioned k-order target transformation, each candidate sub-decomposition point is traversed from the low position, and the storage cost under each sub-decomposition point is determined according to the decomposition cost evaluation function, and then the minimum value is used as the minimum storage cost of the n-order target transformation; if the minimum cost of the first or second transformation corresponding to the current sub-decomposition is still unknown, the first or second transformation is continued to be decomposed until it is decomposed into a known 1st-order transformation. It should be understood that in other examples, the storage cost values ​​of target transformations of more orders can also be initialized as needed, such as pre-setting the minimum cost value of 2nd-order or 3rd-order FFT or NTT, and the end point of the recursive decomposition of higher-order FFT or NTT can also include 2nd-order or 3rd-order FFT or NTT, etc.

[0249] In some examples, as described in Algorithms 1 and 2 above, the current storage cost TC can be determined for the current sub-decomposition point p of each n-order target transformation according to the decomposition cost evaluation function; the current storage cost TC is compared with the first variable value C, and if it is less than the first variable value, the first variable value is updated to the current storage cost, where the first variable value is used to store the minimum storage cost of the n-order target transformation, that is, C = min(TC, C), so that the minimum storage cost of the n-order target transformation is obtained after traversing all sub-decomposition points.

[0250] In some examples, for each n-order target transformation, the minimum cost of each low-order target transformation can be determined in advance by the above method, and then the minimum cost of the current n-order target transformation can be determined. For example, as described in Algorithm 1 and Algorithm 2 above, all minimum costs C of p∈[1,n) can be obtained in sequence from bottom to top by using step S102. FFT (p) and its corresponding decomposition method, and then traverse the value of p, for example, scan p from 1 to n-1, calculate the cost of each sub-decomposition point p of the n-order target transformation, and thus find the C with the minimum cost of the current n-order target transformation FFT (n) and its corresponding decomposition method.

[0251] When the minimum cost of each low-order target transformation has been calculated in advance, when determining the storage cost of the current sub-decomposition point p, the minimum storage cost of the (np)-order target transformation can be read as the storage cost of the (np)-order first transformation, and the minimum storage cost of the p-order target transformation can be read as the storage cost of the p-order second transformation.

[0252] When the target transform is an NTTP transform, the first transform is the target transform itself and the second transform is NTT; when the target transform is an INTTP transform, the first transform is INTT and the second transform is the target transform itself. Therefore, in addition to calculating the minimum cost value of each low-order target transform similar to the aforementioned FFT or NTT case, the minimum cost value of each low-order NTT must also be obtained. The minimum cost value of each low-order NTT can be calculated in advance using the aforementioned example methods, and the value of each order NTT calculated in advance can be directly read when calculating the cost of the NTTP transform or INTTP transform.

[0253] The execution of each step of the above-mentioned two-level decomposition method is described in detail below with reference to specific examples.

[0254] In step S821, in some examples, the number of first storage units included in the rotation factor memory, that is, the first number is a depth P, which is the number of all different modular multiplication results (also referred to as all valid modular multiplication results) generated by all possible values ​​of the first factor and all possible values ​​of the second factor.

[0255] In the case where the target transform is FFT, P can be i p-1:0 *o n-p-1:0 mod 2 n-2 The number of all different outcomes of ; in the case of NTT, P can be i p-1:0 *o n-p-1:0 mod 2 n-1 The number of all different outcomes of ; in the case of NTTP, P can be i p-1:0 *(2*o n-p-1:0 +1) mod 2 n The number of all different outcomes; in the case of INTTP, P can be (2*i p-1:0 +1)*o n-p-1:0 mod 2 n The number of all different outcomes.

[0256] The values ​​of the rotation factors can be stored in the first storage unit at each address from low to high in order of power from small to large, for example Figure 7 As shown, the first address where the target rotation factor is to be stored can be determined. It should be understood that the storage location of each rotation factor in the rotation factor memory is not limited to this, but can be determined in various suitable ways. The bit width of the first storage unit is the first number of bits required by the target rotation factor, such as the number of bits T of the rotation factor value.

[0257] Then, in step S822, in some examples, the number of second storage units included in the index memory, that is, the target value is a depth B, which is the modulus in the modular multiplication of the first factor and the second factor. The power of the target rotation factor determined in the previous step S81 is used as the second address, and the index value pointing to the first address is stored at the second address in the index memory. Therefore, in the index memory, the index values ​​pointing to the addresses of the corresponding rotation factors in the rotation factor memory can be stored in each second storage unit with the power of each rotation factor stored in the rotation factor memory as the address. The bit width of the second storage unit is the second number of bits required for the index value, such as In some examples, the second bit number The secondary storage method is used only when the ratio to the first bit number T is smaller than a preset value.

[0258] After the rotation factors are stored in the secondary storage manner, the rotation factors may be read in a corresponding secondary reading manner. Fig.11 A flow chart of a method for reading rotation factors in a target transform according to one embodiment is shown. Fig.11 The method shown includes the following steps:

[0259] Step S111, determining a target power of the rotation factor to be read, the target power being a result of multiplying a first factor of a first digit by a second factor of a second digit modulo a target value;

[0260] Step S112, determining a second address according to the target power; reading an index value stored at the second address in an index memory; wherein the index memory has the target value of second storage units;

[0261] Step S113, determining a first address according to the index value, and reading the value of the rotation factor stored at the first address in the rotation factor memory; wherein the rotation factor memory includes a first number of first storage units, and the first number is the number of different modular multiplication results generated by the factor of the first digit and the factor of the second digit; the first number is less than the target value.

[0262] These steps correspond to the aforementioned Figure 8 and Fig. 9 Therefore, the specific details and examples are not repeated here.

[0263] Therefore, the embodiment of the present specification avoids unnecessary storage through the secondary storage method, greatly reducing the storage cost. Furthermore, the embodiment of the present specification can further reduce the storage cost by finding a target decomposition method with the minimum storage cost.

[0264] According to another embodiment, a device for storing a rotation factor in a target transform is also provided, wherein the target transform is a discrete transform or an inverse transform thereof that transforms an input coefficient sequence into an output coefficient sequence based on the rotation factor. The storage device comprises:

[0265] a determining unit configured to determine a target rotation factor to be stored, wherein the power of the target rotation factor is a result of multiplying a first factor of a first digit by a second factor of a second digit modulo a target value;

[0266] A storage unit is configured to store the target rotation factor in a secondary storage manner, wherein the secondary storage manner includes:

[0267] Storing the target twiddle factor at a first address in a twiddle factor memory, wherein the twiddle factor memory includes a first number of first storage units, the first number being the number of different modular multiplication results generated by the factors of the first digit and the factors of the second digit;

[0268] An index value pointing to the first address is stored at a second address in an index memory, wherein the index memory includes the target value second storage units, the second address corresponds to a power of the target rotation factor; and the target value is greater than the first number.

[0269] According to another embodiment, a device for reading a rotation factor in a target transform is provided, wherein the target transform is a discrete transform or an inverse transform thereof that transforms an input coefficient sequence into an output coefficient sequence based on the rotation factor. The above-mentioned reading device comprises:

[0270] a determining unit configured to determine a target power of a rotation factor to be read, wherein the target power is a result of multiplying a first factor of a first digit by a second factor of a second digit modulo a target value;

[0271] A first reading unit is configured to: determine a second address according to the target power; read an index value stored at the second address in an index memory; wherein the index memory has the target value of second storage units;

[0272] The second reading unit is configured to: determine the first address according to the index value, and read the value of the rotation factor stored at the first address in the rotation factor memory; wherein the rotation factor memory includes a first number of first storage units, and the first number is the number of different modular multiplication results generated by the factor of the first digit and the factor of the second digit; the first number is less than the target value.

[0273] The above device can be implemented in the form of software, hardware or a combination of software and hardware.

[0274] In addition, according to an embodiment of another aspect, a computing device is also provided, including a memory and a processor, wherein the memory stores executable code, and when the processor executes the executable code, the aforementioned rotation factor storage method and / or rotation factor reading method is implemented.

[0275] Those skilled in the art should be aware that in one or more of the above examples, the functions described in the present invention can be implemented by hardware, software, firmware or any combination thereof. When implemented by software, these functions can be stored in a computer-readable medium or transmitted as one or more instructions or codes on a computer-readable medium.

[0276] The specific implementation methods described above further illustrate the objectives, technical solutions and beneficial effects of the present invention in detail. It should be understood that the above description is only a specific implementation method of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc. made on the basis of the technical solution of the present invention should be included in the scope of protection of the present invention.

Claims

1. A method for storing a rotation factor in a target transform, wherein the target transform is a discrete transform or an inverse transform thereof that transforms an input coefficient sequence into an output coefficient sequence based on the rotation factor; The method comprises: Determine a target rotation factor to be stored, where the power of the target rotation factor is a result of multiplying a first factor of a first digit by a second factor of a second digit modulo a target value; The target rotation factor is stored in a secondary storage manner, and the secondary storage manner includes: Storing the target twiddle factor at a first address in a twiddle factor memory, wherein the twiddle factor memory includes a first number of first storage units, the first number being the number of different modular multiplication results generated by the factors of the first digit and the factors of the second digit; An index value pointing to the first address is stored at a second address in an index memory, wherein the index memory includes the target value second storage units, the second address corresponds to a power of the target rotation factor; and the target value is greater than the first number.

2. The method according to claim 1, wherein: The bit width of the first storage unit is the first number of bits required for the target rotation factor; the bit width of the second storage unit is the second number of bits required for the index value, and the ratio of the second number of bits to the first number of bits is less than a preset value.

3. The method according to claim 1, wherein: The target rotation factor is a rotation factor used for performing inter-combination multiplication when an n-order target transformation is decomposed into a combination of two low-order transformations of (np) order and p order at a decomposition point p, and the first factor and the second factor are obtained by performing first and second linear processing based on coefficient indices of p bits and (np) bits, respectively; The target value is determined according to the target transformation type.

4. The method according to claim 3, wherein: The target transformation is a fast Fourier transform FFT, the first and second linear processing are both identity transformations, and the target value is 2 to the power of n-2.

5. The method according to claim 3, wherein: The target transformation is a fast number theoretic transformation NTT, the first and second linear processing are both identity transformations, and the target value is 2 to the power of n-1.

6. The method according to claim 3, wherein: The target transformation is the NTTP transformation obtained by fusing the preprocessing with the fast number theory transformation NTT in the negative wrapping convolution NWC, the first linear processing is the identity transformation, the second linear processing defines the second factor as 2*x+1, where x represents the coefficient index of (np) bits, and the target value is 2 to the power of n.

7. The method according to claim 3, wherein: The target transformation is the INTTP transformation obtained by fusing the inverse fast number theory transformation INTT with post-processing in the negative wrapping convolution NWC. The first linear processing defines the first factor as 2*x+1, where x represents the coefficient index of p bits; the second linear processing is an identity transformation, and the target value is the nth power of 2.

8. The method according to claim 3, wherein: The target rotation factor is a rotation factor in a target decomposition mode with minimum storage cost for the K-point input coefficient sequence to be processed; The target decomposition method is determined by the following steps: Determine a plurality of candidate decomposition points in the k-bit coefficient index corresponding to the K-point input coefficient sequence, where K is 2 raised to the kth power; Starting from the low-order decomposition point, for each candidate decomposition point in turn, according to the decomposition cost evaluation function, through recursive decomposition of several levels of index bits, the minimum storage cost under each candidate decomposition point is determined, thereby determining the target decomposition method with the minimum storage cost; wherein the decomposition cost evaluation function defines that for the n-order target transformation, the storage cost under the decomposition point p includes the storage cost of the (np)-order first transformation, the storage cost of the p-order second transformation, and the local storage cost of storing the inter-level rotation factors through the secondary storage method, wherein the first transformation and the second transformation are each the target transformation or its corresponding base transformation, and the local storage cost includes the storage cost of the rotation factor memory and the storage cost of the index memory.

9. The method according to claim 8, wherein: The target transform is a fast Fourier transform FFT, the first transform and the second transform are both target transforms; the storage cost of the first-order target transform is initialized to 0.

10. The method according to claim 8, wherein: The target transformation is a fast number theoretic transformation NTT, the first transformation and the second transformation are both target transformations; and the storage cost of the first-order target transformation is initialized to 0.

11. The method according to claim 8, wherein: The target transformation is the NTTP transformation obtained by fusing the preprocessing with the fast number theory transformation NTT in the negative wrapping convolution NWC; the first transformation is the target transformation, and the second transformation is the NTT transformation; the storage cost of the first-order target transformation is initialized to 1.

12. The method according to claim 8, wherein: The target transformation is the INTTP transformation obtained by fusing the inverse fast number theory transformation INTT with post-processing in the negative wrapping convolution NWC; the first transformation is the INTT transformation, and the second transformation is the target transformation; the storage cost of the first-order target transformation is initialized to 1.

13. A method for reading a rotation factor in a target transform, wherein the target transform is a discrete transform or an inverse transform thereof that transforms an input coefficient sequence into an output coefficient sequence based on the rotation factor; The method comprises: Determine a target power of the rotation factor to be read, the target power being a result of multiplying a first factor of the first digit by a second factor of the second digit modulo a target value; Determine a second address according to the target power; read the index value stored at the second address in the index memory; wherein the index memory has the target value of second storage units; A first address is determined according to the index value, and the value of the rotation factor stored at the first address in the rotation factor memory is read; wherein the rotation factor memory includes a first number of first storage units, and the first number is the number of different modular multiplication results generated by the factor of the first digit and the factor of the second digit; and the first number is less than the target value.

14. A device for storing a rotation factor in a target transform, wherein the target transform is a discrete transform or an inverse transform thereof that transforms an input coefficient sequence into an output coefficient sequence based on the rotation factor; The device comprises: a determining unit configured to determine a target rotation factor to be stored, wherein the power of the target rotation factor is a result of multiplying a first factor of a first digit by a second factor of a second digit modulo a target value; A storage unit is configured to store the target rotation factor in a secondary storage manner, wherein the secondary storage manner includes: Storing the target twiddle factor at a first address in a twiddle factor memory, wherein the twiddle factor memory includes a first number of first storage units, the first number being the number of different modular multiplication results generated by the factors of the first digit and the factors of the second digit; An index value pointing to the first address is stored at a second address in an index memory, wherein the index memory includes the target value second storage units, the second address corresponds to a power of the target rotation factor; and the target value is greater than the first number.

15. A device for reading a rotation factor in a target transform, wherein the target transform is a discrete transform or an inverse transform thereof that transforms an input coefficient sequence into an output coefficient sequence based on the rotation factor; The device comprises: a determining unit configured to determine a target power of a rotation factor to be read, wherein the target power is a result of multiplying a first factor of a first digit by a second factor of a second digit modulo a target value; A first reading unit is configured to: determine a second address according to the target power; read an index value stored at the second address in an index memory; wherein the index memory has the target value of second storage units; The second reading unit is configured to: determine the first address according to the index value, and read the value of the rotation factor stored at the first address in the rotation factor memory; wherein the rotation factor memory includes a first number of first storage units, and the first number is the number of different modular multiplication results generated by the factor of the first digit and the factor of the second digit; the first number is less than the target value.

16. A computing device comprising a memory and a processor, characterized in that: The memory stores executable codes, and when the processor executes the executable codes, the method according to any one of claims 1 to 13 is implemented.

Citation Information

Patent Citations

  • Quick Fourier transformation implementation device and method

    CN103970718A

  • Number theory transformation circuit for large number multiplication

    CN111221501A

  • Iterative NTT staggered storage system based on BRAM

    CN116679905A

  • Method and apparatus for constructing processing circuit for target transformation

    CN119719591A

  • Fast fourier transform apparatus for outputting data in repositioned order

    KR1020120100197A

Cited By

  • Method and apparatus for constructing processing circuit for target transformation

    CN119719591A

  • Method and apparatus for constructing processing circuitry for target transform

    CN119719591B