Compute Library
 21.08
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...
 
bool is_window_configured () const
 Function to check if the embedded window of this kernel has been configured. 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 935 of file NEFFTRadixStageKernel.cpp.

References FFTRadixStageKernelInfo::is_first_stage, and FFTRadixStageKernelInfo::radix.

Referenced by NEFFTRadixStageKernel::name().

936  : _input(nullptr), _output(nullptr), _Nx(0), _axis(0), _radix(0), _func_0(), _func_1()
937 {
938 }

◆ 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 983 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, and FFTRadixStageKernelInfo::radix.

Referenced by NEFFTRadixStageKernel::name().

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

◆ 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 1037 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(), BorderSize::left, ITensorInfo::padding(), Iterator::ptr(), BorderSize::right, Window::set(), and IKernel::window().

Referenced by NEFFTRadixStageKernel::name().

1038 {
1042 
1043  Window input_window = window;
1044  input_window.set(_axis, 0);
1045 
1046  Iterator in(_input, input_window);
1047  Iterator out(_output, input_window);
1048 
1049  // Precompute FFT constants
1050  const unsigned int NxRadix = _radix * _Nx;
1051  const float alpha = 2.0f * kPi / float(NxRadix);
1052  const float32x2_t w_m{ cosf(alpha), -sinf(alpha) };
1053 
1054  if(_axis == 0)
1055  {
1056  const unsigned int N = _input->info()->dimension(0);
1057  execute_window_loop(input_window, [&](const Coordinates &)
1058  {
1059  _func_0(reinterpret_cast<float *>(out.ptr()), reinterpret_cast<float *>(in.ptr()), _Nx, NxRadix, w_m, N);
1060  },
1061  in, out);
1062  }
1063  else
1064  {
1065  const unsigned int N = _input->info()->dimension(0);
1066  const unsigned int M = _input->info()->dimension(1);
1067  execute_window_loop(input_window, [&](const Coordinates &)
1068  {
1069  _func_1(reinterpret_cast<float *>(out.ptr()), reinterpret_cast<float *>(in.ptr()), _Nx, NxRadix, w_m, N, M,
1070  _input->info()->padding().right + _input->info()->padding().left,
1071  _output->info()->padding().right + _output->info()->padding().left);
1072  },
1073  in, out);
1074  }
1075 
1078 }
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 M
#define ARM_COMPUTE_UNUSED(...)
To avoid unused variables warnings.
Definition: Error.h:152
unsigned int N
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
virtual PaddingSize padding() const =0
Padding of tensor.
unsigned int left
left of the border
Definition: Types.h:375
unsigned int right
right of the border
Definition: Types.h:373
#define ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(k)
Definition: Validate.h:915
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:201

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

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

1033 {
1034  return std::set<unsigned int> { 2, 3, 4, 5, 7, 8 };
1035 }

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

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

Referenced by NEFFTRadixStageKernel::name().

1021 {
1022  const bool run_in_place = (output == nullptr) || (output == input);
1023  ARM_COMPUTE_RETURN_ON_ERROR(validate_arguments(input, output, config));
1024  ARM_COMPUTE_RETURN_ON_ERROR(validate_and_configure_window(input->clone().get(),
1025  (run_in_place) ? nullptr : output->clone().get(),
1026  config)
1027  .first);
1028 
1029  return Status{};
1030 }
#define ARM_COMPUTE_RETURN_ON_ERROR(status)
Checks if a status contains an error and returns it.
Definition: Error.h:204

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