Compute Library
 19.08
NEArgMinMaxLayer Class Reference

Function to calculate the index of the minimum or maximum values in a tensor based on an axis. More...

#include <NEArgMinMaxLayer.h>

Collaboration diagram for NEArgMinMaxLayer:
[legend]

Public Member Functions

 NEArgMinMaxLayer (std::shared_ptr< IMemoryManager > memory_manager=nullptr)
 Constructor. More...
 
void configure (ITensor *input, int axis, ITensor *output, const ReductionOperation &op)
 Set the input and output tensors. 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, int axis, const ITensorInfo *output, const ReductionOperation &op)
 Static function to check if given info will lead to a valid configuration of NEArgMinMaxLayer. More...
 

Detailed Description

Function to calculate the index of the minimum or maximum values in a tensor based on an axis.

This function calls the following NEON kernels:

  1. NEReductionOperationKernel
  2. NEFillBorderKernel

Definition at line 44 of file NEArgMinMaxLayer.h.

Constructor & Destructor Documentation

◆ NEArgMinMaxLayer()

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

Constructor.

Definition at line 36 of file NEArgMinMaxLayer.cpp.

37  : _memory_group(std::move(memory_manager)), _reduction_kernel(), _fill_border_kernel(), _run_fill_border(false)
38 {
39 }

Member Function Documentation

◆ configure()

void configure ( ITensor input,
int  axis,
ITensor output,
const ReductionOperation op 
)

Set the input and output tensors.

Parameters
[in]inputInput source tensor. Data types supported: QASYMM8/S32/F16/F32.
[in]axisAxis to find max/min index.
[out]outputOutput source tensor. Data types supported: U32.
[in]opOperation to perform: min or max

Definition at line 40 of file NEArgMinMaxLayer.cpp.

41 {
42  _reduction_kernel.configure(input, output, axis, op);
43 
44  if(axis == 0)
45  {
46  _fill_border_kernel.configure(input, _reduction_kernel.border_size(), BorderMode::REPLICATE);
47  _run_fill_border = true;
48  }
49 }
void configure(ITensor *tensor, BorderSize border_size, BorderMode border_mode, const PixelValue &constant_border_value=PixelValue())
Initialise the function.
BorderSize border_size() const override
The size of the border for that kernel.
void configure(const ITensor *input, ITensor *output, unsigned int axis, ReductionOperation op)
Set the source, destination of the kernel.
Pixels outside the image are assumed to have the same value as the closest image pixel.

References arm_compute::test::validation::axis, NEReductionOperationKernel::border_size(), NEReductionOperationKernel::configure(), NEFillBorderKernel::configure(), and arm_compute::REPLICATE.

◆ 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 58 of file NEArgMinMaxLayer.cpp.

59 {
60  MemoryGroupResourceScope scope_mg(_memory_group);
61 
62  if(_run_fill_border)
63  {
64  NEScheduler::get().schedule(&_fill_border_kernel, Window::DimY);
65  }
66  NEScheduler::get().schedule(&_reduction_kernel, Window::DimY);
67 }
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 IScheduler & get()
Access the scheduler singleton.
Definition: Scheduler.cpp:96

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

◆ validate()

Status validate ( const ITensorInfo input,
int  axis,
const ITensorInfo output,
const ReductionOperation op 
)
static

Static function to check if given info will lead to a valid configuration of NEArgMinMaxLayer.

Parameters
[in]inputInput source tensor info. Data types supported: QASYMM8/S32/F16/F32.
[in]axisAxis to find max/min index.
[in]outputOutput source tensor info. Data types supported: U32.
[in]opOperation to perform: min or max
Returns
a status

Definition at line 51 of file NEArgMinMaxLayer.cpp.

52 {
55  return Status{};
56 }
#define ARM_COMPUTE_RETURN_ON_ERROR(status)
Checks if a status contains an error and returns it.
Definition: Error.h:193
static Status validate(const ITensorInfo *input, const ITensorInfo *output, unsigned int axis, ReductionOperation op)
Static function to check if given info will lead to a valid configuration of NEReductionOperationKern...
#define ARM_COMPUTE_RETURN_ERROR_ON_MSG(cond,...)
If the condition is true, an error is returned.
Definition: Error.h:214

References arm_compute::ARG_IDX_MAX, arm_compute::ARG_IDX_MIN, ARM_COMPUTE_RETURN_ERROR_ON_MSG, ARM_COMPUTE_RETURN_ON_ERROR, arm_compute::test::validation::axis, and NEReductionOperationKernel::validate().


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