Compute Library
 21.02
NEEdgeTraceKernel Class Reference

Neon kernel to perform Edge tracing. More...

#include <NECannyEdgeKernel.h>

Collaboration diagram for NEEdgeTraceKernel:
[legend]

Public Member Functions

const char * name () const override
 Name of the kernel. More...
 
 NEEdgeTraceKernel ()
 Default constructor. More...
 
 NEEdgeTraceKernel (const NEEdgeTraceKernel &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
NEEdgeTraceKerneloperator= (const NEEdgeTraceKernel &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
 NEEdgeTraceKernel (NEEdgeTraceKernel &&)=default
 Allow instances of this class to be moved. More...
 
NEEdgeTraceKerneloperator= (NEEdgeTraceKernel &&)=default
 Allow instances of this class to be moved. More...
 
 ~NEEdgeTraceKernel ()
 Default destructor. More...
 
void configure (ITensor *input, ITensor *output)
 Initialise the kernel's source, destination and border mode. 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...
 
bool is_parallelisable () const override
 Indicates whether or not the kernel is parallelisable. 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...
 
const Windowwindow () const
 The maximum window the kernel can be executed on. More...
 

Detailed Description

Neon kernel to perform Edge tracing.

Definition at line 152 of file NECannyEdgeKernel.h.

Constructor & Destructor Documentation

◆ NEEdgeTraceKernel() [1/3]

Default constructor.

Definition at line 1044 of file NECannyEdgeKernel.cpp.

1045  : _input(nullptr), _output(nullptr)
1046 {
1047 }

◆ NEEdgeTraceKernel() [2/3]

NEEdgeTraceKernel ( const NEEdgeTraceKernel )
delete

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

◆ NEEdgeTraceKernel() [3/3]

Allow instances of this class to be moved.

◆ ~NEEdgeTraceKernel()

~NEEdgeTraceKernel ( )
default

Default destructor.

Referenced by NEEdgeNonMaxSuppressionKernel::run().

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 1049 of file NECannyEdgeKernel.cpp.

Referenced by NEEdgeTraceKernel::configure().

1050 {
1051  return BorderSize(1);
1052 }

◆ configure()

void configure ( ITensor input,
ITensor output 
)

Initialise the kernel's source, destination and border mode.

Parameters
[in,out]inputSource tensor. Data type supported: U8. Must contain 0 for "no edge", 127 for "maybe", 255 for "edge"
[in,out]outputDestination tensor. Data type supported: U8. Must be initialized to 0 (No edge).

Definition at line 1059 of file NECannyEdgeKernel.cpp.

References ValidRegion::anchor, 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, NEEdgeTraceKernel::border_size(), BorderSize::bottom, arm_compute::calculate_max_window(), ITensor::info(), arm_compute::test::validation::input, BorderSize::left, num_elems_processed_per_iteration, BorderSize::right, arm_compute::set_format_if_unknown(), arm_compute::set_shape_if_empty(), ValidRegion::shape, ITensorInfo::tensor_shape(), BorderSize::top, arm_compute::U8, arm_compute::update_window_and_padding(), and ITensorInfo::valid_region().

1060 {
1062 
1063  set_shape_if_empty(*output->info(), input->info()->tensor_shape());
1064 
1066  set_format_if_unknown(*output->info(), Format::U8);
1067 
1072 
1073  _input = input;
1074  _output = output;
1075 
1076  constexpr unsigned int num_elems_processed_per_iteration = 1;
1077 
1078  // Configure kernel window
1079  Window win = calculate_max_window(*_input->info(), Steps(num_elems_processed_per_iteration));
1080 
1081  const ValidRegion &input_valid_region = input->info()->valid_region();
1082  const ValidRegion &output_valid_region = output->info()->valid_region();
1083 
1084  // Reads can occur within the valid region of the input + border
1085  AccessWindowStatic input_access(input->info(),
1086  input_valid_region.anchor[0] - border_size().left,
1087  input_valid_region.anchor[1] - border_size().top,
1088  input_valid_region.anchor[0] + input_valid_region.shape[0] + border_size().right,
1089  input_valid_region.anchor[1] + input_valid_region.shape[1] + border_size().bottom);
1090 
1091  // Writes can occur within the valid region of the output + border
1092  AccessWindowStatic output_access(output->info(),
1093  output_valid_region.anchor[0] - border_size().left,
1094  output_valid_region.anchor[1] - border_size().top,
1095  output_valid_region.anchor[0] + output_valid_region.shape[0] + border_size().right,
1096  output_valid_region.anchor[1] + output_valid_region.shape[1] + border_size().bottom);
1097 
1098  update_window_and_padding(win, input_access, output_access);
1099 
1100  output_access.set_valid_region(win, _input->info()->valid_region());
1101 
1102  INEKernel::configure(win);
1103 }
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...
unsigned int top
top of the border
Definition: Types.h:375
Window calculate_max_window(const ValidRegion &valid_region, const Steps &steps, bool skip_border, BorderSize border_size)
1 channel, 1 U8 per channel
unsigned int bottom
bottom of the border
Definition: Types.h:377
virtual ValidRegion valid_region() const =0
Valid region of the tensor.
bool update_window_and_padding(Window &win, Ts &&... patterns)
Update window and padding size for each of the access patterns.
Definition: WindowHelpers.h:46
#define ARM_COMPUTE_ERROR_ON_MISMATCHING_DATA_TYPES(...)
Definition: Validate.h:543
BorderSize border_size() const override
The size of the border for that kernel.
#define ARM_COMPUTE_ERROR_ON_MISMATCHING_SHAPES(...)
Definition: Validate.h:441
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.
unsigned int left
left of the border
Definition: Types.h:378
unsigned int right
right of the border
Definition: Types.h:376
#define ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(t, c,...)
Definition: Validate.h:790
unsigned int num_elems_processed_per_iteration
#define ARM_COMPUTE_ERROR_ON_NULLPTR(...)
Definition: Validate.h:161

◆ is_parallelisable()

bool is_parallelisable ( ) const
overridevirtual

Indicates whether or not the kernel is parallelisable.

If the kernel is parallelisable then the window returned by window() can be split into sub-windows which can then be run in parallel.

If the kernel is not parallelisable then only the window returned by window() can be passed to run()

Returns
True if the kernel is parallelisable

Reimplemented from IKernel.

Definition at line 1054 of file NECannyEdgeKernel.cpp.

1055 {
1056  return false;
1057 }

◆ name()

const char* name ( ) const
inlineoverridevirtual

◆ operator=() [1/2]

NEEdgeTraceKernel& operator= ( const NEEdgeTraceKernel )
delete

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

◆ operator=() [2/2]

NEEdgeTraceKernel& operator= ( NEEdgeTraceKernel &&  )
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 1105 of file NECannyEdgeKernel.cpp.

References ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW, ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL, ARM_COMPUTE_UNUSED, arm_compute::execute_window_loop(), ITensor::info(), arm_compute::test::validation::input, Iterator::ptr(), ITensorInfo::strides_in_bytes(), and IKernel::window().

1106 {
1110  Iterator input(_input, window);
1111  Iterator output(_output, window);
1112 
1113  const size_t input_stride = _input->info()->strides_in_bytes()[1];
1114  const size_t output_stride = _output->info()->strides_in_bytes()[1];
1115 
1116  execute_window_loop(window, [&](const Coordinates &)
1117  {
1118  edge_trace_U8_U8(input.ptr(), output.ptr(), input_stride, output_stride);
1119  },
1120  input, output);
1121 }
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
virtual ITensorInfo * info() const =0
Interface to be implemented by the child class to return the tensor&#39;s metadata.
#define ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(k)
Definition: Validate.h:941
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
virtual const Strides & strides_in_bytes() const =0
The strides in bytes for accessing each dimension of the tensor.
#define ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW(f, s)
Definition: Validate.h:205

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