From 6940dd720ebb6b3d1df8ca203ab696daefe58189 Mon Sep 17 00:00:00 2001 From: Jim Flynn Date: Fri, 20 Mar 2020 12:25:56 +0000 Subject: renamed Documentation folder 20.02 and added .nojekyll file Signed-off-by: Jim Flynn --- 20.02/classarmnn_1_1_fully_connected_layer.xhtml | 687 +++++++++++++++++++++++ 1 file changed, 687 insertions(+) create mode 100644 20.02/classarmnn_1_1_fully_connected_layer.xhtml (limited to '20.02/classarmnn_1_1_fully_connected_layer.xhtml') diff --git a/20.02/classarmnn_1_1_fully_connected_layer.xhtml b/20.02/classarmnn_1_1_fully_connected_layer.xhtml new file mode 100644 index 0000000000..1837dc07f2 --- /dev/null +++ b/20.02/classarmnn_1_1_fully_connected_layer.xhtml @@ -0,0 +1,687 @@ + + + + + + + + + + + + + +ArmNN: FullyConnectedLayer Class Reference + + + + + + + + + + + + + + + + +
+
+ + + + ArmNN + + + +
+
+  20.02 +
+
+
+ + + + + + + +
+
+ +
+
+
+ +
+ +
+
+ + +
+ +
+ +
+ +
+
FullyConnectedLayer Class Reference
+
+
+ +

This layer represents a fully connected operation. + More...

+ +

#include <FullyConnectedLayer.hpp>

+
+Inheritance diagram for FullyConnectedLayer:
+
+
+ + +LayerWithParameters< FullyConnectedDescriptor > +Layer +IConnectableLayer + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

+Public Member Functions

virtual std::unique_ptr< IWorkloadCreateWorkload (const IWorkloadFactory &factory) const override
 Makes a workload for the FullyConnected type. More...
 
FullyConnectedLayerClone (Graph &graph) const override
 Creates a dynamically-allocated copy of this layer. More...
 
void ValidateTensorShapesFromInputs () override
 Check if the input tensor shape(s) will lead to a valid configuration of FullyConnectedLayer. More...
 
std::vector< TensorShapeInferOutputShapes (const std::vector< TensorShape > &inputShapes) const override
 By default returns inputShapes if the number of inputs are equal to number of outputs, otherwise infers the output shapes from given input shapes and layer properties. More...
 
void Accept (ILayerVisitor &visitor) const override
 Apply a visitor to this layer. More...
 
- Public Member Functions inherited from LayerWithParameters< FullyConnectedDescriptor >
const FullyConnectedDescriptorGetParameters () const
 
void SerializeLayerParameters (ParameterStringifyFunction &fn) const override
 Helper to serialize the layer parameters to string (currently used in DotSerializer and company). More...
 
- Public Member Functions inherited from Layer
 Layer (unsigned int numInputSlots, unsigned int numOutputSlots, LayerType type, const char *name)
 
 Layer (unsigned int numInputSlots, unsigned int numOutputSlots, LayerType type, DataLayout layout, const char *name)
 
const std::string & GetNameStr () const
 
const OutputHandlerGetOutputHandler (unsigned int i=0) const
 
OutputHandlerGetOutputHandler (unsigned int i=0)
 
const std::vector< InputSlot > & GetInputSlots () const
 
const std::vector< OutputSlot > & GetOutputSlots () const
 
std::vector< InputSlot >::iterator BeginInputSlots ()
 
std::vector< InputSlot >::iterator EndInputSlots ()
 
std::vector< OutputSlot >::iterator BeginOutputSlots ()
 
std::vector< OutputSlot >::iterator EndOutputSlots ()
 
bool IsOutputUnconnected ()
 
void ResetPriority () const
 
LayerPriority GetPriority () const
 
LayerType GetType () const
 
DataType GetDataType () const
 
const BackendIdGetBackendId () const
 
void SetBackendId (const BackendId &id)
 
virtual void CreateTensorHandles (const TensorHandleFactoryRegistry &registry, const IWorkloadFactory &factory, const bool IsMemoryManaged=true)
 
void VerifyLayerConnections (unsigned int expectedConnections, const CheckLocation &location) const
 
virtual void ReleaseConstantData ()
 
template<typename Op >
void OperateOnConstantTensors (Op op)
 
const char * GetName () const override
 Returns the name of the layer. More...
 
unsigned int GetNumInputSlots () const override
 Returns the number of connectable input slots. More...
 
unsigned int GetNumOutputSlots () const override
 Returns the number of connectable output slots. More...
 
const InputSlotGetInputSlot (unsigned int index) const override
 Get a const input slot handle by slot index. More...
 
InputSlotGetInputSlot (unsigned int index) override
 Get the input slot handle by slot index. More...
 
const OutputSlotGetOutputSlot (unsigned int index=0) const override
 Get the const output slot handle by slot index. More...
 
OutputSlotGetOutputSlot (unsigned int index=0) override
 Get the output slot handle by slot index. More...
 
void SetGuid (LayerGuid guid)
 
LayerGuid GetGuid () const final
 Returns the unique id of the layer. More...
 
void AddRelatedLayerName (const std::string layerName)
 
const std::list< std::string > & GetRelatedLayerNames ()
 
virtual void Reparent (Graph &dest, std::list< Layer *>::const_iterator iterator)=0
 
void BackendSelectionHint (Optional< BackendId > backend) final
 Provide a hint for the optimizer as to which backend to prefer for this layer. More...
 
Optional< BackendIdGetBackendHint () const
 
+ + + + + + + +

+Public Attributes

std::unique_ptr< ScopedCpuTensorHandlem_Weight
 A unique pointer to store Weight values. More...
 
std::unique_ptr< ScopedCpuTensorHandlem_Bias
 A unique pointer to store Bias values. More...
 
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

+Protected Member Functions

 FullyConnectedLayer (const FullyConnectedDescriptor &param, const char *name)
 Constructor to create a FullyConnectedLayer. More...
 
 ~FullyConnectedLayer ()=default
 Default destructor. More...
 
ConstantTensors GetConstantTensorsByRef () override
 Retrieve the handles to the constant values stored by the layer. More...
 
- Protected Member Functions inherited from LayerWithParameters< FullyConnectedDescriptor >
 LayerWithParameters (unsigned int numInputSlots, unsigned int numOutputSlots, LayerType type, const FullyConnectedDescriptor &param, const char *name)
 
 ~LayerWithParameters ()=default
 
WorkloadInfo PrepInfoAndDesc (QueueDescriptor &descriptor) const
 Helper function to reduce duplication in *LayerCreateWorkload. More...
 
- Protected Member Functions inherited from Layer
virtual ~Layer ()=default
 
template<typename QueueDescriptor >
void CollectQueueDescriptorInputs (QueueDescriptor &descriptor, WorkloadInfo &info) const
 
template<typename QueueDescriptor >
void CollectQueueDescriptorOutputs (QueueDescriptor &descriptor, WorkloadInfo &info) const
 
template<typename QueueDescriptor >
WorkloadInfo PrepInfoAndDesc (QueueDescriptor &descriptor) const
 Helper function to reduce duplication in *LayerCreateWorkload. More...
 
template<typename LayerType , typename ... Params>
LayerTypeCloneBase (Graph &graph, Params &&... params) const
 
- Protected Member Functions inherited from IConnectableLayer
 ~IConnectableLayer ()
 Objects are not deletable via the handle. More...
 
+ + + + + + + + + + + + + + +

+Additional Inherited Members

- Public Types inherited from LayerWithParameters< FullyConnectedDescriptor >
using DescriptorType = FullyConnectedDescriptor
 
- Protected Types inherited from Layer
using ConstantTensors = std::vector< std::reference_wrapper< std::unique_ptr< ScopedCpuTensorHandle > >>
 
- Protected Attributes inherited from LayerWithParameters< FullyConnectedDescriptor >
FullyConnectedDescriptor m_Param
 The parameters for the layer (not including tensor-valued weights etc.). More...
 
- Protected Attributes inherited from Layer
std::vector< OutputHandlerm_OutputHandlers
 
+

Detailed Description

+

This layer represents a fully connected operation.

+ +

Definition at line 15 of file FullyConnectedLayer.hpp.

+

Constructor & Destructor Documentation

+ +

◆ FullyConnectedLayer()

+ +
+
+ + + + + +
+ + + + + + + + + + + + + + + + + + +
FullyConnectedLayer (const FullyConnectedDescriptorparam,
const char * name 
)
+
+protected
+
+ +

Constructor to create a FullyConnectedLayer.

+
Parameters
+ + + +
[in]paramFullyConnectedDescriptor to configure the fully connected operation.
[in]nameOptional name for the layer.
+
+
+ +

Definition at line 17 of file FullyConnectedLayer.cpp.

+
19 {
20 }
LayerWithParameters(unsigned int numInputSlots, unsigned int numOutputSlots, LayerType type, const FullyConnectedDescriptor &param, const char *name)
+ +
+
+
+ +

◆ ~FullyConnectedLayer()

+ +
+
+ + + + + +
+ + + + + + + +
~FullyConnectedLayer ()
+
+protecteddefault
+
+ +

Default destructor.

+ +
+
+

Member Function Documentation

+ +

◆ Accept()

+ +
+
+ + + + + +
+ + + + + + + + +
void Accept (ILayerVisitorvisitor) const
+
+overridevirtual
+
+ +

Apply a visitor to this layer.

+ +

Implements IConnectableLayer.

+ +

Definition at line 88 of file FullyConnectedLayer.cpp.

+ +

References Layer::GetName(), LayerWithParameters< FullyConnectedDescriptor >::GetParameters(), FullyConnectedLayer::m_Bias, FullyConnectedLayer::m_Weight, and ILayerVisitor::VisitFullyConnectedLayer().

+
89 {
90  ConstTensor weightsTensor(m_Weight->GetTensorInfo(), m_Weight->Map(true));
91  Optional<ConstTensor> optionalBiasTensor = EmptyOptional();
92 
93  if (GetParameters().m_BiasEnabled)
94  {
95  ConstTensor biasTensor(m_Bias->GetTensorInfo(), m_Bias->GetConstTensor<void>());
96  optionalBiasTensor = Optional<ConstTensor>(biasTensor);
97  }
98 
99  visitor.VisitFullyConnectedLayer(this, GetParameters(), weightsTensor, optionalBiasTensor, GetName());
100 }
const FullyConnectedDescriptor & GetParameters() const
+
std::unique_ptr< ScopedCpuTensorHandle > m_Weight
A unique pointer to store Weight values.
+
std::unique_ptr< ScopedCpuTensorHandle > m_Bias
A unique pointer to store Bias values.
+
const char * GetName() const override
Returns the name of the layer.
Definition: Layer.hpp:305
+
+
+
+ +

◆ Clone()

+ +
+
+ + + + + +
+ + + + + + + + +
FullyConnectedLayer * Clone (Graphgraph) const
+
+overridevirtual
+
+ +

Creates a dynamically-allocated copy of this layer.

+
Parameters
+ + +
[in]graphThe graph into which this layer is being cloned.
+
+
+ +

Implements Layer.

+ +

Definition at line 38 of file FullyConnectedLayer.cpp.

+ +

References Layer::GetName(), FullyConnectedLayer::m_Bias, LayerWithParameters< FullyConnectedDescriptor >::m_Param, and FullyConnectedLayer::m_Weight.

+
39 {
40  auto layer = CloneBase<FullyConnectedLayer>(graph, m_Param, GetName());
41 
42  layer->m_Weight = m_Weight ? std::make_unique<ScopedCpuTensorHandle>(*m_Weight) : nullptr;
43  if (layer->m_Param.m_BiasEnabled)
44  {
45  layer->m_Bias = m_Bias ? std::make_unique<ScopedCpuTensorHandle>(*m_Bias) : nullptr;
46  }
47 
48  return std::move(layer);
49 }
FullyConnectedDescriptor m_Param
The parameters for the layer (not including tensor-valued weights etc.).
+
std::unique_ptr< ScopedCpuTensorHandle > m_Weight
A unique pointer to store Weight values.
+
std::unique_ptr< ScopedCpuTensorHandle > m_Bias
A unique pointer to store Bias values.
+
const char * GetName() const override
Returns the name of the layer.
Definition: Layer.hpp:305
+
+
+
+ +

◆ CreateWorkload()

+ +
+
+ + + + + +
+ + + + + + + + +
std::unique_ptr< IWorkload > CreateWorkload (const IWorkloadFactoryfactory) const
+
+overridevirtual
+
+ +

Makes a workload for the FullyConnected type.

+
Parameters
+ + + +
[in]graphThe graph where this layer can be found.
[in]factoryThe workload factory which will create the workload.
+
+
+
Returns
A pointer to the created workload, or nullptr if not created.
+ +

Implements Layer.

+ +

Definition at line 22 of file FullyConnectedLayer.cpp.

+ +

References IWorkloadFactory::CreateFullyConnected(), FullyConnectedLayer::m_Bias, FullyConnectedQueueDescriptor::m_Bias, FullyConnectedDescriptor::m_BiasEnabled, LayerWithParameters< FullyConnectedDescriptor >::m_Param, FullyConnectedLayer::m_Weight, FullyConnectedQueueDescriptor::m_Weight, and LayerWithParameters< FullyConnectedDescriptor >::PrepInfoAndDesc().

+
23 {
24  // on this level constant data should not be released..
25  BOOST_ASSERT_MSG(m_Weight != nullptr, "FullyConnectedLayer: Weights data should not be null.");
26 
27  FullyConnectedQueueDescriptor descriptor;
28 
29  descriptor.m_Weight = m_Weight.get();
31  {
32  BOOST_ASSERT_MSG(m_Bias != nullptr, "FullyConnectedLayer: Bias data should not be null.");
33  descriptor.m_Bias = m_Bias.get();
34  }
35  return factory.CreateFullyConnected(descriptor, PrepInfoAndDesc(descriptor));
36 }
FullyConnectedDescriptor m_Param
The parameters for the layer (not including tensor-valued weights etc.).
+
std::unique_ptr< ScopedCpuTensorHandle > m_Weight
A unique pointer to store Weight values.
+
bool m_BiasEnabled
Enable/disable bias.
+
std::unique_ptr< ScopedCpuTensorHandle > m_Bias
A unique pointer to store Bias values.
+
WorkloadInfo PrepInfoAndDesc(QueueDescriptor &descriptor) const
Helper function to reduce duplication in *LayerCreateWorkload.
+
+
+
+ +

◆ GetConstantTensorsByRef()

+ +
+
+ + + + + +
+ + + + + + + +
Layer::ConstantTensors GetConstantTensorsByRef ()
+
+overrideprotectedvirtual
+
+ +

Retrieve the handles to the constant values stored by the layer.

+
Returns
A vector of the constant tensors stored by this layer.
+ +

Reimplemented from Layer.

+ +

Definition at line 83 of file FullyConnectedLayer.cpp.

+ +

References FullyConnectedLayer::m_Bias, and FullyConnectedLayer::m_Weight.

+
84 {
85  return {m_Weight, m_Bias};
86 }
std::unique_ptr< ScopedCpuTensorHandle > m_Weight
A unique pointer to store Weight values.
+
std::unique_ptr< ScopedCpuTensorHandle > m_Bias
A unique pointer to store Bias values.
+
+
+
+ +

◆ InferOutputShapes()

+ +
+
+ + + + + +
+ + + + + + + + +
std::vector< TensorShape > InferOutputShapes (const std::vector< TensorShape > & inputShapes) const
+
+overridevirtual
+
+ +

By default returns inputShapes if the number of inputs are equal to number of outputs, otherwise infers the output shapes from given input shapes and layer properties.

+
Parameters
+ + +
[in]inputShapesThe input shapes layer has.
+
+
+
Returns
A vector to the inferred output shape.
+ +

Reimplemented from Layer.

+ +

Definition at line 51 of file FullyConnectedLayer.cpp.

+ +

References LayerWithParameters< FullyConnectedDescriptor >::m_Param, and FullyConnectedDescriptor::m_TransposeWeightMatrix.

+ +

Referenced by FullyConnectedLayer::ValidateTensorShapesFromInputs().

+
52 {
53  BOOST_ASSERT(inputShapes.size() == 2);
54  const TensorShape& inputShape = inputShapes[0];
55  const TensorShape weightShape = inputShapes[1];
56 
57  // Output for FC is [1, w[1]].
58  unsigned int batches = inputShape[0];
59  unsigned int dimIdx = m_Param.m_TransposeWeightMatrix ? 0 : 1;
60 
61  return std::vector<TensorShape>({ TensorShape({batches, weightShape[dimIdx]})});
62 }
FullyConnectedDescriptor m_Param
The parameters for the layer (not including tensor-valued weights etc.).
+
bool m_TransposeWeightMatrix
Enable/disable transpose weight matrix.
+
+
+
+ +

◆ ValidateTensorShapesFromInputs()

+ +
+
+ + + + + +
+ + + + + + + +
void ValidateTensorShapesFromInputs ()
+
+overridevirtual
+
+ +

Check if the input tensor shape(s) will lead to a valid configuration of FullyConnectedLayer.

+ +

Implements Layer.

+ +

Definition at line 64 of file FullyConnectedLayer.cpp.

+ +

References CHECK_LOCATION, InputSlot::GetConnection(), Layer::GetInputSlot(), Layer::GetOutputSlot(), TensorInfo::GetShape(), IOutputSlot::GetTensorInfo(), OutputSlot::GetTensorInfo(), FullyConnectedLayer::InferOutputShapes(), FullyConnectedLayer::m_Weight, and Layer::VerifyLayerConnections().

+
65 {
67 
68  // check if we m_Weight data is not nullptr
69  BOOST_ASSERT_MSG(m_Weight != nullptr, "FullyConnectedLayer: Weights data should not be null.");
70 
71  auto inferredShapes = InferOutputShapes({
73  m_Weight->GetTensorInfo().GetShape() });
74 
75  BOOST_ASSERT(inferredShapes.size() == 1);
76 
77  ConditionalThrowIfNotEqual<LayerValidationException>(
78  "FullyConnectedLayer: TensorShape set on OutputSlot[0] does not match the inferred shape.",
80  inferredShapes[0]);
81 }
std::vector< TensorShape > InferOutputShapes(const std::vector< TensorShape > &inputShapes) const override
By default returns inputShapes if the number of inputs are equal to number of outputs, otherwise infers the output shapes from given input shapes and layer properties.
+
const TensorShape & GetShape() const
Definition: Tensor.hpp:88
+
std::unique_ptr< ScopedCpuTensorHandle > m_Weight
A unique pointer to store Weight values.
+
const IOutputSlot * GetConnection() const override
Definition: Layer.hpp:199
+
void VerifyLayerConnections(unsigned int expectedConnections, const CheckLocation &location) const
Definition: Layer.cpp:338
+
const InputSlot & GetInputSlot(unsigned int index) const override
Get a const input slot handle by slot index.
Definition: Layer.hpp:310
+
#define CHECK_LOCATION()
Definition: Exceptions.hpp:192
+
const OutputSlot & GetOutputSlot(unsigned int index=0) const override
Get the const output slot handle by slot index.
Definition: Layer.hpp:312
+
virtual const TensorInfo & GetTensorInfo() const =0
+
const TensorInfo & GetTensorInfo() const override
Definition: Layer.cpp:63
+
+
+
+

Member Data Documentation

+ +

◆ m_Bias

+ +
+
+ + + + +
std::unique_ptr<ScopedCpuTensorHandle> m_Bias
+
+
+ +

◆ m_Weight

+ + +
The documentation for this class was generated from the following files: +
+
+ + + + -- cgit v1.2.1