FFT Common APIs

asdFftCreate

Function: This API is used to register an FFT handle.

Prototype: AspbStatus asdFftCreate(asdFftHandle &handle)

Parameter description:

Parameter

Input/Output

Type

Description

handle

Input

asdFftHandle

Handle of the asdFftCreate API.

asdFftSetStream

Function: This API is used to bind an NPU to execute a flow.

Prototype: AspbStatus asdFftSetStream(asdFftHandle handle, void *stream)

Parameter description:

Parameter

Input/Output

Type

Description

handle

Input

asdFftHandle

Handle of the asdFftSetStream API.

stream

Input

void*

Stream object.

asdFftGetWorkspaceSize

Function: This API is used to compute the size of the workspace required by an FFT execution flow in the current plan.

Prototype: AspbStatus asdFftGetWorkspaceSize(asdFftHandle handle, size_t &workSize)

Parameter description:

Parameter

Input/Output

Type

Description

handle

Input

asdFftHandle

Handle of the asdFftGetWorkspaceSize API.

workSize

Input

size_t

Size of the required workspace.

asdFftSetWorkspace

Function: This API is used to configure the workspace required for the FFT calculation process bound to the current handle.

Prototype: AspbStatus asdFftSetWorkspace(asdFftHandle handle, void *workspace)

Parameter description:

Parameter

Input/Output

Type

Description

handle

Input

asdFftHandle

Handle of the asdFftSetWorkspace API.

workspace

Input

void *

Pointer to a workspace.

asdFftSynchronize

Function: This API is used to synchronize the NPU status.

Prototype: AspbStatus asdFftSynchronize(asdFftHandle handle)

Parameter description:

Parameter

Input/Output

Type

Description

handle

Input

asdFftHandle

Handle of the asdFftSynchronize API.

asdFftGetType

Function: This API is used to return the FFT calculation type bound to the current handle. The options are ASCEND_FFT_C2C, ASCEND_FFT_C2R, and ASCEND_FFT_R2C.

Prototype: AspbStatus asdFftGetType(asdFftHandle handle, asdFftType &fftType)

Parameter description:

Parameter

Input/Output

Type

Description

handle

Input

asdFftHandle

Indicates the handle of the asdFftGetType API.

fftType

Input

asdFftType

Receives FFT values.

asdFftDestroy

Function: This API is used to destroy a handle and release the space occupied by the handle.

Prototype: AspbStatus asdFftDestroy(asdFftHandle handle)

Parameter description:

Parameter

Input/Output

Type

Description

handle

Input

asdFftHandle

Handle of the asdFftDestroy API.

To use an FFT operator, you need to create a handle, call the plan API of the corresponding operator to initialize the operator configuration corresponding to the handle and bind the handle, call the FFT common API asdFftGetWorkspaceSize to obtain the workspace size required for computation and the executor that contains the operator calculation process, call asdFftSetWorkspace to set the workspace for the corresponding plan, and call the FFT operator API to perform calculation. After the calculation is complete, destroy the plan to prevent memory leakage.