24.04
|
Basic function to compute a Fully Connected layer on OpenCL. More...
#include <ClFullyConnected.h>
Public Member Functions | |
ClFullyConnected () | |
~ClFullyConnected () | |
void | configure (const CLCompileContext &compile_context, ITensorInfo *src, ITensorInfo *weights, ITensorInfo *biases, ITensorInfo *dst, FullyConnectedLayerInfo fc_info=FullyConnectedLayerInfo()) |
Set the input and output tensors. More... | |
void | run (ITensorPack &tensors) override |
Run the kernels contained in the function. More... | |
void | prepare (ITensorPack &tensors) override |
Prepare the function for executing. More... | |
experimental::MemoryRequirements | workspace () const override |
Return the memory requirements required by the workspace. More... | |
Public Member Functions inherited from ICLOperator | |
ICLOperator (IRuntimeContext *ctx=nullptr) | |
Constructor. More... | |
ICLOperator (const ICLOperator &)=delete | |
Prevent instances of this class from being copied (As this class contains pointers) More... | |
ICLOperator (ICLOperator &&)=default | |
Default move constructor. More... | |
ICLOperator & | operator= (const ICLOperator &)=delete |
Prevent instances of this class from being copied (As this class contains pointers) More... | |
ICLOperator & | operator= (ICLOperator &&)=default |
Default move assignment operator. More... | |
Public Member Functions inherited from IOperator | |
virtual | ~IOperator ()=default |
Destructor. More... | |
Static Public Member Functions | |
static Status | validate (const ITensorInfo *src, const ITensorInfo *weights, const ITensorInfo *biases, const ITensorInfo *dst, FullyConnectedLayerInfo fc_info=FullyConnectedLayerInfo()) |
Static function to check if given info will lead to a valid configuration. 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 61 of file ClFullyConnected.h.
ClFullyConnected | ( | ) |
Definition at line 188 of file ClFullyConnected.cpp.
|
default |
void configure | ( | const CLCompileContext & | compile_context, |
ITensorInfo * | src, | ||
ITensorInfo * | weights, | ||
ITensorInfo * | biases, | ||
ITensorInfo * | dst, | ||
FullyConnectedLayerInfo | fc_info = FullyConnectedLayerInfo() |
||
) |
Set the input and output tensors.
Valid data layouts:
Valid data type configurations:
src0 | src1 | src2 | dst |
---|---|---|---|
F16 | F16 | F16 | F16 |
F32 | F32 | F32 | F32 |
QASYMM8 | QASYMM8 | S32 | QASYMM8 |
QASYMM8_SIGNED | QASYMM8_SIGNED | S32 | QASYMM8_SIGNED |
[in] | compile_context | The compile context to be used. |
[in] | src | 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 src . |
[in] | biases | Bias tensor. Can be nullptr. Data type supported:Same as src . |
[out] | dst | 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 330 of file ClFullyConnected.cpp.
References arm_compute::ACL_SRC_1, ITensorInfo::are_values_constant(), FullyConnectedLayerInfo::are_weights_reshaped, ARM_COMPUTE_ERROR_ON_NULLPTR, ARM_COMPUTE_ERROR_THROW_ON, ARM_COMPUTE_LOG_PARAMS, arm_compute::test::validation::dst, CLScheduler::get(), arm_compute::get_arch_from_target(), arm_compute::is_data_type_quantized_asymmetric(), arm_compute::MIDGARD, Dimensions< size_t >::num_max_dimensions, arm_compute::offset_int_vec(), arm_compute::experimental::Prepare, FullyConnectedLayerInfo::retain_internal_weights, arm_compute::test::validation::src, TensorInfo::total_size(), FullyConnectedLayerInfo::transpose_weights, ClFullyConnected::validate(), and FullyConnectedLayerInfo::weights_trained_layout.
|
overridevirtual |
Prepare the function for executing.
Any one off pre-processing step required by the function is handled here
[in] | constants | Vector that contains the constants tensors. |
Reimplemented from ICLOperator.
Definition at line 634 of file ClFullyConnected.cpp.
References arm_compute::ACL_DST, arm_compute::ACL_SRC, arm_compute::ACL_SRC_1, ITensorPack::add_const_tensor(), ARM_COMPUTE_ERROR_ON, CLAuxTensorHandler::get(), ITensorPack::get_const_tensor(), ITensor::mark_as_unused(), and arm_compute::offset_int_vec().
Referenced by ClFullyConnected::run().
|
overridevirtual |
Run the kernels contained in the function.
[in] | tensors | Vector that contains the tensors to operate on. |
Reimplemented from ICLOperator.
Definition at line 579 of file ClFullyConnected.cpp.
References arm_compute::ACL_DST, arm_compute::ACL_SRC, arm_compute::ACL_SRC_0, arm_compute::ACL_SRC_1, ITensorPack::add_const_tensor(), ARM_COMPUTE_ERROR_ON, CLScheduler::enqueue_op(), CLScheduler::get(), CLAuxTensorHandler::get(), ITensorPack::get_const_tensor(), arm_compute::offset_int_vec(), ClFullyConnected::prepare(), and arm_compute::test::validation::src.
|
static |
Static function to check if given info will lead to a valid configuration.
Similar to ClFullyConnected::configure()
Definition at line 464 of file ClFullyConnected.cpp.
References ActivationLayerInfo::activation(), FullyConnectedLayerInfo::activation_info, ITensorInfo::are_values_constant(), 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, ICloneable< T >::clone(), arm_compute::misc::shape_calculator::compute_flatten_shape(), arm_compute::misc::shape_calculator::compute_transposed_shape(), ITensorInfo::dimension(), arm_compute::test::validation::dst, ActivationLayerInfo::enabled(), arm_compute::F16, arm_compute::F32, CLScheduler::get(), arm_compute::get_arch_from_target(), arm_compute::is_data_type_quantized(), arm_compute::MIDGARD, arm_compute::NCHW, ITensorInfo::num_dimensions(), Dimensions< size_t >::num_max_dimensions, arm_compute::QASYMM8, arm_compute::QASYMM8_SIGNED, arm_compute::S32, arm_compute::test::validation::set_data_layout(), arm_compute::test::validation::src, FullyConnectedLayerInfo::transpose_weights, ClTranspose::validate(), ClConvertFullyConnectedWeights::validate(), ClFlatten::validate(), and FullyConnectedLayerInfo::weights_trained_layout.
Referenced by ClFullyConnected::configure(), and CLFullyConnectedLayer::validate().
|
overridevirtual |
Return the memory requirements required by the workspace.
Reimplemented from ICLOperator.
Definition at line 693 of file ClFullyConnected.cpp.