Compute Library
 19.08
CLFFT2D Class Reference

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

#include <CLFFT2D.h>

Collaboration diagram for CLFFT2D:
[legend]

Public Member Functions

 CLFFT2D (std::shared_ptr< IMemoryManager > memory_manager=nullptr)
 Default Constructor. More...
 
void configure (const ICLTensor *input, ICLTensor *output, const FFT2DInfo &config)
 Initialise the function's source, destinations and border mode. 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 CLFFT2D. More...
 

Detailed Description

Basic function to execute two dimensional FFT.

This function calls the following OpenCL kernels:

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

Definition at line 44 of file CLFFT2D.h.

Constructor & Destructor Documentation

◆ CLFFT2D()

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

Default Constructor.

Definition at line 32 of file CLFFT2D.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 ICLTensor input,
ICLTensor output,
const FFT2DInfo config 
)

Initialise the function's source, destinations and border mode.

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 CLFFT2D.cpp.

38 {
39  ARM_COMPUTE_ERROR_ON_NULLPTR(input, output);
40  ARM_COMPUTE_ERROR_THROW_ON(CLFFT2D::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 }
void configure(const ICLTensor *input, ICLTensor *output, const FFT1DInfo &config)
Initialise the function's source, destinations and border mode.
Definition: CLFFT1D.cpp:38
CLTensorAllocator * allocator()
Return a pointer to the tensor's allocator.
Definition: CLTensor.cpp:55
#define ARM_COMPUTE_ERROR_THROW_ON(status)
Definition: Error.h:327
void manage(TensorType *obj)
Sets a object to be managed by the given memory group.
void allocate() override
Allocate size specified by TensorInfo of OpenCL memory.
#define ARM_COMPUTE_ERROR_ON_NULLPTR(...)
Definition: Validate.h:161
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 CLFFT2D.
Definition: CLFFT2D.cpp:57

References CLTensorAllocator::allocate(), CLTensor::allocator(), ARM_COMPUTE_ERROR_ON_NULLPTR, ARM_COMPUTE_ERROR_THROW_ON, FFT2DInfo::axes, FFT1DInfo::axis, CLFFT1D::configure(), FFT1DInfo::direction, FFT2DInfo::direction, ITensor::info(), MemoryGroupBase< TensorType >::manage(), and CLFFT2D::validate().

Referenced by CLFFTConvolutionLayer::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 CLFFT2D.cpp.

87 {
88  MemoryGroupResourceScope scope_mg(_memory_group);
89 
90  _first_pass_func.run();
91  _second_pass_func.run();
92 }
void run() override
Run the kernels contained in the function.
Definition: CLFFT1D.cpp:125

References CLFFT1D::run().

Referenced by CLFFTConvolutionLayer::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 CLFFT2D.

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 CLFFT2D.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(CLFFT1D::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(CLFFT1D::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
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 CLFFT1D.
Definition: CLFFT1D.cpp:100
#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

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 CLFFT1D::validate().

Referenced by CLFFT2D::configure().


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