Compute Library
 19.08
NEConvolutionLayerReshapeWeights Class Reference

Function to reshape the weights. More...

#include <NEGEMMConvolutionLayer.h>

Collaboration diagram for NEConvolutionLayerReshapeWeights:
[legend]

Public Member Functions

 NEConvolutionLayerReshapeWeights ()
 Constructor. More...
 
void configure (const ITensor *weights, const ITensor *biases, ITensor *output)
 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)
 Static function to check if given info will lead to a valid configuration of NEConvolutionLayerReshapeWeights. More...
 

Detailed Description

Function to reshape the weights.

This function calls the following kernel:

  1. NEWeightsReshapeKernel

Definition at line 52 of file NEGEMMConvolutionLayer.h.

Constructor & Destructor Documentation

◆ NEConvolutionLayerReshapeWeights()

Constructor.

Definition at line 41 of file NEGEMMConvolutionLayer.cpp.

42  : _weights_reshape_kernel()
43 {
44 }

Member Function Documentation

◆ configure()

void configure ( const ITensor weights,
const ITensor biases,
ITensor output 
)

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.

Definition at line 46 of file NEGEMMConvolutionLayer.cpp.

47 {
48  // Perform validation step
51  (biases != nullptr) ? biases->info() : nullptr,
52  output->info()));
53 
54  const bool append_biases = (biases != nullptr) && !is_data_type_quantized_asymmetric(weights->info()->data_type());
55  const ITensor *biases_to_use = (append_biases) ? biases : nullptr;
56 
57  _weights_reshape_kernel.configure(weights, biases_to_use, output);
58 
60 }
void configure(const ITensor *input, const ITensor *bias, ITensor *output)
Set the input and output of the kernel.
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
Interface for NEON tensor.
Definition: ITensor.h:36
DataType data_type() const override
Data type used for each element of the tensor.
Definition: TensorInfo.h:256
static Status validate(const ITensorInfo *weights, const ITensorInfo *biases, const ITensorInfo *output)
Static function to check if given info will lead to a valid configuration of NEConvolutionLayerReshap...
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
#define ARM_COMPUTE_ERROR_ON_NULLPTR(...)
Definition: Validate.h:161

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

Referenced by NEGEMMConvolutionLayer::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 87 of file NEGEMMConvolutionLayer.cpp.

88 {
89  NEScheduler::get().schedule(&_weights_reshape_kernel, 3);
90 }
virtual void schedule(ICPPKernel *kernel, const Hints &hints)=0
Runs the kernel in the same thread as the caller synchronously.
static IScheduler & get()
Access the scheduler singleton.
Definition: Scheduler.cpp:96

References Scheduler::get(), and IScheduler::schedule().

Referenced by NEGEMMConvolutionLayer::prepare().

◆ validate()

Status validate ( const ITensorInfo weights,
const ITensorInfo biases,
const ITensorInfo output 
)
static

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

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.
Returns
an error status

Definition at line 62 of file NEGEMMConvolutionLayer.cpp.

63 {
66  ARM_COMPUTE_RETURN_ERROR_ON(weights->num_dimensions() > 4);
67 
68  if(biases != nullptr)
69  {
70  const int idx_kernels = get_data_layout_dimension_index(weights->data_layout(), DataLayoutDimension::BATCHES);
73  ARM_COMPUTE_RETURN_ERROR_ON(biases->dimension(0) != weights->dimension(idx_kernels));
75  }
76 
77  if((output != nullptr) && (output->total_size() != 0))
78  {
80 
82  }
83 
84  return Status{};
85 }
virtual size_t num_dimensions() const =0
The number of dimensions of the tensor (rank)
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
static Status validate(const ITensorInfo *input, const ITensorInfo *biases, const ITensorInfo *output)
Static function to check if given info will lead to a valid configuration of NEWeightsReshapeKernel.
1 channel, 1 F16 per channel
quantized, asymmetric fixed-point 8-bit number
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::QASYMM8, ITensorInfo::total_size(), NEWeightsReshapeKernel::validate(), and arm_compute::test::validation::weights.

Referenced by NEConvolutionLayerReshapeWeights::configure(), and NEGEMMConvolutionLayer::validate().


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