21.02
|
Basic function to compute a Fully Connected layer on Neon. More...
#include <NEFullyConnectedLayer.h>
Public Member Functions | |
NEFullyConnectedLayer (std::shared_ptr< IMemoryManager > memory_manager=nullptr, IWeightsManager *weights_manager=nullptr) | |
Constructor. More... | |
NEFullyConnectedLayer (const NEFullyConnectedLayer &)=delete | |
Prevent instances of this class from being copied (As this class contains pointers) More... | |
NEFullyConnectedLayer (NEFullyConnectedLayer &&)=delete | |
Prevent instances of this class from being moved (As this class contains pointers) More... | |
NEFullyConnectedLayer & | operator= (const NEFullyConnectedLayer &)=delete |
Prevent instances of this class from being copied (As this class contains pointers) More... | |
NEFullyConnectedLayer & | operator= (NEFullyConnectedLayer &&)=delete |
Prevent instances of this class from being moved (As this class contains pointers) More... | |
~NEFullyConnectedLayer () | |
Default destructor. More... | |
void | configure (const ITensor *input, const ITensor *weights, const ITensor *biases, ITensor *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 NEFullyConnectedLayer. More... | |
Basic function to compute a Fully Connected layer on Neon.
This function calls the following Neon kernels:
are_weights_reshaped
is set to false and transpose_weights is set to true ) (called once)biases
is not equal to nullptr)Definition at line 122 of file NEFullyConnectedLayer.h.
NEFullyConnectedLayer | ( | std::shared_ptr< IMemoryManager > | memory_manager = nullptr , |
IWeightsManager * | weights_manager = nullptr |
||
) |
Constructor.
Definition at line 159 of file NEFullyConnectedLayer.cpp.
|
delete |
Prevent instances of this class from being copied (As this class contains pointers)
|
delete |
Prevent instances of this class from being moved (As this class contains pointers)
|
default |
Default destructor.
Referenced by NEFullyConnectedLayerReshapeWeights::validate().
void configure | ( | const ITensor * | input, |
const ITensor * | weights, | ||
const ITensor * | biases, | ||
ITensor * | 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 weights , S32 if weights is QASYMM8/QASYMM8_SIGNED. |
[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 231 of file NEFullyConnectedLayer.cpp.
References IWeightsManager::acquire(), FullyConnectedLayerInfo::activation_info, IWeightsManager::are_weights_managed(), FullyConnectedLayerInfo::are_weights_reshaped, ARM_COMPUTE_ERROR_ON_NULLPTR, ARM_COMPUTE_ERROR_THROW_ON, Dimensions< T >::cbegin(), Dimensions< T >::cend(), NEConvertFullyConnectedWeights::configure(), NEFullyConnectedLayerReshapeWeights::configure(), NEFullyConnectedLayerReshapeWeightsManaged::configure(), NEConvertFullyConnectedWeightsManaged::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, NEFullyConnectedLayer::validate(), and FullyConnectedLayerInfo::weights_trained_layout.
Referenced by NERNNLayer::configure(), and NELSTMLayer::configure().
|
delete |
Prevent instances of this class from being copied (As this class contains pointers)
|
delete |
Prevent instances of this class from being moved (As this class contains pointers)
|
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 429 of file NEFullyConnectedLayer.cpp.
References TensorAllocator::allocate(), Tensor::allocator(), IWeightsManager::are_weights_managed(), ARM_COMPUTE_ERROR_ON, ITensor::is_used(), ITensor::mark_as_unused(), NEGEMM::prepare(), INESimpleFunctionNoBorder::run(), IWeightsManager::run(), NEConvertFullyConnectedWeights::run(), and arm_compute::test::validation::w.
Referenced by NERNNLayer::prepare(), and NEFullyConnectedLayer::run().
|
overridevirtual |
Run the kernels contained in the function.
For Neon kernels:
For OpenCL kernels:
Implements IFunction.
Definition at line 406 of file NEFullyConnectedLayer.cpp.
References NEFullyConnectedLayer::prepare(), NEFlattenLayer::run(), NEGEMM::run(), and NEGEMMLowpMatrixMultiplyCore::run().
Referenced by NERNNLayer::run(), and NELSTMLayer::run().
|
static |
Static function to check if given info will lead to a valid configuration of NEFullyConnectedLayer.
[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. Can be nullptr. Data type supported: Same as weights , S32 if weights is QASYMM8/QASYMM8_SIGNED. |
[in] | 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 327 of file NEFullyConnectedLayer.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, ARM_COMPUTE_UNUSED, 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, ITensorInfo::num_dimensions(), Dimensions< size_t >::num_max_dimensions, arm_compute::QASYMM8, arm_compute::QASYMM8_SIGNED, ActivationLayerInfo::RELU, FullyConnectedLayerInfo::retain_internal_weights, ITensorInfo::tensor_shape(), FullyConnectedLayerInfo::transpose_weights, NEFlattenLayer::validate(), NEFullyConnectedLayerReshapeWeights::validate(), NEConvertFullyConnectedWeights::validate(), and FullyConnectedLayerInfo::weights_trained_layout.
Referenced by NEFullyConnectedLayer::configure(), arm_compute::test::validation::DATA_TEST_CASE(), NERNNLayer::validate(), and NELSTMLayer::validate().