Compute Library
 19.11
NELogits1DMaxKernel Class Reference

Interface for the identifying the max value of 1D Logits. More...

#include <NESoftmaxLayerKernel.h>

Collaboration diagram for NELogits1DMaxKernel:
[legend]

Public Member Functions

const char * name () const override
 Name of the kernel. More...
 
 NELogits1DMaxKernel ()
 Default constructor. More...
 
void configure (const ITensor *input, ITensor *output)
 Set the input and output tensors. More...
 
void run (const Window &window, const ThreadInfo &info) override
 Execute the kernel on the passed window. More...
 
BorderSize border_size () const override
 The size of the border for that kernel. More...
 
- Public Member Functions inherited from ICPPSimpleKernel
 ICPPSimpleKernel ()
 Constructor. More...
 
 ICPPSimpleKernel (const ICPPSimpleKernel &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
ICPPSimpleKerneloperator= (const ICPPSimpleKernel &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
 ICPPSimpleKernel (ICPPSimpleKernel &&)=default
 Allow instances of this class to be moved. More...
 
ICPPSimpleKerneloperator= (ICPPSimpleKernel &&)=default
 Allow instances of this class to be moved. More...
 
 ~ICPPSimpleKernel ()=default
 Default destructor. More...
 
- Public Member Functions inherited from ICPPKernel
virtual ~ICPPKernel ()=default
 Default destructor. 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...
 
const Windowwindow () const
 The maximum window the kernel can be executed on. More...
 

Static Public Member Functions

static Status validate (const ITensorInfo *input, const ITensorInfo *output)
 Static function to check if given info will lead to a valid configuration of NELogits1DMaxKernel. More...
 

Detailed Description

Interface for the identifying the max value of 1D Logits.

Definition at line 35 of file NESoftmaxLayerKernel.h.

Constructor & Destructor Documentation

◆ NELogits1DMaxKernel()

Default constructor.

Definition at line 440 of file NESoftmaxLayerKernel.cpp.

441  : _func(nullptr), _border_size()
442 {
443 }

Member Function Documentation

◆ border_size()

BorderSize border_size ( ) const
overridevirtual

The size of the border for that kernel.

Returns
The width in number of elements of the border.

Reimplemented from IKernel.

Definition at line 445 of file NESoftmaxLayerKernel.cpp.

446 {
447  return _border_size;
448 }

◆ configure()

void configure ( const ITensor input,
ITensor output 
)

Set the input and output tensors.

Parameters
[in]inputSource tensor. Data types supported: QASYMM8/F16/F32.
[out]outputDestination tensor. Data types supported: same as input

Definition at line 450 of file NESoftmaxLayerKernel.cpp.

451 {
453  ARM_COMPUTE_ERROR_ON_NULLPTR(input->info(), output->info());
454  // Perform validation step
455  ARM_COMPUTE_ERROR_THROW_ON(validate_arguments_logits_1d_max(*input->info(), *output->info()));
456  // Configure kernel window
457  auto win_config = validate_and_configure_window_logits_1d_max(*input->info(), *output->info());
458  ARM_COMPUTE_ERROR_THROW_ON(win_config.first);
459 
460  switch(input->info()->data_type())
461  {
462  case DataType::QASYMM8:
463  _func = &logits_1d_max<qasymm8_t>;
464  break;
465 #ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC
466  case DataType::F16:
467  _func = &logits_1d_max<float16_t>;
468  break;
469 #endif /* __ARM_FEATURE_FP16_VECTOR_ARITHMETIC */
470  case DataType::F32:
471  _func = &logits_1d_max<float>;
472  break;
473  default:
474  ARM_COMPUTE_ERROR("Unsupported data type.");
475  }
476 
477  _input = input;
478  _output = output;
479 
480  const int input_width = input->info()->valid_region().shape.x();
481  const int num_elems_processed_per_iteration = 16U / data_size_from_type(input->info()->data_type());
482  const int num_elems_read_per_iteration = ceil_to_multiple(input_width, num_elems_processed_per_iteration);
483 
484  _border_size = BorderSize(0, num_elems_read_per_iteration - input_width, 0, 0);
485 
486  INEKernel::configure(win_config.second);
487 }
#define ARM_COMPUTE_ERROR(msg)
Print the given message then throw an std::runtime_error.
Definition: Error.h:352
1 channel, 1 F32 per channel
#define ARM_COMPUTE_ERROR_THROW_ON(status)
Definition: Error.h:455
1 channel, 1 F16 per channel
auto ceil_to_multiple(S value, T divisor) -> decltype(((value+divisor - 1)/divisor) *divisor)
Computes the smallest number larger or equal to value that is a multiple of divisor.
Definition: Utils.h:66
quantized, asymmetric fixed-point 8-bit number unsigned
size_t data_size_from_type(DataType data_type)
The size in bytes of the data type.
Definition: Utils.h:109
#define ARM_COMPUTE_ERROR_ON_NULLPTR(...)
Definition: Validate.h:161

References ARM_COMPUTE_ERROR, ARM_COMPUTE_ERROR_ON_NULLPTR, ARM_COMPUTE_ERROR_THROW_ON, arm_compute::F16, arm_compute::F32, ITensor::info(), arm_compute::test::validation::input, and arm_compute::QASYMM8.

◆ name()

const char* name ( ) const
inlineoverridevirtual

Name of the kernel.

Returns
Kernel name

Implements ICPPKernel.

Definition at line 38 of file NESoftmaxLayerKernel.h.

39  {
40  return "NELogits1DMaxKernel";
41  }

◆ 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.

Implements ICPPKernel.

Definition at line 499 of file NESoftmaxLayerKernel.cpp.

500 {
504  ARM_COMPUTE_ERROR_ON(_func == nullptr);
505 
506  (*_func)(*_input, *_output, window);
507 }
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_INVALID_SUBWINDOW(f, s)
Definition: Validate.h:205
#define ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(k)
Definition: Validate.h:941

References ARM_COMPUTE_ERROR_ON, ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW, ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL, ARM_COMPUTE_UNUSED, arm_compute::test::validation::info, and IKernel::window().

◆ validate()

Status validate ( const ITensorInfo input,
const ITensorInfo output 
)
static

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

Parameters
[in]inputSource tensor. Data types supported: QASYMM8/F16/F32.
[in]outputDestination tensor. Data types supported: same as input
Returns
a status

Definition at line 489 of file NESoftmaxLayerKernel.cpp.

490 {
492 
493  ARM_COMPUTE_RETURN_ON_ERROR(validate_arguments_logits_1d_max(*input, *output));
494  ARM_COMPUTE_RETURN_ON_ERROR(validate_and_configure_window_logits_1d_max(*input->clone(), *output->clone()).first);
495 
496  return Status{};
497 }
#define ARM_COMPUTE_RETURN_ON_ERROR(status)
Checks if a status contains an error and returns it.
Definition: Error.h:204
#define ARM_COMPUTE_ERROR_ON_NULLPTR(...)
Definition: Validate.h:161

References ARM_COMPUTE_ERROR_ON_NULLPTR, ARM_COMPUTE_RETURN_ON_ERROR, ICloneable< T >::clone(), and arm_compute::test::validation::input.

Referenced by NESoftmaxLayerGeneric< IS_LOG >::validate().


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