FFT_2D
Applicable Products
|
Hardware Model |
Supported or Not |
|---|---|
|
|
Not supported |
|
|
Not supported |
|
|
Not supported |
|
|
Supported |
|
|
Supported |
Function Description
API function
- asdFftMakePlan2D: Initializes the 2D FFT configuration.
- asdFftExecC2C: performs FFT from a complex number to another complex number.
- asdFftExecC2R: performs FFT from a complex number to a real number.
- asdFftExecR2C: performs FFT from a real number to a complex number.
Formula
Fourier transform indicates a linear integral transform. It is used to transform signals between the time domain and the frequency domain. It is widely used in physics and engineering. For a signal with a given length of N, the DFT formula is as follows:

The coefficient matrix (N*N) and time-domain signal (N*1) are considered as two tensors. DFT can be completed by directly using matrix multiplication on the NPU. However, the time complexity is too high. Therefore, FFT is required. The basic principle is to split a sequence into sub-sequences by using the rotation symmetry of trigonometric functions in the complex domain. The butterfly operation is performed to reduce calculation complexity.

Function Prototype
- AspbStatus asdFftMakePlan2D(asdFftHandle handle, int64_t fftSizeX, int64_t fftSizeY, asdFftType fftType, asdFftDirection direction, int32_t batchSize)
- AspbStatus asdFftExecC2C(asdFftHandle handle, const aclTensor *input, const aclTensor *output)
- AspbStatus asdFftExecC2R(asdFftHandle handle, const aclTensor *input, const aclTensor *output)
- AspbStatus asdFftExecR2C(asdFftHandle handle, const aclTensor *input, const aclTensor *output)
Parameter Description
- asdFftMakePlan2D
Parameter
Input/Output
Type
Description
handle
Input
asdFftHandle
Handle of the FFT operator. You need to manually create the asdFftHandle object.
fftSizeX
Input
int64_t
M in the formula, which indicates the FFT signal length (the first dimension).
fftSizeY
Input
int64_t
N in the formula, which indicates the FFT signal length (the second dimension).
fftType
Input
asdFftType
FFT type. The options are as follows:
- ASCEND_FFT_C2C - ASCEND_FFT_C2R - ASCEND_FFT_R2Cdirection
Input
asdFftDirection
Forward transform or inverse transform:
- ASCEND_FFT_FORWARD - ASCEND_FFT_INVERSEbatchSize
Input
int32_t
Number of data batches in the FFT batch processing operation.
- asdFftExecC2C
Parameter
Input/Output
Type
Description
handle
Input
asdFftHandle
Handle of the FFT operator. You need to manually create the asdFftHandle object.
inData
Input
const aclTensor *
x in the formula, which is a tensor on the device. The data type can only be COMPELX64, the data format can be ND, and the input shape is (batchSize, fftSizeX, fftSizeY).
outData
Output
aclTensor *
y in the formula, which is a tensor on the device. The data type can only be COMPELX64, the data format can be ND, and the input shape is (batchSize, fftSizeX, fftSizeY).
- asdFftExecC2R
Parameter
Input/Output
Type
Description
handle
Input
asdFftHandle
Handle of the FFT operator. You need to manually create the asdFftHandle object.
inData
Input
const aclTensor *
x in the formula, which is a tensor on the device. The data type can only be COMPELX64, the data format can be ND, and the input shape is (batchSize, fftSizeX, fftSizeY/2+1).
outData
Output
aclTensor *
y in the formula, which is a tensor on the device. The data type can only be FLOAT32, the data format can be ND, and the input shape is (batchSize, fftSizeX, fftSizeY).
- asdFftExecR2C
Parameter
Input/Output
Type
Description
handle
Input
asdFftHandle
Handle of the FFT operator. You need to manually create the asdFftHandle object.
inData
Input
const aclTensor *
x in the formula, which is a tensor on the device. The data type can only be FLOAT32, the data format can be ND, and the input shape is (batchSize, fftSizeX, fftSizeY).
outData
Output
aclTensor *
y in the formula, which is a tensor on the device. The data type can only be COMPELX64, the data format can be ND, and the input shape is (batchSize, fftSizeX, fftSizeY/2+1).
Return Value Description
For details about the return values, see Return Value.
Constraints
Local update is not supported in FFT_2D. That is, the input tensor and output tensor cannot be the same tensor.
- asdFftMakePlan2D
- The values of fftSizeX and fftSizeY must be less than or equal to 2^27, and the prime factors after factorization must not be greater than 199.
- There is no additional restriction on batchSize within the storage scope.
- The theoretical range of the number of input elements is [1, 2^30].
- The input elements cannot be inf, -inf, or nan. If the input contains these values, the result is undefined.
- asdFftExecC2C
- asdFftExecC2R
- asdFftExecR2C
Calling Example
For details about the operator calling example, see FFT_2D.