Compute Library
 19.08
NEFFT2D Class Reference

Basic function to execute two dimensional FFT. More...

#include <NEFFT2D.h>

Collaboration diagram for NEFFT2D:
[legend]

Public Member Functions

 NEFFT2D (std::shared_ptr< IMemoryManager > memory_manager=nullptr)
 Default Constructor. More...
 
void configure (const ITensor *input, ITensor *output, const FFT2DInfo &config)
 Initialise the function's source and destinations. More...
 
void run () override
 Run the kernels contained in the function. More...
 
- Public Member Functions inherited from IFunction
virtual ~IFunction ()=default
 Destructor. More...
 
virtual void prepare ()
 Prepare the function for executing. More...
 

Static Public Member Functions

static Status validate (const ITensorInfo *input, const ITensorInfo *output, const FFT2DInfo &config)
 Static function to check if given info will lead to a valid configuration of NEFFT2D. More...
 

Detailed Description

Basic function to execute two dimensional FFT.

This function calls the following NEON kernels:

  1. NEFFT1D 1D FFT is performed on the first given axis
  2. NEFFT1D 1D FFT is performed on the second given axis

Definition at line 44 of file NEFFT2D.h.

Constructor & Destructor Documentation

◆ NEFFT2D()

NEFFT2D ( std::shared_ptr< IMemoryManager memory_manager = nullptr)

Default Constructor.

Definition at line 32 of file NEFFT2D.cpp.

33  : _memory_group(memory_manager), _first_pass_func(memory_manager), _second_pass_func(memory_manager), _first_pass_tensor()
34 {
35 }

Member Function Documentation

◆ configure()

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

Initialise the function's source and destinations.

Parameters
[in]inputSource tensor. Data types supported: F32.
[out]outputDestination tensor. Data types and data layouts supported: Same as input.
[in]configFFT related configuration

Definition at line 37 of file NEFFT2D.cpp.

38 {
39  ARM_COMPUTE_ERROR_ON_NULLPTR(input, output);
40  ARM_COMPUTE_ERROR_THROW_ON(NEFFT2D::validate(input->info(), output->info(), config));
41 
42  // Setup first pass
43  FFT1DInfo first_pass_config;
44  first_pass_config.axis = config.axes.first;
45  first_pass_config.direction = config.direction;
46  _memory_group.manage(&_first_pass_tensor);
47  _first_pass_func.configure(input, &_first_pass_tensor, first_pass_config);
48 
49  // Setup second pass
50  FFT1DInfo second_pass_config;
51  second_pass_config.axis = config.axes.second;
52  second_pass_config.direction = config.direction;
53  _second_pass_func.configure(&_first_pass_tensor, output, second_pass_config);
54  _first_pass_tensor.allocator()->allocate();
55 }
#define ARM_COMPUTE_ERROR_THROW_ON(status)
Definition: Error.h:327
TensorAllocator * allocator()
Return a pointer to the tensor's allocator.
Definition: Tensor.cpp:48
void manage(TensorType *obj)
Sets a object to be managed by the given memory group.
void configure(const ITensor *input, ITensor *output, const FFT1DInfo &config)
Initialise the function's source and destinations.
Definition: NEFFT1D.cpp:38
void allocate() override
Allocate size specified by TensorInfo of CPU memory.
static Status validate(const ITensorInfo *input, const ITensorInfo *output, const FFT2DInfo &config)
Static function to check if given info will lead to a valid configuration of NEFFT2D.
Definition: NEFFT2D.cpp:57
#define ARM_COMPUTE_ERROR_ON_NULLPTR(...)
Definition: Validate.h:161

References TensorAllocator::allocate(), Tensor::allocator(), ARM_COMPUTE_ERROR_ON_NULLPTR, ARM_COMPUTE_ERROR_THROW_ON, FFT2DInfo::axes, FFT1DInfo::axis, NEFFT1D::configure(), FFT1DInfo::direction, FFT2DInfo::direction, ITensor::info(), MemoryGroupBase< TensorType >::manage(), and NEFFT2D::validate().

Referenced by NEFFTConvolutionLayer::configure().

◆ run()

void run ( )
overridevirtual

Run the kernels contained in the function.

For NEON kernels:

  • Multi-threading is used for the kernels which are parallelisable.
  • By default std::thread::hardware_concurrency() threads are used.
Note
CPPScheduler::set_num_threads() can be used to manually set the number of threads

For OpenCL kernels:

  • All the kernels are enqueued on the queue associated with CLScheduler.
  • The queue is then flushed.
Note
The function will not block until the kernels are executed. It is the user's responsibility to wait.
Will call prepare() on first run if hasn't been done

Implements IFunction.

Definition at line 86 of file NEFFT2D.cpp.

87 {
88  _memory_group.acquire();
89 
90  _first_pass_func.run();
91  _second_pass_func.run();
92 
93  _memory_group.release();
94 }
void acquire() override
Acquires backing memory for the whole group.
void run() override
Run the kernels contained in the function.
Definition: NEFFT1D.cpp:127
void release() override
Releases backing memory of the whole group.

References MemoryGroupBase< TensorType >::acquire(), MemoryGroupBase< TensorType >::release(), and NEFFT1D::run().

Referenced by NEFFTConvolutionLayer::run().

◆ validate()

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

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

Parameters
[in]inputSource tensor info. Data types supported: F32.
[in]outputDestination tensor info. Data types and data layouts supported: Same as input.
[in]configFFT related configuration
Returns
a status

Definition at line 57 of file NEFFT2D.cpp.

58 {
60 
61  // Create intermediate tensor info
62  TensorInfo first_pass_tensor(input->clone()->set_is_resizable(true).reset_padding().set_num_channels(2));
63 
64  // Validate first pass
65  FFT1DInfo first_pass_config;
66  first_pass_config.axis = config.axes.first;
67  first_pass_config.direction = config.direction;
68  ARM_COMPUTE_RETURN_ON_ERROR(NEFFT1D::validate(input, &first_pass_tensor, first_pass_config));
69 
70  // Validate second pass
71  FFT1DInfo second_pass_config;
72  second_pass_config.axis = config.axes.second;
73  second_pass_config.direction = config.direction;
74  ARM_COMPUTE_RETURN_ON_ERROR(NEFFT1D::validate(&first_pass_tensor, output, second_pass_config));
75 
76  // Checks performed when output is configured
77  if((output != nullptr) && (output->total_size() != 0))
78  {
81  }
82 
83  return Status{};
84 }
#define ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES(...)
Definition: Validate.h:545
#define ARM_COMPUTE_RETURN_ON_ERROR(status)
Checks if a status contains an error and returns it.
Definition: Error.h:193
#define ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_SHAPES(...)
Definition: Validate.h:443
#define ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR(...)
Definition: Validate.h:163
static Status validate(const ITensorInfo *input, const ITensorInfo *output, const FFT1DInfo &config)
Static function to check if given info will lead to a valid configuration of NEFFT1D.
Definition: NEFFT1D.cpp:101

References ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES, ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_SHAPES, ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR, ARM_COMPUTE_RETURN_ON_ERROR, FFT2DInfo::axes, FFT1DInfo::axis, ICloneable< T >::clone(), FFT1DInfo::direction, FFT2DInfo::direction, ITensorInfo::total_size(), and NEFFT1D::validate().

Referenced by NEFFT2D::configure().


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