Compute Library
 21.08
CpuFloorKernel Class Reference

Cpu accelarated kernel to perform a floor operation. More...

#include <CpuFloorKernel.h>

Collaboration diagram for CpuFloorKernel:
[legend]

Public Member Functions

 CpuFloorKernel ()=default
 
 ARM_COMPUTE_DISALLOW_COPY_ALLOW_MOVE (CpuFloorKernel)
 
void configure (const ITensorInfo *src, ITensorInfo *dst)
 Configure kernel for a given list of arguments. More...
 
Window infer_window (const ITensorInfo *src, const ITensorInfo *dst)
 Infer execution window. More...
 
void run_op (ITensorPack &tensors, const Window &window, const ThreadInfo &info) override
 Execute the kernel on the passed window. More...
 
const char * name () const override
 Name of the kernel. More...
 
- Public Member Functions inherited from ICPPKernel
virtual ~ICPPKernel ()=default
 Default destructor. More...
 
virtual void run (const Window &window, const ThreadInfo &info)
 Execute the kernel on the passed window. More...
 
virtual void run_nd (const Window &window, const ThreadInfo &info, const Window &thread_locator)
 legacy compatibility layer for implemantions which do not support thread_locator In these cases we simply narrow the interface down the legacy version 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...
 
bool is_window_configured () const
 Function to check if the embedded window of this kernel has been configured. More...
 

Static Public Member Functions

static Status validate (const ITensorInfo *src, const ITensorInfo *dst)
 Static function to check if given info will lead to a valid configuration. More...
 

Detailed Description

Cpu accelarated kernel to perform a floor operation.

Definition at line 37 of file CpuFloorKernel.h.

Constructor & Destructor Documentation

◆ CpuFloorKernel()

CpuFloorKernel ( )
default

Member Function Documentation

◆ ARM_COMPUTE_DISALLOW_COPY_ALLOW_MOVE()

ARM_COMPUTE_DISALLOW_COPY_ALLOW_MOVE ( CpuFloorKernel  )

◆ configure()

void configure ( const ITensorInfo src,
ITensorInfo dst 
)

Configure kernel for a given list of arguments.

Parameters
[in]srcSource tensor. Data type supported: F16/F32.
[out]dstDestination tensor. Same as src

Definition at line 110 of file CpuFloorKernel.cpp.

References ARM_COMPUTE_ERROR_ON_NULLPTR, ARM_COMPUTE_ERROR_THROW_ON, arm_compute::auto_init_if_empty(), arm_compute::calculate_max_window(), ITensorInfo::data_type(), and ITensorInfo::tensor_shape().

111 {
113  ARM_COMPUTE_ERROR_THROW_ON(validate_arguments(src, dst));
114 
115  auto_init_if_empty(*dst, src->tensor_shape(), 1, src->data_type());
116 
117  const auto *uk = get_implementation(FloorSelectorData{ src->data_type() });
119 
120  _run_method = uk->ukernel;
121  _name = std::string("CpuFloorKernel").append("/").append(uk->name);
122 
123  // Configure kernel window
124  const Window win = calculate_max_window(*src, Steps());
125 
126  ICPPKernel::configure(win);
127 }
Window calculate_max_window(const ValidRegion &valid_region, const Steps &steps, bool skip_border, BorderSize border_size)
#define ARM_COMPUTE_ERROR_THROW_ON(status)
Definition: Error.h:455
SimpleTensor< float > src
Definition: DFT.cpp:155
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...
#define ARM_COMPUTE_ERROR_ON_NULLPTR(...)
Definition: Validate.h:157

◆ infer_window()

Window infer_window ( const ITensorInfo src,
const ITensorInfo dst 
)

Infer execution window.

Parameters
[in]srcSource tensor info. Data type supported: F16/F32.
[in]dstDestination tensor info. Same as src
Returns
an execution Window

Definition at line 129 of file CpuFloorKernel.cpp.

References ARM_COMPUTE_ERROR_ON, ARM_COMPUTE_UNUSED, ITensorInfo::tensor_shape(), and Window::use_tensor_dimensions().

130 {
132  ARM_COMPUTE_ERROR_ON(!bool(validate_arguments(src, dst)));
133 
134  Window win;
135  win.use_tensor_dimensions(src->tensor_shape());
136  return win;
137 }
#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
SimpleTensor< float > src
Definition: DFT.cpp:155
#define ARM_COMPUTE_UNUSED(...)
To avoid unused variables warnings.
Definition: Error.h:152

◆ name()

const char * name ( ) const
overridevirtual

Name of the kernel.

Returns
Kernel name

Implements ICPPKernel.

Definition at line 171 of file CpuFloorKernel.cpp.

172 {
173  return _name.c_str();
174 }

◆ run_op()

void run_op ( ITensorPack tensors,
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]tensorsA vector containing the tensors to operate on.
[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.

Reimplemented from ICPPKernel.

Definition at line 145 of file CpuFloorKernel.cpp.

References arm_compute::ACL_DST, arm_compute::ACL_SRC, ARM_COMPUTE_ERROR_ON, ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW, ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL, ARM_COMPUTE_UNUSED, Window::DimX, arm_compute::test::validation::dst, ITensorPack::empty(), Window::Dimension::end(), arm_compute::execute_window_loop(), ITensorPack::get_const_tensor(), ITensorPack::get_tensor(), Iterator::ptr(), Window::set(), arm_compute::test::validation::src, Window::Dimension::start(), IKernel::window(), and Window::x().

146 {
150 
151  ARM_COMPUTE_ERROR_ON(tensors.empty());
152  ARM_COMPUTE_ERROR_ON(_run_method == nullptr);
153 
154  const ITensor *src = tensors.get_const_tensor(TensorType::ACL_SRC);
155  ITensor *dst = tensors.get_tensor(TensorType::ACL_DST);
156  const auto len = static_cast<int>(window.x().end()) - static_cast<int>(window.x().start());
157 
158  Window win{ window };
159  win.set(Window::DimX, Window::Dimension(0, 1, 1));
160 
161  Iterator src_it(src, win);
162  Iterator dst_it(dst, win);
163 
164  execute_window_loop(win, [&](const Coordinates &)
165  {
166  _run_method(src_it.ptr(), dst_it.ptr(), len);
167  },
168  src_it, dst_it);
169 }
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
SimpleTensor< float > src
Definition: DFT.cpp:155
static constexpr size_t DimX
Alias for dimension 0 also known as X dimension.
Definition: Window.h:43
#define ARM_COMPUTE_UNUSED(...)
To avoid unused variables warnings.
Definition: Error.h:152
void set(size_t dimension, const Dimension &dim)
Set the values of a given dimension.
Definition: Window.inl:49
#define ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(k)
Definition: Validate.h:915
ScaleKernelInfo info(interpolation_policy, default_border_mode, PixelValue(), sampling_policy, false)
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:77
constexpr int end() const
Return the end of the dimension.
Definition: Window.h:99
constexpr int start() const
Return the start of the dimension.
Definition: Window.h:94
#define ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW(f, s)
Definition: Validate.h:201
constexpr const Dimension & x() const
Alias to access the first dimension of the window.
Definition: Window.h:145

◆ validate()

Status validate ( const ITensorInfo src,
const ITensorInfo dst 
)
static

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

Similar to CpuFloorKernel::configure()

Returns
a status

Definition at line 139 of file CpuFloorKernel.cpp.

References ARM_COMPUTE_RETURN_ON_ERROR.

Referenced by CpuFloor::validate().

140 {
141  ARM_COMPUTE_RETURN_ON_ERROR(validate_arguments(input, output));
142  return Status{};
143 }
#define ARM_COMPUTE_RETURN_ON_ERROR(status)
Checks if a status contains an error and returns it.
Definition: Error.h:204

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