Compute Library
 19.08
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...
 
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

Definition at line 47 of file NEHOGGradient.h.

Constructor & Destructor Documentation

◆ NEHOGGradient()

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

Default constructor.

Definition at line 33 of file NEHOGGradient.cpp.

34  : _memory_group(std::move(memory_manager)),
35  _derivative(),
36  _mag_phase(nullptr),
37  _gx(),
38  _gy()
39 {
40 }

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 42 of file NEHOGGradient.cpp.

43 {
47 
48  const TensorShape &shape_img = input->info()->tensor_shape();
49 
50  // Allocate image memory
51  TensorInfo info(shape_img, Format::S16);
52  _gx.allocator()->init(info);
53  _gy.allocator()->init(info);
54 
55  // Manage intermediate buffers
56  _memory_group.manage(&_gx);
57  _memory_group.manage(&_gy);
58 
59  // Initialise derivate kernel
60  _derivative.configure(input, &_gx, &_gy, border_mode, constant_border_value);
61 
62  // Initialise magnitude/phase kernel
63  if(PhaseType::UNSIGNED == phase_type)
64  {
65  auto k = arm_compute::support::cpp14::make_unique<NEMagnitudePhaseKernel<MagnitudeType::L2NORM, PhaseType::UNSIGNED>>();
66  k->configure(&_gx, &_gy, output_magnitude, output_phase);
67  _mag_phase = std::move(k);
68  }
69  else
70  {
71  auto k = arm_compute::support::cpp14::make_unique<NEMagnitudePhaseKernel<MagnitudeType::L2NORM, PhaseType::SIGNED>>();
72  k->configure(&_gx, &_gy, output_magnitude, output_phase);
73  _mag_phase = std::move(k);
74  }
75 
76  // Allocate intermediate tensors
77  _gx.allocator()->allocate();
78  _gy.allocator()->allocate();
79 }
Shape of a tensor.
Definition: TensorShape.h:39
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's source, destinations and border mode.
1 channel, 1 U8 per channel
TensorAllocator * allocator()
Return a pointer to the tensor's allocator.
Definition: Tensor.cpp:48
void manage(TensorType *obj)
Sets a object to be managed by the given memory group.
virtual const TensorShape & tensor_shape() const =0
Size for each dimension of the tensor.
void allocate() override
Allocate size specified by TensorInfo of CPU memory.
virtual ITensorInfo * info() const =0
Interface to be implemented by the child class to return the tensor's metadata.
1 channel, 1 S16 per channel
#define ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(t, c,...)
Definition: Validate.h:789
Store the tensor's metadata.
Definition: TensorInfo.h:45

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

Referenced by NEHOGDescriptor::configure(), and NEHOGMultiDetection::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 81 of file NEHOGGradient.cpp.

82 {
83  MemoryGroupResourceScope scope_mg(_memory_group);
84 
85  // Run derivative
86  _derivative.run();
87 
88  // Run magnitude/phase kernel
89  NEScheduler::get().schedule(_mag_phase.get(), Window::DimY);
90 }
static constexpr size_t DimY
Alias for dimension 1 also known as Y dimension.
Definition: Window.h:45
Memory group resources scope handling class.
Definition: IMemoryGroup.h:46
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:96

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

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


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