Compute Library
 19.08
NEFloorKernel Class Reference

NEON kernel to perform a floor operation. More...

#include <NEFloorKernel.h>

Collaboration diagram for NEFloorKernel:
[legend]

Public Member Functions

const char * name () const override
 Name of the kernel. More...
 
void configure (const ITensor *input, ITensor *output)
 Set the source, destination of the kernel. More...
 
void run (const Window &window, const ThreadInfo &info) override
 Execute the kernel on the passed window. 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...
 
virtual BorderSize border_size () const
 The size of the border for that kernel. 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 NEFloorKernel. More...
 

Detailed Description

NEON kernel to perform a floor operation.

Definition at line 34 of file NEFloorKernel.h.

Member Function Documentation

◆ configure()

void configure ( const ITensor input,
ITensor output 
)

Set the source, destination of the kernel.

Parameters
[in]inputSource tensor. Data type supported: F16/F32.
[out]outputDestination tensor. Same as input

Definition at line 74 of file NEFloorKernel.cpp.

75 {
76  ARM_COMPUTE_ERROR_ON_NULLPTR(input, output);
77 
78  // Auto initialize output
79  auto_init_if_empty(*output->info(), input->info()->tensor_shape(), 1, input->info()->data_type());
80 
81  // Validate
82  ARM_COMPUTE_ERROR_THROW_ON(validate_arguments(input->info(), output->info()));
83 
84  _input = input;
85  _output = output;
86 
87  // Configure kernel window
88  auto win_config = validate_and_configure_window(input->info(), output->info());
89  ARM_COMPUTE_ERROR_THROW_ON(win_config.first);
90  INEKernel::configure(win_config.second);
91 }
std::pair< Status, Window > validate_and_configure_window(ITensorInfo *input, ITensorInfo *weights, ITensorInfo *biases, ITensorInfo *output, const PadStrideInfo &conv_info, unsigned int depth_multiplier, const Size2D &dilation)
#define ARM_COMPUTE_ERROR_THROW_ON(status)
Definition: Error.h:327
bool auto_init_if_empty(ITensorInfo &info, const TensorShape &shape, int num_channels, DataType data_type, QuantizationInfo quantization_info=QuantizationInfo())
Auto initialize the tensor info (shape, number of channels and data type) if the current assignment i...
Definition: Helpers.inl:201
#define ARM_COMPUTE_ERROR_ON_NULLPTR(...)
Definition: Validate.h:161

References ARM_COMPUTE_ERROR_ON_NULLPTR, ARM_COMPUTE_ERROR_THROW_ON, arm_compute::auto_init_if_empty(), ITensorInfo::data_type(), ITensor::info(), ITensorInfo::tensor_shape(), and arm_compute::validate_and_configure_window().

◆ name()

const char* name ( ) const
inlineoverridevirtual

Name of the kernel.

Returns
Kernel name

Implements ICPPKernel.

Definition at line 37 of file NEFloorKernel.h.

38  {
39  return "NEFloorKernel";
40  }

◆ 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 101 of file NEFloorKernel.cpp.

102 {
106 
107  const DataType data_type = _input->info()->data_type();
108 
109  Iterator input(_input, window);
110  Iterator output(_output, window);
111 
112  if(data_type == DataType::F32)
113  {
114  execute_window_loop(window, [&](const Coordinates &)
115  {
116  const float32x4_t res = vfloorq_f32(vld1q_f32(reinterpret_cast<const float *>(input.ptr())));
117  vst1q_f32(reinterpret_cast<float *>(output.ptr()), res);
118  },
119  input, output);
120  }
121 #ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC
122  else if(data_type == DataType::F16)
123  {
124  execute_window_loop(window, [&](const Coordinates &)
125  {
126  const float16x8_t res = vfloorq_f16(vld1q_f16(reinterpret_cast<const float16_t *>(input.ptr())));
127  vst1q_f16(reinterpret_cast<float16_t *>(output.ptr()), res);
128  },
129  input, output);
130  }
131 #endif // __ARM_FEATURE_FP16_VECTOR_ARITHMETIC
132  else
133  {
134  ARM_COMPUTE_ERROR("Invalid data type!");
135  }
136 }
#define ARM_COMPUTE_ERROR(...)
Print the given message then throw an std::runtime_error.
Definition: Error.h:261
const Window & window() const
The maximum window the kernel can be executed on.
Definition: IKernel.cpp:28
1 channel, 1 F32 per channel
float32x4_t vfloorq_f32(float32x4_t val)
Calculate floor of a vector.
1 channel, 1 F16 per channel
#define ARM_COMPUTE_UNUSED(...)
To avoid unused variables warnings.
Definition: Error.h:160
void execute_window_loop(const Window &w, L &&lambda_function, Ts &&... iterators)
Iterate through the passed window, automatically adjusting the iterators and calling the lambda_funct...
Definition: Helpers.inl:122
DataType
Available data types.
Definition: Types.h:74
#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, ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW, ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL, ARM_COMPUTE_UNUSED, arm_compute::test::validation::data_type, arm_compute::execute_window_loop(), arm_compute::F16, arm_compute::F32, arm_compute::test::validation::info, Iterator::ptr(), arm_compute::vfloorq_f32(), 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 NEFloorKernel.

Parameters
[in]inputSource tensor info. Data type supported: F16/F32.
[in]outputDestination tensor info. Same as input
Returns
a status

Definition at line 93 of file NEFloorKernel.cpp.

94 {
95  ARM_COMPUTE_RETURN_ON_ERROR(validate_arguments(input, output));
96  ARM_COMPUTE_RETURN_ON_ERROR(validate_and_configure_window(input->clone().get(), output->clone().get()).first);
97 
98  return Status{};
99 }
std::pair< Status, Window > validate_and_configure_window(ITensorInfo *input, ITensorInfo *weights, ITensorInfo *biases, ITensorInfo *output, const PadStrideInfo &conv_info, unsigned int depth_multiplier, const Size2D &dilation)
#define ARM_COMPUTE_RETURN_ON_ERROR(status)
Checks if a status contains an error and returns it.
Definition: Error.h:193

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

Referenced by NEFloor::validate().


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