Compute Library
 22.11
CLFillBorderKernel Class Reference

Interface for filling the border of a kernel. More...

#include <CLFillBorderKernel.h>

Collaboration diagram for CLFillBorderKernel:
[legend]

Public Member Functions

 CLFillBorderKernel ()
 Default constructor. More...
 
 CLFillBorderKernel (const CLFillBorderKernel &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
CLFillBorderKerneloperator= (const CLFillBorderKernel &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
 CLFillBorderKernel (CLFillBorderKernel &&)=default
 Allow instances of this class to be moved. More...
 
CLFillBorderKerneloperator= (CLFillBorderKernel &&)=default
 Allow instances of this class to be moved. More...
 
 ~CLFillBorderKernel ()=default
 Default destructor. More...
 
void configure (const CLCompileContext &compile_context, ICLTensor *tensor, BorderSize border_size, BorderMode border_mode, const PixelValue &constant_border_value=PixelValue())
 Initialise the kernel's input, output and border mode. More...
 
void configure (ICLTensor *tensor, BorderSize border_size, BorderMode border_mode, const PixelValue &constant_border_value=PixelValue())
 Initialise the kernel's input, output and border mode. More...
 
void configure (const CLCompileContext &compile_context, ITensorInfo *tensor, BorderSize border_size, BorderMode border_mode, const PixelValue &constant_border_value=PixelValue())
 Initialise the kernel's input, output and border mode. More...
 
template<class T >
void set_constant_border (unsigned int idx, const PixelValue &constant_border_value)
 Function to set the constant value on fill border kernel depending on type. More...
 
void run_op (ITensorPack &tensors, const Window &window, cl::CommandQueue &queue) override
 Enqueue the OpenCL kernel to process the given window on the passed OpenCL command queue. More...
 
void run (const Window &window, cl::CommandQueue &queue) override
 Enqueue the OpenCL kernel to process the given window on the passed OpenCL command queue. More...
 
bool is_parallelisable () const override
 Indicates whether or not the kernel is parallelisable. More...
 
- Public Member Functions inherited from ICLKernel
 ICLKernel ()
 Constructor. More...
 
cl::Kernel & kernel ()
 Returns a reference to the OpenCL kernel of this object. More...
 
CLKernelType type () const
 Returns the CL kernel type. More...
 
template<typename T >
void add_1D_array_argument (unsigned int &idx, const ICLArray< T > *array, const Strides &strides, unsigned int num_dimensions, const Window &window)
 Add the passed 1D array's parameters to the object's kernel's arguments starting from the index idx. More...
 
void add_1D_tensor_argument (unsigned int &idx, const ICLTensor *tensor, const Window &window)
 Add the passed 1D tensor's parameters to the object's kernel's arguments starting from the index idx. More...
 
void add_1D_tensor_argument_if (bool cond, unsigned int &idx, const ICLTensor *tensor, const Window &window)
 Add the passed 1D tensor's parameters to the object's kernel's arguments starting from the index idx if the condition is true. More...
 
void add_2D_tensor_argument (unsigned int &idx, const ICLTensor *tensor, const Window &window)
 Add the passed 2D tensor's parameters to the object's kernel's arguments starting from the index idx. More...
 
void add_2D_tensor_argument_if (bool cond, unsigned int &idx, const ICLTensor *tensor, const Window &window)
 Add the passed 2D tensor's parameters to the object's kernel's arguments starting from the index idx if the condition is true. More...
 
void add_3D_tensor_argument (unsigned int &idx, const ICLTensor *tensor, const Window &window)
 Add the passed 3D tensor's parameters to the object's kernel's arguments starting from the index idx. More...
 
void add_4D_tensor_argument (unsigned int &idx, const ICLTensor *tensor, const Window &window)
 Add the passed 4D tensor's parameters to the object's kernel's arguments starting from the index idx. More...
 
void add_5D_tensor_argument (unsigned int &idx, const ICLTensor *tensor, const Window &window)
 Add the passed 5D tensor's parameters to the object's kernel's arguments starting from the index idx. More...
 
void add_3d_tensor_nhw_argument (unsigned int &idx, const ICLTensor *tensor)
 Add the passed NHW 3D tensor's parameters to the object's kernel's arguments by passing strides, dimensions and the offset to the first valid element in bytes. More...
 
void add_4d_tensor_nhwc_argument (unsigned int &idx, const ICLTensor *tensor)
 Add the passed NHWC 4D tensor's parameters to the object's kernel's arguments by passing strides, dimensions and the offset to the first valid element in bytes. More...
 
virtual void run_composite_op (ITensorPack &tensors, const Window &window, cl::CommandQueue &queue, const experimental::dynamic_fusion::ClExecutionDescriptor &exec_desc)
 The execution is carried out through run_op method. But the run_op method needs to be extended to include ClExecutionDescriptor as now LWS GWS tuning will be separated from the IKernel. More...
 
template<typename T >
void add_argument (unsigned int &idx, T value)
 Add the passed parameters to the object's kernel's arguments starting from the index idx. More...
 
void set_lws_hint (const cl::NDRange &lws_hint)
 Set the Local-Workgroup-Size hint. More...
 
cl::NDRange lws_hint () const
 Return the Local-Workgroup-Size hint. More...
 
void set_wbsm_hint (const cl_int &wbsm_hint)
 Set the workgroup batch size modifier hint. More...
 
cl_int wbsm_hint () const
 Return the workgroup batch size modifier hint. More...
 
const std::string & config_id () const
 Get the configuration ID. More...
 
void set_target (GPUTarget target)
 Set the targeted GPU architecture. More...
 
void set_target (cl::Device &device)
 Set the targeted GPU architecture according to the CL device. More...
 
GPUTarget get_target () const
 Get the targeted GPU architecture. More...
 
size_t get_max_workgroup_size ()
 Get the maximum workgroup size for the device the CLKernelLibrary uses. More...
 
template<unsigned int dimension_size>
void add_tensor_argument (unsigned &idx, const ICLTensor *tensor, const Window &window)
 
template<typename T , unsigned int dimension_size>
void add_array_argument (unsigned &idx, const ICLArray< T > *array, const Strides &strides, unsigned int num_dimensions, const Window &window)
 Add the passed array's parameters to the object's kernel's arguments starting from the index idx. More...
 
- Public Member Functions inherited from IKernel
 IKernel ()
 Constructor. More...
 
virtual ~IKernel ()=default
 Destructor. 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...
 

Additional Inherited Members

- Static Public Member Functions inherited from ICLKernel
static constexpr unsigned int num_arguments_per_3d_tensor_nhw ()
 Returns the number of arguments enqueued per NHW 3D Tensor object. More...
 
static constexpr unsigned int num_arguments_per_4d_tensor_nhwc ()
 Returns the number of arguments enqueued per NHWC 4D Tensor object. More...
 
static constexpr unsigned int num_arguments_per_1D_array ()
 Returns the number of arguments enqueued per 1D array object. More...
 
static constexpr unsigned int num_arguments_per_1D_tensor ()
 Returns the number of arguments enqueued per 1D tensor object. More...
 
static constexpr unsigned int num_arguments_per_2D_tensor ()
 Returns the number of arguments enqueued per 2D tensor object. More...
 
static constexpr unsigned int num_arguments_per_3D_tensor ()
 Returns the number of arguments enqueued per 3D tensor object. More...
 
static constexpr unsigned int num_arguments_per_4D_tensor ()
 Returns the number of arguments enqueued per 4D tensor object. More...
 
static cl::NDRange gws_from_window (const Window &window)
 Get the global work size given an execution window. More...
 

Detailed Description

Interface for filling the border of a kernel.

Definition at line 36 of file CLFillBorderKernel.h.

Constructor & Destructor Documentation

◆ CLFillBorderKernel() [1/3]

Default constructor.

Definition at line 39 of file CLFillBorderKernel.cpp.

References arm_compute::ELEMENTWISE.

40  : ICLKernel(), _tensor(nullptr)
41 {
43 }
Elementwise CL kernel type.
Definition: CLTypes.h:85
ICLKernel()
Constructor.
Definition: ICLKernel.h:139

◆ CLFillBorderKernel() [2/3]

CLFillBorderKernel ( const CLFillBorderKernel )
delete

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

◆ CLFillBorderKernel() [3/3]

Allow instances of this class to be moved.

◆ ~CLFillBorderKernel()

~CLFillBorderKernel ( )
default

Default destructor.

Member Function Documentation

◆ configure() [1/3]

void configure ( const CLCompileContext compile_context,
ICLTensor tensor,
BorderSize  border_size,
BorderMode  border_mode,
const PixelValue constant_border_value = PixelValue() 
)

Initialise the kernel's input, output and border mode.

Parameters
[in]compile_contextThe compile context to be used.
[in,out]tensorTensor to process Data types supported: U8/QASYMM8/S8/QASYMM8_SIGNED/U16/S16/U32/S32/F16/F32.
[in]border_sizeSize of the border to fill in elements.
[in]border_modeBorder mode to use for the convolution.
[in]constant_border_value(Optional) Constant value to use for borders if border_mode is set to CONSTANT.

Definition at line 63 of file CLFillBorderKernel.cpp.

References IKernel::border_size(), ITensor::info(), and tensor.

Referenced by CLFillBorderKernel::configure(), ClWinogradConv2d::configure(), and arm_compute::test::validation::DATA_TEST_CASE().

64 {
65  _tensor = tensor;
66  configure(compile_context, tensor->info(), border_size, border_mode, constant_border_value);
67 }
void configure(const CLCompileContext &compile_context, ICLTensor *tensor, BorderSize border_size, BorderMode border_mode, const PixelValue &constant_border_value=PixelValue())
Initialise the kernel&#39;s input, output and border mode.
virtual BorderSize border_size() const
The size of the border for that kernel.
Definition: IKernel.cpp:46
CLTensor * tensor
Pointer to the auxiliary tensor.

◆ configure() [2/3]

void configure ( ICLTensor tensor,
BorderSize  border_size,
BorderMode  border_mode,
const PixelValue constant_border_value = PixelValue() 
)

Initialise the kernel's input, output and border mode.

Parameters
[in,out]tensorTensor to process Data types supported: U8/QASYMM8/S8/QASYMM8_SIGNED/U16/S16/U32/S32/F16/F32.
[in]border_sizeSize of the border to fill in elements.
[in]border_modeBorder mode to use for the convolution.
[in]constant_border_value(Optional) Constant value to use for borders if border_mode is set to CONSTANT.

Definition at line 58 of file CLFillBorderKernel.cpp.

References CLFillBorderKernel::configure(), and CLKernelLibrary::get().

59 {
60  configure(CLKernelLibrary::get().get_compile_context(), tensor, border_size, border_mode, constant_border_value);
61 }
void configure(const CLCompileContext &compile_context, ICLTensor *tensor, BorderSize border_size, BorderMode border_mode, const PixelValue &constant_border_value=PixelValue())
Initialise the kernel&#39;s input, output and border mode.
static CLKernelLibrary & get()
Access the KernelLibrary singleton.
virtual BorderSize border_size() const
The size of the border for that kernel.
Definition: IKernel.cpp:46
CLTensor * tensor
Pointer to the auxiliary tensor.

◆ configure() [3/3]

void configure ( const CLCompileContext compile_context,
ITensorInfo tensor,
BorderSize  border_size,
BorderMode  border_mode,
const PixelValue constant_border_value = PixelValue() 
)

Initialise the kernel's input, output and border mode.

Parameters
[in]compile_contextThe compile context to be used.
[in,out]tensorTensor to process Data types supported: U8/QASYMM8/S8/QASYMM8_SIGNED/U16/S16/U32/S32/F16/F32.
[in]border_sizeSize of the border to fill in elements.
[in]border_modeBorder mode to use for the convolution.
[in]constant_border_value(Optional) Constant value to use for borders if border_mode is set to CONSTANT.

Definition at line 69 of file CLFillBorderKernel.cpp.

References CLBuildOptions::add_option(), ValidRegion::anchor, ARM_COMPUTE_ERROR, ARM_COMPUTE_ERROR_ON, BorderSize::bottom, arm_compute::CONSTANT, arm_compute::create_kernel(), ITensorInfo::data_type(), ITensorInfo::dimension(), Window::DimX, Window::DimY, Window::DimZ, dt, BorderSize::empty(), arm_compute::F16, arm_compute::F32, arm_compute::get_cl_type_from_data_type(), arm_compute::get_padding_info(), arm_compute::has_padding_changed(), kernel_name, BorderSize::left, BorderSize::limit(), arm_compute::lower_string(), ICLKernel::num_arguments_per_3D_tensor(), ITensorInfo::num_channels(), CLBuildOptions::options(), ITensorInfo::padding(), arm_compute::QASYMM8, arm_compute::QASYMM8_SIGNED, BorderSize::right, arm_compute::S16, arm_compute::S32, arm_compute::S8, Window::set(), ValidRegion::shape, arm_compute::string_from_border_mode(), arm_compute::string_from_data_type(), ITensorInfo::tensor_shape(), arm_compute::support::cpp11::to_string(), BorderSize::top, arm_compute::U16, arm_compute::U32, arm_compute::U8, arm_compute::UNDEFINED, Window::use_tensor_dimensions(), and ITensorInfo::valid_region().

70 {
71  ARM_COMPUTE_ERROR_ON(tensor == nullptr);
72  ARM_COMPUTE_ERROR_ON(tensor->num_channels() != 1);
73  auto padding_info = get_padding_info({ tensor });
74 
75  border_size.limit(tensor->padding());
76 
77  // If there is no border: early exit
78  if(border_size.empty() || border_mode == BorderMode::UNDEFINED)
79  {
80  return;
81  }
82 
83  // Select appropriate kernel
84  std::string kernel_name = "fill_image_borders_" + lower_string(string_from_border_mode(border_mode));
85 
86  const DataType dt = tensor->data_type();
87 
88  // Define build options
89  CLBuildOptions build_opts;
90  build_opts.add_option("-DDATA_TYPE=" + get_cl_type_from_data_type(dt));
91  build_opts.add_option("-DBORDER_SIZE_TOP=" + support::cpp11::to_string(border_size.top));
92  build_opts.add_option("-DBORDER_SIZE_BOTTOM=" + support::cpp11::to_string(border_size.bottom));
93  build_opts.add_option("-DBORDER_SIZE_LEFT=" + support::cpp11::to_string(border_size.left));
94  build_opts.add_option("-DBORDER_SIZE_RIGHT=" + support::cpp11::to_string(border_size.right));
95 
96  // Create kernel
97  _kernel = create_kernel(compile_context, kernel_name, build_opts.options());
98 
99  // Create static kernel arguments
100  const unsigned int valid_width = tensor->valid_region().shape[0];
101  const unsigned int valid_height = tensor->valid_region().shape[1];
102  const cl_int2 valid_region_coords =
103  {
104  {
105  static_cast<cl_int>(tensor->valid_region().anchor[0]),
106  static_cast<cl_int>(tensor->valid_region().anchor[1]),
107  }
108  };
109  const unsigned int total_valid_width = border_size.left + valid_width + border_size.right;
110 
111  // Set static kernel arguments
112  unsigned int idx = num_arguments_per_3D_tensor(); //Skip the tensor parameters
113  ICLKernel::add_argument<cl_uint>(idx, valid_width);
114  ICLKernel::add_argument<cl_uint>(idx, valid_height);
115  ICLKernel::add_argument<cl_int2>(idx, valid_region_coords);
116  if(BorderMode::CONSTANT == border_mode)
117  {
118  switch(dt)
119  {
120  case DataType::U8:
121  case DataType::QASYMM8:
122  set_constant_border<uint8_t>(idx, constant_border_value);
123  break;
124  case DataType::S8:
126  set_constant_border<int8_t>(idx, constant_border_value);
127  break;
128  case DataType::U16:
129  set_constant_border<uint16_t>(idx, constant_border_value);
130  break;
131  case DataType::S16:
132  set_constant_border<int16_t>(idx, constant_border_value);
133  break;
134  case DataType::U32:
135  set_constant_border<uint32_t>(idx, constant_border_value);
136  break;
137  case DataType::S32:
138  set_constant_border<int32_t>(idx, constant_border_value);
139  break;
140  case DataType::F32:
141  static_assert(sizeof(float) == 4, "Float must be 32 bit");
142  set_constant_border<float>(idx, constant_border_value);
143  break;
144  case DataType::F16:
145  static_assert(sizeof(cl_half) == sizeof(half), "Half must be same size as cl_half");
146  static_assert(sizeof(cl_half) == 2, "Half must be 16 bit");
147  set_constant_border<half>(idx, constant_border_value);
148  break;
149  default:
150  ARM_COMPUTE_ERROR("Not handled");
151  }
152  }
153 
154  // Configure kernel window
155  Window win;
156  win.set(Window::DimX, Window::Dimension(0, total_valid_width + valid_height));
157  win.set(Window::DimY, Window::Dimension(0, 1, 1));
158  win.use_tensor_dimensions(tensor->tensor_shape(), Window::DimZ);
159  ICLKernel::configure_internal(win);
160 
161  // Set config_id for enabling LWS tuning
162  _config_id = kernel_name;
163  _config_id += "_";
164  _config_id += lower_string(string_from_data_type(dt));
165  _config_id += "_";
166  _config_id += support::cpp11::to_string(tensor->dimension(0));
167  _config_id += "_";
168  _config_id += support::cpp11::to_string(tensor->dimension(1));
169  _config_id += "_";
170  _config_id += lower_string(string_from_border_mode(border_mode));
172 }
unsigned int top
top of the border
Definition: Types.h:390
#define ARM_COMPUTE_ERROR(msg)
Print the given message then throw an std::runtime_error.
Definition: Error.h:352
1 channel, 1 U8 per channel
std::string to_string(T &&value)
Convert integer and float values to string.
half_float::half half
16-bit floating point type
Definition: Types.h:48
1 channel, 1 F32 per channel
#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
1 channel, 1 U16 per channel
unsigned int bottom
bottom of the border
Definition: Types.h:392
std::string lower_string(const std::string &val)
Lower a given string.
Definition: Utils.cpp:353
1 channel, 1 F16 per channel
const std::string & string_from_border_mode(BorderMode border_mode)
Translates a given border mode policy to a string.
Definition: Utils.cpp:201
1 channel, 1 S32 per channel
cl::Kernel create_kernel(const CLCompileContext &ctx, const std::string &kernel_name, const std::set< std::string > &build_opts=std::set< std::string >())
Creates an opencl kernel using a compile context.
Definition: CLHelpers.cpp:404
const std::string & string_from_data_type(DataType dt)
Convert a data type identity into a string.
Definition: Utils.cpp:135
static constexpr size_t DimX
Alias for dimension 0 also known as X dimension.
Definition: Window.h:43
static constexpr unsigned int num_arguments_per_3D_tensor()
Returns the number of arguments enqueued per 3D tensor object.
Definition: ICLKernel.h:313
1 channel, 1 U32 per channel
quantized, asymmetric fixed-point 8-bit number unsigned
std::string get_cl_type_from_data_type(const DataType &dt)
Translates a tensor data type to the appropriate OpenCL type.
Definition: CLHelpers.cpp:39
virtual BorderSize border_size() const
The size of the border for that kernel.
Definition: IKernel.cpp:46
unsigned int left
left of the border
Definition: Types.h:393
unsigned int right
right of the border
Definition: Types.h:391
1 channel, 1 S16 per channel
bool has_padding_changed(const std::unordered_map< const ITensorInfo *, PaddingSize > &padding_map)
Check if the previously stored padding info has changed after configuring a kernel.
Definition: Utils.cpp:603
static constexpr size_t DimY
Alias for dimension 1 also known as Y dimension.
Definition: Window.h:45
constexpr bool empty() const
Check if the entire border is zero.
Definition: Types.h:315
static constexpr size_t DimZ
Alias for dimension 2 also known as Z dimension.
Definition: Window.h:47
Borders are left undefined.
std::unordered_map< const ITensorInfo *, PaddingSize > get_padding_info(std::initializer_list< const ITensorInfo *> infos)
Stores padding information before configuring a kernel.
Definition: Utils.cpp:588
CLTensor * tensor
Pointer to the auxiliary tensor.
quantized, asymmetric fixed-point 8-bit number signed
std::string kernel_name
DataType
Available data types.
Definition: Types.h:79
signed 8-bit number
void limit(const BorderSize &limit)
Limit this border size.
Definition: Types.h:382

◆ 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 45 of file CLFillBorderKernel.cpp.

46 {
47  return false;
48 }

◆ operator=() [1/2]

CLFillBorderKernel& operator= ( const CLFillBorderKernel )
delete

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

◆ operator=() [2/2]

CLFillBorderKernel& operator= ( CLFillBorderKernel &&  )
default

Allow instances of this class to be moved.

◆ run()

void run ( const Window window,
cl::CommandQueue &  queue 
)
overridevirtual

Enqueue the OpenCL kernel to process the given window on the passed OpenCL command queue.

Note
The queue is not flushed by this method, and therefore the kernel will not have been executed by the time this method returns.
Parameters
[in]windowRegion on which to execute the kernel. (Must be a valid region of the window returned by window()).
[in,out]queueCommand queue on which to enqueue the kernel.

Reimplemented from ICLKernel.

Definition at line 199 of file CLFillBorderKernel.cpp.

References ICLKernel::add_3D_tensor_argument(), ARM_COMPUTE_ERROR_ON_MISMATCHING_WINDOWS, ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL, Window::collapse_if_possible(), Window::DimZ, arm_compute::enqueue(), Window::first_slice_window_3D(), ICLKernel::lws_hint(), arm_compute::test::validation::reference::slice(), Window::slide_window_slice_3D(), and IKernel::window().

Referenced by arm_compute::test::validation::DATA_TEST_CASE().

200 {
201  // Border mode undefined or border width == 0
202  if(_kernel() == nullptr)
203  {
204  return;
205  }
206 
209 
211  Window slice = collapsed.first_slice_window_3D();
212 
213  do
214  {
215  unsigned int idx = 0;
216  add_3D_tensor_argument(idx, _tensor, slice);
217  enqueue(queue, *this, slice, lws_hint());
218  }
219  while(collapsed.slide_window_slice_3D(slice));
220 }
const Window & window() const
The maximum window the kernel can be executed on.
Definition: IKernel.cpp:28
void enqueue(cl::CommandQueue &queue, ICLKernel &kernel, const Window &window, const cl::NDRange &lws_hint=CLKernelLibrary::get().default_ndrange(), bool use_dummy_work_items=false)
Add the kernel to the command queue with the given window.
Definition: ICLKernel.cpp:32
cl::NDRange lws_hint() const
Return the Local-Workgroup-Size hint.
Definition: ICLKernel.h:383
void add_3D_tensor_argument(unsigned int &idx, const ICLTensor *tensor, const Window &window)
Add the passed 3D tensor&#39;s parameters to the object&#39;s kernel&#39;s arguments starting from the index idx...
Definition: ICLKernel.h:226
#define ARM_COMPUTE_ERROR_ON_MISMATCHING_WINDOWS(f, w)
Definition: Validate.h:179
Window collapse_if_possible(const Window &full_window, size_t first, size_t last, bool *has_collapsed=nullptr) const
Collapse the dimensions between first and last if possible.
Definition: Window.inl:68
#define ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(k)
Definition: Validate.h:915
static constexpr size_t DimZ
Alias for dimension 2 also known as Z dimension.
Definition: Window.h:47
SimpleTensor< T > slice(const SimpleTensor< T > &src, Coordinates starts, Coordinates ends)

◆ run_op()

void run_op ( ITensorPack tensors,
const Window window,
cl::CommandQueue &  queue 
)
overridevirtual

Enqueue the OpenCL kernel to process the given window on the passed OpenCL command queue.

Note
The queue is not flushed by this method, and therefore the kernel will not have been executed by the time this method returns.
Parameters
[in]tensorsA vector containing the tensors to operato on.
[in]windowRegion on which to execute the kernel. (Must be a valid region of the window returned by window()).
[in,out]queueCommand queue on which to enqueue the kernel.

Reimplemented from ICLKernel.

Definition at line 174 of file CLFillBorderKernel.cpp.

References arm_compute::ACL_SRC, ICLKernel::add_3D_tensor_argument(), ARM_COMPUTE_ERROR_ON_MISMATCHING_WINDOWS, ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL, Window::collapse_if_possible(), Window::DimZ, arm_compute::enqueue(), Window::first_slice_window_3D(), ITensorPack::get_const_tensor(), ICLKernel::lws_hint(), arm_compute::test::validation::reference::slice(), Window::slide_window_slice_3D(), tensor, and IKernel::window().

175 {
176  // Border mode undefined or border width == 0
177  if(_kernel() == nullptr)
178  {
179  return;
180  }
181 
182  const auto tensor = utils::cast::polymorphic_downcast<const ICLTensor *>(tensors.get_const_tensor(TensorType::ACL_SRC));
183 
186 
188  Window slice = collapsed.first_slice_window_3D();
189 
190  do
191  {
192  unsigned int idx = 0;
193  add_3D_tensor_argument(idx, tensor, slice);
194  enqueue(queue, *this, slice, lws_hint());
195  }
196  while(collapsed.slide_window_slice_3D(slice));
197 }
const Window & window() const
The maximum window the kernel can be executed on.
Definition: IKernel.cpp:28
void enqueue(cl::CommandQueue &queue, ICLKernel &kernel, const Window &window, const cl::NDRange &lws_hint=CLKernelLibrary::get().default_ndrange(), bool use_dummy_work_items=false)
Add the kernel to the command queue with the given window.
Definition: ICLKernel.cpp:32
cl::NDRange lws_hint() const
Return the Local-Workgroup-Size hint.
Definition: ICLKernel.h:383
void add_3D_tensor_argument(unsigned int &idx, const ICLTensor *tensor, const Window &window)
Add the passed 3D tensor&#39;s parameters to the object&#39;s kernel&#39;s arguments starting from the index idx...
Definition: ICLKernel.h:226
#define ARM_COMPUTE_ERROR_ON_MISMATCHING_WINDOWS(f, w)
Definition: Validate.h:179
Window collapse_if_possible(const Window &full_window, size_t first, size_t last, bool *has_collapsed=nullptr) const
Collapse the dimensions between first and last if possible.
Definition: Window.inl:68
#define ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(k)
Definition: Validate.h:915
static constexpr size_t DimZ
Alias for dimension 2 also known as Z dimension.
Definition: Window.h:47
CLTensor * tensor
Pointer to the auxiliary tensor.
SimpleTensor< T > slice(const SimpleTensor< T > &src, Coordinates starts, Coordinates ends)

◆ set_constant_border()

void set_constant_border ( unsigned int  idx,
const PixelValue constant_border_value 
)

Function to set the constant value on fill border kernel depending on type.

Parameters
[in]idxIndex of the kernel argument to set.
[in]constant_border_valueConstant value to use for borders if border_mode is set to CONSTANT.

Definition at line 51 of file CLFillBorderKernel.cpp.

References PixelValue::get().

52 {
53  T value;
54  constant_border_value.get(value);
55  ICLKernel::add_argument<T>(idx, static_cast<T>(value));
56 }

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