FFT_1D
Applicable Products
|
Hardware Model |
Supported or Not |
|---|---|
|
|
Not supported |
|
|
Not supported |
|
|
Not supported |
|
|
Supported |
|
|
Supported |
Function Description
API function
- asdFftMakePlan1D: initializes the FFT configuration corresponding to the handle.
- 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.
- asdFftExecC2CSeparated: performs FFT from a complex number to another complex number. The real and imaginary parts can be separately input and output.
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 Discrete Fourier Transform (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 asdFftMakePlan1D(asdFftHandle handle, int64_t fftSize, asdFftType fftType,asdFftDirection direction, int64_t batchSize,asdFft1dDimType dimType)
- 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)
- AspbStatus asdFftExecC2CSeparated(asdFftHandle handle, const aclTensor *inputReal, const aclTensor *inputImag,const aclTensor *outputReal, const aclTensor *outputImag)
Parameter Description
- asdFftMakePlan1D
Parameter
Input/Output
Type
Description
handle
Input
asdFftHandle
Handle of the FFT operator. You need to manually create the asdFftHandle object.
fftSize
Input
int64_t
N in the formula, which indicates the FFT signal length.
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
int64_t
Number of data batches in the FFT batch processing operation.
dimType
Input
asdFft1dDimType
Direction of the FFT_1D dimension (FFT by row or FFT by column):
- ASCEND_FFT_HORIZONTAL: horizontal FFT - ASCEND_FFT_VERTICAL: vertical FFT - 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 must be COMPLEX64, and the data format must be ND.
- For row-wise FFT, the input shape is (batchSize, fftSize).
- For column-wise FFT, the input shape is (fftSize, batchSize).
outData
Output
aclTensor *
y in the formula, which is a tensor on the device. The data type must be COMPLEX64, and the data format must be ND.
- For row-wise FFT, the input shape is (batchSize, fftSize).
- For column-wise FFT, the input shape is (fftSize, batchSize).
- 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 must be COMPLEX64, and the data format must be ND.
- For row-wise FFT, the input shape is (batchSize, fftSize/2 + 1).
- For column-wise FFT, the input shape is (fftSize/2 + 1, batchSize).
outData
Output
aclTensor *
y in the formula, which is a tensor on the device. The data type must be FLOAT32, and the data format must be ND.
- For row-wise FFT, the input shape is (batchSize, fftSize).
- For column-wise FFT, the input shape is (fftSize, batchSize).
- 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 must be FLOAT32, and the data format must be ND.
- For row-wise FFT, the input shape is (batchSize, fftSize).
- For column-wise FFT, the input shape is (fftSize, batchSize).
outData
Output
aclTensor *
y in the formula, which is a tensor on the device. The data type must be COMPLEX64, and the data format must be ND.
- For row-wise FFT, the input shape is (batchSize, fftSize/2 + 1).
- For column-wise FFT, the input shape is (fftSize/2 + 1, batchSize).
- asdFftExecC2CSeparated
AspbStatus asdFftExecC2CSeparated(asdFftHandle handle, const aclTensor *inputReal, const aclTensor *inputImag,const aclTensor *outputReal, const aclTensor *outputImag)
Parameter
Input/Output
Type
Description
handle
Input
asdFftHandle
Handle of the FFT operator. You need to manually create the asdFftHandle object.
inputReal
Input
const aclTensor *
The real part of x in the formula, which is the real part of the input. The data type can only be FLOAT32, the data format can be ND, and the input shape is (batchSize, fftSize).
inputImag
Input
const aclTensor *
The imaginary part of x in the formula, which is the imaginary part of the input. The data type can only be FLOAT32, the data format can be ND, and the input shape is (batchSize, fftSize).
outputReal
Output
const aclTensor *
The real part of y in the formula, which is the real part of the output. The data type can only be FLOAT32, the data format can be ND, and the input shape is (batchSize, fftSize).
outputImag
Output
const aclTensor *
The imaginary part of y in the formula, which is the imaginary part of the output. The data type can only be FLOAT32, the data format can be ND, and the input shape is (batchSize, fftSize).
Return Value Description
For details about the return values, see Return Value.
Constraints
Local update is not supported in FFT_1D. That is, the input tensor and output tensor cannot be the same tensor.
- asdFftMakePlan1D
- For horizontal FFT:
- The value of fftSize must be less than or equal to 2^27, and the prime factors after factorization must not exceed 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].
- Because the corresponding function has not been implemented, when the horizontal FFT input length (fftSize) is greater than or equal to 32768 and is a power of 2, the input data will be modified. Therefore, you need to back up the data in advance.
- For vertical FFT:
- The value of fftSize must be a power of 2 and greater than or equal to 256 and less than or equal to 65536.
- The value of batchSize must be an integer multiple of 128.
- 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.
- For horizontal FFT:
- asdFftExecC2C
- asdFftExecC2R
- asdFftExecR2C
- asdFftExecC2CSeparated
Calling Example
For details about the operator calling example, see FFT_1D.