Compute Library
 21.02
NEMagnitudePhaseKernel< mag_type, phase_type > Class Template Reference

Template interface for the kernel to compute magnitude and phase. More...

#include <NEMagnitudePhaseKernel.h>

Collaboration diagram for NEMagnitudePhaseKernel< mag_type, phase_type >:
[legend]

Public Member Functions

const char * name () const override
 Name of the kernel. More...
 
 NEMagnitudePhaseKernel ()
 Default constructor. More...
 
 NEMagnitudePhaseKernel (const NEMagnitudePhaseKernel &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
 NEMagnitudePhaseKernel (NEMagnitudePhaseKernel &&)=default
 Default move constructor. More...
 
NEMagnitudePhaseKerneloperator= (const NEMagnitudePhaseKernel &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
NEMagnitudePhaseKerneloperator= (NEMagnitudePhaseKernel &&)=default
 Default move assignment operator. More...
 
 ~NEMagnitudePhaseKernel ()=default
 Destructor. More...
 
void configure (const ITensor *gx, const ITensor *gy, ITensor *magnitude, ITensor *phase)
 Initialise the kernel's input, output. 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...
 

Detailed Description

template<MagnitudeType mag_type, PhaseType phase_type>
class arm_compute::NEMagnitudePhaseKernel< mag_type, phase_type >

Template interface for the kernel to compute magnitude and phase.

Definition at line 36 of file NEMagnitudePhaseKernel.h.

Constructor & Destructor Documentation

◆ NEMagnitudePhaseKernel() [1/3]

Default constructor.

Definition at line 246 of file NEMagnitudePhaseKernel.cpp.

Referenced by NEMagnitudePhaseKernel< mag_type, phase_type >::name().

247  : _func(nullptr), _gx(nullptr), _gy(nullptr), _magnitude(nullptr), _phase(nullptr)
248 {
249 }

◆ NEMagnitudePhaseKernel() [2/3]

NEMagnitudePhaseKernel ( const NEMagnitudePhaseKernel< mag_type, phase_type > &  )
delete

Prevent instances of this class from being copied (As this class contains pointers)

◆ NEMagnitudePhaseKernel() [3/3]

NEMagnitudePhaseKernel ( NEMagnitudePhaseKernel< mag_type, phase_type > &&  )
default

Default move constructor.

◆ ~NEMagnitudePhaseKernel()

Member Function Documentation

◆ configure()

void configure ( const ITensor gx,
const ITensor gy,
ITensor magnitude,
ITensor phase 
)

Initialise the kernel's input, output.

Note
At least one of out1 or out2 must be set
Parameters
[in]gxGradient X tensor. Data type supported: S16.
[in]gyGradient Y tensor. Data type supported: S16.
[out]magnitude(Optional) The output tensor - Magnitude. Data type supported: S16.
[out]phase(Optional) The output tensor - Phase. Data type supported: U8.

Definition at line 252 of file NEMagnitudePhaseKernel.cpp.

References ARM_COMPUTE_ERROR, ARM_COMPUTE_ERROR_ON, ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN, arm_compute::calculate_max_window(), arm_compute::execute_window_loop(), ITensor::info(), arm_compute::intersect_valid_regions(), arm_compute::L2NORM, arm_compute::test::validation::reference::magnitude(), magnitude_l1(), magnitude_l2(), magnitude_phase(), num_elems_processed_per_iteration, arm_compute::test::validation::reference::phase(), phase_signed(), phase_unsigned(), Iterator::ptr(), arm_compute::S16, arm_compute::SIGNED, arm_compute::U8, arm_compute::update_window_and_padding(), arm_compute::test::validation::valid_region, ITensorInfo::valid_region(), and IKernel::window().

Referenced by NEMagnitudePhaseKernel< mag_type, phase_type >::name().

253 {
256  ARM_COMPUTE_ERROR_ON((nullptr == magnitude) && (nullptr == phase));
257 
258  const bool run_mag = magnitude != nullptr;
259  const bool run_phase = phase != nullptr;
260 
261  if(run_mag)
262  {
264  }
265 
266  if(run_phase)
267  {
269  }
270 
271  _gx = gx;
272  _gy = gy;
273  _magnitude = magnitude;
274  _phase = phase;
275 
276  if(run_mag && run_phase)
277  {
278  /* Run magnitude and phase */
280  }
281  else
282  {
283  if(run_mag)
284  {
285  /* Run magnitude */
287  }
288  else if(run_phase)
289  {
290  /* Run phase */
292  }
293  else
294  {
295  ARM_COMPUTE_ERROR("At least one output must be NOT NULL");
296  }
297  }
298 
299  constexpr unsigned int num_elems_processed_per_iteration = 16;
300 
301  // Configure kernel window
302  Window win = calculate_max_window(*gx->info(), Steps(num_elems_processed_per_iteration));
303  AccessWindowHorizontal magnitude_access(magnitude == nullptr ? nullptr : magnitude->info(), 0, num_elems_processed_per_iteration);
304  AccessWindowHorizontal phase_access(phase == nullptr ? nullptr : phase->info(), 0, num_elems_processed_per_iteration);
305 
309  magnitude_access,
310  phase_access);
311 
313  gy->info()->valid_region());
314 
315  magnitude_access.set_valid_region(win, valid_region);
316  phase_access.set_valid_region(win, valid_region);
317 
318  INEKernel::configure(win);
319 }
Window calculate_max_window(const ValidRegion &valid_region, const Steps &steps, bool skip_border, BorderSize border_size)
#define ARM_COMPUTE_ERROR(msg)
Print the given message then throw an std::runtime_error.
Definition: Error.h:352
1 channel, 1 U8 per channel
#define ARM_COMPUTE_ERROR_ON(cond)
If the condition is true then an error message is printed and an exception thrown.
Definition: Error.h:466
Template interface for the kernel to compute magnitude and phase.
const ValidRegion valid_region
Definition: Scale.cpp:221
virtual ValidRegion valid_region() const =0
Valid region of the tensor.
bool update_window_and_padding(Window &win, Ts &&... patterns)
Update window and padding size for each of the access patterns.
Definition: WindowHelpers.h:46
Class to describe a number of elements in each dimension.
Definition: Steps.h:40
Implementation of a row access pattern.
virtual ITensorInfo * info() const =0
Interface to be implemented by the child class to return the tensor&#39;s metadata.
ValidRegion intersect_valid_regions(const Ts &... regions)
Intersect multiple valid regions.
Definition: WindowHelpers.h:74
1 channel, 1 S16 per channel
#define ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(t, c,...)
Definition: Validate.h:790
unsigned int num_elems_processed_per_iteration
Container for valid region of a window.
Definition: Types.h:188
Describe a multidimensional execution window.
Definition: Window.h:39

◆ name()

◆ operator=() [1/2]

NEMagnitudePhaseKernel& operator= ( const NEMagnitudePhaseKernel< mag_type, phase_type > &  )
delete

Prevent instances of this class from being copied (As this class contains pointers)

Referenced by NEMagnitudePhaseKernel< mag_type, phase_type >::name().

◆ operator=() [2/2]

NEMagnitudePhaseKernel& operator= ( NEMagnitudePhaseKernel< mag_type, phase_type > &&  )
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 477 of file NEMagnitudePhaseKernel.cpp.

References ARM_COMPUTE_ERROR_ON, ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW, ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL, ARM_COMPUTE_UNUSED, and IKernel::window().

Referenced by NEMagnitudePhaseKernel< mag_type, phase_type >::name().

478 {
479  ARM_COMPUTE_UNUSED(info);
482  ARM_COMPUTE_ERROR_ON(_func == nullptr);
483 
484  (this->*_func)(window);
485 }
const Window & window() const
The maximum window the kernel can be executed on.
Definition: IKernel.cpp:28
#define ARM_COMPUTE_ERROR_ON(cond)
If the condition is true then an error message is printed and an exception thrown.
Definition: Error.h:466
#define ARM_COMPUTE_UNUSED(...)
To avoid unused variables warnings.
Definition: Error.h:152
#define ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(k)
Definition: Validate.h:941
#define ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW(f, s)
Definition: Validate.h:205

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