Compute Library
 21.08
NEBitwiseAndKernel Class Reference

Interface for the kernel to perform bitwise AND between XY-planes of two tensors. More...

#include <NEBitwiseAndKernel.h>

Collaboration diagram for NEBitwiseAndKernel:
[legend]

Public Member Functions

const char * name () const override
 Name of the kernel. More...
 
 NEBitwiseAndKernel ()
 Default constructor. More...
 
 NEBitwiseAndKernel (const NEBitwiseAndKernel &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
NEBitwiseAndKerneloperator= (const NEBitwiseAndKernel &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
 NEBitwiseAndKernel (NEBitwiseAndKernel &&)=default
 Allow instances of this class to be moved. More...
 
NEBitwiseAndKerneloperator= (NEBitwiseAndKernel &&)=default
 Allow instances of this class to be moved. More...
 
 ~NEBitwiseAndKernel ()=default
 Default destructor. More...
 
void configure (const ITensor *input1, const ITensor *input2, ITensor *output)
 Initialise the kernel's inputs and output. More...
 
void run (const Window &window, const ThreadInfo &info) override
 Execute the kernel on the passed window. More...
 
- Public Member Functions inherited from ICPPKernel
virtual ~ICPPKernel ()=default
 Default destructor. 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...
 
virtual void run_op (ITensorPack &tensors, const Window &window, const ThreadInfo &info)
 Execute the kernel on the passed window. 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...
 

Detailed Description

Interface for the kernel to perform bitwise AND between XY-planes of two tensors.

Result is computed by:

\[ output(x,y) = input1(x,y) \land input2(x,y) \]

Definition at line 38 of file NEBitwiseAndKernel.h.

Constructor & Destructor Documentation

◆ NEBitwiseAndKernel() [1/3]

Default constructor.

Definition at line 58 of file NEBitwiseAndKernel.cpp.

Referenced by NEBitwiseAndKernel::name().

59  : _input1(nullptr), _input2(nullptr), _output(nullptr)
60 {
61 }

◆ NEBitwiseAndKernel() [2/3]

NEBitwiseAndKernel ( const NEBitwiseAndKernel )
delete

Prevent instances of this class from being copied (As this class contains pointers)

◆ NEBitwiseAndKernel() [3/3]

Allow instances of this class to be moved.

◆ ~NEBitwiseAndKernel()

~NEBitwiseAndKernel ( )
default

Default destructor.

Referenced by NEBitwiseAndKernel::name().

Member Function Documentation

◆ configure()

void configure ( const ITensor input1,
const ITensor input2,
ITensor output 
)

Initialise the kernel's inputs and output.

Parameters
[in]input1An input tensor. Data type supported: U8.
[in]input2An input tensor. Data type supported: U8
[out]outputOutput tensor. Data type supported: U8.

Definition at line 63 of file NEBitwiseAndKernel.cpp.

References ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN, ARM_COMPUTE_ERROR_ON_MISMATCHING_DATA_TYPES, ARM_COMPUTE_ERROR_ON_MISMATCHING_SHAPES, ARM_COMPUTE_ERROR_ON_NULLPTR, arm_compute::calculate_max_window(), arm_compute::test::validation::configure(), ITensor::info(), num_elems_processed_per_iteration, arm_compute::set_format_if_unknown(), arm_compute::set_shape_if_empty(), ITensorInfo::tensor_shape(), arm_compute::U8, and arm_compute::update_window_and_padding().

Referenced by NEBitwiseAndKernel::name().

64 {
65  ARM_COMPUTE_ERROR_ON_NULLPTR(input1, input2, output);
66 
67  set_shape_if_empty(*output->info(), input1->info()->tensor_shape());
68 
72 
73  ARM_COMPUTE_ERROR_ON_MISMATCHING_SHAPES(input1, input2, output);
77  ARM_COMPUTE_ERROR_ON_MISMATCHING_DATA_TYPES(input1, input2, output);
78 
79  _input1 = input1;
80  _input2 = input2;
81  _output = output;
82 
83  constexpr unsigned int num_elems_processed_per_iteration = 16;
84 
85  // Configure kernel window
86  Window win = calculate_max_window(*input1->info(), Steps(num_elems_processed_per_iteration));
88 
92  output_access);
93 
94  INEKernel::configure(win);
95 }
bool set_format_if_unknown(ITensorInfo &info, Format format)
Set the format, data type and number of channels to the specified value if the current data type is u...
Window calculate_max_window(const ValidRegion &valid_region, const Steps &steps, bool skip_border, BorderSize border_size)
1 channel, 1 U8 per channel
bool update_window_and_padding(Window &win, Ts &&... patterns)
Update window and padding size for each of the access patterns.
Definition: WindowHelpers.h:46
virtual const TensorShape & tensor_shape() const =0
Size for each dimension of the tensor.
#define ARM_COMPUTE_ERROR_ON_MISMATCHING_DATA_TYPES(...)
Definition: Validate.h:539
Class to describe a number of elements in each dimension.
Definition: Steps.h:40
Implementation of a row access pattern.
#define ARM_COMPUTE_ERROR_ON_MISMATCHING_SHAPES(...)
Definition: Validate.h:437
unsigned int num_elems_processed_per_iteration
virtual ITensorInfo * info() const =0
Interface to be implemented by the child class to return the tensor&#39;s metadata.
bool set_shape_if_empty(ITensorInfo &info, const TensorShape &shape)
Set the shape to the specified value if the current assignment is empty.
#define ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(t, c,...)
Definition: Validate.h:786
#define ARM_COMPUTE_ERROR_ON_NULLPTR(...)
Definition: Validate.h:157
Describe a multidimensional execution window.
Definition: Window.h:39

◆ name()

const char* name ( ) const
inlineoverridevirtual

◆ operator=() [1/2]

NEBitwiseAndKernel& operator= ( const NEBitwiseAndKernel )
delete

Prevent instances of this class from being copied (As this class contains pointers)

Referenced by NEBitwiseAndKernel::name().

◆ operator=() [2/2]

NEBitwiseAndKernel& operator= ( NEBitwiseAndKernel &&  )
default

Allow instances of this class to be moved.

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

Reimplemented from ICPPKernel.

Definition at line 97 of file NEBitwiseAndKernel.cpp.

References ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW, ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL, ARM_COMPUTE_UNUSED, arm_compute::execute_window_loop(), Iterator::ptr(), and IKernel::window().

Referenced by NEBitwiseAndKernel::name().

98 {
99  ARM_COMPUTE_UNUSED(info);
102  Iterator input1(_input1, window);
103  Iterator input2(_input2, window);
104  Iterator output(_output, window);
105 
106  execute_window_loop(window, [&](const Coordinates &)
107  {
108  bitwise_and<uint8_t>(input1.ptr(), input2.ptr(), output.ptr());
109  },
110  input1, input2, output);
111 }
const Window & window() const
The maximum window the kernel can be executed on.
Definition: IKernel.cpp:28
#define ARM_COMPUTE_UNUSED(...)
To avoid unused variables warnings.
Definition: Error.h:152
Coordinates of an item.
Definition: Coordinates.h:37
#define ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(k)
Definition: Validate.h:915
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
Iterator updated by execute_window_loop for each window element.
Definition: Helpers.h:46
#define ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW(f, s)
Definition: Validate.h:201

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