Compute Library
 21.02
NEDerivative Class Reference

Basic function to execute first order derivative operator. More...

#include <NEDerivative.h>

Collaboration diagram for NEDerivative:
[legend]

Public Member Functions

 NEDerivative ()
 Default constructor. More...
 
 NEDerivative (const NEDerivative &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
NEDerivativeoperator= (const NEDerivative &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
 NEDerivative (NEDerivative &&)=delete
 Prevent instances of this class from being moved (As this class contains non movable objects) More...
 
NEDerivativeoperator= (NEDerivative &&)=delete
 Prevent instances of this class from being moved (As this class contains non movable objects) More...
 
 ~NEDerivative ()
 Default destructor. More...
 
void configure (ITensor *input, ITensor *output_x, ITensor *output_y, BorderMode border_mode, uint8_t constant_border_value=0)
 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...
 

Detailed Description

Basic function to execute first order derivative operator.

This function calls the following Neon kernels:

  1. NEFillBorderKernel (executed if border_mode == CONSTANT or border_mode == REPLICATE)
  2. NEDerivativeKernel
Deprecated:
This function is deprecated and is intended to be removed in 21.05 release

Definition at line 46 of file NEDerivative.h.

Constructor & Destructor Documentation

◆ NEDerivative() [1/3]

Default constructor.

Definition at line 37 of file NEDerivative.cpp.

38  : _kernel(), _border_handler()
39 {
40 }

◆ NEDerivative() [2/3]

NEDerivative ( const NEDerivative )
delete

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

◆ NEDerivative() [3/3]

NEDerivative ( NEDerivative &&  )
delete

Prevent instances of this class from being moved (As this class contains non movable objects)

◆ ~NEDerivative()

~NEDerivative ( )
default

Default destructor.

Member Function Documentation

◆ configure()

void configure ( ITensor input,
ITensor output_x,
ITensor output_y,
BorderMode  border_mode,
uint8_t  constant_border_value = 0 
)

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

Note
At least one of output_x or output_y must be not NULL.
Parameters
[in,out]inputSource tensor. Data type supported: U8. (Written to only for border_mode != UNDEFINED)
[out]output_x(optional) Destination tensor. Derivative along the X direction. Data type supported: S16.
[out]output_y(optional) Destination tensor. Derivative along the Y direction. Data type supported: S16.
[in]border_modeBorder mode to use
[in]constant_border_value(Optional) Constant value to use for borders if border_mode is set to CONSTANT.

Definition at line 42 of file NEDerivative.cpp.

References ARM_COMPUTE_ERROR_ON, ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN, arm_compute::U8, and arm_compute::UNDEFINED.

Referenced by NEHOGGradient::configure().

43 {
45  ARM_COMPUTE_ERROR_ON((output_x == nullptr) && (output_y == nullptr));
46 
47  _kernel = std::make_unique<NEDerivativeKernel>();
48  _border_handler = std::make_unique<NEFillBorderKernel>();
49 
50  _kernel->configure(input, output_x, output_y, border_mode == BorderMode::UNDEFINED);
51  _border_handler->configure(input, BorderSize(1), border_mode, PixelValue(constant_border_value));
52 }
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
#define ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(t, c,...)
Definition: Validate.h:790
Borders are left undefined.

◆ operator=() [1/2]

NEDerivative& operator= ( const NEDerivative )
delete

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

◆ operator=() [2/2]

NEDerivative& operator= ( NEDerivative &&  )
delete

Prevent instances of this class from being moved (As this class contains non movable objects)

◆ 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 54 of file NEDerivative.cpp.

References Window::DimY, Window::DimZ, Scheduler::get(), and IScheduler::schedule().

Referenced by NEHOGGradient::run().

55 {
56  NEScheduler::get().schedule(_border_handler.get(), Window::DimZ);
57  NEScheduler::get().schedule(_kernel.get(), Window::DimY);
58 }
static constexpr size_t DimY
Alias for dimension 1 also known as Y dimension.
Definition: Window.h:45
virtual void schedule(ICPPKernel *kernel, const Hints &hints)=0
Runs the kernel in the same thread as the caller synchronously.
static constexpr size_t DimZ
Alias for dimension 2 also known as Z dimension.
Definition: Window.h:47
static IScheduler & get()
Access the scheduler singleton.
Definition: Scheduler.cpp:94

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