Compute Library
 19.08
CLColorConvertKernel.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2016-2019 ARM Limited.
3  *
4  * SPDX-License-Identifier: MIT
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a copy
7  * of this software and associated documentation files (the "Software"), to
8  * deal in the Software without restriction, including without limitation the
9  * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10  * sell copies of the Software, and to permit persons to whom the Software is
11  * furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included in all
14  * copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22  * SOFTWARE.
23  */
25 
30 #include "arm_compute/core/Error.h"
34 #include "arm_compute/core/Types.h"
35 #include "arm_compute/core/Utils.h"
38 
39 #include <sstream>
40 
41 using namespace arm_compute;
42 
44  : _input(nullptr), _output(nullptr), _multi_input(nullptr), _multi_output(nullptr)
45 {
46 }
47 
49 {
50  ARM_COMPUTE_ERROR_ON(input == nullptr);
51  ARM_COMPUTE_ERROR_ON(output == nullptr);
52 
53  unsigned int num_elems_processed_per_iteration = 0;
54  switch(input->info()->format())
55  {
56  case Format::RGBA8888:
57  {
58  switch(output->info()->format())
59  {
60  case Format::RGB888:
61  num_elems_processed_per_iteration = 16;
62  break;
63  default:
64  ARM_COMPUTE_ERROR("Not supported");
65  break;
66  }
67  break;
68  }
69  case Format::UYVY422:
70  case Format::YUYV422:
71  {
72  switch(output->info()->format())
73  {
74  case Format::RGB888:
75  case Format::RGBA8888:
76  num_elems_processed_per_iteration = 8;
77  break;
78  default:
79  ARM_COMPUTE_ERROR("Not supported");
80  break;
81  }
82  break;
83  }
84  case Format::RGB888:
85  {
86  switch(output->info()->format())
87  {
88  case Format::RGBA8888:
89  case Format::U8:
90  num_elems_processed_per_iteration = 16;
91  break;
92  default:
93  ARM_COMPUTE_ERROR("Not supported");
94  break;
95  }
96  break;
97  }
98  default:
99  break;
100  }
101  ARM_COMPUTE_ERROR_ON_MSG(num_elems_processed_per_iteration == 0, "Conversion from %s to %s not supported",
102  string_from_format(input->info()->format()).c_str(),
103  string_from_format(output->info()->format()).c_str());
104 
105  std::stringstream kernel_name;
106 
107  kernel_name << string_from_format(input->info()->format());
108  kernel_name << "_to_";
109  kernel_name << string_from_format(output->info()->format());
110  kernel_name << "_bt709";
111 
112  _input = input;
113  _output = output;
114 
115  // Create kernel
116  _kernel = static_cast<cl::Kernel>(CLKernelLibrary::get().create_kernel(kernel_name.str()));
117 
118  // Configure kernel window
119  Window win = calculate_max_window(*input->info(), Steps(num_elems_processed_per_iteration));
120  AccessWindowHorizontal input_access(input->info(), 0, num_elems_processed_per_iteration);
121  AccessWindowHorizontal output_access(output->info(), 0, num_elems_processed_per_iteration);
122 
123  update_window_and_padding(win, input_access, output_access);
124 
125  output_access.set_valid_region(win, input->info()->valid_region());
126 
127  ICLKernel::configure_internal(win);
128 
129  // Set config_id for enabling LWS tuning
130  _config_id = kernel_name.str();
131  _config_id += "_";
132  _config_id += lower_string(string_from_data_type(input->info()->data_type()));
133  _config_id += "_";
134  _config_id += support::cpp11::to_string(input->info()->dimension(0));
135  _config_id += "_";
136  _config_id += support::cpp11::to_string(input->info()->dimension(1));
137 }
138 
140 {
142  ARM_COMPUTE_ERROR_ON(output == nullptr);
143 
144  unsigned int num_elems_processed_per_iteration = 0;
145 
146  switch(input->info()->format())
147  {
148  case Format::NV12:
149  case Format::NV21:
150  case Format::IYUV:
151  {
152  switch(output->info()->format())
153  {
154  case Format::RGB888:
155  case Format::RGBA8888:
156  num_elems_processed_per_iteration = 4;
157  break;
158  default:
159  ARM_COMPUTE_ERROR("Not supported");
160  break;
161  }
162  break;
163  }
164  default:
165  break;
166  }
167  ARM_COMPUTE_ERROR_ON_MSG(num_elems_processed_per_iteration == 0, "Conversion from %s to %s not supported",
168  string_from_format(input->info()->format()).c_str(),
169  string_from_format(output->info()->format()).c_str());
170 
171  std::stringstream kernel_name;
172 
173  kernel_name << string_from_format(input->info()->format());
174  kernel_name << "_to_";
175  kernel_name << string_from_format(output->info()->format());
176  kernel_name << "_bt709";
177 
178  _multi_input = input;
179  _output = output;
180 
181  // Create kernel
182  _kernel = static_cast<cl::Kernel>(CLKernelLibrary::get().create_kernel(kernel_name.str()));
183 
184  // Configure kernel window
185  const bool has_two_planes = (input->info()->format() == Format::NV12) || (input->info()->format() == Format::NV21);
186  const float sub_sampling = (has_two_planes || (input->info()->format() == Format::IYUV)) ? 0.5f : 1;
187 
188  Window win = calculate_max_window(*output->info(), Steps(num_elems_processed_per_iteration));
190 
191  AccessWindowHorizontal plane0_access(input->plane(0)->info(), 0, num_elems_processed_per_iteration);
192  AccessWindowRectangle plane1_access(input->plane(1)->info(), 0, 0, num_elems_processed_per_iteration, 1,
193  sub_sampling, sub_sampling);
194  AccessWindowRectangle plane2_access(has_two_planes ? nullptr : input->plane(2)->info(), 0, 0, num_elems_processed_per_iteration, 1,
195  sub_sampling, sub_sampling);
196  AccessWindowHorizontal output_access(output->info(), 0, num_elems_processed_per_iteration);
197 
199  plane0_access, plane1_access, plane2_access,
200  output_access);
201 
202  ValidRegion intersect_region = intersect_valid_regions(input->plane(0)->info()->valid_region(), input->plane(1)->info()->valid_region(),
203  input->plane(2)->info()->valid_region());
204  output_access.set_valid_region(win, ValidRegion(intersect_region.anchor, output->info()->tensor_shape()));
205 
206  ICLKernel::configure_internal(win);
207 
208  // Set config_id for enabling LWS tuning
209  _config_id = kernel_name.str();
210  _config_id += "_";
211  _config_id += lower_string(string_from_data_type(input->plane(0)->info()->data_type()));
212  _config_id += "_";
213  _config_id += support::cpp11::to_string(input->plane(0)->info()->dimension(0));
214  _config_id += "_";
215  _config_id += support::cpp11::to_string(input->plane(0)->info()->dimension(1));
216  _config_id += "_";
217  _config_id += lower_string(string_from_data_type(input->plane(1)->info()->data_type()));
218  _config_id += "_";
219  _config_id += support::cpp11::to_string(input->plane(1)->info()->dimension(0));
220  _config_id += "_";
221  _config_id += support::cpp11::to_string(input->plane(1)->info()->dimension(1));
222 }
223 
225 {
227  ARM_COMPUTE_ERROR_ON(output == nullptr);
228 
229  unsigned int num_elems_processed_per_iteration = 0;
230  unsigned int num_elems_read_per_iteration_x = 0;
231 
232  bool has_two_planes = (output->info()->format() == Format::NV12) || (output->info()->format() == Format::NV21);
233  float sub_sampling = (has_two_planes || (output->info()->format() == Format::IYUV)) ? 0.5f : 1;
234 
235  switch(input->info()->format())
236  {
237  case Format::RGB888:
238  case Format::RGBA8888:
239  {
240  switch(output->info()->format())
241  {
242  case Format::NV12:
243  case Format::IYUV:
244  num_elems_processed_per_iteration = 2;
245  num_elems_read_per_iteration_x = 8;
246  break;
247  case Format::YUV444:
248  num_elems_processed_per_iteration = 4;
249  num_elems_read_per_iteration_x = 16;
250  break;
251  default:
252  ARM_COMPUTE_ERROR("Not supported");
253  break;
254  }
255  break;
256  }
257  case Format::UYVY422:
258  case Format::YUYV422:
259  {
260  switch(output->info()->format())
261  {
262  case Format::NV12:
263  case Format::IYUV:
264  num_elems_processed_per_iteration = 8;
265  num_elems_read_per_iteration_x = 8;
266  break;
267  default:
268  ARM_COMPUTE_ERROR("Not supported");
269  break;
270  }
271  break;
272  }
273  default:
274  break;
275  }
276 
277  ARM_COMPUTE_ERROR_ON_MSG(num_elems_processed_per_iteration == 0, "Conversion from %s to %s not supported",
278  string_from_format(input->info()->format()).c_str(),
279  string_from_format(output->info()->format()).c_str());
280 
281  std::stringstream kernel_name;
282 
283  kernel_name << string_from_format(input->info()->format());
284  kernel_name << "_to_";
285  kernel_name << string_from_format(output->info()->format());
286  kernel_name << "_bt709";
287  _input = input;
288  _multi_output = output;
289 
290  // Create kernel
291  _kernel = static_cast<cl::Kernel>(CLKernelLibrary::get().create_kernel(kernel_name.str()));
292 
293  // Configure kernel window
294  Window win = calculate_max_window(*input->info(), Steps(num_elems_processed_per_iteration));
295  if((input->info()->format() != Format::RGB888 || output->info()->format() != Format::YUV444) && (input->info()->format() != Format::RGBA8888 || output->info()->format() != Format::YUV444))
296  {
298  }
299 
300  AccessWindowHorizontal output_plane0_access(output->plane(0)->info(), 0, num_elems_processed_per_iteration);
301  AccessWindowRectangle output_plane1_access(output->plane(1)->info(), 0, 0, num_elems_processed_per_iteration, 1, sub_sampling, sub_sampling);
302  AccessWindowRectangle output_plane2_access(has_two_planes ? nullptr : output->plane(2)->info(), 0, 0,
303  num_elems_processed_per_iteration, 1, sub_sampling, sub_sampling);
304 
305  AccessWindowHorizontal input_access(input->info(), 0, num_elems_read_per_iteration_x);
306 
308  input_access,
309  output_plane0_access,
310  output_plane1_access,
311  output_plane2_access);
312 
313  ValidRegion input_region = input->info()->valid_region();
314 
315  output_plane0_access.set_valid_region(win, ValidRegion(input_region.anchor, output->plane(0)->info()->tensor_shape()));
316  output_plane1_access.set_valid_region(win, ValidRegion(input_region.anchor, output->plane(1)->info()->tensor_shape()));
317  output_plane2_access.set_valid_region(win, ValidRegion(input_region.anchor, output->plane(2)->info()->tensor_shape()));
318 
319  ICLKernel::configure_internal(win);
320 
321  // Set config_id for enabling LWS tuning
322  _config_id = kernel_name.str();
323  _config_id += "_";
324  _config_id += lower_string(string_from_data_type(input->info()->data_type()));
325  _config_id += "_";
326  _config_id += support::cpp11::to_string(input->info()->dimension(0));
327  _config_id += "_";
328  _config_id += support::cpp11::to_string(input->info()->dimension(1));
329 }
330 
332 {
333  unsigned int num_elems_processed_per_iteration = 0;
334  switch(input->info()->format())
335  {
336  case Format::NV12:
337  case Format::NV21:
338  {
339  switch(output->info()->format())
340  {
341  case Format::IYUV:
342  case Format::YUV444:
343  num_elems_processed_per_iteration = 16;
344  break;
345  default:
346  ARM_COMPUTE_ERROR("Not supported");
347  break;
348  }
349  break;
350  }
351  case Format::IYUV:
352  {
353  switch(output->info()->format())
354  {
355  case Format::YUV444:
356  case Format::NV12:
357  num_elems_processed_per_iteration = 16;
358  break;
359  default:
360  ARM_COMPUTE_ERROR("Not supported");
361  break;
362  }
363  break;
364  }
365  default:
366  break;
367  }
368  ARM_COMPUTE_ERROR_ON_MSG(num_elems_processed_per_iteration == 0, "Conversion from %s to %s not supported",
369  string_from_format(input->info()->format()).c_str(),
370  string_from_format(output->info()->format()).c_str());
371 
372  std::stringstream kernel_name;
373 
374  kernel_name << string_from_format(input->info()->format());
375  kernel_name << "_to_";
376  kernel_name << string_from_format(output->info()->format());
377  kernel_name << "_bt709";
378 
379  _multi_input = input;
380  _multi_output = output;
381 
382  // Create kernel
383  bool has_two_input_planars = (input->info()->format() == Format::NV12) || (input->info()->format() == Format::NV21);
384  bool has_two_output_planars = (output->info()->format() == Format::NV12) || (output->info()->format() == Format::NV21);
385 
386  float sub_sampling_input = (has_two_input_planars || (input->info()->format() == Format::IYUV)) ? 0.5f : 1;
387  float sub_sampling_output = (has_two_output_planars || (output->info()->format() == Format::IYUV)) ? 0.5f : 1;
388 
389  _kernel = static_cast<cl::Kernel>(CLKernelLibrary::get().create_kernel(kernel_name.str()));
390 
391  Window win = calculate_max_window(*input->cl_plane(0)->info(), Steps(num_elems_processed_per_iteration));
393 
394  AccessWindowHorizontal input_plane0_access(input->plane(0)->info(), 0, num_elems_processed_per_iteration);
395  AccessWindowRectangle input_plane1_access(input->plane(1)->info(), 0, 0, num_elems_processed_per_iteration, 1,
396  sub_sampling_input, sub_sampling_input);
397  AccessWindowRectangle input_plane2_access(has_two_input_planars ? nullptr : input->plane(2)->info(), 0, 0, num_elems_processed_per_iteration, 1,
398  sub_sampling_input, sub_sampling_input);
399  AccessWindowHorizontal output_plane0_access(output->plane(0)->info(), 0, num_elems_processed_per_iteration);
400  AccessWindowRectangle output_plane1_access(output->plane(1)->info(), 0, 0, num_elems_processed_per_iteration, 1, sub_sampling_output, sub_sampling_output);
401  AccessWindowRectangle output_plane2_access(has_two_output_planars ? nullptr : output->plane(2)->info(), 0, 0,
402  num_elems_processed_per_iteration, 1, sub_sampling_output, sub_sampling_output);
403 
405  input_plane0_access, input_plane1_access, input_plane2_access,
406  output_plane0_access, output_plane1_access, output_plane2_access);
407 
408  ValidRegion intersect_region = intersect_valid_regions(input->plane(0)->info()->valid_region(), input->plane(1)->info()->valid_region(),
409  input->plane(2)->info()->valid_region());
410  output_plane0_access.set_valid_region(win, ValidRegion(intersect_region.anchor, output->plane(0)->info()->tensor_shape()));
411  output_plane1_access.set_valid_region(win, ValidRegion(intersect_region.anchor, output->plane(1)->info()->tensor_shape()));
412  output_plane2_access.set_valid_region(win, ValidRegion(intersect_region.anchor, output->plane(2)->info()->tensor_shape()));
413 
414  ICLKernel::configure_internal(win);
415 
416  // Set config_id for enabling LWS tuning
417  _config_id = kernel_name.str();
418  _config_id += "_";
419  _config_id += lower_string(string_from_data_type(input->plane(0)->info()->data_type()));
420  _config_id += "_";
421  _config_id += support::cpp11::to_string(input->plane(0)->info()->dimension(0));
422  _config_id += "_";
423  _config_id += support::cpp11::to_string(input->plane(0)->info()->dimension(1));
424  _config_id += "_";
425  _config_id += lower_string(string_from_data_type(input->plane(1)->info()->data_type()));
426  _config_id += "_";
427  _config_id += support::cpp11::to_string(input->plane(1)->info()->dimension(0));
428  _config_id += "_";
429  _config_id += support::cpp11::to_string(input->plane(1)->info()->dimension(1));
430 }
431 
432 void CLColorConvertKernel::run(const Window &window, cl::CommandQueue &queue)
433 {
436 
438 
439  if(nullptr != _input && nullptr != _output)
440  {
441  do
442  {
443  unsigned int idx = 0;
444  add_2D_tensor_argument(idx, _input, slice);
445  add_2D_tensor_argument(idx, _output, slice);
446  enqueue(queue, *this, slice, lws_hint());
447  }
449  }
450  else if(nullptr != _input && nullptr != _multi_output)
451  {
452  Format format = _multi_output->info()->format();
453  do
454  {
455  Window win_uv(slice);
456 
457  if((Format::NV12 == format) || (Format::NV21 == format) || (Format::IYUV == format))
458  {
459  win_uv.set(Window::DimX, Window::Dimension(win_uv.x().start() / 2, win_uv.x().end() / 2, win_uv.x().step() / 2));
460  win_uv.set(Window::DimY, Window::Dimension(win_uv.y().start() / 2, win_uv.y().end() / 2, 1));
461  }
462  unsigned int idx = 0;
463  add_2D_tensor_argument(idx, _input, slice);
464  add_2D_tensor_argument(idx, _multi_output->cl_plane(0), slice);
465  for(int i = 1; i < 3 && (0 != _multi_output->cl_plane(i)->info()->num_dimensions()); ++i)
466  {
467  add_2D_tensor_argument(idx, _multi_output->cl_plane(i), win_uv);
468  }
469  enqueue(queue, *this, slice, lws_hint());
470  }
472  }
473  else if(nullptr != _multi_input && nullptr != _output)
474  {
475  Format format = _multi_input->info()->format();
476  do
477  {
478  Window win_uv(slice);
479 
480  if((Format::NV12 == format) || (Format::NV21 == format) || (Format::IYUV == format))
481  {
482  win_uv.set(Window::DimX, Window::Dimension(win_uv.x().start() / 2, win_uv.x().end() / 2, win_uv.x().step() / 2));
483  win_uv.set(Window::DimY, Window::Dimension(win_uv.y().start() / 2, win_uv.y().end() / 2, 1));
484  }
485 
486  unsigned int idx = 0;
487  add_2D_tensor_argument(idx, _multi_input->cl_plane(0), slice);
488 
489  for(int i = 1; i < 3 && (0 != _multi_input->cl_plane(i)->info()->num_dimensions()); ++i)
490  {
491  add_2D_tensor_argument(idx, _multi_input->cl_plane(i), win_uv);
492  }
493  add_2D_tensor_argument(idx, _output, slice);
494  enqueue(queue, *this, slice, lws_hint());
495  }
497  }
498  else if(nullptr != _multi_input && nullptr != _multi_output)
499  {
500  Format in_format = _multi_input->info()->format();
501  Format out_format = _multi_output->info()->format();
502  do
503  {
504  Window win_in_uv(slice);
505  if((Format::NV12 == in_format) || (Format::NV21 == in_format) || (Format::IYUV == in_format))
506  {
507  win_in_uv.set(Window::DimX, Window::Dimension(win_in_uv.x().start() / 2,
508  win_in_uv.x().end() / 2, win_in_uv.x().step() / 2));
509  win_in_uv.set(Window::DimY, Window::Dimension(win_in_uv.y().start() / 2, win_in_uv.y().end() / 2, 1));
510  }
511  unsigned int idx = 0;
512  add_2D_tensor_argument(idx, _multi_input->cl_plane(0), slice);
513  for(int i = 1; i < 3 && (0 != _multi_input->cl_plane(i)->info()->num_dimensions()); ++i)
514  {
515  add_2D_tensor_argument(idx, _multi_input->cl_plane(i), win_in_uv);
516  }
517 
518  Window win_out_uv(slice);
519  if((Format::NV12 == out_format) || (Format::NV21 == out_format) || (Format::IYUV == out_format))
520  {
521  win_out_uv.set(Window::DimX, Window::Dimension(win_out_uv.x().start() / 2,
522  win_out_uv.x().end() / 2, win_out_uv.x().step() / 2));
523  win_out_uv.set(Window::DimY, Window::Dimension(win_out_uv.y().start() / 2, win_out_uv.y().end() / 2, 1));
524  }
525 
526  add_2D_tensor_argument(idx, _multi_output->cl_plane(0), slice);
527  for(int i = 1; i < 3 && (0 != _multi_output->cl_plane(i)->info()->num_dimensions()); ++i)
528  {
529  add_2D_tensor_argument(idx, _multi_output->cl_plane(i), win_out_uv);
530  }
531  enqueue(queue, *this, slice, lws_hint());
532  }
534  }
535  else
536  {
537  ARM_COMPUTE_ERROR("Not supported");
538  }
539 }
void run(const Window &window, cl::CommandQueue &queue) override
Enqueue the OpenCL kernel to process the given window on the passed OpenCL command queue.
Window first_slice_window_2D() const
First 2D slice of the window.
Definition: Window.h:267
#define ARM_COMPUTE_ERROR(...)
Print the given message then throw an std::runtime_error.
Definition: Error.h:261
virtual size_t num_dimensions() const =0
The number of dimensions of the tensor (rank)
A single plane of 32-bit macro pixel of U0, Y0, V0, Y1 byte.
const Window & window() const
The maximum window the kernel can be executed on.
Definition: IKernel.cpp:28
virtual size_t dimension(size_t index) const =0
Return the size of the requested dimension.
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:39
constexpr int step() const
Return the step of the dimension.
Definition: Window.h:102
cl::NDRange lws_hint() const
Return the Local-Workgroup-Size hint.
Definition: ICLKernel.h:247
1 channel, 1 U8 per channel
std::string to_string(T &&value)
Convert integer and float values to string.
virtual DataType data_type() const =0
Data type used for each element of the tensor.
#define ARM_COMPUTE_ERROR_ON(cond)
If the condition is true then an error message is printed and an exception thrown.
Definition: Error.h:337
static CLKernelLibrary & get()
Access the KernelLibrary singleton.
Interface for OpenCL multi-planar images.
Definition: ICLMultiImage.h:36
A 2 plane YUV format of Luma (Y) and interleaved UV data at 4:2:0 sampling.
Describe one of the image's dimensions with a start, end and step.
Definition: Window.h:75
virtual ICLImage * cl_plane(unsigned int index)=0
Return a pointer to the requested OpenCL plane of the image.
std::string lower_string(const std::string &val)
Lower a given string.
Definition: Utils.cpp:327
Window calculate_max_window(const ValidRegion &valid_region, const Steps &steps=Steps(), bool skip_border=false, BorderSize border_size=BorderSize())
Calculate the maximum window for a given tensor shape and border setting.
Definition: Helpers.cpp:28
A 2 plane YUV format of Luma (Y) and interleaved VU data at 4:2:0 sampling.
bool slide_window_slice_2D(Window &slice) const
Slide the passed 2D window slice.
Definition: Window.h:307
Copyright (c) 2017-2018 ARM Limited.
virtual ValidRegion valid_region() const =0
Valid region of the tensor.
3 channels, 1 U8 per channel
#define ARM_COMPUTE_ERROR_ON_TENSOR_NOT_2D(t)
Definition: Validate.h:855
Implementation of a rectangular access pattern.
virtual Format format() const =0
Colour format of the image.
const std::string & string_from_data_type(DataType dt)
Convert a data type identity into a string.
Definition: Utils.cpp:144
static constexpr size_t DimX
Alias for dimension 0 also known as X dimension.
Definition: Window.h:43
bool update_window_and_padding(Window &win, Ts &&... patterns)
Update window and padding size for each of the access patterns.
Definition: Helpers.h:402
virtual const TensorShape & tensor_shape() const =0
Size for each dimension of the tensor.
Format
Image colour formats.
Definition: Types.h:52
Class to describe a number of elements in each dimension.
Definition: Steps.h:40
Implementation of a row access pattern.
A 3 plane of 8 bit 4:4:4 sampled Y, U, V planes.
virtual ITensorInfo * info() const =0
Interface to be implemented by the child class to return the tensor's metadata.
ValidRegion intersect_valid_regions(const Ts &... regions)
Intersect multiple valid regions.
Definition: Helpers.h:503
void set(size_t dimension, const Dimension &dim)
Set the values of a given dimension.
Definition: Window.inl:48
IImage * plane(unsigned int index) override
Return a pointer to the requested plane of the image.
std::unique_ptr< Kernel > create_kernel()
Helper function to create and return a unique_ptr pointed to a CL/GLES kernel object.
Definition: Helpers.h:86
virtual const MultiImageInfo * info() const =0
Interface to be implemented by the child class to return the multi-planar image's metadata.
A 3 plane of 8-bit 4:2:0 sampled Y, U, V planes.
static constexpr size_t DimY
Alias for dimension 1 also known as Y dimension.
Definition: Window.h:45
4 channels, 1 U8 per channel
void set_dimension_step(size_t dimension, int step)
Set the step of a given dimension.
Definition: Window.inl:153
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.
Definition: ICLKernel.h:134
void configure(const ICLTensor *input, ICLTensor *output)
Set the input and output of the kernel.
Interface for OpenCL tensor.
Definition: ICLTensor.h:42
constexpr const Dimension & y() const
Alias to access the second dimension of the window.
Definition: Window.h:152
Container for valid region of a window.
Definition: Types.h:174
constexpr int end() const
Return the end of the dimension.
Definition: Window.h:97
A single plane of 32-bit macro pixel of Y0, U0, Y1, V0 bytes.
Format format() const
Colour format of the image.
#define ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW(f, s)
Definition: Validate.h:205
constexpr int start() const
Return the start of the dimension.
Definition: Window.h:92
Describe a multidimensional execution window.
Definition: Window.h:39
#define ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(k)
Definition: Validate.h:940
Coordinates anchor
Anchor for the start of the valid region.
Definition: Types.h:246
SimpleTensor< T > slice(const SimpleTensor< T > &src, Coordinates starts, Coordinates ends)
constexpr const Dimension & x() const
Alias to access the first dimension of the window.
Definition: Window.h:143
#define ARM_COMPUTE_ERROR_ON_MSG(cond,...)
Definition: Error.h:328
const std::string & string_from_format(Format format)
Convert a tensor format into a string.
Definition: Utils.cpp:85