Compute Library
 19.08
NEDepthwiseVectorToTensorKernel Class Reference

Interface for the depthwise vector to tensor kernel. More...

#include <NEDepthwiseVectorToTensorKernel.h>

Collaboration diagram for NEDepthwiseVectorToTensorKernel:
[legend]

Public Member Functions

const char * name () const override
 Name of the kernel. More...
 
 NEDepthwiseVectorToTensorKernel ()
 Default constructor. More...
 
 NEDepthwiseVectorToTensorKernel (const NEDepthwiseVectorToTensorKernel &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
NEDepthwiseVectorToTensorKerneloperator= (const NEDepthwiseVectorToTensorKernel &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
 NEDepthwiseVectorToTensorKernel (NEDepthwiseVectorToTensorKernel &&)=default
 Allow instances of this class to be moved. More...
 
NEDepthwiseVectorToTensorKerneloperator= (NEDepthwiseVectorToTensorKernel &&)=default
 Allow instances of this class to be moved. More...
 
void configure (const ITensor *input, ITensor *output, size_t conv_w, size_t conv_h)
 Set the input and output of the kernel. More...
 
void run (const Window &window, const ThreadInfo &info) override
 Execute the kernel on the passed window. More...
 
- Public Member Functions inherited from ICPPKernel
virtual ~ICPPKernel ()=default
 Default destructor. 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, size_t conv_w, size_t conv_h)
 Static function to check if given info will lead to a valid configuration of NEDepthwiseVectorToTensorKernel. More...
 

Detailed Description

Interface for the depthwise vector to tensor kernel.

This kernel takes the 1D tensor that's been produced by the MatrixVectorMultiply kernel and reshapes it to given width and height (previously calculated, based on input/weights dimensions and convolution strides and padding).

Definition at line 40 of file NEDepthwiseVectorToTensorKernel.h.

Constructor & Destructor Documentation

◆ NEDepthwiseVectorToTensorKernel() [1/3]

Default constructor.

Definition at line 93 of file NEDepthwiseVectorToTensorKernel.cpp.

94  : _func(nullptr), _input(nullptr), _output(nullptr), _conv_dims()
95 {
96 }

◆ NEDepthwiseVectorToTensorKernel() [2/3]

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

◆ NEDepthwiseVectorToTensorKernel() [3/3]

Allow instances of this class to be moved.

Member Function Documentation

◆ configure()

void configure ( const ITensor input,
ITensor output,
size_t  conv_w,
size_t  conv_h 
)

Set the input and output of the kernel.

Parameters
[in]inputThe input vector to convert. Data type supported: QASYMM8/S32/F16/F32.
[out]outputThe output tensor. 3 lower dimensions represent a single input [width, height, IFM]. Data type supported: same as input.
[in]conv_wThe converted tensor's width.
[in]conv_hThe converted tensor's height.

Definition at line 98 of file NEDepthwiseVectorToTensorKernel.cpp.

99 {
100  ARM_COMPUTE_ERROR_ON_NULLPTR(input, output);
101 
102  // Output auto inizialitation if not yet initialized
104  auto_init_if_empty(*output->info(), input->info()->clone()->set_tensor_shape(output_shape));
105 
106  ARM_COMPUTE_ERROR_THROW_ON(validate_arguments(input->info(), output->info(), conv_w, conv_h));
107 
108  _input = input;
109  _output = output;
110  _conv_dims = std::pair<size_t, size_t>(conv_w, conv_h);
111 
112  // Set appropriate function to run
113  switch(input->info()->data_type())
114  {
115  case DataType::QASYMM8:
116  _func = &NEDepthwiseVectorToTensorKernel::vector_to_tensor<uint8_t>;
117  break;
118  case DataType::S32:
119  _func = &NEDepthwiseVectorToTensorKernel::vector_to_tensor<int32_t>;
120  break;
121  case DataType::F16:
122  _func = &NEDepthwiseVectorToTensorKernel::vector_to_tensor<half>;
123  break;
124  case DataType::F32:
125  _func = &NEDepthwiseVectorToTensorKernel::vector_to_tensor<float>;
126  break;
127  default:
128  ARM_COMPUTE_ERROR("Unsupported data type");
129  }
130 
131  // Configure kernel window
132  Window win = calculate_max_window(*input->info(), Steps());
133  // The NEDepthwisevectorToTensorKernel doesn't need padding so update_window_and_padding() can be skipped
134  output->info()->set_valid_region(ValidRegion(Coordinates(), output->info()->tensor_shape()));
135 
136  INEKernel::configure(win);
137 }
#define ARM_COMPUTE_ERROR(...)
Print the given message then throw an std::runtime_error.
Definition: Error.h:261
Shape of a tensor.
Definition: TensorShape.h:39
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_THROW_ON(status)
Definition: Error.h: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
virtual void set_valid_region(const ValidRegion &valid_region)=0
Set the valid region of the tensor.
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
1 channel, 1 F16 per channel
1 channel, 1 S32 per channel
TensorShape compute_vector_to_tensor_output_shape(const TensorShape &input, size_t conv_w, size_t conv_h, const DataLayout &data_layout)
Calculate the output tensor shape of a vector input given the convolution dimensions.
virtual const TensorShape & tensor_shape() const =0
Size for each dimension of the tensor.
quantized, asymmetric fixed-point 8-bit number
Class to describe a number of elements in each dimension.
Definition: Steps.h:40
Coordinates of an item.
Definition: Coordinates.h:37
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.
#define ARM_COMPUTE_ERROR_ON_NULLPTR(...)
Definition: Validate.h:161
Container for valid region of a window.
Definition: Types.h:174
Describe a multidimensional execution window.
Definition: Window.h:39
virtual DataLayout data_layout() const =0
Get the data layout of the tensor.

References ARM_COMPUTE_ERROR, ARM_COMPUTE_ERROR_ON_NULLPTR, ARM_COMPUTE_ERROR_THROW_ON, arm_compute::auto_init_if_empty(), arm_compute::calculate_max_window(), ICloneable< T >::clone(), arm_compute::misc::shape_calculator::compute_vector_to_tensor_output_shape(), ITensorInfo::data_layout(), ITensorInfo::data_type(), arm_compute::F16, arm_compute::F32, ITensor::info(), arm_compute::test::validation::output_shape, arm_compute::QASYMM8, arm_compute::S32, ITensorInfo::set_valid_region(), and ITensorInfo::tensor_shape().

Referenced by NEDepthwiseConvolutionLayer::configure().

◆ name()

const char* name ( ) const
inlineoverridevirtual

Name of the kernel.

Returns
Kernel name

Implements ICPPKernel.

Definition at line 43 of file NEDepthwiseVectorToTensorKernel.h.

44  {
45  return "NEDepthwiseVectorToTensorKernel";
46  }

◆ 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,
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.

Implements ICPPKernel.

Definition at line 146 of file NEDepthwiseVectorToTensorKernel.cpp.

147 {
151 
152  if(_func != nullptr)
153  {
154  (this->*_func)(window);
155  }
156 }
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:160
#define ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW(f, s)
Definition: Validate.h:205
#define ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(k)
Definition: Validate.h:940

References ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW, ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL, ARM_COMPUTE_UNUSED, arm_compute::test::validation::info, and IKernel::window().

◆ validate()

Status validate ( const ITensorInfo input,
const ITensorInfo output,
size_t  conv_w,
size_t  conv_h 
)
static

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

Parameters
[in]inputThe input vector to convert. Data type supported: QASYMM8/S32/F16/F32.
[in]outputThe output tensor. 3 lower dimensions represent a single input [width, height, IFM]. Data type supported: same as input.
[in]conv_wThe converted tensor's width.
[in]conv_hThe converted tensor's height.

Definition at line 139 of file NEDepthwiseVectorToTensorKernel.cpp.

140 {
142  ARM_COMPUTE_RETURN_ON_ERROR(validate_arguments(input, output, conv_w, conv_h));
143  return Status{};
144 }
#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
#define ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR(...)
Definition: Validate.h:163

References ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR, and ARM_COMPUTE_RETURN_ON_ERROR.

Referenced by NEDepthwiseConvolutionLayer::validate().


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