Compute Library
 22.05
FullyConnectedLayer Class Referencefinal

Fully Connected Layer. More...

#include <Layers.h>

Collaboration diagram for FullyConnectedLayer:
[legend]

Public Member Functions

 FullyConnectedLayer (unsigned int num_outputs, ITensorAccessorUPtr weights, ITensorAccessorUPtr bias, const FullyConnectedLayerInfo fc_info=FullyConnectedLayerInfo(), const QuantizationInfo weights_quant_info=QuantizationInfo(), const QuantizationInfo out_quant_info=QuantizationInfo())
 Construct a fully connected layer. More...
 
 FullyConnectedLayer (unsigned int num_outputs, SubStream sub_stream_weights, SubStream sub_stream_bias, const FullyConnectedLayerInfo fc_info=FullyConnectedLayerInfo(), const QuantizationInfo weights_quant_info=QuantizationInfo(), const QuantizationInfo out_quant_info=QuantizationInfo())
 Construct a fully connected layer. More...
 
NodeID create_layer (IStream &s) override
 Create layer and add to the given stream. More...
 
- Public Member Functions inherited from ILayer
virtual ~ILayer ()=default
 Default destructor. More...
 
ILayerset_name (std::string name)
 Sets the name of the layer. More...
 
const std::string & name () const
 Layer name accessor. More...
 

Detailed Description

Fully Connected Layer.

Definition at line 710 of file Layers.h.

Constructor & Destructor Documentation

◆ FullyConnectedLayer() [1/2]

FullyConnectedLayer ( unsigned int  num_outputs,
ITensorAccessorUPtr  weights,
ITensorAccessorUPtr  bias,
const FullyConnectedLayerInfo  fc_info = FullyConnectedLayerInfo(),
const QuantizationInfo  weights_quant_info = QuantizationInfo(),
const QuantizationInfo  out_quant_info = QuantizationInfo() 
)
inline

Construct a fully connected layer.

Parameters
[in]num_outputsNumber of outputs.
[in]weightsAccessor to get weights from.
[in]biasAccessor to get bias from.
[in]fc_info(Optional) Fully connected layer metadata
[in]weights_quant_info(Optional) Weights quantization information
[in]out_quant_info(Optional) Output quantization info

Definition at line 722 of file Layers.h.

728  : _num_outputs(num_outputs),
729  _weights(std::move(weights)),
730  _bias(std::move(bias)),
731  _weights_ss(nullptr),
732  _bias_ss(nullptr),
733  _fc_info(fc_info),
734  _weights_quant_info(std::move(weights_quant_info)),
735  _out_quant_info(std::move(out_quant_info))
736  {
737  }
const int32_t * bias

◆ FullyConnectedLayer() [2/2]

FullyConnectedLayer ( unsigned int  num_outputs,
SubStream  sub_stream_weights,
SubStream  sub_stream_bias,
const FullyConnectedLayerInfo  fc_info = FullyConnectedLayerInfo(),
const QuantizationInfo  weights_quant_info = QuantizationInfo(),
const QuantizationInfo  out_quant_info = QuantizationInfo() 
)
inline

Construct a fully connected layer.

Parameters
[in]num_outputsNumber of outputs.
[in]sub_stream_weightsGraph sub-stream for the weights.
[in]sub_stream_biasGraph sub-stream for the bias.
[in]fc_info(Optional) Fully connected layer metadata
[in]weights_quant_info(Optional) Weights quantization information
[in]out_quant_info(Optional) Output quantization info

Definition at line 748 of file Layers.h.

754  : _num_outputs(num_outputs),
755  _weights(nullptr),
756  _bias(nullptr),
757  _weights_ss(std::make_unique<SubStream>(std::move(sub_stream_weights))),
758  _bias_ss(std::make_unique<SubStream>(std::move(sub_stream_bias))),
759  _fc_info(fc_info),
760  _weights_quant_info(std::move(weights_quant_info)),
761  _out_quant_info(std::move(out_quant_info))
762  {
763  }

Member Function Documentation

◆ create_layer()

NodeID create_layer ( IStream s)
inlineoverridevirtual

Create layer and add to the given stream.

Parameters
[in]sStream to add layer to.
Returns
ID of the created node.

Implements ILayer.

Definition at line 771 of file Layers.h.

References GraphBuilder::add_fully_connected_layer(), ARM_COMPUTE_ERROR_ON, arm_compute::graph::EmptyNodeID, StreamHints::fast_math_hint, IStream::graph(), IStream::hints(), arm_compute::test::validation::input, ILayer::name(), IStream::tail_node(), and StreamHints::target_hint.

772  {
773  NodeParams common_params = { name(), s.hints().target_hint };
774  NodeIdxPair input = { s.tail_node(), 0 };
775  if(_weights != nullptr)
776  {
777  return GraphBuilder::add_fully_connected_layer(s.graph(), common_params, input, _num_outputs,
778  std::move(_weights), std::move(_bias), _fc_info,
779  std::move(_weights_quant_info), std::move(_out_quant_info), s.hints().fast_math_hint);
780  }
781  else
782  {
783  ARM_COMPUTE_ERROR_ON(_weights_ss == nullptr);
784 
785  NodeID bias_nid = (_bias_ss == nullptr) ? EmptyNodeID : _bias_ss->tail_node();
786  return GraphBuilder::add_fully_connected_layer(s.graph(), common_params, input, _num_outputs,
787  _weights_ss->tail_node(), bias_nid, _fc_info,
788  std::move(_out_quant_info), s.hints().fast_math_hint);
789  }
790  }
#define ARM_COMPUTE_ERROR_ON(cond)
If the condition is true then an error message is printed and an exception thrown.
Definition: Error.h:466
static NodeID add_fully_connected_layer(Graph &g, NodeParams params, NodeIdxPair input, unsigned int num_outputs, NodeID weights_nid, NodeID bias_nid=EmptyNodeID, const FullyConnectedLayerInfo fc_info=FullyConnectedLayerInfo(), const QuantizationInfo &out_quant_info=QuantizationInfo(), FastMathHint fast_math_hint=FastMathHint::Disabled)
Adds a fully connected layer node to the graph.
unsigned int NodeID
Definition: Types.h:69
constexpr NodeID EmptyNodeID
Constant EdgeID specifying an equivalent of null edge.
Definition: Types.h:76
const std::string & name() const
Layer name accessor.
Definition: ILayer.h:64

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