21.02
|
Basic function to compute a Fully Connected layer on OpenCL. More...
#include <CLFullyConnectedLayer.h>
Public Member Functions | |
CLFullyConnectedLayer (std::shared_ptr< IMemoryManager > memory_manager=nullptr, IWeightsManager *weights_manager=nullptr) | |
Constructor. More... | |
CLFullyConnectedLayer (const CLFullyConnectedLayer &)=delete | |
Prevent instances of this class from being copied (As this class contains pointers) More... | |
CLFullyConnectedLayer (CLFullyConnectedLayer &&)=default | |
Default move constructor. More... | |
CLFullyConnectedLayer & | operator= (const CLFullyConnectedLayer &)=delete |
Prevent instances of this class from being copied (As this class contains pointers) More... | |
CLFullyConnectedLayer & | operator= (CLFullyConnectedLayer &&)=default |
Default move assignment operator. More... | |
void | configure (const ICLTensor *input, const ICLTensor *weights, const ICLTensor *biases, ICLTensor *output, FullyConnectedLayerInfo fc_info=FullyConnectedLayerInfo()) |
Set the input and output tensors. More... | |
void | configure (const CLCompileContext &compile_context, const ICLTensor *input, const ICLTensor *weights, const ICLTensor *biases, ICLTensor *output, FullyConnectedLayerInfo fc_info=FullyConnectedLayerInfo()) |
Set the input and output tensors. More... | |
void | run () override |
Run the kernels contained in the function. More... | |
void | prepare () override |
Prepare the function for executing. More... | |
Public Member Functions inherited from IFunction | |
virtual | ~IFunction ()=default |
Destructor. More... | |
Static Public Member Functions | |
static Status | validate (const ITensorInfo *input, const ITensorInfo *weights, const ITensorInfo *biases, const ITensorInfo *output, FullyConnectedLayerInfo fc_info=FullyConnectedLayerInfo()) |
Static function to check if given info will lead to a valid configuration of CLFullyConnectedLayer. More... | |
Basic function to compute a Fully Connected layer on OpenCL.
This function calls the following OpenCL kernels:
are_weights_reshaped
is set to false and transpose_weights is set to true ) (called once)Definition at line 136 of file CLFullyConnectedLayer.h.
CLFullyConnectedLayer | ( | std::shared_ptr< IMemoryManager > | memory_manager = nullptr , |
IWeightsManager * | weights_manager = nullptr |
||
) |
Constructor.
Definition at line 161 of file CLFullyConnectedLayer.cpp.
|
delete |
Prevent instances of this class from being copied (As this class contains pointers)
|
default |
Default move constructor.
void configure | ( | const ICLTensor * | input, |
const ICLTensor * | weights, | ||
const ICLTensor * | biases, | ||
ICLTensor * | output, | ||
FullyConnectedLayerInfo | fc_info = FullyConnectedLayerInfo() |
||
) |
Set the input and output tensors.
[in] | input | Source tensor. Data type supported: QASYMM8/QASYMM8_SIGNED/F16/F32. |
[in] | weights | Weights tensor. The weights must be 2 dimensional. If this function is called after a Convolution Layer, the (transposed) weights will have as many rows as the product of the first 3 input's dimensions. If it is called after another FullyConnected Layer, the (transposed) weights will have as many rows as the input's first dimension. Data type supported: Same as input . |
[in] | biases | Bias tensor. Can be nullptr. Data type supported:Same as input . |
[out] | output | Destination tensor. Its shape should be equal to the output of a matrix multiplication between:
|
[in] | fc_info | (Optional) Fully connected layer additional info |
Definition at line 239 of file CLFullyConnectedLayer.cpp.
References CLKernelLibrary::get().
Referenced by CLRNNLayer::configure(), and CLLSTMLayer::configure().
void configure | ( | const CLCompileContext & | compile_context, |
const ICLTensor * | input, | ||
const ICLTensor * | weights, | ||
const ICLTensor * | biases, | ||
ICLTensor * | output, | ||
FullyConnectedLayerInfo | fc_info = FullyConnectedLayerInfo() |
||
) |
Set the input and output tensors.
[in] | compile_context | The compile context to be used. |
[in] | input | Source tensor. Data type supported: QASYMM8/QASYMM8_SIGNED/F16/F32. |
[in] | weights | Weights tensor. The weights must be 2 dimensional. If this function is called after a Convolution Layer, the (transposed) weights will have as many rows as the product of the first 3 input's dimensions. If it is called after another FullyConnected Layer, the (transposed) weights will have as many rows as the input's first dimension. Data type supported: Same as input . |
[in] | biases | Bias tensor. Can be nullptr. Data type supported:Same as input . |
[out] | output | Destination tensor. Its shape should be equal to the output of a matrix multiplication between:
|
[in] | fc_info | (Optional) Fully connected layer additional info |
Definition at line 245 of file CLFullyConnectedLayer.cpp.
References IWeightsManager::acquire(), IWeightsManager::are_weights_managed(), FullyConnectedLayerInfo::are_weights_reshaped, ARM_COMPUTE_ERROR_ON_NULLPTR, ARM_COMPUTE_ERROR_THROW_ON, Dimensions< T >::cbegin(), Dimensions< T >::cend(), CLConvertFullyConnectedWeights::configure(), CLFullyConnectedLayerReshapeWeights::configure(), CLFullyConnectedLayerReshapeWeightsManaged::configure(), CLConvertFullyConnectedWeightsManaged::configure(), ITensorInfo::data_layout(), ITensorInfo::data_type(), ITensorInfo::dimension(), ITensor::info(), arm_compute::is_data_type_quantized_asymmetric(), IWeightsManager::manage(), ITensorInfo::num_dimensions(), Dimensions< size_t >::num_max_dimensions, FullyConnectedLayerInfo::retain_internal_weights, ITensorInfo::tensor_shape(), FullyConnectedLayerInfo::transpose_weights, CLFullyConnectedLayer::validate(), and FullyConnectedLayerInfo::weights_trained_layout.
|
delete |
Prevent instances of this class from being copied (As this class contains pointers)
|
default |
Default move assignment operator.
|
overridevirtual |
Prepare the function for executing.
Any one off pre-processing step required by the function is handled here
Reimplemented from IFunction.
Definition at line 441 of file CLFullyConnectedLayer.cpp.
References CLTensorAllocator::allocate(), CLTensor::allocator(), IWeightsManager::are_weights_managed(), ARM_COMPUTE_ERROR_ON, CLScheduler::get(), ITensor::is_used(), ITensor::mark_as_unused(), CLGEMM::prepare(), CLScheduler::queue(), ICLSimpleFunction::run(), IWeightsManager::run(), and arm_compute::test::validation::w.
Referenced by CLRNNLayer::prepare(), and CLFullyConnectedLayer::run().
|
overridevirtual |
Run the kernels contained in the function.
For Neon kernels:
For OpenCL kernels:
Implements IFunction.
Definition at line 418 of file CLFullyConnectedLayer.cpp.
References CLFullyConnectedLayer::prepare(), CLFlattenLayer::run(), CLGEMMLowpMatrixMultiplyCore::run(), and CLGEMM::run().
Referenced by CLRNNLayer::run(), and CLLSTMLayer::run().
|
static |
Static function to check if given info will lead to a valid configuration of CLFullyConnectedLayer.
[in] | input | Source tensor info. Data type supported: QASYMM8/QASYMM8_SIGNED/F16/F32. |
[in] | weights | Weights tensor info. The weights must be 2 dimensional. If this function is called after a Convolution Layer, the (transposed) weights will have as many rows as the product of the first 3 input's dimensions. If it is called after another FullyConnected Layer, the (transposed) weights will have as many rows as the input's first dimension. Data type supported: Same as input . |
[in] | biases | Bias tensor info. Can be nullptr. Data type supported:Same as input . |
[out] | output | Destination tensor info. Its shape should be equal to the output of a matrix multiplication between:
|
[in] | fc_info | (Optional) Fully connected layer additional info |
Definition at line 341 of file CLFullyConnectedLayer.cpp.
References ActivationLayerInfo::activation(), FullyConnectedLayerInfo::activation_info, FullyConnectedLayerInfo::are_weights_reshaped, 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_RETURN_ON_ERROR, ActivationLayerInfo::BOUNDED_RELU, Dimensions< T >::cbegin(), Dimensions< T >::cend(), ICloneable< T >::clone(), arm_compute::misc::shape_calculator::compute_flatten_shape(), arm_compute::misc::shape_calculator::compute_transposed_shape(), ITensorInfo::data_layout(), ITensorInfo::data_type(), ITensorInfo::dimension(), ActivationLayerInfo::enabled(), arm_compute::F16, arm_compute::F32, arm_compute::test::validation::input, arm_compute::is_data_type_quantized(), ActivationLayerInfo::LU_BOUNDED_RELU, arm_compute::NCHW, ITensorInfo::num_dimensions(), Dimensions< size_t >::num_max_dimensions, arm_compute::QASYMM8, arm_compute::QASYMM8_SIGNED, ActivationLayerInfo::RELU, ITensorInfo::tensor_shape(), FullyConnectedLayerInfo::transpose_weights, CLFullyConnectedLayerReshapeWeights::validate(), CLFlattenLayer::validate(), CLConvertFullyConnectedWeights::validate(), and FullyConnectedLayerInfo::weights_trained_layout.
Referenced by CLFullyConnectedLayer::configure(), arm_compute::test::validation::DATA_TEST_CASE(), CLRNNLayer::validate(), and CLLSTMLayer::validate().