23.08
|
Basic function to compute a Fully Connected layer. More...
#include <CpuFullyConnected.h>
Public Member Functions | |
CpuFullyConnected () | |
Constructor. More... | |
~CpuFullyConnected () | |
Destructor. More... | |
void | configure (const ITensorInfo *src, const ITensorInfo *weights, const ITensorInfo *biases, ITensorInfo *dst, FullyConnectedLayerInfo fc_info=FullyConnectedLayerInfo(), const WeightsInfo &weights_info=WeightsInfo()) |
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... | |
![]() | |
INEOperator (IRuntimeContext *ctx=nullptr) | |
Constructor. More... | |
INEOperator (const INEOperator &)=delete | |
Prevent instances of this class from being copied (As this class contains pointers) More... | |
INEOperator (INEOperator &&)=default | |
Default move constructor. More... | |
INEOperator & | operator= (const INEOperator &)=delete |
Prevent instances of this class from being copied (As this class contains pointers) More... | |
INEOperator & | operator= (INEOperator &&)=default |
Default move assignment operator. More... | |
~INEOperator () | |
Default destructor. More... | |
![]() | |
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(), const WeightsInfo &weights_info=WeightsInfo()) |
Static function to check if given info will lead to a valid configuration of CpuFullyConnected. More... | |
static Status | has_opt_impl (arm_compute::WeightFormat &expected_weight_format, const ITensorInfo *src, const ITensorInfo *weights, const ITensorInfo *biases, const ITensorInfo *dst, FullyConnectedLayerInfo fc_info, WeightsInfo weights_info) |
Static function that queries whether there exists fixed-format kernel and if it exists it will return in the first argument in what format weights are expected to be reshaped as defined by WeightFormat class. More... | |
Basic function to compute a Fully Connected layer.
This function calls the following 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 55 of file CpuFullyConnected.h.
|
default |
Destructor.
void configure | ( | const ITensorInfo * | src, |
const ITensorInfo * | weights, | ||
const ITensorInfo * | biases, | ||
ITensorInfo * | dst, | ||
FullyConnectedLayerInfo | fc_info = FullyConnectedLayerInfo() , |
||
const WeightsInfo & | weights_info = WeightsInfo() |
||
) |
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] | src | 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 src . |
[in] | biases | Bias tensor info. Can be nullptr. Data type supported: Same as weights , S32 if weights is QASYMM8/QASYMM8_SIGNED. |
[out] | dst | 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 |
[in] | weights_info | (Optional) Stores neccessary compute information when weights are already reshaped |
Definition at line 206 of file CpuFullyConnected.cpp.
References FullyConnectedLayerInfo::activation_info, 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, FullyConnectedLayerInfo::enable_fast_math, arm_compute::is_data_type_quantized_asymmetric(), Dimensions< size_t >::num_max_dimensions, arm_compute::offset_int_vec(), arm_compute::experimental::Prepare, FullyConnectedLayerInfo::retain_internal_weights, TensorInfo::set_are_values_constant(), arm_compute::test::validation::src, TensorInfo::total_size(), FullyConnectedLayerInfo::transpose_weights, arm_compute::UNSPECIFIED, CpuFullyConnected::validate(), arm_compute::test::validation::weights_info, and FullyConnectedLayerInfo::weights_trained_layout.
|
static |
Static function that queries whether there exists fixed-format kernel and if it exists it will return in the first argument in what format weights are expected to be reshaped as defined by WeightFormat class.
Apart from the first argument the rest of the arguments are the same as in CpuFullyConnectedLayer::validate() except that all arguments are required.
Definition at line 336 of file CpuFullyConnected.cpp.
References FullyConnectedLayerInfo::activation_info, arm_compute::test::validation::dst, FullyConnectedLayerInfo::enable_fast_math, arm_compute::test::validation::gemm_info, CpuGemm::has_opt_impl(), arm_compute::test::validation::src, arm_compute::UNSPECIFIED, and arm_compute::test::validation::weights_info.
Referenced by NEFullyConnectedLayer::has_opt_impl().
|
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 INEOperator.
Definition at line 487 of file CpuFullyConnected.cpp.
References arm_compute::ACL_DST, arm_compute::ACL_SRC, arm_compute::ACL_SRC_1, ITensorPack::add_const_tensor(), ARM_COMPUTE_ERROR_ON, Window::DimY, Scheduler::get(), CpuAuxTensorHandler::get(), ITensorPack::get_const_tensor(), ITensor::mark_as_unused(), arm_compute::offset_int_vec(), and IScheduler::schedule_op().
Referenced by CpuFullyConnected::run().
|
overridevirtual |
Run the kernels contained in the function.
[in] | tensors | Vector that contains the tensors to operate on. |
Reimplemented from INEOperator.
Definition at line 448 of file CpuFullyConnected.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, CpuAuxTensorHandler::get(), ITensorPack::get_const_tensor(), arm_compute::offset_int_vec(), CpuFullyConnected::prepare(), and arm_compute::test::validation::src.
|
static |
Static function to check if given info will lead to a valid configuration of CpuFullyConnected.
Similar to CpuFullyConnected::configure()
Definition at line 348 of file CpuFullyConnected.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_DATA_TYPE_NOT_IN, ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES, ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR, ARM_COMPUTE_RETURN_ON_ERROR, ARM_COMPUTE_UNUSED, arm_compute::BFLOAT16, 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, FullyConnectedLayerInfo::enable_fast_math, ActivationLayerInfo::enabled(), arm_compute::F16, arm_compute::F32, arm_compute::is_data_type_quantized(), arm_compute::is_fixed_format_fast_math(), ITensorInfo::num_dimensions(), Dimensions< size_t >::num_max_dimensions, arm_compute::QASYMM8, arm_compute::QASYMM8_SIGNED, FullyConnectedLayerInfo::retain_internal_weights, arm_compute::S32, arm_compute::test::validation::src, FullyConnectedLayerInfo::transpose_weights, CpuConvertFullyConnectedWeights::validate(), CpuTransposeKernel::validate(), CpuFlatten::validate(), arm_compute::test::validation::weights_info, and FullyConnectedLayerInfo::weights_trained_layout.
Referenced by CpuFullyConnected::configure(), and NEFullyConnectedLayer::validate().
|
overridevirtual |
Return the memory requirements required by the workspace.
Reimplemented from INEOperator.
Definition at line 542 of file CpuFullyConnected.cpp.