Compute Library
 19.08
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 427 of file NESoftmaxLayerKernel.cpp.

428  : _func(nullptr), _border_size()
429 {
430 }

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 432 of file NESoftmaxLayerKernel.cpp.

433 {
434  return _border_size;
435 }

Referenced by NESoftmaxLayer::configure().

◆ 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 437 of file NESoftmaxLayerKernel.cpp.

438 {
439  ARM_COMPUTE_ERROR_ON_NULLPTR(input, output);
440  ARM_COMPUTE_ERROR_ON_NULLPTR(input->info(), output->info());
441  // Perform validation step
442  ARM_COMPUTE_ERROR_THROW_ON(validate_arguments_logits_1d_max(*input->info(), *output->info()));
443  // Configure kernel window
444  auto win_config = validate_and_configure_window_logits_1d_max(*input->info(), *output->info());
445  ARM_COMPUTE_ERROR_THROW_ON(win_config.first);
446 
447  switch(input->info()->data_type())
448  {
449  case DataType::QASYMM8:
450  _func = &logits_1d_max<qasymm8_t>;
451  break;
452 #ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC
453  case DataType::F16:
454  _func = &logits_1d_max<float16_t>;
455  break;
456 #endif /* __ARM_FEATURE_FP16_VECTOR_ARITHMETIC */
457  case DataType::F32:
458  _func = &logits_1d_max<float>;
459  break;
460  default:
461  ARM_COMPUTE_ERROR("Unsupported data type.");
462  }
463 
464  _input = input;
465  _output = output;
466 
467  const int input_width = input->info()->valid_region().shape.x();
468  const int num_elems_processed_per_iteration = 16U / data_size_from_type(input->info()->data_type());
469  const int num_elems_read_per_iteration = ceil_to_multiple(input_width, num_elems_processed_per_iteration);
470 
471  _border_size = BorderSize(0, num_elems_read_per_iteration - input_width, 0, 0);
472 
473  INEKernel::configure(win_config.second);
474 }
#define ARM_COMPUTE_ERROR(...)
Print the given message then throw an std::runtime_error.
Definition: Error.h:261
1 channel, 1 F32 per channel
#define ARM_COMPUTE_ERROR_THROW_ON(status)
Definition: Error.h:327
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
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::ceil_to_multiple(), arm_compute::data_size_from_type(), ITensorInfo::data_type(), arm_compute::F16, arm_compute::F32, ITensor::info(), arm_compute::QASYMM8, ValidRegion::shape, arm_compute::U, ITensorInfo::valid_region(), and Dimensions< T >::x().

Referenced by NESoftmaxLayer::configure().

◆ 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 486 of file NESoftmaxLayerKernel.cpp.

487 {
491  ARM_COMPUTE_ERROR_ON(_func == nullptr);
492 
493  (*_func)(*_input, *_output, window);
494 }
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:337
#define ARM_COMPUTE_UNUSED(...)
To avoid unused variables warnings.
Definition: Error.h:160
#define ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW(f, s)
Definition: Validate.h:205
#define ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(k)
Definition: Validate.h:940

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 476 of file NESoftmaxLayerKernel.cpp.

477 {
478  ARM_COMPUTE_ERROR_ON_NULLPTR(input, output);
479 
480  ARM_COMPUTE_RETURN_ON_ERROR(validate_arguments_logits_1d_max(*input, *output));
481  ARM_COMPUTE_RETURN_ON_ERROR(validate_and_configure_window_logits_1d_max(*input->clone(), *output->clone()).first);
482 
483  return Status{};
484 }
#define ARM_COMPUTE_RETURN_ON_ERROR(status)
Checks if a status contains an error and returns it.
Definition: Error.h:193
#define ARM_COMPUTE_ERROR_ON_NULLPTR(...)
Definition: Validate.h:161

References ARM_COMPUTE_ERROR_ON_NULLPTR, ARM_COMPUTE_RETURN_ON_ERROR, and ICloneable< T >::clone().

Referenced by NESoftmaxLayer::validate().


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