Compute Library
 21.02
NEFFTRadixStageKernel Class Reference

Interface for the FFT kernel. More...

#include <NEFFTRadixStageKernel.h>

Collaboration diagram for NEFFTRadixStageKernel:
[legend]

Public Member Functions

const char * name () const override
 Name of the kernel. More...
 
 NEFFTRadixStageKernel ()
 Constructor. More...
 
 NEFFTRadixStageKernel (const NEFFTRadixStageKernel &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
NEFFTRadixStageKerneloperator= (const NEFFTRadixStageKernel &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
 NEFFTRadixStageKernel (NEFFTRadixStageKernel &&)=default
 Default Move Constructor. More...
 
NEFFTRadixStageKerneloperator= (NEFFTRadixStageKernel &&)=default
 Default move assignment operator. More...
 
 ~NEFFTRadixStageKernel ()=default
 Default destructor. More...
 
void configure (ITensor *input, ITensor *output, const FFTRadixStageKernelInfo &config)
 Set the input and output tensors. More...
 
void run (const Window &window, const ThreadInfo &info) override
 Execute the kernel on the passed window. More...
 
- Public Member Functions inherited from ICPPKernel
virtual ~ICPPKernel ()=default
 Default destructor. More...
 
virtual void run_nd (const Window &window, const ThreadInfo &info, const Window &thread_locator)
 legacy compatibility layer for implemantions which do not support thread_locator In these cases we simply narrow the interface down the legacy version More...
 
virtual void run_op (ITensorPack &tensors, const Window &window, const ThreadInfo &info)
 Execute the kernel on the passed window. More...
 
- Public Member Functions inherited from IKernel
 IKernel ()
 Constructor. More...
 
virtual ~IKernel ()=default
 Destructor. More...
 
virtual bool is_parallelisable () const
 Indicates whether or not the kernel is parallelisable. More...
 
virtual BorderSize border_size () const
 The size of the border for that kernel. More...
 
const Windowwindow () const
 The maximum window the kernel can be executed on. More...
 

Static Public Member Functions

static Status validate (const ITensorInfo *input, const ITensorInfo *output, const FFTRadixStageKernelInfo &config)
 Static function to check if given info will lead to a valid configuration of NEFFTRadixStageKernel. More...
 
static std::set< unsigned int > supported_radix ()
 Returns the radix that are support by the FFT kernel. More...
 

Detailed Description

Interface for the FFT kernel.

Definition at line 39 of file NEFFTRadixStageKernel.h.

Constructor & Destructor Documentation

◆ NEFFTRadixStageKernel() [1/3]

Constructor.

Definition at line 939 of file NEFFTRadixStageKernel.cpp.

Referenced by NEFFTRadixStageKernel::name().

940  : _input(nullptr), _output(nullptr), _run_in_place(false), _Nx(0), _axis(0), _radix(0), _func_0(), _func_1()
941 {
942 }

◆ NEFFTRadixStageKernel() [2/3]

Prevent instances of this class from being copied (As this class contains pointers)

◆ NEFFTRadixStageKernel() [3/3]

Default Move Constructor.

◆ ~NEFFTRadixStageKernel()

~NEFFTRadixStageKernel ( )
default

Default destructor.

Referenced by NEFFTRadixStageKernel::name().

Member Function Documentation

◆ configure()

void configure ( ITensor input,
ITensor output,
const FFTRadixStageKernelInfo config 
)

Set the input and output tensors.

Note
If the output tensor is nullptr, the FFT will be performed in-place
Parameters
[in,out]inputSource tensor. Data types supported: F32. Number of channels supported: 2 (complex tensor).
[out]outputDestination tensor. Data type supported: same as input. Number of channels supported: same as input.
[in]configFFT descriptor metadata.

Definition at line 987 of file NEFFTRadixStageKernel.cpp.

References ARM_COMPUTE_ERROR, ARM_COMPUTE_ERROR_ON_NULLPTR, ARM_COMPUTE_ERROR_THROW_ON, arm_compute::auto_init_if_empty(), FFTRadixStageKernelInfo::axis, ICloneable< T >::clone(), ITensor::info(), arm_compute::test::validation::input, FFTRadixStageKernelInfo::Nx, FFTRadixStageKernelInfo::radix, and arm_compute::validate_arguments().

Referenced by NEFFTRadixStageKernel::name().

988 {
990 
991  // Output auto inizialitation if not yet initialized
992  if(output != nullptr)
993  {
994  auto_init_if_empty(*output->info(), *input->info()->clone());
995  }
996 
997  ARM_COMPUTE_ERROR_THROW_ON(validate_arguments(input->info(), (output != nullptr) ? output->info() : nullptr, config));
998 
999  _input = input;
1000  _output = output;
1001  _run_in_place = (output == nullptr) || (output == input);
1002  _Nx = config.Nx;
1003  _axis = config.axis;
1004  _radix = config.radix;
1005 
1006  switch(config.axis)
1007  {
1008  case 0:
1009  set_radix_stage_axis0(config);
1010  break;
1011  case 1:
1012  set_radix_stage_axis1(config);
1013  break;
1014  default:
1015  ARM_COMPUTE_ERROR("Axis not supported");
1016  break;
1017  }
1018 
1019  // Configure kernel window
1020  auto win_config = validate_and_configure_window(input->info(), (_run_in_place) ? nullptr : output->info(), config);
1021  ARM_COMPUTE_ERROR_THROW_ON(win_config.first);
1022  INEKernel::configure(win_config.second);
1023 }
#define ARM_COMPUTE_ERROR(msg)
Print the given message then throw an std::runtime_error.
Definition: Error.h:352
#define ARM_COMPUTE_ERROR_THROW_ON(status)
Definition: Error.h:455
bool auto_init_if_empty(ITensorInfo &info, const TensorShape &shape, int num_channels, DataType data_type, QuantizationInfo quantization_info=QuantizationInfo())
Auto initialize the tensor info (shape, number of channels and data type) if the current assignment i...
Status validate_arguments(const ITensorInfo *input, const ITensorInfo *bias, const ITensorInfo *output, const GEMMLowpOutputStageInfo *output_stage)
#define ARM_COMPUTE_ERROR_ON_NULLPTR(...)
Definition: Validate.h:161

◆ name()

◆ operator=() [1/2]

NEFFTRadixStageKernel& operator= ( const NEFFTRadixStageKernel )
delete

Prevent instances of this class from being copied (As this class contains pointers)

Referenced by NEFFTRadixStageKernel::name().

◆ operator=() [2/2]

NEFFTRadixStageKernel& operator= ( NEFFTRadixStageKernel &&  )
default

Default move assignment operator.

◆ run()

void run ( const Window window,
const ThreadInfo info 
)
overridevirtual

Execute the kernel on the passed window.

Warning
If is_parallelisable() returns false then the passed window must be equal to window()
Note
The window has to be a region within the window returned by the window() method
The width of the window has to be a multiple of num_elems_processed_per_iteration().
Parameters
[in]windowRegion on which to execute the kernel. (Must be a region of the window returned by window())
[in]infoInfo about executing thread and CPU.

Reimplemented from ICPPKernel.

Definition at line 1042 of file NEFFTRadixStageKernel.cpp.

References ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW, ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL, ARM_COMPUTE_UNUSED, ITensorInfo::dimension(), arm_compute::execute_window_loop(), ITensor::info(), Iterator::ptr(), Window::set(), and IKernel::window().

Referenced by NEFFTRadixStageKernel::name().

1043 {
1047 
1048  Window input_window = window;
1049  input_window.set(_axis, 0);
1050 
1051  Iterator in(_input, input_window);
1052  Iterator out(_run_in_place ? _input : _output, input_window);
1053 
1054  // Precompute FFT constants
1055  const unsigned int NxRadix = _radix * _Nx;
1056  const float alpha = 2.0f * kPi / float(NxRadix);
1057  const float32x2_t w_m{ cosf(alpha), -sinf(alpha) };
1058 
1059  if(_axis == 0)
1060  {
1061  const unsigned int N = _input->info()->dimension(0);
1062  execute_window_loop(input_window, [&](const Coordinates &)
1063  {
1064  _func_0(reinterpret_cast<float *>(out.ptr()), reinterpret_cast<float *>(in.ptr()), _Nx, NxRadix, w_m, N);
1065  },
1066  in, out);
1067  }
1068  else
1069  {
1070  const unsigned int N = _input->info()->dimension(0);
1071  const unsigned int M = _input->info()->dimension(1);
1072  execute_window_loop(input_window, [&](const Coordinates &)
1073  {
1074  _func_1(reinterpret_cast<float *>(out.ptr()), reinterpret_cast<float *>(in.ptr()), _Nx, NxRadix, w_m, N, M);
1075  },
1076  in, out);
1077  }
1078 
1081 }
unsigned int M
const Window & window() const
The maximum window the kernel can be executed on.
Definition: IKernel.cpp:28
virtual size_t dimension(size_t index) const =0
Return the size of the requested dimension.
unsigned int N
#define ARM_COMPUTE_UNUSED(...)
To avoid unused variables warnings.
Definition: Error.h:152
virtual ITensorInfo * info() const =0
Interface to be implemented by the child class to return the tensor&#39;s metadata.
void set(size_t dimension, const Dimension &dim)
Set the values of a given dimension.
Definition: Window.inl:49
#define ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(k)
Definition: Validate.h:941
ScaleKernelInfo info(interpolation_policy, default_border_mode, PixelValue(), sampling_policy, false)
void execute_window_loop(const Window &w, L &&lambda_function, Ts &&... iterators)
Iterate through the passed window, automatically adjusting the iterators and calling the lambda_funct...
Definition: Helpers.inl:77
#define ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW(f, s)
Definition: Validate.h:205

◆ supported_radix()

std::set< unsigned int > supported_radix ( )
static

Returns the radix that are support by the FFT kernel.

Returns
A set of supported radix

Definition at line 1037 of file NEFFTRadixStageKernel.cpp.

Referenced by NEFFT1D::configure(), NEFFTRadixStageKernel::name(), and NEFFT1D::validate().

1038 {
1039  return std::set<unsigned int> { 2, 3, 4, 5, 7, 8 };
1040 }

◆ validate()

Status validate ( const ITensorInfo input,
const ITensorInfo output,
const FFTRadixStageKernelInfo config 
)
static

Static function to check if given info will lead to a valid configuration of NEFFTRadixStageKernel.

Parameters
[in]inputSource tensor info. Data types supported: F32. Number of channels supported: 2 (complex tensor).
[in]outputDestination tensor info. Data type supported: same as input. Number of channels supported: same as input.
[in]configFFT descriptor metadata.
Returns
a status

Definition at line 1025 of file NEFFTRadixStageKernel.cpp.

References ARM_COMPUTE_RETURN_ON_ERROR, ICloneable< T >::clone(), and arm_compute::validate_arguments().

Referenced by NEFFTRadixStageKernel::name().

1026 {
1027  const bool run_in_place = (output == nullptr) || (output == input);
1029  ARM_COMPUTE_RETURN_ON_ERROR(validate_and_configure_window(input->clone().get(),
1030  (run_in_place) ? nullptr : output->clone().get(),
1031  config)
1032  .first);
1033 
1034  return Status{};
1035 }
#define ARM_COMPUTE_RETURN_ON_ERROR(status)
Checks if a status contains an error and returns it.
Definition: Error.h:204
Status validate_arguments(const ITensorInfo *input, const ITensorInfo *bias, const ITensorInfo *output, const GEMMLowpOutputStageInfo *output_stage)

The documentation for this class was generated from the following files: