Istft
Applicable Products
|
Hardware Model |
Supported or Not |
|---|---|
|
|
Not supported |
|
|
Not supported |
|
|
Not supported |
|
|
Supported |
|
|
Not supported |
Function Description
API function
- asdFftIstftMakePlan: initializes the istft configuration corresponding to the handle.
- asdFftExecIstft: performs inverse short-time Fourier transform.
Formula
istft is used to perform inverse short-time Fourier transform. It converts the frequency domain data obtained by stft into time domain signals, which is the inverse operation of stft. The short-time Fourier transform is reversible. This means that an original signal can be restored by using the inverse short-distance Fourier transform. The overlap-add method is used as the most widely accepted inverse short-distance Fourier transform method. 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.

The overlap-add method features block convolution and sectioned convolution. It can effectively compute the discrete convolution of a long signal x[n] and an FIR filter h[n].

The value of h [m] is 0 outside [1, M].
Function Prototype
- AspbStatus asdFftIstftMakePlan(asdFftHandle handle, const aclTensor *input, const int64_t nFft,const int64_t hopLengthOpt, const int64_t winLengthOpt,const bool center, const bool normalized, const bool onesidedOpt,const int64_t lengthOpt, const bool returnComplex)
- AspbStatus asdFftExecIstft(asdFftHandle handle, const aclTensor *input, const aclTensor *windowOpt, const aclTensor *output)
Parameter Description
- asdFftIstftMakePlan
Parameter
Input/Output
Type
Description
handle
Input
asdFftHandle
Handle of the FFT operator. You need to manually create the asdFftHandle object.
input
Input
aclTensor *
x in the formula, which indicates the tensor on the device. The data format can be ND. The expected format is the same as that of the stft output.
Data type: Only COMPELX64 is supported.
shape: (B, N, T)
In the preceding information:
- B indicates the batch processing dimension.
- N indicates the number of frequency samples. If onesided is true, the input is (n_fft // 2) + 1. Otherwise, the input is n_fft.
- T indicates the number of frames. For the stft with central padding, the value is 1 + length // hop_length. Otherwise, the value is 1 + (length - n_fft) // hop_length.
nFft
Input
int64_t
Size of Fourier transform.
hopLengthOpt
Input
int64_t
Distance between adjacent sliding window frames. The value is of the 0 < hopLengthOpt <= nFft type.
winLengthOpt
Input
int64_t
Window frame length. The value is of the winLengthOpt = nFft type.
center
Input
bool
Whether padding is performed on both sides of the input. The default value is true. The current version only allows the value true.
normalized
Input
bool
Whether STFT is standardized. The default value is false. The current version only allows the value false.
onesidedOpt
Input
bool
Whether STFT is one-sided. The default value is false. The current version only allows the value false.
lengthOpt
Input
int64_t
The amount of the signal to be pruned (that is, the length of the original signal). For the stft with central padding, the default value is (T – 1) * hop_length. Otherwise, the default value is n_fft + (T – 1) * hop_length, where T indicates the number of input frames.
This parameter is not supported in the current version. The default value is 0.
returnComplex
Input
bool
Whether the output should be complex. The default value is True. The current only allows the value True.
- asdFftExecIstft
Parameter
Input/Output
Type
Description
handle
Input
asdFftHandle
Handle of the FFT operator. You need to manually create the asdFftHandle object.
input
Input
aclTensor *
X in the formula, which indicates the tensor on the device. The data format can be ND. The expected format is the same as that of the stft output.
Data type: Only COMPELX64 is supported.
shape: (B, N, T)
In the preceding information:
- B indicates the batch processing dimension.
- N indicates the number of frequency samples. If onesided is true, the input is (n_fft // 2) + 1. Otherwise, the input is n_fft.
- T indicates the number of frames. For the stft with central padding, the value is 1 + length // hop_length. Otherwise, the value is 1 + (length - n_fft) // hop_length.
windowOpt
Input
aclTensor *
w in the formula, which is a tensor on the device. The data format can be ND.
shape: [win_length]
Data type: float
output
Output
aclTensor *
Tensor on the device. The data format can be ND.
shape: 2D, (B, length)
Data type: COMPLEX64
Return Value Description
For details about the return values, see Return Value.
Constraints
Local update is not supported in istft. That is, the input tensor and output tensor cannot be the same tensor.
▪ To ensure that the istft can correctly reconstruct signals, the n_fft, hop_length, win_length, window, center, and normalized parameters must be the same as those used for stft transformation.
•The input elements cannot be inf, -inf, or nan. If the input contains these values, the result is undefined.
- asdFftIstftMakePlan
•The value of nFft must be less than or equal to 1500, and the prime factors after factorization must not exceed 199.
▪ Because the corresponding function has not been implemented, when nFft 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.
▪ hopLengthOpt <= 1500
- asdFftExecIstft
•The tensor value of windowOpt cannot be close to zero. Otherwise, the result is undefined.
Calling Example
For details about the operator calling example, see Istft.