Compute Library
 19.08
CLConvolutionLayerReshapeWeights Class Reference

Function to reshape and transpose the weights. More...

#include <CLGEMMConvolutionLayer.h>

Collaboration diagram for CLConvolutionLayerReshapeWeights:
[legend]

Public Member Functions

 CLConvolutionLayerReshapeWeights ()
 Constructor. More...
 
void configure (const ICLTensor *weights, const ICLTensor *biases, ICLTensor *output, unsigned int num_groups=1)
 Set the input and output tensors. More...
 
void run () override
 Run the kernels contained in the function. More...
 
- Public Member Functions inherited from IFunction
virtual ~IFunction ()=default
 Destructor. More...
 
virtual void prepare ()
 Prepare the function for executing. More...
 

Static Public Member Functions

static Status validate (const ITensorInfo *weights, const ITensorInfo *biases, const ITensorInfo *output, unsigned int num_groups=1)
 Static function to check if given info will lead to a valid configuration of CLConvolutionLayerReshapeWeights. More...
 

Detailed Description

Function to reshape and transpose the weights.

This function calls the following kernels:

  1. CLWeightsReshapeKernel

Definition at line 53 of file CLGEMMConvolutionLayer.h.

Constructor & Destructor Documentation

◆ CLConvolutionLayerReshapeWeights()

Constructor.

Definition at line 41 of file CLGEMMConvolutionLayer.cpp.

42  : _weights_reshape_kernel()
43 {
44 }

Member Function Documentation

◆ configure()

void configure ( const ICLTensor weights,
const ICLTensor biases,
ICLTensor output,
unsigned int  num_groups = 1 
)

Set the input and output tensors.

Parameters
[in]weightsWeights tensor. Weights are 4D tensor with dimensions [kernel_x, kernel_y, IFM, OFM]. Data type supported: QASYMM8/F16/F32.
[in]biasesBiases tensor. Shared biases supported. Biases are 1D tensor with dimensions [OFM]. Data type supported: Same as weights.
[out]outputDestination tensor. Data types supported: Same as weights.
[in]num_groups(Optional) Number of groups when performing a grouped convolution. num_groups != 1 is only supported for NCHW data layout

Definition at line 46 of file CLGEMMConvolutionLayer.cpp.

47 {
48  // Perform validation step
51  (biases != nullptr) ? biases->info() : nullptr,
52  output->info(),
53  num_groups));
54 
55  const bool append_biases = (biases != nullptr) && !is_data_type_quantized_asymmetric(weights->info()->data_type());
56  const ICLTensor *biases_to_use = (append_biases) ? biases : nullptr;
57 
58  _weights_reshape_kernel.configure(weights, biases_to_use, output, num_groups);
59 
61 }
TensorInfo * info() const override
Interface to be implemented by the child class to return the tensor's metadata.
Definition: CLTensor.cpp:35
QuantizationInfo quantization_info() const override
Get the quantization settings (scale and offset) of the tensor.
Definition: TensorInfo.h:293
#define ARM_COMPUTE_ERROR_THROW_ON(status)
Definition: Error.h:327
DataType data_type() const override
Data type used for each element of the tensor.
Definition: TensorInfo.h:256
void configure(const ICLTensor *input, const ICLTensor *biases, ICLTensor *output, unsigned int num_groups=1)
Set the input and output of the kernel.
const unsigned int num_groups
Definition: Im2Col.cpp:148
virtual ITensorInfo * info() const =0
Interface to be implemented by the child class to return the tensor's metadata.
virtual ITensorInfo & set_quantization_info(const QuantizationInfo &quantization_info)=0
Set the quantization settings (scale and offset) of the tensor.
bool is_data_type_quantized_asymmetric(DataType dt)
Check if a given data type is of asymmetric quantized type.
Definition: Utils.h:1030
static Status validate(const ITensorInfo *weights, const ITensorInfo *biases, const ITensorInfo *output, unsigned int num_groups=1)
Static function to check if given info will lead to a valid configuration of CLConvolutionLayerReshap...
#define ARM_COMPUTE_ERROR_ON_NULLPTR(...)
Definition: Validate.h:161
Interface for OpenCL tensor.
Definition: ICLTensor.h:42

References ARM_COMPUTE_ERROR_ON_NULLPTR, ARM_COMPUTE_ERROR_THROW_ON, CLWeightsReshapeKernel::configure(), TensorInfo::data_type(), ITensor::info(), CLTensor::info(), arm_compute::is_data_type_quantized_asymmetric(), arm_compute::test::validation::num_groups, TensorInfo::quantization_info(), ITensorInfo::set_quantization_info(), CLConvolutionLayerReshapeWeights::validate(), and arm_compute::test::validation::weights.

Referenced by CLGEMMConvolutionLayer::configure().

◆ run()

void run ( )
overridevirtual

Run the kernels contained in the function.

For NEON kernels:

  • Multi-threading is used for the kernels which are parallelisable.
  • By default std::thread::hardware_concurrency() threads are used.
Note
CPPScheduler::set_num_threads() can be used to manually set the number of threads

For OpenCL kernels:

  • All the kernels are enqueued on the queue associated with CLScheduler.
  • The queue is then flushed.
Note
The function will not block until the kernels are executed. It is the user's responsibility to wait.
Will call prepare() on first run if hasn't been done

Implements IFunction.

Definition at line 88 of file CLGEMMConvolutionLayer.cpp.

89 {
90  CLScheduler::get().enqueue(_weights_reshape_kernel);
91 }
static CLScheduler & get()
Access the scheduler singleton.
Definition: CLScheduler.cpp:41
void enqueue(ICLKernel &kernel, bool flush=true)
Schedule the execution of the passed kernel if possible.
Definition: CLScheduler.cpp:95

References CLScheduler::enqueue(), and CLScheduler::get().

Referenced by CLGEMMConvolutionLayer::prepare().

◆ validate()

Status validate ( const ITensorInfo weights,
const ITensorInfo biases,
const ITensorInfo output,
unsigned int  num_groups = 1 
)
static

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

Parameters
[in]weightsWeights tensor. Weights are 4D tensor with dimensions [kernel_x, kernel_y, IFM, OFM]. Data type supported: QASYMM8/F16/F32.
[in]biasesBiases tensor. Shared biases supported. Biases are 1D tensor with dimensions [OFM]. Data type supported: Same as weights.
[in]outputDestination tensor. Data types supported: Same as weights.
[in]num_groups(Optional) Number of groups when performing a grouped convolution. num_groups != 1 is only supported for NCHW data layout
Returns
a status

Definition at line 63 of file CLGEMMConvolutionLayer.cpp.

64 {
67  ARM_COMPUTE_RETURN_ERROR_ON(weights->num_dimensions() > 4);
68 
69  if(biases != nullptr)
70  {
71  const int idx_kernels = get_data_layout_dimension_index(weights->data_layout(), DataLayoutDimension::BATCHES);
74  ARM_COMPUTE_RETURN_ERROR_ON(biases->dimension(0) != weights->dimension(idx_kernels));
76  }
77 
78  if((output != nullptr) && (output->total_size() != 0))
79  {
81 
83  }
84 
85  return Status{};
86 }
virtual size_t num_dimensions() const =0
The number of dimensions of the tensor (rank)
static Status validate(const ITensorInfo *input, const ITensorInfo *biases, const ITensorInfo *output, unsigned int num_groups=1)
Static function to check if given info will lead to a valid configuration of CLWeightsReshapeKernel.
virtual size_t dimension(size_t index) const =0
Return the size of the requested dimension.
#define ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES(...)
Definition: Validate.h:545
#define ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(t, c,...)
Definition: Validate.h:791
1 channel, 1 F32 per channel
Status class.
Definition: Error.h:52
#define ARM_COMPUTE_RETURN_ERROR_ON(cond)
If the condition is true, an error is returned.
Definition: Error.h:244
1 channel, 1 F16 per channel
quantized, asymmetric fixed-point 8-bit number
const unsigned int num_groups
Definition: Im2Col.cpp:148
bool is_data_type_quantized_asymmetric(DataType dt)
Check if a given data type is of asymmetric quantized type.
Definition: Utils.h:1030
#define ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR(...)
Definition: Validate.h:163
virtual size_t total_size() const =0
Returns the total size of the tensor in bytes.
size_t get_data_layout_dimension_index(const DataLayout data_layout, const DataLayoutDimension data_layout_dimension)
Get the index of the given dimension.
Definition: Helpers.inl:326

References ARM_COMPUTE_RETURN_ERROR_ON, ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN, ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES, ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR, arm_compute::BATCHES, ITensorInfo::dimension(), arm_compute::F16, arm_compute::F32, arm_compute::get_data_layout_dimension_index(), arm_compute::is_data_type_quantized_asymmetric(), ITensorInfo::num_dimensions(), arm_compute::test::validation::num_groups, arm_compute::QASYMM8, ITensorInfo::total_size(), CLWeightsReshapeKernel::validate(), and arm_compute::test::validation::weights.

Referenced by CLConvolutionLayerReshapeWeights::configure(), and CLGEMMConvolutionLayer::validate().


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