Compute Library
 19.08
GCNormalizePlanarYUVLayerKernel Class Reference

Interface for the NormalizePlanarYUV layer kernel. More...

#include <GCNormalizePlanarYUVLayerKernel.h>

Collaboration diagram for GCNormalizePlanarYUVLayerKernel:
[legend]

Public Member Functions

 GCNormalizePlanarYUVLayerKernel ()
 Constructor. More...
 
 GCNormalizePlanarYUVLayerKernel (const GCNormalizePlanarYUVLayerKernel &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
GCNormalizePlanarYUVLayerKerneloperator= (const GCNormalizePlanarYUVLayerKernel &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
 GCNormalizePlanarYUVLayerKernel (GCNormalizePlanarYUVLayerKernel &&)=default
 Default Move Constructor. More...
 
GCNormalizePlanarYUVLayerKerneloperator= (GCNormalizePlanarYUVLayerKernel &&)=default
 Default move assignment operator. More...
 
 ~GCNormalizePlanarYUVLayerKernel ()=default
 Default destructor. More...
 
void configure (const IGCTensor *input, IGCTensor *output, const IGCTensor *mean, const IGCTensor *std)
 Set the input and output tensors. 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...
 

Static Public Member Functions

static Status validate (const ITensorInfo *input, const ITensorInfo *output, const ITensorInfo *mean, const ITensorInfo *std)
 Static function to check if given info will lead to a valid configuration of GCNormalizePlanarYUVLayerKernel. More...
 

Detailed Description

Interface for the NormalizePlanarYUV layer kernel.

Definition at line 35 of file GCNormalizePlanarYUVLayerKernel.h.

Constructor & Destructor Documentation

◆ GCNormalizePlanarYUVLayerKernel() [1/3]

Constructor.

Definition at line 89 of file GCNormalizePlanarYUVLayerKernel.cpp.

90  : _input(nullptr), _output(nullptr), _mean(nullptr), _std(nullptr)
91 {
92 }

◆ GCNormalizePlanarYUVLayerKernel() [2/3]

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

◆ GCNormalizePlanarYUVLayerKernel() [3/3]

Default Move Constructor.

◆ ~GCNormalizePlanarYUVLayerKernel()

Default destructor.

Member Function Documentation

◆ configure()

void configure ( const IGCTensor input,
IGCTensor output,
const IGCTensor mean,
const IGCTensor std 
)

Set the input and output tensors.

Parameters
[in]inputSource tensor. 3 lower dimensions represent a single input with dimensions [width, height, channels]. Data types supported: F16.
[out]outputDestination tensor. Data type supported: same as input
[in]meanMean values tensor. 1 dimension with size equal to the number of input channels. Data types supported: same as input
[in]stdStandard deviation values tensor. 1 dimension with size equal to the feature maps [FM]. Data types supported: same as input

Definition at line 94 of file GCNormalizePlanarYUVLayerKernel.cpp.

95 {
96  ARM_COMPUTE_ERROR_ON_NULLPTR(input, output, mean, std);
97 
98  // Output tensor auto initialization if not yet initialized
99  auto_init_if_empty(*output->info(), *input->info()->clone());
100 
101  // Perform validation step
102  ARM_COMPUTE_ERROR_THROW_ON(validate_arguments(input->info(), output->info(), mean->info(), std->info()));
103 
104  _input = input;
105  _output = output;
106  _mean = mean;
107  _std = std;
108 
109  // Set build options
110  std::set<std::string> build_opts;
111  build_opts.emplace(("#define LOCAL_SIZE_X " + support::cpp11::to_string(1)));
112  build_opts.emplace(("#define LOCAL_SIZE_Y " + support::cpp11::to_string(1)));
113  build_opts.emplace(("#define LOCAL_SIZE_Z " + support::cpp11::to_string(1)));
114 
115  // Create kernel
116  _kernel = static_cast<GCKernel>(GCKernelLibrary::get().create_kernel("normalize_planar_yuv_layer", build_opts));
117 
118  // Configure kernel window
119  auto win_config = validate_and_configure_window(input->info(), output->info(), mean->info(), std->info());
120  ARM_COMPUTE_ERROR_THROW_ON(std::get<0>(win_config));
121 
122  IGCKernel::configure(std::get<1>(win_config));
123 }
std::pair< Status, Window > validate_and_configure_window(ITensorInfo *input, ITensorInfo *weights, ITensorInfo *biases, ITensorInfo *output, const PadStrideInfo &conv_info, unsigned int depth_multiplier, const Size2D &dilation)
std::string to_string(T &&value)
Convert integer and float values to string.
#define ARM_COMPUTE_ERROR_THROW_ON(status)
Definition: Error.h:327
bool auto_init_if_empty(ITensorInfo &info, const TensorShape &shape, int num_channels, DataType data_type, QuantizationInfo quantization_info=QuantizationInfo())
Auto initialize the tensor info (shape, number of channels and data type) if the current assignment i...
Definition: Helpers.inl:201
virtual std::unique_ptr< T > clone() const =0
Provide a clone of the current object of class T.
virtual ITensorInfo * info() const =0
Interface to be implemented by the child class to return the tensor's metadata.
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
static GCKernelLibrary & get()
Get the static instance of GCKernelLibrary.
#define ARM_COMPUTE_ERROR_ON_NULLPTR(...)
Definition: Validate.h:161

References ARM_COMPUTE_ERROR_ON_NULLPTR, ARM_COMPUTE_ERROR_THROW_ON, arm_compute::auto_init_if_empty(), ICloneable< T >::clone(), arm_compute::create_kernel(), GCKernelLibrary::get(), ITensor::info(), arm_compute::support::cpp11::to_string(), and arm_compute::validate_and_configure_window().

Referenced by GCNormalizePlanarYUVLayer::configure().

◆ operator=() [1/2]

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

◆ operator=() [2/2]

Default move assignment operator.

◆ 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 132 of file GCNormalizePlanarYUVLayerKernel.cpp.

133 {
136 
137  _kernel.use();
138 
139  _output->set_needs_shifting(true);
140 
142 
143  Window slice_in;
144  //slice_in.use_tensor_dimensions(_mean->info()->tensor_shape());
145  slice_in = window.first_slice_window_1D();
146  slice_in.set(Window::DimX, Window::Dimension(0, 0, 0));
147 
148  unsigned int idx = 2 * num_arguments_per_3D_tensor();
149  add_1D_tensor_argument(idx, _mean, 3, slice_in);
150  add_1D_tensor_argument(idx, _std, 4, slice_in);
151 
152  slice_in = window.first_slice_window_3D();
153 
154  slice.shift(Window::DimX, -(_output->info()->padding()).left);
155 
156  do
157  {
158  idx = 0;
159  add_3D_tensor_argument(idx, _input, 1, slice_in);
160  add_3D_tensor_argument(idx, _output, 2, slice);
161 
162  _kernel.update_shader_params();
163 
164  enqueue(*this, slice);
165  }
167 }
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
unsigned int num_arguments_per_3D_tensor() const
Returns the number of arguments enqueued per 3D tensor object.
Definition: IGCKernel.cpp:147
static constexpr size_t DimX
Alias for dimension 0 also known as X dimension.
Definition: Window.h:43
void set_needs_shifting(bool needs_shifting)
Set the flag indicating whether or not a tensor needs shifting.
Definition: IGCTensor.cpp:61
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
virtual PaddingSize padding() const =0
Padding of tensor.
bool slide_window_slice_3D(Window &slice) const
Slide the passed 3D window slice.
Definition: Window.h:319
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
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.
Definition: IGCKernel.cpp:122
Window first_slice_window_1D() const
First 1D slice of the window.
Definition: Window.h:259
SimpleTensor< T > slice(const SimpleTensor< T > &src, Coordinates starts, Coordinates ends)

References IGCKernel::add_1D_tensor_argument(), IGCKernel::add_3D_tensor_argument(), ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW, ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL, Window::DimX, arm_compute::enqueue(), Window::first_slice_window_1D(), Window::first_slice_window_3D(), ITensor::info(), IGCKernel::num_arguments_per_3D_tensor(), ITensorInfo::padding(), Window::set(), IGCTensor::set_needs_shifting(), arm_compute::test::validation::reference::slice(), Window::slide_window_slice_3D(), and IKernel::window().

◆ validate()

Status validate ( const ITensorInfo input,
const ITensorInfo output,
const ITensorInfo mean,
const ITensorInfo std 
)
static

Static function to check if given info will lead to a valid configuration of GCNormalizePlanarYUVLayerKernel.

Parameters
[in]inputSource tensor info. 3 lower dimensions represent a single input with dimensions [width, height, channels]. Data types supported: F16.
[out]outputDestination tensor info. Data type supported: same as input
[in]meanMean values tensor info. 1 dimension with size equal to the number of input channels. Data types supported: same as input
[in]stdStandard deviation values tensor info. 1 dimension with size equal to the number of input channels. Data types supported: same as input
Returns
a status

Definition at line 125 of file GCNormalizePlanarYUVLayerKernel.cpp.

126 {
127  ARM_COMPUTE_RETURN_ON_ERROR(validate_arguments(input, output, mean, std));
128  ARM_COMPUTE_RETURN_ON_ERROR(std::get<0>(validate_and_configure_window(input->clone().get(), output->clone().get(), mean->clone().get(), std->clone().get())));
129  return Status{};
130 }
std::pair< Status, Window > validate_and_configure_window(ITensorInfo *input, ITensorInfo *weights, ITensorInfo *biases, ITensorInfo *output, const PadStrideInfo &conv_info, unsigned int depth_multiplier, const Size2D &dilation)
#define ARM_COMPUTE_RETURN_ON_ERROR(status)
Checks if a status contains an error and returns it.
Definition: Error.h:193
Status class.
Definition: Error.h:52
virtual std::unique_ptr< T > clone() const =0
Provide a clone of the current object of class T.

References ARM_COMPUTE_RETURN_ON_ERROR, ICloneable< T >::clone(), and arm_compute::validate_and_configure_window().

Referenced by GCNormalizePlanarYUVLayer::validate().


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