Compute Library
 19.08
GCDepthConcatenateLayerKernel Class Reference

Interface for the depth concatenate kernel. More...

#include <GCDepthConcatenateLayerKernel.h>

Collaboration diagram for GCDepthConcatenateLayerKernel:
[legend]

Public Member Functions

 GCDepthConcatenateLayerKernel ()
 Default constructor. More...
 
 GCDepthConcatenateLayerKernel (const GCDepthConcatenateLayerKernel &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
GCDepthConcatenateLayerKerneloperator= (const GCDepthConcatenateLayerKernel &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
 GCDepthConcatenateLayerKernel (GCDepthConcatenateLayerKernel &&)=default
 Allow instances of this class to be moved. More...
 
GCDepthConcatenateLayerKerneloperator= (GCDepthConcatenateLayerKernel &&)=default
 Allow instances of this class to be moved. More...
 
 ~GCDepthConcatenateLayerKernel ()=default
 Default destructor. More...
 
void configure (const IGCTensor *input, unsigned int depth_offset, IGCTensor *output)
 Initialise the kernel's inputs and output. More...
 
void run (const Window &window) override
 Enqueue the OpenGL ES shader to process the given window. More...
 
- Public Member Functions inherited from IGCKernel
 IGCKernel ()
 Constructor. More...
 
GCKernelkernel ()
 Returns a reference to the GLES kernel of this object. More...
 
void add_1D_tensor_argument (unsigned int &idx, const IGCTensor *tensor, const unsigned int binding_point, 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_2D_tensor_argument (unsigned int &idx, const IGCTensor *tensor, const unsigned int binding_point, 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_3D_tensor_argument (unsigned int &idx, const IGCTensor *tensor, const unsigned int binding_point, const Window &window)
 Add the passed 3D tensor's parameters to the object's kernel's arguments starting from the index idx. More...
 
unsigned int num_arguments_per_1D_tensor () const
 Returns the number of arguments enqueued per 1D tensor object. More...
 
unsigned int num_arguments_per_2D_tensor () const
 Returns the number of arguments enqueued per 2D tensor object. More...
 
unsigned int num_arguments_per_3D_tensor () const
 Returns the number of arguments enqueued per 3D tensor object. More...
 
void set_lws_hint (gles::NDRange &lws_hint)
 Set the Local-Workgroup-Size hint. More...
 
void set_target (GPUTarget target)
 Set the targeted GPU architecture. More...
 
GPUTarget get_target () const
 Get the targeted GPU architecture. 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...
 

Detailed Description

Interface for the depth concatenate kernel.

The input tensor will be concatenated into the output tensor.

Definition at line 38 of file GCDepthConcatenateLayerKernel.h.

Constructor & Destructor Documentation

◆ GCDepthConcatenateLayerKernel() [1/3]

Default constructor.

Definition at line 40 of file GCDepthConcatenateLayerKernel.cpp.

41  : _input(nullptr), _output(nullptr), _depth_offset(0)
42 {
43 }

◆ GCDepthConcatenateLayerKernel() [2/3]

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

◆ GCDepthConcatenateLayerKernel() [3/3]

Allow instances of this class to be moved.

◆ ~GCDepthConcatenateLayerKernel()

Default destructor.

Member Function Documentation

◆ configure()

void configure ( const IGCTensor input,
unsigned int  depth_offset,
IGCTensor output 
)

Initialise the kernel's inputs and output.

Parameters
[in]inputInput tensor. Data types supported: F16/F32.
[in]depth_offsetThe offset on the Z axis.
[in,out]outputOutput tensor. Data types supported: Same as input.
Note
: The output tensor's low two dimensions can't be smaller than the input one's.
: The gaps between the two lowest dimensions of input and output need to be divisible by 2.

Definition at line 44 of file GCDepthConcatenateLayerKernel.cpp.

45 {
48 
51  ARM_COMPUTE_ERROR_ON(input->info()->dimension(2) + depth_offset > output->info()->dimension(2));
53 
54  _input = input;
55  _output = output;
56  _depth_offset = depth_offset;
57 
58  // Add build options
59  std::set<std::string> build_opts;
60  std::string dt_name = (input->info()->data_type() == DataType::F32) ? "DATA_TYPE_FP32" : "DATA_TYPE_FP16";
61  build_opts.emplace(("#define " + dt_name));
62  build_opts.emplace("#define LOCAL_SIZE_X " + support::cpp11::to_string(1));
63  build_opts.emplace("#define LOCAL_SIZE_Y " + support::cpp11::to_string(1));
64  build_opts.emplace("#define LOCAL_SIZE_Z " + support::cpp11::to_string(1));
65 
66  // Create kernel
67  _kernel = static_cast<GCKernel>(GCKernelLibrary::get().create_kernel("concatenate_depth", build_opts));
68 
69  unsigned int num_elems_processed_per_iteration = 1;
70  if(input->info()->data_type() == DataType::F16)
71  {
72  num_elems_processed_per_iteration = 4;
73  }
74 
75  // The window needs to be based on input as we copy all the depths of input
76  Window win = calculate_max_window(*output->info(), Steps(num_elems_processed_per_iteration));
77  win.set(Window::DimZ, Window::Dimension(0, input->info()->tensor_shape().z(), 1));
78 
79  AccessWindowHorizontal input_access(input->info(), 0, num_elems_processed_per_iteration);
80  AccessWindowHorizontal output_access(output->info(), 0, num_elems_processed_per_iteration);
81  update_window_and_padding(win, input_access, output_access);
82  output_access.set_valid_region(win, ValidRegion(Coordinates(), output->info()->tensor_shape()));
83 
84  IGCKernel::configure(win);
85 }
virtual size_t dimension(size_t index) const =0
Return the size of the requested dimension.
#define ARM_COMPUTE_ERROR_ON_MISMATCHING_DATA_TYPES(...)
Definition: Validate.h:543
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.
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:337
Describe one of the image's dimensions with a start, end and step.
Definition: Window.h:75
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
#define ARM_COMPUTE_ERROR_ON_MISMATCHING_SHAPES(...)
Definition: Validate.h:441
1 channel, 1 F16 per channel
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.
Class to describe a number of elements in each dimension.
Definition: Steps.h:40
T z() const
Alias to access the size of the third dimension.
Definition: Dimensions.h:91
Coordinates of an item.
Definition: Coordinates.h:37
Implementation of a row access pattern.
virtual ITensorInfo * info() const =0
Interface to be implemented by the child class to return the tensor's metadata.
void set(size_t dimension, const Dimension &dim)
Set the values of a given dimension.
Definition: Window.inl:48
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
#define ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(t, c,...)
Definition: Validate.h:789
static constexpr size_t DimY
Alias for dimension 1 also known as Y dimension.
Definition: Window.h:45
static GCKernelLibrary & get()
Get the static instance of GCKernelLibrary.
static constexpr size_t DimZ
Alias for dimension 2 also known as Z dimension.
Definition: Window.h:47
Container for valid region of a window.
Definition: Types.h:174
Describe a multidimensional execution window.
Definition: Window.h:39

References ARM_COMPUTE_ERROR_ON, ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN, ARM_COMPUTE_ERROR_ON_MISMATCHING_DATA_TYPES, ARM_COMPUTE_ERROR_ON_MISMATCHING_SHAPES, arm_compute::calculate_max_window(), arm_compute::create_kernel(), ITensorInfo::data_type(), ITensorInfo::dimension(), Window::DimX, Window::DimY, Window::DimZ, arm_compute::F16, arm_compute::F32, GCKernelLibrary::get(), ITensor::info(), Window::set(), ITensorInfo::tensor_shape(), arm_compute::support::cpp11::to_string(), arm_compute::update_window_and_padding(), and Dimensions< T >::z().

◆ operator=() [1/2]

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

◆ operator=() [2/2]

Allow instances of this class to be moved.

◆ run()

void run ( const Window window)
overridevirtual

Enqueue the OpenGL ES shader to process the given window.

Parameters
[in]windowRegion on which to execute the kernel. (Must be a valid region of the window returned by window()).

Implements IGCKernel.

Definition at line 87 of file GCDepthConcatenateLayerKernel.cpp.

88 {
91 
92  _kernel.use();
93 
94  _output->set_needs_shifting(true);
95 
96  Window slice_in = window.first_slice_window_3D();
97  Window slice_out = window.first_slice_window_3D();
98 
99  slice_out.set(Window::DimZ, Window::Dimension(_depth_offset));
100 
101  do
102  {
103  unsigned int idx = 0;
104  add_3D_tensor_argument(idx, _input, 1, slice_in);
105  add_3D_tensor_argument(idx, _output, 2, slice_out);
106 
107  _kernel.update_shader_params();
108 
109  enqueue(*this, slice_in);
110  }
111  while(window.slide_window_slice_3D(slice_in));
112 }
const Window & window() const
The maximum window the kernel can be executed on.
Definition: IKernel.cpp:28
void add_3D_tensor_argument(unsigned int &idx, const IGCTensor *tensor, const unsigned int binding_point, const Window &window)
Add the passed 3D tensor's parameters to the object's kernel's arguments starting from the index idx.
Definition: IGCKernel.cpp:132
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
Describe one of the image's dimensions with a start, end and step.
Definition: Window.h:75
void set_needs_shifting(bool needs_shifting)
Set the flag indicating whether or not a tensor needs shifting.
Definition: IGCTensor.cpp:61
void set(size_t dimension, const Dimension &dim)
Set the values of a given dimension.
Definition: Window.inl:48
bool slide_window_slice_3D(Window &slice) const
Slide the passed 3D window slice.
Definition: Window.h:319
static constexpr size_t DimZ
Alias for dimension 2 also known as Z dimension.
Definition: Window.h:47
Window first_slice_window_3D() const
First 3D slice of the window.
Definition: Window.h:275
#define ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW(f, s)
Definition: Validate.h:205
Describe a multidimensional execution window.
Definition: Window.h:39
#define ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(k)
Definition: Validate.h:940

References IGCKernel::add_3D_tensor_argument(), ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW, ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL, Window::DimZ, arm_compute::enqueue(), Window::first_slice_window_3D(), Window::set(), IGCTensor::set_needs_shifting(), Window::slide_window_slice_3D(), and IKernel::window().


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