Compute Library
 19.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...
 
- 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 937 of file NEFFTRadixStageKernel.cpp.

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

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

986 {
988 
989  // Output auto inizialitation if not yet initialized
990  if(output != nullptr)
991  {
992  auto_init_if_empty(*output->info(), *input->info()->clone());
993  }
994 
995  ARM_COMPUTE_ERROR_THROW_ON(validate_arguments(input->info(), (output != nullptr) ? output->info() : nullptr, config));
996 
997  _input = input;
998  _output = output;
999  _run_in_place = (output == nullptr) || (output == input);
1000  _Nx = config.Nx;
1001  _axis = config.axis;
1002  _radix = config.radix;
1003 
1004  switch(config.axis)
1005  {
1006  case 0:
1007  set_radix_stage_axis0(config);
1008  break;
1009  case 1:
1010  set_radix_stage_axis1(config);
1011  break;
1012  default:
1013  ARM_COMPUTE_ERROR("Axis not supported");
1014  break;
1015  }
1016 
1017  // Configure kernel window
1018  auto win_config = validate_and_configure_window(input->info(), (_run_in_place) ? nullptr : output->info(), config);
1019  ARM_COMPUTE_ERROR_THROW_ON(win_config.first);
1020  INEKernel::configure(win_config.second);
1021 }
#define ARM_COMPUTE_ERROR(...)
Print the given message then throw an std::runtime_error.
Definition: Error.h:261
std::pair< Status, Window > validate_and_configure_window(ITensorInfo *input, ITensorInfo *weights, ITensorInfo *biases, ITensorInfo *output, const PadStrideInfo &conv_info, unsigned int depth_multiplier, const Size2D &dilation)
#define ARM_COMPUTE_ERROR_THROW_ON(status)
Definition: Error.h:327
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...
Definition: Helpers.inl:201
#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, ICloneable< T >::clone(), ITensor::info(), FFTRadixStageKernelInfo::Nx, FFTRadixStageKernelInfo::radix, and arm_compute::validate_and_configure_window().

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

Implements ICPPKernel.

Definition at line 1040 of file NEFFTRadixStageKernel.cpp.

1041 {
1045 
1046  Window input_window = window;
1047  input_window.set(_axis, 0);
1048 
1049  Iterator in(_input, input_window);
1050  Iterator out(_run_in_place ? _input : _output, input_window);
1051 
1052  // Precompute FFT constants
1053  const unsigned int NxRadix = _radix * _Nx;
1054  const float alpha = 2.0f * kPi / float(NxRadix);
1055  const float32x2_t w_m{ cosf(alpha), -sinf(alpha) };
1056 
1057  if(_axis == 0)
1058  {
1059  const unsigned int N = _input->info()->dimension(0);
1060  execute_window_loop(input_window, [&](const Coordinates &)
1061  {
1062  _func_0(reinterpret_cast<float *>(out.ptr()), reinterpret_cast<float *>(in.ptr()), _Nx, NxRadix, w_m, N);
1063  },
1064  in, out);
1065  }
1066  else
1067  {
1068  const unsigned int N = _input->info()->dimension(0);
1069  const unsigned int M = _input->info()->dimension(1);
1070  execute_window_loop(input_window, [&](const Coordinates &)
1071  {
1072  _func_1(reinterpret_cast<float *>(out.ptr()), reinterpret_cast<float *>(in.ptr()), _Nx, NxRadix, w_m, N, M);
1073  },
1074  in, out);
1075  }
1076 
1079 }
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.
#define ARM_COMPUTE_UNUSED(...)
To avoid unused variables warnings.
Definition: Error.h:160
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:48
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:122
#define ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW(f, s)
Definition: Validate.h:205
#define ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(k)
Definition: Validate.h:940

References arm_compute::test::validation::alpha, 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, 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 1035 of file NEFFTRadixStageKernel.cpp.

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

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

1024 {
1025  const bool run_in_place = (output == nullptr) || (output == input);
1026  ARM_COMPUTE_RETURN_ON_ERROR(validate_arguments(input, output, config));
1028  (run_in_place) ? nullptr : output->clone().get(),
1029  config)
1030  .first);
1031 
1032  return Status{};
1033 }
std::pair< Status, Window > validate_and_configure_window(ITensorInfo *input, ITensorInfo *weights, ITensorInfo *biases, ITensorInfo *output, const PadStrideInfo &conv_info, unsigned int depth_multiplier, const Size2D &dilation)
#define ARM_COMPUTE_RETURN_ON_ERROR(status)
Checks if a status contains an error and returns it.
Definition: Error.h:193

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


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