Compute Library
 21.02
NEHOGGradient Class Reference

Basic function to calculate the gradient for HOG. More...

#include <NEHOGGradient.h>

Collaboration diagram for NEHOGGradient:
[legend]

Public Member Functions

 NEHOGGradient (std::shared_ptr< IMemoryManager > memory_manager=nullptr)
 Default constructor. More...
 
 NEHOGGradient (const NEHOGGradient &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
NEHOGGradientoperator= (const NEHOGGradient &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
 NEHOGGradient (NEHOGGradient &&)=delete
 Prevent instances of this class from being moved (As this class contains non movable objects) More...
 
NEHOGGradientoperator= (NEHOGGradient &&)=delete
 Prevent instances of this class from being moved (As this class contains non movable objects) More...
 
 ~NEHOGGradient ()
 Default destructor. More...
 
void configure (ITensor *input, ITensor *output_magnitude, ITensor *output_phase, PhaseType phase_type, BorderMode border_mode, uint8_t constant_border_value=0)
 Initialise the function's source, destinations, phase type 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 calculate the gradient for HOG.

This function calls the following Neon kernels:

  1. NEDerivative
  2. NEMagnitudePhaseKernel
Deprecated:
This function is deprecated and is intended to be removed in 21.05 release

Definition at line 50 of file NEHOGGradient.h.

Constructor & Destructor Documentation

◆ NEHOGGradient() [1/3]

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

Default constructor.

Definition at line 36 of file NEHOGGradient.cpp.

37  : _memory_group(std::move(memory_manager)),
38  _derivative(),
39  _mag_phase(nullptr),
40  _gx(),
41  _gy()
42 {
43 }

◆ NEHOGGradient() [2/3]

NEHOGGradient ( const NEHOGGradient )
delete

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

◆ NEHOGGradient() [3/3]

NEHOGGradient ( NEHOGGradient &&  )
delete

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

◆ ~NEHOGGradient()

~NEHOGGradient ( )
default

Default destructor.

Member Function Documentation

◆ configure()

void configure ( ITensor input,
ITensor output_magnitude,
ITensor output_phase,
PhaseType  phase_type,
BorderMode  border_mode,
uint8_t  constant_border_value = 0 
)

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

Parameters
[in,out]inputInput tensor. Data type supported: U8. (Written to only for border_mode != UNDEFINED)
[out]output_magnitudeOutput tensor (magnitude). Data type supported: U16.
[out]output_phaseOutput tensor.(phase). Format supported: U8
[in]phase_typeType of PhaseType
[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 45 of file NEHOGGradient.cpp.

References TensorAllocator::allocate(), Tensor::allocator(), ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN, NEDerivative::configure(), ITensor::info(), arm_compute::test::validation::info, TensorAllocator::init(), MemoryGroup::manage(), arm_compute::S16, ITensorInfo::tensor_shape(), arm_compute::U8, and arm_compute::UNSIGNED.

Referenced by NEHOGDescriptor::configure(), and NEHOGMultiDetection::configure().

46 {
50 
51  const TensorShape &shape_img = input->info()->tensor_shape();
52 
53  // Allocate image memory
54  TensorInfo info(shape_img, Format::S16);
55  _gx.allocator()->init(info);
56  _gy.allocator()->init(info);
57 
58  // Manage intermediate buffers
59  _memory_group.manage(&_gx);
60  _memory_group.manage(&_gy);
61 
62  // Initialise derivate kernel
63  _derivative.configure(input, &_gx, &_gy, border_mode, constant_border_value);
64 
65  // Initialise magnitude/phase kernel
66  if(PhaseType::UNSIGNED == phase_type)
67  {
68  auto k = std::make_unique<NEMagnitudePhaseKernel<MagnitudeType::L2NORM, PhaseType::UNSIGNED>>();
69  k->configure(&_gx, &_gy, output_magnitude, output_phase);
70  _mag_phase = std::move(k);
71  }
72  else
73  {
74  auto k = std::make_unique<NEMagnitudePhaseKernel<MagnitudeType::L2NORM, PhaseType::SIGNED>>();
75  k->configure(&_gx, &_gy, output_magnitude, output_phase);
76  _mag_phase = std::move(k);
77  }
78 
79  // Allocate intermediate tensors
80  _gx.allocator()->allocate();
81  _gy.allocator()->allocate();
82 }
void init(const TensorAllocator &allocator, const Coordinates &coords, TensorInfo &sub_info)
Shares the same backing memory with another tensor allocator, while the tensor info might be differen...
Angle range: [0, 180].
void configure(ITensor *input, ITensor *output_x, ITensor *output_y, BorderMode border_mode, uint8_t constant_border_value=0)
Initialise the function&#39;s source, destinations and border mode.
1 channel, 1 U8 per channel
TensorAllocator * allocator()
Return a pointer to the tensor&#39;s allocator.
Definition: Tensor.cpp:48
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 CPU memory.
1 channel, 1 S16 per channel
#define ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(t, c,...)
Definition: Validate.h:790
ScaleKernelInfo info(interpolation_policy, default_border_mode, PixelValue(), sampling_policy, false)

◆ operator=() [1/2]

NEHOGGradient& operator= ( const NEHOGGradient )
delete

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

◆ operator=() [2/2]

NEHOGGradient& operator= ( NEHOGGradient &&  )
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 84 of file NEHOGGradient.cpp.

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

Referenced by NEHOGDescriptor::run(), and NEHOGMultiDetection::run().

85 {
86  MemoryGroupResourceScope scope_mg(_memory_group);
87 
88  // Run derivative
89  _derivative.run();
90 
91  // Run magnitude/phase kernel
92  NEScheduler::get().schedule(_mag_phase.get(), Window::DimY);
93 }
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.
void run() override
Run the kernels contained in the function.
static IScheduler & get()
Access the scheduler singleton.
Definition: Scheduler.cpp:94

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