Compute Library
 21.02
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...
 
 CLFFT2D (const CLFFT2D &)=delete
 Prevent instances of this class from being copied. More...
 
CLFFT2Doperator= (const CLFFT2D &)=delete
 Prevent instances of this class from being copied. More...
 
 CLFFT2D (CLFFT2D &&)=default
 Default move constructor. More...
 
CLFFT2Doperator= (CLFFT2D &&)=default
 Default move assignment operator. More...
 
 ~CLFFT2D ()
 Default destructor. More...
 
void configure (const ICLTensor *input, ICLTensor *output, const FFT2DInfo &config)
 Initialise the function's source, destinations and border mode. More...
 
void configure (const CLCompileContext &compile_context, 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() [1/3]

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

Default Constructor.

Definition at line 35 of file CLFFT2D.cpp.

References CLFFT2D::~CLFFT2D().

36  : _memory_group(memory_manager), _first_pass_func(memory_manager), _second_pass_func(memory_manager), _first_pass_tensor()
37 {
38 }

◆ CLFFT2D() [2/3]

CLFFT2D ( const CLFFT2D )
delete

Prevent instances of this class from being copied.

◆ CLFFT2D() [3/3]

CLFFT2D ( CLFFT2D &&  )
default

Default move constructor.

◆ ~CLFFT2D()

~CLFFT2D ( )
default

Default destructor.

Referenced by CLFFT2D::CLFFT2D().

Member Function Documentation

◆ configure() [1/2]

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: F16/F32.
[out]outputDestination tensor. Data types and data layouts supported: Same as input.
[in]configFFT related configuration

Definition at line 42 of file CLFFT2D.cpp.

References CLKernelLibrary::get().

Referenced by CLFFTConvolutionLayer::configure().

43 {
44  configure(CLKernelLibrary::get().get_compile_context(), input, output, config);
45 }
void configure(const ICLTensor *input, ICLTensor *output, const FFT2DInfo &config)
Initialise the function&#39;s source, destinations and border mode.
Definition: CLFFT2D.cpp:42
static CLKernelLibrary & get()
Access the KernelLibrary singleton.

◆ configure() [2/2]

void configure ( const CLCompileContext compile_context,
const ICLTensor input,
ICLTensor output,
const FFT2DInfo config 
)

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

Parameters
[in]compile_contextThe compile context to be used.
[in]inputSource tensor. Data types supported: F16/F32.
[out]outputDestination tensor. Data types and data layouts supported: Same as input.
[in]configFFT related configuration

Definition at line 47 of file CLFFT2D.cpp.

References CLTensorAllocator::allocate(), CLTensor::allocator(), ARM_COMPUTE_ERROR_ON_NULLPTR, ARM_COMPUTE_ERROR_THROW_ON, FFT1DInfo::axis, FFT2DInfo::axis0, FFT2DInfo::axis1, CLFFT1D::configure(), FFT1DInfo::direction, FFT2DInfo::direction, ITensor::info(), MemoryGroup::manage(), and CLFFT2D::validate().

48 {
50  ARM_COMPUTE_ERROR_THROW_ON(CLFFT2D::validate(input->info(), output->info(), config));
51 
52  // Setup first pass
53  FFT1DInfo first_pass_config;
54  first_pass_config.axis = config.axis0;
55  first_pass_config.direction = config.direction;
56  _memory_group.manage(&_first_pass_tensor);
57  _first_pass_func.configure(compile_context, input, &_first_pass_tensor, first_pass_config);
58 
59  // Setup second pass
60  FFT1DInfo second_pass_config;
61  second_pass_config.axis = config.axis1;
62  second_pass_config.direction = config.direction;
63  _second_pass_func.configure(compile_context, &_first_pass_tensor, output, second_pass_config);
64  _first_pass_tensor.allocator()->allocate();
65 }
void configure(const ICLTensor *input, ICLTensor *output, const FFT1DInfo &config)
Initialise the function&#39;s source, destinations and border mode.
Definition: CLFFT1D.cpp:50
CLTensorAllocator * allocator()
Return a pointer to the tensor&#39;s allocator.
Definition: CLTensor.cpp:61
#define ARM_COMPUTE_ERROR_THROW_ON(status)
Definition: Error.h:455
void manage(IMemoryManageable *obj) override
Sets a object to be managed by the given memory group.
Definition: MemoryGroup.h:79
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:67

◆ operator=() [1/2]

CLFFT2D& operator= ( const CLFFT2D )
delete

Prevent instances of this class from being copied.

◆ operator=() [2/2]

CLFFT2D& operator= ( CLFFT2D &&  )
default

Default move assignment operator.

◆ 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 97 of file CLFFT2D.cpp.

References CLFFT1D::run().

Referenced by CLFFTConvolutionLayer::run().

98 {
99  MemoryGroupResourceScope scope_mg(_memory_group);
100 
101  _first_pass_func.run();
102  _second_pass_func.run();
103 }
void run() override
Run the kernels contained in the function.
Definition: CLFFT1D.cpp:143

◆ 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: F16/F32.
[in]outputDestination tensor info. Data types and data layouts supported: Same as input.
[in]configFFT related configuration
Returns
a status

Definition at line 67 of file CLFFT2D.cpp.

References ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_NOT_IN, 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, FFT1DInfo::axis, FFT2DInfo::axis0, FFT2DInfo::axis1, ICloneable< T >::clone(), FFT1DInfo::direction, FFT2DInfo::direction, arm_compute::F16, arm_compute::F32, ITensorInfo::total_size(), and CLFFT1D::validate().

Referenced by CLFFT2D::configure().

68 {
71 
72  // Create intermediate tensor info
73  TensorInfo first_pass_tensor(input->clone()->set_is_resizable(true).reset_padding().set_num_channels(2));
74 
75  // Validate first pass
76  FFT1DInfo first_pass_config;
77  first_pass_config.axis = config.axis0;
78  first_pass_config.direction = config.direction;
79  ARM_COMPUTE_RETURN_ON_ERROR(CLFFT1D::validate(input, &first_pass_tensor, first_pass_config));
80 
81  // Validate second pass
82  FFT1DInfo second_pass_config;
83  second_pass_config.axis = config.axis1;
84  second_pass_config.direction = config.direction;
85  ARM_COMPUTE_RETURN_ON_ERROR(CLFFT1D::validate(&first_pass_tensor, output, second_pass_config));
86 
87  // Checks performed when output is configured
88  if((output != nullptr) && (output->total_size() != 0))
89  {
92  }
93 
94  return Status{};
95 }
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:118
#define ARM_COMPUTE_RETURN_ON_ERROR(status)
Checks if a status contains an error and returns it.
Definition: Error.h:204
1 channel, 1 F32 per channel
1 channel, 1 F16 per channel
#define ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR(...)
Definition: Validate.h:163
#define ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_SHAPES(...)
Definition: Validate.h:443
#define ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES(...)
Definition: Validate.h:545
#define ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_NOT_IN(t,...)
Definition: Validate.h:694

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