Compute Library
 20.11
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 938 of file NEFFTRadixStageKernel.cpp.

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

◆ 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.

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 986 of file NEFFTRadixStageKernel.cpp.

987 {
989 
990  // Output auto inizialitation if not yet initialized
991  if(output != nullptr)
992  {
993  auto_init_if_empty(*output->info(), *input->info()->clone());
994  }
995 
996  ARM_COMPUTE_ERROR_THROW_ON(validate_arguments(input->info(), (output != nullptr) ? output->info() : nullptr, config));
997 
998  _input = input;
999  _output = output;
1000  _run_in_place = (output == nullptr) || (output == input);
1001  _Nx = config.Nx;
1002  _axis = config.axis;
1003  _radix = config.radix;
1004 
1005  switch(config.axis)
1006  {
1007  case 0:
1008  set_radix_stage_axis0(config);
1009  break;
1010  case 1:
1011  set_radix_stage_axis1(config);
1012  break;
1013  default:
1014  ARM_COMPUTE_ERROR("Axis not supported");
1015  break;
1016  }
1017 
1018  // Configure kernel window
1019  auto win_config = validate_and_configure_window(input->info(), (_run_in_place) ? nullptr : output->info(), config);
1020  ARM_COMPUTE_ERROR_THROW_ON(win_config.first);
1021  INEKernel::configure(win_config.second);
1022 }
#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

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

◆ name()

const char* name ( ) const
inlineoverridevirtual

Name of the kernel.

Returns
Kernel name

Implements ICPPKernel.

Definition at line 42 of file NEFFTRadixStageKernel.h.

43  {
44  return "NEFFTRadixStageKernel";
45  }

◆ operator=() [1/2]

NEFFTRadixStageKernel& operator= ( const NEFFTRadixStageKernel )
delete

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

◆ 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 1041 of file NEFFTRadixStageKernel.cpp.

1042 {
1046 
1047  Window input_window = window;
1048  input_window.set(_axis, 0);
1049 
1050  Iterator in(_input, input_window);
1051  Iterator out(_run_in_place ? _input : _output, input_window);
1052 
1053  // Precompute FFT constants
1054  const unsigned int NxRadix = _radix * _Nx;
1055  const float alpha = 2.0f * kPi / float(NxRadix);
1056  const float32x2_t w_m{ cosf(alpha), -sinf(alpha) };
1057 
1058  if(_axis == 0)
1059  {
1060  const unsigned int N = _input->info()->dimension(0);
1061  execute_window_loop(input_window, [&](const Coordinates &)
1062  {
1063  _func_0(reinterpret_cast<float *>(out.ptr()), reinterpret_cast<float *>(in.ptr()), _Nx, NxRadix, w_m, N);
1064  },
1065  in, out);
1066  }
1067  else
1068  {
1069  const unsigned int N = _input->info()->dimension(0);
1070  const unsigned int M = _input->info()->dimension(1);
1071  execute_window_loop(input_window, [&](const Coordinates &)
1072  {
1073  _func_1(reinterpret_cast<float *>(out.ptr()), reinterpret_cast<float *>(in.ptr()), _Nx, NxRadix, w_m, N, M);
1074  },
1075  in, out);
1076  }
1077 
1080 }
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'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

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(), arm_compute::test::validation::info, M, N, Iterator::ptr(), Window::set(), and IKernel::window().

◆ 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 1036 of file NEFFTRadixStageKernel.cpp.

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

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

◆ 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 1024 of file NEFFTRadixStageKernel.cpp.

1025 {
1026  const bool run_in_place = (output == nullptr) || (output == input);
1028  ARM_COMPUTE_RETURN_ON_ERROR(validate_and_configure_window(input->clone().get(),
1029  (run_in_place) ? nullptr : output->clone().get(),
1030  config)
1031  .first);
1032 
1033  return Status{};
1034 }
#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)

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


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