ArmNN
 22.02
Layer Class Referenceabstract

#include <Layer.hpp>

Inheritance diagram for Layer:
IConnectableLayer AbsLayer BindableLayer CastLayer ConstantLayer ConvertBf16ToFp32Layer ConvertFp16ToFp32Layer ConvertFp32ToBf16Layer ConvertFp32ToFp16Layer DebugLayer DequantizeLayer ElementwiseBaseLayer FloorLayer LayerWithParameters< Parameters > MapLayer MemCopyLayer MemImportLayer MergeLayer PreluLayer QuantizedLstmLayer QuantizeLayer RankLayer RsqrtLayer ShapeLayer SwitchLayer UnmapLayer LayerWithParameters< ActivationDescriptor > LayerWithParameters< ArgMinMaxDescriptor > LayerWithParameters< BatchNormalizationDescriptor > LayerWithParameters< BatchToSpaceNdDescriptor > LayerWithParameters< ChannelShuffleDescriptor > LayerWithParameters< ComparisonDescriptor > LayerWithParameters< Convolution2dDescriptor > LayerWithParameters< Convolution3dDescriptor > LayerWithParameters< DepthToSpaceDescriptor > LayerWithParameters< DepthwiseConvolution2dDescriptor > LayerWithParameters< DetectionPostProcessDescriptor > LayerWithParameters< ElementwiseUnaryDescriptor > LayerWithParameters< FakeQuantizationDescriptor > LayerWithParameters< FillDescriptor > LayerWithParameters< FullyConnectedDescriptor > LayerWithParameters< GatherDescriptor > LayerWithParameters< InstanceNormalizationDescriptor > LayerWithParameters< L2NormalizationDescriptor > LayerWithParameters< LogicalBinaryDescriptor > LayerWithParameters< LogSoftmaxDescriptor > LayerWithParameters< LstmDescriptor > LayerWithParameters< MeanDescriptor > LayerWithParameters< NormalizationDescriptor > LayerWithParameters< OriginsDescriptor > LayerWithParameters< PadDescriptor > LayerWithParameters< PermuteDescriptor > LayerWithParameters< Pooling2dDescriptor > LayerWithParameters< Pooling3dDescriptor > LayerWithParameters< PreCompiledDescriptor > LayerWithParameters< QLstmDescriptor > LayerWithParameters< ReduceDescriptor > LayerWithParameters< ReshapeDescriptor > LayerWithParameters< ResizeDescriptor > LayerWithParameters< SliceDescriptor > LayerWithParameters< SoftmaxDescriptor > LayerWithParameters< SpaceToBatchNdDescriptor > LayerWithParameters< SpaceToDepthDescriptor > LayerWithParameters< StackDescriptor > LayerWithParameters< StandInDescriptor > LayerWithParameters< StridedSliceDescriptor > LayerWithParameters< TransposeConvolution2dDescriptor > LayerWithParameters< TransposeDescriptor > LayerWithParameters< ViewsDescriptor >

Public Member Functions

 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)
 
void ExecuteStrategy (IStrategy &strategy) const override
 Apply a visitor to this layer. More...
 
const std::string & GetNameStr () const
 
const OutputHandlerGetOutputHandler (unsigned int i=0) const
 
OutputHandlerGetOutputHandler (unsigned int i=0)
 
ShapeInferenceMethod GetShapeInferenceMethod () const
 
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 override
 Returns the armnn::LayerType of this layer. More...
 
DataType GetDataType () const
 
const BackendIdGetBackendId () const
 
void SetBackendId (const BackendId &id)
 
virtual std::unique_ptr< IWorkloadCreateWorkload (const IWorkloadFactory &factory) const =0
 
virtual void CreateTensorHandles (const TensorHandleFactoryRegistry &registry, const IWorkloadFactory &factory, const bool IsMemoryManaged=true)
 
virtual LayerClone (Graph &graph) const =0
 Creates a dynamically-allocated copy of this layer. More...
 
void VerifyLayerConnections (unsigned int expectedConnections, const CheckLocation &location) const
 
virtual void ValidateTensorShapesFromInputs ()=0
 
std::vector< TensorShapeInferOutputShapes (const std::vector< TensorShape > &inputShapes) const override
 Infer the shape of the output(s) based on the provided input shape(s) More...
 
virtual void SerializeLayerParameters (ParameterStringifyFunction &fn) const
 Helper to serialize the layer parameters to string. More...
 
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
 
void SetShapeInferenceMethod (ShapeInferenceMethod shapeInferenceMethod)
 
template<typename T >
std::shared_ptr< T > GetAdditionalInformation () const
 
void SetAdditionalInfoForObject (const AdditionalInfoObjectPtr &additionalInfo)
 
virtual const BaseDescriptorGetParameters () const override
 If the layer has a descriptor return it. More...
 
- Public Member Functions inherited from IConnectableLayer
ARMNN_NO_DEPRECATE_WARN_BEGIN ARMNN_DEPRECATED_MSG_REMOVAL_DATE ("Accept is deprecated. The ILayerVisitor that works in conjunction with this " "Accept function is deprecated. Use IStrategy in combination with " "ExecuteStrategy instead, which is an ABI/API stable version of the " "visitor pattern.", "22.05") virtual void Accept(ILayerVisitor &visitor) const =0
 Apply a visitor to this layer. More...
 

Protected Member Functions

virtual ~Layer ()=default
 
template<typename QueueDescriptor >
void CollectQueueDescriptorInputs (QueueDescriptor &descriptor, WorkloadInfo &info) const
 
template<typename QueueDescriptor >
void CollectQueueDescriptorOutputs (QueueDescriptor &descriptor, WorkloadInfo &info) const
 
void ValidateAndCopyShape (const TensorShape &outputShape, const TensorShape &inferredShape, const ShapeInferenceMethod shapeInferenceMethod, const std::string &layerName, const unsigned int outputSlotIndex=0)
 
void VerifyShapeInferenceType (const TensorShape &outputShape, ShapeInferenceMethod shapeInferenceMethod)
 
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
 
virtual ConstantTensors GetConstantTensorsByRef () override
 
void SetAdditionalInfo (QueueDescriptor &descriptor) const
 
- Protected Member Functions inherited from IConnectableLayer
 ~IConnectableLayer ()
 Objects are not deletable via the handle. More...
 

Protected Attributes

AdditionalInfoObjectPtr m_AdditionalInfoObject
 
std::vector< OutputHandlerm_OutputHandlers
 
ShapeInferenceMethod m_ShapeInferenceMethod
 

Friends

class Graph
 

Additional Inherited Members

- Public Types inherited from IConnectableLayer
using ConstantTensors = std::vector< std::reference_wrapper< std::shared_ptr< ConstTensorHandle > >>
 

Detailed Description

Definition at line 215 of file Layer.hpp.

Constructor & Destructor Documentation

◆ Layer() [1/2]

Layer ( unsigned int  numInputSlots,
unsigned int  numOutputSlots,
LayerType  type,
const char *  name 
)
Parameters
name- Optional name for the layer (may be nullptr).

Definition at line 221 of file Layer.cpp.

References ARMNN_ASSERT, Layer::GetInputSlots(), Layer::m_OutputHandlers, and WorkloadDataCollector::Push().

225 : Layer(numInputSlots, numOutputSlots, type, DataLayout::NCHW, name)
226 {
227 }
Layer(unsigned int numInputSlots, unsigned int numOutputSlots, LayerType type, const char *name)
Definition: Layer.cpp:221

◆ Layer() [2/2]

Layer ( unsigned int  numInputSlots,
unsigned int  numOutputSlots,
LayerType  type,
DataLayout  layout,
const char *  name 
)

Definition at line 194 of file Layer.cpp.

References armnn::IgnoreUnused(), and Layer::m_OutputHandlers.

199 : m_OutputHandlers(numOutputSlots)
201 , m_LayerName(name ? name : "")
202 , m_Type(type)
203 , m_BackendId()
204 , m_BackendHint(EmptyOptional())
206 {
207  IgnoreUnused(layout);
208  m_InputSlots.reserve(numInputSlots);
209  for (unsigned int i = 0; i < numInputSlots; ++i)
210  {
211  m_InputSlots.emplace_back(*this, i);
212  }
213 
214  m_OutputSlots.reserve(numOutputSlots);
215  for (unsigned int i = 0; i < numOutputSlots; ++i)
216  {
217  m_OutputSlots.emplace_back(*this, m_OutputHandlers[i]);
218  }
219 }
void IgnoreUnused(Ts &&...)
Validate all output shapes.
std::vector< OutputHandler > m_OutputHandlers
Definition: Layer.hpp:414
static ProfilingDynamicGuid GetNextGuid()
ShapeInferenceMethod m_ShapeInferenceMethod
Definition: Layer.hpp:415

◆ ~Layer()

virtual ~Layer ( )
protectedvirtualdefault

Member Function Documentation

◆ AddRelatedLayerName()

void AddRelatedLayerName ( const std::string  layerName)
inline

Definition at line 329 of file Layer.hpp.

329 { m_RelatedLayerNames.emplace_back(layerName); }

◆ BackendSelectionHint()

void BackendSelectionHint ( Optional< BackendId backend)
inlinefinalvirtual

Provide a hint for the optimizer as to which backend to prefer for this layer.

Implements IConnectableLayer.

Definition at line 335 of file Layer.hpp.

Referenced by TEST_SUITE().

336  {
337  m_BackendHint = backend;
338  }

◆ BeginInputSlots()

◆ BeginOutputSlots()

◆ Clone()

◆ CloneBase()

LayerType * CloneBase ( Graph graph,
Params &&...  params 
) const
protected

Definition at line 14 of file LayerCloneBase.hpp.

References Graph::AddLayer(), Layer::GetBackendHint(), Layer::GetBackendId(), Layer::GetGuid(), and Layer::m_ShapeInferenceMethod.

15 {
16  LayerType* const layer = graph.AddLayer<LayerType>(std::forward<Params>(params)...);
17 
18  layer->BackendSelectionHint(GetBackendHint());
19  layer->SetBackendId(GetBackendId());
20  layer->SetGuid(GetGuid());
21  layer->SetShapeInferenceMethod(m_ShapeInferenceMethod);
22 
23  return layer;
24 }
Optional< BackendId > GetBackendHint() const
Definition: Layer.hpp:339
const BackendId & GetBackendId() const
Definition: Layer.hpp:274
ShapeInferenceMethod m_ShapeInferenceMethod
Definition: Layer.hpp:415
LayerType
When adding a new layer, adapt also the LastLayer enum value in the enum class LayerType below...
Definition: Types.hpp:458
LayerGuid GetGuid() const final
Returns the unique id of the layer.
Definition: Layer.hpp:327

◆ CollectQueueDescriptorInputs()

void CollectQueueDescriptorInputs ( QueueDescriptor descriptor,
WorkloadInfo info 
) const
inlineprotected

Definition at line 365 of file Layer.hpp.

References QueueDescriptor::m_Inputs, and WorkloadInfo::m_InputTensorInfos.

366  {
367  WorkloadDataCollector dataCollector(descriptor.m_Inputs, info.m_InputTensorInfos);
368  CollectWorkloadInputs(dataCollector);
369  }

◆ CollectQueueDescriptorOutputs()

void CollectQueueDescriptorOutputs ( QueueDescriptor descriptor,
WorkloadInfo info 
) const
inlineprotected

Definition at line 372 of file Layer.hpp.

References QueueDescriptor::m_Outputs, and WorkloadInfo::m_OutputTensorInfos.

373  {
374  WorkloadDataCollector dataCollector(descriptor.m_Outputs, info.m_OutputTensorInfos);
375  CollectWorkloadOutputs(dataCollector);
376  }

◆ CreateTensorHandles()

void CreateTensorHandles ( const TensorHandleFactoryRegistry registry,
const IWorkloadFactory factory,
const bool  IsMemoryManaged = true 
)
virtual

Reimplemented in ConcatLayer, OutputLayer, and SplitterLayer.

Definition at line 253 of file Layer.cpp.

References ARMNN_ASSERT, OutputHandler::CreateTensorHandles(), TensorHandleFactoryRegistry::GetFactory(), Layer::GetNumOutputSlots(), Layer::GetOutputHandler(), Layer::GetOutputSlot(), OutputSlot::GetTensorHandleFactoryId(), and ITensorHandleFactory::LegacyFactoryId.

256 {
257  for (unsigned int idx=0; idx < GetNumOutputSlots(); idx++)
258  {
259 
260  OutputSlot& slot = GetOutputSlot(idx);
261  ITensorHandleFactory::FactoryId factoryId = slot.GetTensorHandleFactoryId();
262 
263  OutputHandler& handler = GetOutputHandler(idx);
264  if (factoryId == ITensorHandleFactory::LegacyFactoryId)
265  {
266  handler.CreateTensorHandles(workloadFactory, IsMemoryManaged);
267  }
268  else
269  {
270  ITensorHandleFactory* handleFactory;
271  handleFactory = registry.GetFactory(factoryId);
272  ARMNN_ASSERT(handleFactory);
273  handler.CreateTensorHandles(*handleFactory, IsMemoryManaged);
274  }
275  }
276 }
unsigned int GetNumOutputSlots() const override
Returns the number of connectable output slots.
Definition: Layer.hpp:319
#define ARMNN_ASSERT(COND)
Definition: Assert.hpp:14
const OutputHandler & GetOutputHandler(unsigned int i=0) const
Definition: Layer.hpp:230
const OutputSlot & GetOutputSlot(unsigned int index=0) const override
Get the const output slot handle by slot index.
Definition: Layer.hpp:323
static const FactoryId LegacyFactoryId

◆ CreateWorkload()

◆ EndInputSlots()

◆ EndOutputSlots()

std::vector<OutputSlot>::iterator EndOutputSlots ( )
inline

◆ ExecuteStrategy()

void ExecuteStrategy ( IStrategy strategy) const
overridevirtual

Apply a visitor to this layer.

Implements IConnectableLayer.

Reimplemented in BindableLayer, QLstmLayer, QuantizedLstmLayer, LayerWithParameters< Parameters >, UnidirectionalSequenceLstmLayer, LayerWithParameters< FakeQuantizationDescriptor >, LayerWithParameters< SoftmaxDescriptor >, LayerWithParameters< ReduceDescriptor >, LayerWithParameters< LogSoftmaxDescriptor >, LayerWithParameters< PreCompiledDescriptor >, LayerWithParameters< LstmDescriptor >, LayerWithParameters< ChannelShuffleDescriptor >, LayerWithParameters< BatchToSpaceNdDescriptor >, LayerWithParameters< PermuteDescriptor >, LayerWithParameters< SpaceToBatchNdDescriptor >, LayerWithParameters< DepthToSpaceDescriptor >, LayerWithParameters< ReshapeDescriptor >, LayerWithParameters< ElementwiseUnaryDescriptor >, LayerWithParameters< GatherDescriptor >, LayerWithParameters< SpaceToDepthDescriptor >, LayerWithParameters< OriginsDescriptor >, LayerWithParameters< ViewsDescriptor >, LayerWithParameters< Pooling2dDescriptor >, LayerWithParameters< Convolution2dDescriptor >, LayerWithParameters< ActivationDescriptor >, LayerWithParameters< StandInDescriptor >, LayerWithParameters< TransposeDescriptor >, LayerWithParameters< StackDescriptor >, LayerWithParameters< MeanDescriptor >, LayerWithParameters< ComparisonDescriptor >, LayerWithParameters< InstanceNormalizationDescriptor >, LayerWithParameters< TransposeConvolution2dDescriptor >, LayerWithParameters< BatchNormalizationDescriptor >, LayerWithParameters< ArgMinMaxDescriptor >, LayerWithParameters< LogicalBinaryDescriptor >, LayerWithParameters< DetectionPostProcessDescriptor >, LayerWithParameters< PadDescriptor >, LayerWithParameters< Convolution3dDescriptor >, LayerWithParameters< L2NormalizationDescriptor >, LayerWithParameters< FillDescriptor >, LayerWithParameters< SliceDescriptor >, LayerWithParameters< DepthwiseConvolution2dDescriptor >, LayerWithParameters< QLstmDescriptor >, LayerWithParameters< NormalizationDescriptor >, LayerWithParameters< FullyConnectedDescriptor >, LayerWithParameters< StridedSliceDescriptor >, LayerWithParameters< ResizeDescriptor >, LayerWithParameters< Pooling3dDescriptor >, LstmLayer, FullyConnectedLayer, Convolution2dLayer, DepthwiseConvolution2dLayer, TransposeConvolution2dLayer, BatchNormalizationLayer, ConstantLayer, Convolution3dLayer, ShapeLayer, DetectionPostProcessLayer, PreCompiledLayer, FakeQuantizationLayer, MemCopyLayer, MemImportLayer, ElementwiseBaseLayer, and RankLayer.

Definition at line 481 of file Layer.cpp.

References IStrategy::ExecuteStrategy(), and Layer::GetName().

482 {
483  strategy.ExecuteStrategy(this, BaseDescriptor(), {}, GetName());
484 }
const char * GetName() const override
Returns the name of the layer.
Definition: Layer.hpp:316

◆ GetAdditionalInformation()

std::shared_ptr<T> GetAdditionalInformation ( ) const
inline

Definition at line 347 of file Layer.hpp.

Referenced by NeonBackend::OptimizeSubgraphView(), and ClBackend::OptimizeSubgraphView().

348  {
349  return std::static_pointer_cast<T>(m_AdditionalInfoObject);
350  }
AdditionalInfoObjectPtr m_AdditionalInfoObject
Definition: Layer.hpp:401

◆ GetBackendHint()

Optional<BackendId> GetBackendHint ( ) const
inline

Definition at line 339 of file Layer.hpp.

Referenced by NetworkImpl::AddPrecompiledLayer(), and Layer::CloneBase().

339 { return m_BackendHint; }

◆ GetBackendId()

◆ GetConstantTensorsByRef()

virtual ConstantTensors GetConstantTensorsByRef ( )
inlineoverrideprotectedvirtual

◆ GetDataType()

DataType GetDataType ( ) const

Definition at line 287 of file Layer.cpp.

References InputSlot::GetConnection(), TensorInfo::GetDataType(), Layer::GetInputSlot(), Layer::GetNumInputSlots(), Layer::GetOutputSlot(), IOutputSlot::GetTensorInfo(), and OutputSlot::GetTensorInfo().

Referenced by ConvertFp32NetworkToFp16Impl::Run(), FuseBatchNorm< ConvLayer, ArmnnType, T >::Run(), ConvertFp32NetworkToBf16Impl::Run(), IsFloat32Layer::Test(), IsFloat16Layer::Test(), IsBFloat16Layer::Test(), and TEST_SUITE().

288 {
289  if (GetNumInputSlots() > 0) // Ignore the input layer.
290  {
292  }
294 }
unsigned int GetNumInputSlots() const override
Returns the number of connectable input slots.
Definition: Layer.hpp:318
const IOutputSlot * GetConnection() const override
Definition: Layer.hpp:204
const InputSlot & GetInputSlot(unsigned int index) const override
Get a const input slot handle by slot index.
Definition: Layer.hpp:321
DataType GetDataType() const
Definition: Tensor.hpp:198
const OutputSlot & GetOutputSlot(unsigned int index=0) const override
Get the const output slot handle by slot index.
Definition: Layer.hpp:323
virtual const TensorInfo & GetTensorInfo() const =0
const TensorInfo & GetTensorInfo() const override
Definition: Layer.cpp:66

◆ GetGuid()

LayerGuid GetGuid ( ) const
inlinefinalvirtual

Returns the unique id of the layer.

Implements IConnectableLayer.

Definition at line 327 of file Layer.hpp.

Referenced by Layer::CloneBase(), DebugLayer::CreateWorkload(), OutputSlot::GetOwningLayerGuid(), NeonBackend::OptimizeSubgraphView(), ClBackend::OptimizeSubgraphView(), and Graph::SerializeToDot().

327 { return m_Guid; }

◆ GetInputSlot() [1/2]

const InputSlot& GetInputSlot ( unsigned int  index) const
inlineoverridevirtual

Get a const input slot handle by slot index.

Implements IConnectableLayer.

Definition at line 321 of file Layer.hpp.

Referenced by armnn::ChainReduceLayers(), ConcatLayer::CreateWorkload(), DebugLayer::CreateWorkload(), armnn::optimizations::pad_fold::FoldPadIntoLayer2dImpl(), Layer::GetDataType(), Graph::Graph(), Graph::InferTensorInfos(), InputSlot::Insert(), armnn::InsertConvertBf16ToFp32LayersBefore(), armnn::InsertConvertFp16ToFp32LayersBefore(), armnn::InsertConvertFp32ToBf16LayersAfter(), armnn::InsertConvertFp32ToBf16LayersBefore(), armnn::InsertConvertFp32ToFp16LayersAfter(), armnn::InsertDebugLayerAfter(), NeonBackend::OptimizeSubgraphView(), ClBackend::OptimizeSubgraphView(), LoadedNetwork::RegisterDebugCallback(), PermuteAsReshapeImpl::Run(), TransposeAsReshapeImpl::Run(), OptimizeConsecutiveReshapesImpl::Run(), OptimizeInverseConversionsImpl::Run(), PermuteAndBatchToSpaceAsDepthToSpaceImpl< PermuteType >::Run(), MovePermuteUpImpl::Run(), MoveTransposeUpImpl::Run(), OptimizeInversePermutesImpl< PermuteType >::Run(), AddBroadcastReshapeLayerImpl::Run(), FuseBatchNorm< ConvLayer, ArmnnType, T >::Run(), Convolution3dLayer::SerializeLayerParameters(), DepthwiseConvolution2dLayer::SerializeLayerParameters(), Convolution2dLayer::SerializeLayerParameters(), TEST_SUITE(), ElementwiseBaseLayer::ValidateTensorShapesFromInputs(), QuantizeLayer::ValidateTensorShapesFromInputs(), ActivationLayer::ValidateTensorShapesFromInputs(), FillLayer::ValidateTensorShapesFromInputs(), ConvertFp32ToFp16Layer::ValidateTensorShapesFromInputs(), ReduceLayer::ValidateTensorShapesFromInputs(), RsqrtLayer::ValidateTensorShapesFromInputs(), SwitchLayer::ValidateTensorShapesFromInputs(), ConvertBf16ToFp32Layer::ValidateTensorShapesFromInputs(), StackLayer::ValidateTensorShapesFromInputs(), FakeQuantizationLayer::ValidateTensorShapesFromInputs(), FloorLayer::ValidateTensorShapesFromInputs(), ConvertFp16ToFp32Layer::ValidateTensorShapesFromInputs(), InstanceNormalizationLayer::ValidateTensorShapesFromInputs(), MemCopyLayer::ValidateTensorShapesFromInputs(), L2NormalizationLayer::ValidateTensorShapesFromInputs(), BatchToSpaceNdLayer::ValidateTensorShapesFromInputs(), MemImportLayer::ValidateTensorShapesFromInputs(), ConvertFp32ToBf16Layer::ValidateTensorShapesFromInputs(), MergeLayer::ValidateTensorShapesFromInputs(), NormalizationLayer::ValidateTensorShapesFromInputs(), AbsLayer::ValidateTensorShapesFromInputs(), DebugLayer::ValidateTensorShapesFromInputs(), Pooling2dLayer::ValidateTensorShapesFromInputs(), Pooling3dLayer::ValidateTensorShapesFromInputs(), SliceLayer::ValidateTensorShapesFromInputs(), DequantizeLayer::ValidateTensorShapesFromInputs(), ResizeLayer::ValidateTensorShapesFromInputs(), CastLayer::ValidateTensorShapesFromInputs(), ShapeLayer::ValidateTensorShapesFromInputs(), SoftmaxLayer::ValidateTensorShapesFromInputs(), PadLayer::ValidateTensorShapesFromInputs(), LogSoftmaxLayer::ValidateTensorShapesFromInputs(), TransposeLayer::ValidateTensorShapesFromInputs(), ChannelShuffleLayer::ValidateTensorShapesFromInputs(), MeanLayer::ValidateTensorShapesFromInputs(), PermuteLayer::ValidateTensorShapesFromInputs(), ReshapeLayer::ValidateTensorShapesFromInputs(), Convolution3dLayer::ValidateTensorShapesFromInputs(), ElementwiseUnaryLayer::ValidateTensorShapesFromInputs(), GatherLayer::ValidateTensorShapesFromInputs(), StridedSliceLayer::ValidateTensorShapesFromInputs(), ArgMinMaxLayer::ValidateTensorShapesFromInputs(), ComparisonLayer::ValidateTensorShapesFromInputs(), DepthwiseConvolution2dLayer::ValidateTensorShapesFromInputs(), PreluLayer::ValidateTensorShapesFromInputs(), TransposeConvolution2dLayer::ValidateTensorShapesFromInputs(), SpaceToDepthLayer::ValidateTensorShapesFromInputs(), LogicalBinaryLayer::ValidateTensorShapesFromInputs(), DepthToSpaceLayer::ValidateTensorShapesFromInputs(), SpaceToBatchNdLayer::ValidateTensorShapesFromInputs(), Convolution2dLayer::ValidateTensorShapesFromInputs(), FullyConnectedLayer::ValidateTensorShapesFromInputs(), LstmLayer::ValidateTensorShapesFromInputs(), UnidirectionalSequenceLstmLayer::ValidateTensorShapesFromInputs(), ConcatLayer::ValidateTensorShapesFromInputs(), BatchNormalizationLayer::ValidateTensorShapesFromInputs(), OutputLayer::ValidateTensorShapesFromInputs(), QuantizedLstmLayer::ValidateTensorShapesFromInputs(), QLstmLayer::ValidateTensorShapesFromInputs(), and Layer::VerifyLayerConnections().

321 { return m_InputSlots.at(index); }

◆ GetInputSlot() [2/2]

InputSlot& GetInputSlot ( unsigned int  index)
inlineoverridevirtual

Get the input slot handle by slot index.

Implements IConnectableLayer.

Definition at line 322 of file Layer.hpp.

322 { return m_InputSlots.at(index); }

◆ GetInputSlots()

◆ GetName()

const char* GetName ( ) const
inlineoverridevirtual

Returns the name of the layer.

Implements IConnectableLayer.

Definition at line 316 of file Layer.hpp.

Referenced by RankLayer::Accept(), AdditionLayer::Accept(), QuantizeLayer::Accept(), DivisionLayer::Accept(), MaximumLayer::Accept(), SubtractionLayer::Accept(), MinimumLayer::Accept(), MultiplicationLayer::Accept(), ActivationLayer::Accept(), FillLayer::Accept(), ReduceLayer::Accept(), SoftmaxLayer::Accept(), L2NormalizationLayer::Accept(), InstanceNormalizationLayer::Accept(), SwitchLayer::Accept(), DequantizeLayer::Accept(), NormalizationLayer::Accept(), AbsLayer::Accept(), FloorLayer::Accept(), InputLayer::Accept(), RsqrtLayer::Accept(), LogSoftmaxLayer::Accept(), MeanLayer::Accept(), MergeLayer::Accept(), BatchToSpaceNdLayer::Accept(), StackLayer::Accept(), StridedSliceLayer::Accept(), ArgMinMaxLayer::Accept(), DetectionPostProcessLayer::Accept(), Pooling2dLayer::Accept(), Pooling3dLayer::Accept(), ElementwiseUnaryLayer::Accept(), ResizeLayer::Accept(), GatherLayer::Accept(), SliceLayer::Accept(), SpaceToBatchNdLayer::Accept(), SpaceToDepthLayer::Accept(), LogicalBinaryLayer::Accept(), DepthToSpaceLayer::Accept(), ComparisonLayer::Accept(), PadLayer::Accept(), PreluLayer::Accept(), StandInLayer::Accept(), BatchNormalizationLayer::Accept(), ConstantLayer::Accept(), TransposeConvolution2dLayer::Accept(), OutputLayer::Accept(), DepthwiseConvolution2dLayer::Accept(), Convolution2dLayer::Accept(), SplitterLayer::Accept(), FullyConnectedLayer::Accept(), LstmLayer::Accept(), ConcatLayer::Accept(), ReshapeLayer::Accept(), TransposeLayer::Accept(), PermuteLayer::Accept(), QuantizedLstmLayer::Accept(), QLstmLayer::Accept(), Graph::AddCompatibilityLayers(), ChannelShuffleLayer::Clone(), RankLayer::Clone(), QuantizeLayer::Clone(), FillLayer::Clone(), ConvertFp32ToFp16Layer::Clone(), ActivationLayer::Clone(), InstanceNormalizationLayer::Clone(), L2NormalizationLayer::Clone(), StridedSliceLayer::Clone(), CastLayer::Clone(), DebugLayer::Clone(), SwitchLayer::Clone(), ResizeLayer::Clone(), BatchToSpaceNdLayer::Clone(), MapLayer::Clone(), UnmapLayer::Clone(), DequantizeLayer::Clone(), MemCopyLayer::Clone(), MemImportLayer::Clone(), MergeLayer::Clone(), AbsLayer::Clone(), NormalizationLayer::Clone(), SoftmaxLayer::Clone(), Pooling2dLayer::Clone(), Pooling3dLayer::Clone(), ConvertBf16ToFp32Layer::Clone(), FakeQuantizationLayer::Clone(), ConvertFp16ToFp32Layer::Clone(), FloorLayer::Clone(), ReduceLayer::Clone(), ConvertFp32ToBf16Layer::Clone(), StackLayer::Clone(), RsqrtLayer::Clone(), ShapeLayer::Clone(), InputLayer::Clone(), SliceLayer::Clone(), AdditionLayer::Clone(), GatherLayer::Clone(), SpaceToBatchNdLayer::Clone(), SpaceToDepthLayer::Clone(), LogicalBinaryLayer::Clone(), ElementwiseUnaryLayer::Clone(), DepthToSpaceLayer::Clone(), MaximumLayer::Clone(), ComparisonLayer::Clone(), SubtractionLayer::Clone(), ArgMinMaxLayer::Clone(), MinimumLayer::Clone(), MultiplicationLayer::Clone(), LogSoftmaxLayer::Clone(), PadLayer::Clone(), DivisionLayer::Clone(), StandInLayer::Clone(), TransposeLayer::Clone(), PreluLayer::Clone(), MeanLayer::Clone(), PermuteLayer::Clone(), ConstantLayer::Clone(), ReshapeLayer::Clone(), Convolution3dLayer::Clone(), PreCompiledLayer::Clone(), DetectionPostProcessLayer::Clone(), TransposeConvolution2dLayer::Clone(), DepthwiseConvolution2dLayer::Clone(), Convolution2dLayer::Clone(), SplitterLayer::Clone(), FullyConnectedLayer::Clone(), LstmLayer::Clone(), UnidirectionalSequenceLstmLayer::Clone(), ConcatLayer::Clone(), BatchNormalizationLayer::Clone(), OutputLayer::Clone(), QuantizedLstmLayer::Clone(), QLstmLayer::Clone(), ElementwiseBaseLayer::ExecuteStrategy(), RankLayer::ExecuteStrategy(), DetectionPostProcessLayer::ExecuteStrategy(), ShapeLayer::ExecuteStrategy(), Convolution3dLayer::ExecuteStrategy(), ConstantLayer::ExecuteStrategy(), BatchNormalizationLayer::ExecuteStrategy(), TransposeConvolution2dLayer::ExecuteStrategy(), DepthwiseConvolution2dLayer::ExecuteStrategy(), Convolution2dLayer::ExecuteStrategy(), FullyConnectedLayer::ExecuteStrategy(), LstmLayer::ExecuteStrategy(), UnidirectionalSequenceLstmLayer::ExecuteStrategy(), LayerWithParameters< Pooling3dDescriptor >::ExecuteStrategy(), QuantizedLstmLayer::ExecuteStrategy(), QLstmLayer::ExecuteStrategy(), Layer::ExecuteStrategy(), armnn::optimizations::pad_fold::FoldPadIntoLayer2dImpl(), ElementwiseBaseLayer::InferOutputShapes(), Graph::InferTensorInfos(), armnn::InsertConvertBf16ToFp32LayersBefore(), armnn::InsertConvertFp16ToFp32LayersBefore(), armnn::InsertConvertFp32ToBf16LayersAfter(), armnn::InsertConvertFp32ToBf16LayersBefore(), armnn::InsertConvertFp32ToFp16LayersAfter(), NeonBackend::OptimizeSubgraphView(), ClBackend::OptimizeSubgraphView(), TransposeAsReshapeImpl::Run(), PermuteAsReshapeImpl::Run(), OptimizeConsecutiveReshapesImpl::Run(), PermuteAndBatchToSpaceAsDepthToSpaceImpl< PermuteType >::Run(), FuseBatchNorm< ConvLayer, ArmnnType, T >::Run(), TEST_SUITE(), and ErasedLayerNamesObservable::Update().

316 { return m_LayerName.c_str(); }

◆ GetNameStr()

◆ GetNumInputSlots()

◆ GetNumOutputSlots()

◆ GetOutputHandler() [1/2]

◆ GetOutputHandler() [2/2]

OutputHandler& GetOutputHandler ( unsigned int  i = 0)
inline

Definition at line 235 of file Layer.hpp.

236  {
237  return const_cast<OutputHandler&>(const_cast<const Layer*>(this)->GetOutputHandler(i));
238  }
Layer(unsigned int numInputSlots, unsigned int numOutputSlots, LayerType type, const char *name)
Definition: Layer.cpp:221
const OutputHandler & GetOutputHandler(unsigned int i=0) const
Definition: Layer.hpp:230

◆ GetOutputSlot() [1/2]

const OutputSlot& GetOutputSlot ( unsigned int  index = 0) const
inlineoverridevirtual

Get the const output slot handle by slot index.

Implements IConnectableLayer.

Examples:
CustomMemoryAllocatorSample.cpp.

Definition at line 323 of file Layer.hpp.

Referenced by Graph::AddCompatibilityLayers(), NetworkImpl::AddFullyConnectedLayer(), armnn::AttemptBackendAssignment(), OutputSlot::CalculateIndexOnOwner(), armnn::ChainReduceLayers(), armnn::CheckScaleSetOnQuantizedType(), SplitterLayer::CreateTensorHandles(), ConcatLayer::CreateTensorHandles(), Layer::CreateTensorHandles(), CreateTestNetwork(), SplitterLayer::CreateWorkload(), ConcatLayer::CreateWorkload(), armnn::optimizations::pad_fold::FoldPadIntoLayer2dImpl(), Layer::GetDataType(), InputSlot::Insert(), armnn::InsertConvertBf16ToFp32LayersBefore(), armnn::InsertConvertFp16ToFp32LayersBefore(), armnn::InsertConvertFp32ToBf16LayersAfter(), armnn::InsertConvertFp32ToBf16LayersBefore(), armnn::InsertConvertFp32ToFp16LayersAfter(), armnn::InsertDebugLayerAfter(), IsConnected(), PermuteAsReshapeImpl::Run(), TransposeAsReshapeImpl::Run(), OptimizeConsecutiveReshapesImpl::Run(), OptimizeInverseConversionsImpl::Run(), PermuteAndBatchToSpaceAsDepthToSpaceImpl< PermuteType >::Run(), OptimizeInversePermutesImpl< PermuteType >::Run(), MovePermuteUpImpl::Run(), MoveTransposeUpImpl::Run(), AddBroadcastReshapeLayerImpl::Run(), FuseBatchNorm< ConvLayer, ArmnnType, T >::Run(), armnn::SelectTensorHandleStrategy(), TEST_SUITE(), Layer::ValidateAndCopyShape(), ElementwiseBaseLayer::ValidateTensorShapesFromInputs(), RankLayer::ValidateTensorShapesFromInputs(), QuantizeLayer::ValidateTensorShapesFromInputs(), ActivationLayer::ValidateTensorShapesFromInputs(), FillLayer::ValidateTensorShapesFromInputs(), ConvertFp32ToFp16Layer::ValidateTensorShapesFromInputs(), ReduceLayer::ValidateTensorShapesFromInputs(), SliceLayer::ValidateTensorShapesFromInputs(), FakeQuantizationLayer::ValidateTensorShapesFromInputs(), NormalizationLayer::ValidateTensorShapesFromInputs(), FloorLayer::ValidateTensorShapesFromInputs(), StackLayer::ValidateTensorShapesFromInputs(), SwitchLayer::ValidateTensorShapesFromInputs(), Pooling2dLayer::ValidateTensorShapesFromInputs(), ConvertBf16ToFp32Layer::ValidateTensorShapesFromInputs(), ConvertFp32ToBf16Layer::ValidateTensorShapesFromInputs(), MemCopyLayer::ValidateTensorShapesFromInputs(), ShapeLayer::ValidateTensorShapesFromInputs(), ConvertFp16ToFp32Layer::ValidateTensorShapesFromInputs(), BatchToSpaceNdLayer::ValidateTensorShapesFromInputs(), InstanceNormalizationLayer::ValidateTensorShapesFromInputs(), L2NormalizationLayer::ValidateTensorShapesFromInputs(), MemImportLayer::ValidateTensorShapesFromInputs(), CastLayer::ValidateTensorShapesFromInputs(), DebugLayer::ValidateTensorShapesFromInputs(), Pooling3dLayer::ValidateTensorShapesFromInputs(), DequantizeLayer::ValidateTensorShapesFromInputs(), ResizeLayer::ValidateTensorShapesFromInputs(), RsqrtLayer::ValidateTensorShapesFromInputs(), MergeLayer::ValidateTensorShapesFromInputs(), AbsLayer::ValidateTensorShapesFromInputs(), SoftmaxLayer::ValidateTensorShapesFromInputs(), TransposeLayer::ValidateTensorShapesFromInputs(), PadLayer::ValidateTensorShapesFromInputs(), MeanLayer::ValidateTensorShapesFromInputs(), LogSoftmaxLayer::ValidateTensorShapesFromInputs(), ChannelShuffleLayer::ValidateTensorShapesFromInputs(), PermuteLayer::ValidateTensorShapesFromInputs(), ConstantLayer::ValidateTensorShapesFromInputs(), ReshapeLayer::ValidateTensorShapesFromInputs(), Convolution3dLayer::ValidateTensorShapesFromInputs(), ElementwiseUnaryLayer::ValidateTensorShapesFromInputs(), ArgMinMaxLayer::ValidateTensorShapesFromInputs(), DetectionPostProcessLayer::ValidateTensorShapesFromInputs(), GatherLayer::ValidateTensorShapesFromInputs(), StridedSliceLayer::ValidateTensorShapesFromInputs(), SpaceToDepthLayer::ValidateTensorShapesFromInputs(), ComparisonLayer::ValidateTensorShapesFromInputs(), SpaceToBatchNdLayer::ValidateTensorShapesFromInputs(), LogicalBinaryLayer::ValidateTensorShapesFromInputs(), DepthwiseConvolution2dLayer::ValidateTensorShapesFromInputs(), TransposeConvolution2dLayer::ValidateTensorShapesFromInputs(), DepthToSpaceLayer::ValidateTensorShapesFromInputs(), PreluLayer::ValidateTensorShapesFromInputs(), Convolution2dLayer::ValidateTensorShapesFromInputs(), FullyConnectedLayer::ValidateTensorShapesFromInputs(), SplitterLayer::ValidateTensorShapesFromInputs(), ConcatLayer::ValidateTensorShapesFromInputs(), UnidirectionalSequenceLstmLayer::ValidateTensorShapesFromInputs(), LstmLayer::ValidateTensorShapesFromInputs(), BatchNormalizationLayer::ValidateTensorShapesFromInputs(), QuantizedLstmLayer::ValidateTensorShapesFromInputs(), and QLstmLayer::ValidateTensorShapesFromInputs().

323 { return m_OutputSlots.at(index); }

◆ GetOutputSlot() [2/2]

OutputSlot& GetOutputSlot ( unsigned int  index = 0)
inlineoverridevirtual

Get the output slot handle by slot index.

Implements IConnectableLayer.

Definition at line 324 of file Layer.hpp.

324 { return m_OutputSlots.at(index); }

◆ GetOutputSlots()

const std::vector<OutputSlot>& GetOutputSlots ( ) const
inline

◆ GetParameters()

virtual const BaseDescriptor& GetParameters ( ) const
inlineoverridevirtual

If the layer has a descriptor return it.

The base descriptor can then be cast to the correct descriptor class. If the layer has no associated descriptor a struct of type NullDescriptor will be returned. Note: NullDescriptors can be detected because they return true when the BaseDescriptor IsNull function is invoked.

Implements IConnectableLayer.

Reimplemented in LayerWithParameters< Parameters >, LayerWithParameters< FakeQuantizationDescriptor >, LayerWithParameters< SoftmaxDescriptor >, LayerWithParameters< ReduceDescriptor >, LayerWithParameters< LogSoftmaxDescriptor >, LayerWithParameters< PreCompiledDescriptor >, LayerWithParameters< LstmDescriptor >, LayerWithParameters< ChannelShuffleDescriptor >, LayerWithParameters< BatchToSpaceNdDescriptor >, LayerWithParameters< PermuteDescriptor >, LayerWithParameters< SpaceToBatchNdDescriptor >, LayerWithParameters< DepthToSpaceDescriptor >, LayerWithParameters< ReshapeDescriptor >, LayerWithParameters< ElementwiseUnaryDescriptor >, LayerWithParameters< GatherDescriptor >, LayerWithParameters< SpaceToDepthDescriptor >, LayerWithParameters< OriginsDescriptor >, LayerWithParameters< ViewsDescriptor >, LayerWithParameters< Pooling2dDescriptor >, LayerWithParameters< Convolution2dDescriptor >, LayerWithParameters< ActivationDescriptor >, LayerWithParameters< StandInDescriptor >, LayerWithParameters< TransposeDescriptor >, LayerWithParameters< StackDescriptor >, LayerWithParameters< MeanDescriptor >, LayerWithParameters< ComparisonDescriptor >, LayerWithParameters< InstanceNormalizationDescriptor >, LayerWithParameters< TransposeConvolution2dDescriptor >, LayerWithParameters< BatchNormalizationDescriptor >, LayerWithParameters< ArgMinMaxDescriptor >, LayerWithParameters< LogicalBinaryDescriptor >, LayerWithParameters< DetectionPostProcessDescriptor >, LayerWithParameters< PadDescriptor >, LayerWithParameters< Convolution3dDescriptor >, LayerWithParameters< L2NormalizationDescriptor >, LayerWithParameters< FillDescriptor >, LayerWithParameters< SliceDescriptor >, LayerWithParameters< DepthwiseConvolution2dDescriptor >, LayerWithParameters< QLstmDescriptor >, LayerWithParameters< NormalizationDescriptor >, LayerWithParameters< FullyConnectedDescriptor >, LayerWithParameters< StridedSliceDescriptor >, LayerWithParameters< ResizeDescriptor >, and LayerWithParameters< Pooling3dDescriptor >.

Definition at line 357 of file Layer.hpp.

357 { return m_NullDescriptor; }

◆ GetPriority()

LayerPriority GetPriority ( ) const

Definition at line 302 of file Layer.cpp.

References Layer::GetInputSlots(), OutputSlot::GetOwningLayer(), Layer::GetPriority(), Layer::GetType(), armnn::Input, and armnn::Output.

Referenced by Layer::GetPriority(), and SquashEqualSiblingsImpl< Comparable >::Run().

303 {
304  constexpr LayerPriority inputPrio = std::numeric_limits<LayerPriority>::lowest();
305  constexpr LayerPriority outputPrio = std::numeric_limits<LayerPriority>::max();
306 
307  if (GetType() == LayerType::Input)
308  {
309  m_Priority = inputPrio;
310  }
311  else if (GetType() == LayerType::Output)
312  {
313  m_Priority = outputPrio;
314  }
315  else if (m_Priority == 0)
316  {
317  if (m_Visiting)
318  {
319  throw GraphValidationException("Graph has circular dependencies: cannot walk");
320  }
321 
322  auto maxPrio = [](const LayerPriority prio, const InputSlot& slot) -> LayerPriority
323  {
324  const OutputSlot *outputSlot = slot.GetConnectedOutputSlot();
325  if (outputSlot)
326  {
327  const Layer& input = outputSlot->GetOwningLayer();
328  return std::max(prio, input.GetPriority());
329  }
330  else
331  {
332  // unconnected input slot
333  return prio;
334  }
335  };
336 
337  m_Visiting = true;
338  LayerPriority parentPrio = std::accumulate(GetInputSlots().cbegin(), GetInputSlots().cend(), 0U, maxPrio);
339  m_Visiting = false;
340 
341  if (parentPrio >= outputPrio)
342  {
343  throw GraphValidationException("Graph has too many edges");
344  }
345 
346  m_Priority = parentPrio + 1U;
347  }
348 
349  return m_Priority;
350 }
unsigned int LayerPriority
Definition: Layer.hpp:212
const std::vector< InputSlot > & GetInputSlots() const
Definition: Layer.hpp:242
LayerType GetType() const override
Returns the armnn::LayerType of this layer.
Definition: Layer.hpp:270
Layer(unsigned int numInputSlots, unsigned int numOutputSlots, LayerType type, const char *name)
Definition: Layer.cpp:221

◆ GetRelatedLayerNames()

const std::list<std::string>& GetRelatedLayerNames ( )
inline

Definition at line 331 of file Layer.hpp.

Referenced by ErasedLayerNamesObservable::Update().

331 { return m_RelatedLayerNames; }

◆ GetShapeInferenceMethod()

ShapeInferenceMethod GetShapeInferenceMethod ( ) const
inline

Definition at line 240 of file Layer.hpp.

240 { return m_ShapeInferenceMethod; };
ShapeInferenceMethod m_ShapeInferenceMethod
Definition: Layer.hpp:415

◆ GetType()

LayerType GetType ( ) const
inlineoverridevirtual

Returns the armnn::LayerType of this layer.

Implements IConnectableLayer.

Definition at line 270 of file Layer.hpp.

Referenced by armnn::ApplyBackendOptimizations(), armnn::AttemptBackendAssignment(), armnn::CalculateEdgeStrategy(), armnn::CalculateSlotOption(), armnn::CalculateSlotOptionForInput(), armnn::CheckScaleSetOnQuantizedType(), ConcatLayer::CreateWorkload(), SplitterLayer::CreateWorkload(), LoadedNetwork::EnqueueWorkload(), Layer::GetPriority(), LoadedNetwork::ImportInputs(), LoadedNetwork::ImportOutputs(), ElementwiseBaseLayer::InferOutputShapes(), Layer::InferOutputShapes(), Graph::InferTensorInfos(), ReshapeLayer::IsEqual(), TransposeLayer::IsEqual(), PermuteLayer::IsEqual(), TransposeLayer::IsInverse(), PermuteLayer::IsInverse(), IsLayerOfType(), NeonBackend::OptimizeSubgraphView(), ClBackend::OptimizeSubgraphView(), MockBackend::OptimizeSubgraphView(), LoadedNetwork::RegisterDebugCallback(), armnn::ReturnWithError(), ConvertFp32NetworkToFp16Impl::Run(), OptimizeConsecutiveReshapesImpl::Run(), AddDebugImpl::Run(), OptimizeInverseConversionsImpl::Run(), PermuteAndBatchToSpaceAsDepthToSpaceImpl< PermuteType >::Run(), MovePermuteUpImpl::Run(), RedirectMembersToConstantInputsImpl::Run(), MoveTransposeUpImpl::Run(), AddBroadcastReshapeLayerImpl::Run(), FuseBatchNorm< ConvLayer, ArmnnType, T >::Run(), OptimizeForTypeImpl< BaseType, OptimizeForConnectionImpl< BaseType, ChildType, Wrapped > >::Run(), ConvertFp32NetworkToBf16Impl::Run(), armnn::SelectTensorHandleStrategy(), TEST_SUITE(), ElementwiseBaseLayer::ValidateTensorShapesFromInputs(), ElementwiseUnaryLayer::ValidateTensorShapesFromInputs(), and Layer::VerifyLayerConnections().

270 { return m_Type; }

◆ InferOutputShapes()

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

Infer the shape of the output(s) based on the provided input shape(s)

Implements IConnectableLayer.

Reimplemented in QLstmLayer, QuantizedLstmLayer, ConcatLayer, LstmLayer, UnidirectionalSequenceLstmLayer, FullyConnectedLayer, SplitterLayer, Convolution2dLayer, DepthwiseConvolution2dLayer, TransposeConvolution2dLayer, Convolution3dLayer, ConstantLayer, PermuteLayer, ReshapeLayer, PadLayer, StandInLayer, BatchToSpaceNdLayer, Pooling2dLayer, Pooling3dLayer, ResizeLayer, ShapeLayer, SliceLayer, StackLayer, TransposeLayer, MergeLayer, ComparisonLayer, DepthToSpaceLayer, LogicalBinaryLayer, PreluLayer, SpaceToBatchNdLayer, SpaceToDepthLayer, ArgMinMaxLayer, ElementwiseUnaryLayer, GatherLayer, StridedSliceLayer, and ElementwiseBaseLayer.

Definition at line 371 of file Layer.cpp.

References ARMNN_ASSERT, CHECK_LOCATION, armnn::GetLayerTypeAsCString(), Layer::GetNameStr(), Layer::GetNumInputSlots(), Layer::GetNumOutputSlots(), and Layer::GetType().

Referenced by QuantizeLayer::ValidateTensorShapesFromInputs(), ActivationLayer::ValidateTensorShapesFromInputs(), ConvertFp32ToFp16Layer::ValidateTensorShapesFromInputs(), FillLayer::ValidateTensorShapesFromInputs(), SoftmaxLayer::ValidateTensorShapesFromInputs(), AbsLayer::ValidateTensorShapesFromInputs(), MemImportLayer::ValidateTensorShapesFromInputs(), MemCopyLayer::ValidateTensorShapesFromInputs(), ConvertFp32ToBf16Layer::ValidateTensorShapesFromInputs(), L2NormalizationLayer::ValidateTensorShapesFromInputs(), InstanceNormalizationLayer::ValidateTensorShapesFromInputs(), FloorLayer::ValidateTensorShapesFromInputs(), FakeQuantizationLayer::ValidateTensorShapesFromInputs(), SwitchLayer::ValidateTensorShapesFromInputs(), DequantizeLayer::ValidateTensorShapesFromInputs(), NormalizationLayer::ValidateTensorShapesFromInputs(), CastLayer::ValidateTensorShapesFromInputs(), DebugLayer::ValidateTensorShapesFromInputs(), ConvertFp16ToFp32Layer::ValidateTensorShapesFromInputs(), ConvertBf16ToFp32Layer::ValidateTensorShapesFromInputs(), RsqrtLayer::ValidateTensorShapesFromInputs(), ChannelShuffleLayer::ValidateTensorShapesFromInputs(), LogSoftmaxLayer::ValidateTensorShapesFromInputs(), and BatchNormalizationLayer::ValidateTensorShapesFromInputs().

372 {
375 
376  // By default we return what we got, meaning the output shape(s) are the same as the input(s).
377  // This only works if the number of inputs and outputs are the same. Since we are in the Layer
378  // base class, this means the implementation needs to be overridden in the specific layers for
379  // the other cases. So the missing implementation justifies the UnimplementedException.
380 
382  {
383  throw UnimplementedException(
384  fmt::format("Default implementation for InferOutputShapes can only be used for "
385  "layers with the same number of input and output slots. This doesn't "
386  "hold for {0} layer {1} (#inputs={2} #outputs={3}) {4}",
388  GetNameStr(),
391  CHECK_LOCATION().AsString()));
392  }
393  return inputShapes;
394 }
unsigned int GetNumInputSlots() const override
Returns the number of connectable input slots.
Definition: Layer.hpp:318
unsigned int GetNumOutputSlots() const override
Returns the number of connectable output slots.
Definition: Layer.hpp:319
const std::string & GetNameStr() const
Definition: Layer.hpp:225
LayerType GetType() const override
Returns the armnn::LayerType of this layer.
Definition: Layer.hpp:270
#define ARMNN_ASSERT(COND)
Definition: Assert.hpp:14
#define CHECK_LOCATION()
Definition: Exceptions.hpp:209
const char * GetLayerTypeAsCString(LayerType type)

◆ IsOutputUnconnected()

bool IsOutputUnconnected ( )
inline

Definition at line 254 of file Layer.hpp.

Referenced by OptimizeForConnectionImpl< BaseType, ChildType, Wrapped >::Run(), and OptimizeForExclusiveConnectionImpl< BaseType, ChildType, Wrapped >::Run().

255  {
256  unsigned int numConnections = 0;
257 
258  for (auto&& output : GetOutputSlots())
259  {
260  numConnections += output.GetNumConnections();
261  }
262 
263  return (GetNumOutputSlots() > 0) && (numConnections == 0);
264  }
unsigned int GetNumOutputSlots() const override
Returns the number of connectable output slots.
Definition: Layer.hpp:319
const std::vector< OutputSlot > & GetOutputSlots() const
Definition: Layer.hpp:243

◆ OperateOnConstantTensors()

void OperateOnConstantTensors ( Op  op)
inline

Definition at line 303 of file Layer.hpp.

Referenced by Layer::ReleaseConstantData(), and ConvertConstants< Converter, Predicate >::Run().

304  {
305  for (auto constant : GetConstantTensorsByRef())
306  {
307  if (constant.get())
308  {
309  op(constant);
310  }
311  }
312  };
virtual ConstantTensors GetConstantTensorsByRef() override
Definition: Layer.hpp:401

◆ PrepInfoAndDesc()

WorkloadInfo PrepInfoAndDesc ( QueueDescriptor descriptor) const
inlineprotected

Helper function to reduce duplication in *LayerCreateWorkload.

Definition at line 388 of file Layer.hpp.

References armnn::info.

Referenced by ConvertFp32ToFp16Layer::CreateWorkload(), RankLayer::CreateWorkload(), UnmapLayer::CreateWorkload(), AdditionLayer::CreateWorkload(), ShapeLayer::CreateWorkload(), RsqrtLayer::CreateWorkload(), QuantizeLayer::CreateWorkload(), MemCopyLayer::CreateWorkload(), MemImportLayer::CreateWorkload(), DebugLayer::CreateWorkload(), AbsLayer::CreateWorkload(), DequantizeLayer::CreateWorkload(), ConvertBf16ToFp32Layer::CreateWorkload(), CastLayer::CreateWorkload(), ConvertFp16ToFp32Layer::CreateWorkload(), MapLayer::CreateWorkload(), FloorLayer::CreateWorkload(), SwitchLayer::CreateWorkload(), ConvertFp32ToBf16Layer::CreateWorkload(), PreluLayer::CreateWorkload(), SubtractionLayer::CreateWorkload(), DivisionLayer::CreateWorkload(), MinimumLayer::CreateWorkload(), MaximumLayer::CreateWorkload(), MultiplicationLayer::CreateWorkload(), ConstantLayer::CreateWorkload(), QuantizedLstmLayer::CreateWorkload(), and LayerWithParameters< Pooling3dDescriptor >::PrepInfoAndDesc().

389  {
390  WorkloadInfo info;
391  CollectQueueDescriptorInputs(descriptor, info);
392  CollectQueueDescriptorOutputs(descriptor, info);
393  return info;
394  }
void CollectQueueDescriptorInputs(QueueDescriptor &descriptor, WorkloadInfo &info) const
Definition: Layer.hpp:365
void CollectQueueDescriptorOutputs(QueueDescriptor &descriptor, WorkloadInfo &info) const
Definition: Layer.hpp:372

◆ ReleaseConstantData()

void ReleaseConstantData ( )
virtual

Reimplemented in ConstantLayer.

Definition at line 278 of file Layer.cpp.

References Layer::OperateOnConstantTensors().

Referenced by TEST_SUITE().

279 {
280  // Now free up the static data.
281  OperateOnConstantTensors([](std::shared_ptr<ConstTensorHandle>& handle)
282  {
283  handle.reset();
284  });
285 }
void OperateOnConstantTensors(Op op)
Definition: Layer.hpp:303

◆ Reparent()

virtual void Reparent ( Graph dest,
std::list< Layer *>::const_iterator  iterator 
)
pure virtual

Referenced by Graph::operator=().

◆ ResetPriority()

void ResetPriority ( ) const

Definition at line 296 of file Layer.cpp.

297 {
298  m_Priority = 0;
299  m_Visiting = false;
300 }

◆ SerializeLayerParameters()

void SerializeLayerParameters ( ParameterStringifyFunction fn) const
virtual

Helper to serialize the layer parameters to string.

(currently used in DotSerializer and company).

Reimplemented in Convolution2dLayer, DepthwiseConvolution2dLayer, Convolution3dLayer, LayerWithParameters< Parameters >, LayerWithParameters< FakeQuantizationDescriptor >, LayerWithParameters< SoftmaxDescriptor >, LayerWithParameters< ReduceDescriptor >, LayerWithParameters< LogSoftmaxDescriptor >, LayerWithParameters< PreCompiledDescriptor >, LayerWithParameters< LstmDescriptor >, LayerWithParameters< ChannelShuffleDescriptor >, LayerWithParameters< BatchToSpaceNdDescriptor >, LayerWithParameters< PermuteDescriptor >, LayerWithParameters< SpaceToBatchNdDescriptor >, LayerWithParameters< DepthToSpaceDescriptor >, LayerWithParameters< ReshapeDescriptor >, LayerWithParameters< ElementwiseUnaryDescriptor >, LayerWithParameters< GatherDescriptor >, LayerWithParameters< SpaceToDepthDescriptor >, LayerWithParameters< OriginsDescriptor >, LayerWithParameters< ViewsDescriptor >, LayerWithParameters< Pooling2dDescriptor >, LayerWithParameters< Convolution2dDescriptor >, LayerWithParameters< ActivationDescriptor >, LayerWithParameters< StandInDescriptor >, LayerWithParameters< TransposeDescriptor >, LayerWithParameters< StackDescriptor >, LayerWithParameters< MeanDescriptor >, LayerWithParameters< ComparisonDescriptor >, LayerWithParameters< InstanceNormalizationDescriptor >, LayerWithParameters< TransposeConvolution2dDescriptor >, LayerWithParameters< BatchNormalizationDescriptor >, LayerWithParameters< ArgMinMaxDescriptor >, LayerWithParameters< LogicalBinaryDescriptor >, LayerWithParameters< DetectionPostProcessDescriptor >, LayerWithParameters< PadDescriptor >, LayerWithParameters< Convolution3dDescriptor >, LayerWithParameters< L2NormalizationDescriptor >, LayerWithParameters< FillDescriptor >, LayerWithParameters< SliceDescriptor >, LayerWithParameters< DepthwiseConvolution2dDescriptor >, LayerWithParameters< QLstmDescriptor >, LayerWithParameters< NormalizationDescriptor >, LayerWithParameters< FullyConnectedDescriptor >, LayerWithParameters< StridedSliceDescriptor >, LayerWithParameters< ResizeDescriptor >, and LayerWithParameters< Pooling3dDescriptor >.

Definition at line 450 of file Layer.cpp.

References armnn::GetLayerTypeAsCString(), and StringifyLayerParameters< LayerParameter >::Serialize().

Referenced by LayerWithParameters< Pooling3dDescriptor >::SerializeLayerParameters().

451 {
452  std::string guid = std::to_string(m_Guid);
453  std::string layerType = GetLayerTypeAsCString(m_Type);
454  std::string backendId = std::string(m_BackendId);
455  if (!(guid.compare("") == 0) && !guid.empty())
456  {
457  fn("Guid", guid);
458  }
459  if(!(m_LayerName.compare("") == 0) && !m_LayerName.empty())
460  {
461  fn("LayerName",m_LayerName);
462  }
463  if(!(layerType.compare("") == 0) && !layerType.empty())
464  {
465  fn("LayerType",layerType);
466  }
467  if(!(backendId.compare("") == 0) && !backendId.empty())
468  {
469  fn("BackendID",backendId);
470  }
471  std::shared_ptr<ActivationDescriptor>
472  activationDescPtr = GetAdditionalInformation<ActivationDescriptor>();
473 
474  if (activationDescPtr)
475  {
476  StringifyLayerParameters<ActivationDescriptor>::Serialize(fn, *activationDescPtr.get());
477  }
478 }
static void Serialize(ParameterStringifyFunction &, const LayerParameter &)
const char * GetLayerTypeAsCString(LayerType type)

◆ SetAdditionalInfo()

void SetAdditionalInfo ( QueueDescriptor descriptor) const
protected

Definition at line 248 of file Layer.cpp.

References QueueDescriptor::m_AdditionalInfoObject, and Layer::m_AdditionalInfoObject.

Referenced by ActivationLayer::CreateWorkload(), ConvertFp32ToFp16Layer::CreateWorkload(), FillLayer::CreateWorkload(), RankLayer::CreateWorkload(), AbsLayer::CreateWorkload(), DebugLayer::CreateWorkload(), MapLayer::CreateWorkload(), SwitchLayer::CreateWorkload(), StackLayer::CreateWorkload(), SplitterLayer::CreateWorkload(), UnmapLayer::CreateWorkload(), MemCopyLayer::CreateWorkload(), SoftmaxLayer::CreateWorkload(), MemImportLayer::CreateWorkload(), ShapeLayer::CreateWorkload(), ConcatLayer::CreateWorkload(), ResizeLayer::CreateWorkload(), DequantizeLayer::CreateWorkload(), ReduceLayer::CreateWorkload(), NormalizationLayer::CreateWorkload(), Pooling2dLayer::CreateWorkload(), Pooling3dLayer::CreateWorkload(), FakeQuantizationLayer::CreateWorkload(), QuantizeLayer::CreateWorkload(), BatchToSpaceNdLayer::CreateWorkload(), ConvertBf16ToFp32Layer::CreateWorkload(), ConvertFp16ToFp32Layer::CreateWorkload(), FloorLayer::CreateWorkload(), RsqrtLayer::CreateWorkload(), AdditionLayer::CreateWorkload(), ConvertFp32ToBf16Layer::CreateWorkload(), SliceLayer::CreateWorkload(), InstanceNormalizationLayer::CreateWorkload(), CastLayer::CreateWorkload(), L2NormalizationLayer::CreateWorkload(), StridedSliceLayer::CreateWorkload(), SpaceToBatchNdLayer::CreateWorkload(), SubtractionLayer::CreateWorkload(), ArgMinMaxLayer::CreateWorkload(), MinimumLayer::CreateWorkload(), TransposeLayer::CreateWorkload(), MaximumLayer::CreateWorkload(), SpaceToDepthLayer::CreateWorkload(), LogSoftmaxLayer::CreateWorkload(), DepthToSpaceLayer::CreateWorkload(), GatherLayer::CreateWorkload(), PadLayer::CreateWorkload(), DivisionLayer::CreateWorkload(), PreluLayer::CreateWorkload(), MeanLayer::CreateWorkload(), MultiplicationLayer::CreateWorkload(), ComparisonLayer::CreateWorkload(), ReshapeLayer::CreateWorkload(), PermuteLayer::CreateWorkload(), ConstantLayer::CreateWorkload(), Convolution3dLayer::CreateWorkload(), ChannelShuffleLayer::CreateWorkload(), DetectionPostProcessLayer::CreateWorkload(), TransposeConvolution2dLayer::CreateWorkload(), DepthwiseConvolution2dLayer::CreateWorkload(), Convolution2dLayer::CreateWorkload(), PreCompiledLayer::CreateWorkload(), FullyConnectedLayer::CreateWorkload(), LstmLayer::CreateWorkload(), UnidirectionalSequenceLstmLayer::CreateWorkload(), BatchNormalizationLayer::CreateWorkload(), QuantizedLstmLayer::CreateWorkload(), and QLstmLayer::CreateWorkload().

249 {
250  descriptor.m_AdditionalInfoObject = m_AdditionalInfoObject.get();
251 }
AdditionalInfoObjectPtr m_AdditionalInfoObject
Definition: Layer.hpp:401

◆ SetAdditionalInfoForObject()

void SetAdditionalInfoForObject ( const AdditionalInfoObjectPtr additionalInfo)
inline

Definition at line 352 of file Layer.hpp.

353  {
354  m_AdditionalInfoObject = additionalInfo;
355  }
AdditionalInfoObjectPtr m_AdditionalInfoObject
Definition: Layer.hpp:401

◆ SetBackendId()

void SetBackendId ( const BackendId id)
inline

Definition at line 275 of file Layer.hpp.

References CreateWorkload().

Referenced by NetworkImpl::AddPrecompiledLayer(), armnn::AttemptBackendAssignment(), armnn::InsertDebugLayerAfter(), and TEST_SUITE().

275 { m_BackendId = id; }

◆ SetGuid()

void SetGuid ( LayerGuid  guid)
inline

Definition at line 326 of file Layer.hpp.

326 { m_Guid = guid; }

◆ SetShapeInferenceMethod()

void SetShapeInferenceMethod ( ShapeInferenceMethod  shapeInferenceMethod)
inline

Definition at line 341 of file Layer.hpp.

342  {
343  m_ShapeInferenceMethod = shapeInferenceMethod;
344  }
ShapeInferenceMethod m_ShapeInferenceMethod
Definition: Layer.hpp:415

◆ ValidateAndCopyShape()

void ValidateAndCopyShape ( const TensorShape outputShape,
const TensorShape inferredShape,
const ShapeInferenceMethod  shapeInferenceMethod,
const std::string &  layerName,
const unsigned int  outputSlotIndex = 0 
)
protected

Definition at line 396 of file Layer.cpp.

References TensorShape::GetDimensionality(), TensorShape::GetDimensionSpecificity(), TensorShape::GetNumDimensions(), Layer::GetOutputSlot(), OutputSlot::GetTensorInfo(), armnn::info, OutputSlot::SetTensorInfo(), armnn::Specified, and armnn::ValidateOnly.

Referenced by ElementwiseBaseLayer::ValidateTensorShapesFromInputs(), RankLayer::ValidateTensorShapesFromInputs(), QuantizeLayer::ValidateTensorShapesFromInputs(), ActivationLayer::ValidateTensorShapesFromInputs(), ReduceLayer::ValidateTensorShapesFromInputs(), ConvertFp32ToFp16Layer::ValidateTensorShapesFromInputs(), StackLayer::ValidateTensorShapesFromInputs(), ConvertBf16ToFp32Layer::ValidateTensorShapesFromInputs(), MemCopyLayer::ValidateTensorShapesFromInputs(), MemImportLayer::ValidateTensorShapesFromInputs(), SoftmaxLayer::ValidateTensorShapesFromInputs(), MergeLayer::ValidateTensorShapesFromInputs(), NormalizationLayer::ValidateTensorShapesFromInputs(), DequantizeLayer::ValidateTensorShapesFromInputs(), ResizeLayer::ValidateTensorShapesFromInputs(), Pooling2dLayer::ValidateTensorShapesFromInputs(), Pooling3dLayer::ValidateTensorShapesFromInputs(), AbsLayer::ValidateTensorShapesFromInputs(), ConvertFp16ToFp32Layer::ValidateTensorShapesFromInputs(), BatchToSpaceNdLayer::ValidateTensorShapesFromInputs(), FakeQuantizationLayer::ValidateTensorShapesFromInputs(), ConvertFp32ToBf16Layer::ValidateTensorShapesFromInputs(), FloorLayer::ValidateTensorShapesFromInputs(), CastLayer::ValidateTensorShapesFromInputs(), RsqrtLayer::ValidateTensorShapesFromInputs(), ShapeLayer::ValidateTensorShapesFromInputs(), SliceLayer::ValidateTensorShapesFromInputs(), InstanceNormalizationLayer::ValidateTensorShapesFromInputs(), L2NormalizationLayer::ValidateTensorShapesFromInputs(), DebugLayer::ValidateTensorShapesFromInputs(), SwitchLayer::ValidateTensorShapesFromInputs(), PadLayer::ValidateTensorShapesFromInputs(), MeanLayer::ValidateTensorShapesFromInputs(), LogSoftmaxLayer::ValidateTensorShapesFromInputs(), TransposeLayer::ValidateTensorShapesFromInputs(), ChannelShuffleLayer::ValidateTensorShapesFromInputs(), ReshapeLayer::ValidateTensorShapesFromInputs(), PermuteLayer::ValidateTensorShapesFromInputs(), Convolution3dLayer::ValidateTensorShapesFromInputs(), StridedSliceLayer::ValidateTensorShapesFromInputs(), GatherLayer::ValidateTensorShapesFromInputs(), DetectionPostProcessLayer::ValidateTensorShapesFromInputs(), ElementwiseUnaryLayer::ValidateTensorShapesFromInputs(), ArgMinMaxLayer::ValidateTensorShapesFromInputs(), PreluLayer::ValidateTensorShapesFromInputs(), DepthToSpaceLayer::ValidateTensorShapesFromInputs(), SpaceToDepthLayer::ValidateTensorShapesFromInputs(), TransposeConvolution2dLayer::ValidateTensorShapesFromInputs(), SpaceToBatchNdLayer::ValidateTensorShapesFromInputs(), DepthwiseConvolution2dLayer::ValidateTensorShapesFromInputs(), LogicalBinaryLayer::ValidateTensorShapesFromInputs(), ComparisonLayer::ValidateTensorShapesFromInputs(), Convolution2dLayer::ValidateTensorShapesFromInputs(), SplitterLayer::ValidateTensorShapesFromInputs(), FullyConnectedLayer::ValidateTensorShapesFromInputs(), LstmLayer::ValidateTensorShapesFromInputs(), UnidirectionalSequenceLstmLayer::ValidateTensorShapesFromInputs(), BatchNormalizationLayer::ValidateTensorShapesFromInputs(), QuantizedLstmLayer::ValidateTensorShapesFromInputs(), and QLstmLayer::ValidateTensorShapesFromInputs().

401 {
402  if (shapeInferenceMethod == ShapeInferenceMethod::ValidateOnly)
403  {
404  ConditionalThrowIfNotEqual<LayerValidationException>(
405  layerName + ": TensorShape set on OutputSlot[0] does not match the inferred shape.",
406  outputShape,
407  inferredShape);
408  return;
409  }
410 
411  if (outputShape.GetDimensionality() == Dimensionality::Specified)
412  {
413  for (unsigned int i = 0; i < outputShape.GetNumDimensions(); ++i)
414  {
415  if (outputShape.GetDimensionSpecificity(i) && outputShape[i] != inferredShape[i])
416  {
417  std::stringstream ss;
418  ss << layerName << ": TensorShape set on OutputSlot[" << outputSlotIndex <<
419  "] does not match the inferred shape at dimension index [";
420  ss << i << "] " << outputShape << " != " << inferredShape;
421  throw LayerValidationException(ss.str());
422  }
423  }
424  }
425 
426  TensorInfo info = GetOutputSlot(outputSlotIndex).GetTensorInfo();
427 
428  armnn::TensorInfo inferredTensorInfo(inferredShape,
429  info.GetDataType(),
430  info.GetQuantizationScale(),
431  info.GetQuantizationOffset());
432 
433  GetOutputSlot(outputSlotIndex).SetTensorInfo(inferredTensorInfo);
434 }
Validate all output shapes.
void SetTensorInfo(const TensorInfo &tensorInfo) override
Definition: Layer.cpp:61
const OutputSlot & GetOutputSlot(unsigned int index=0) const override
Get the const output slot handle by slot index.
Definition: Layer.hpp:323
const TensorInfo & GetTensorInfo() const override
Definition: Layer.cpp:66

◆ ValidateTensorShapesFromInputs()

◆ VerifyLayerConnections()

void VerifyLayerConnections ( unsigned int  expectedConnections,
const CheckLocation location 
) const

Definition at line 352 of file Layer.cpp.

References ARMNN_ASSERT, CheckLocation::AsString(), Layer::GetInputSlot(), armnn::GetLayerTypeAsCString(), Layer::GetNameStr(), Layer::GetNumInputSlots(), and Layer::GetType().

Referenced by ElementwiseBaseLayer::ValidateTensorShapesFromInputs(), RankLayer::ValidateTensorShapesFromInputs(), QuantizeLayer::ValidateTensorShapesFromInputs(), ActivationLayer::ValidateTensorShapesFromInputs(), ReduceLayer::ValidateTensorShapesFromInputs(), ConvertFp32ToFp16Layer::ValidateTensorShapesFromInputs(), FillLayer::ValidateTensorShapesFromInputs(), DebugLayer::ValidateTensorShapesFromInputs(), MapLayer::ValidateTensorShapesFromInputs(), MemCopyLayer::ValidateTensorShapesFromInputs(), SoftmaxLayer::ValidateTensorShapesFromInputs(), MemImportLayer::ValidateTensorShapesFromInputs(), ShapeLayer::ValidateTensorShapesFromInputs(), DequantizeLayer::ValidateTensorShapesFromInputs(), MergeLayer::ValidateTensorShapesFromInputs(), NormalizationLayer::ValidateTensorShapesFromInputs(), AbsLayer::ValidateTensorShapesFromInputs(), BatchToSpaceNdLayer::ValidateTensorShapesFromInputs(), Pooling2dLayer::ValidateTensorShapesFromInputs(), Pooling3dLayer::ValidateTensorShapesFromInputs(), ConvertBf16ToFp32Layer::ValidateTensorShapesFromInputs(), ConvertFp16ToFp32Layer::ValidateTensorShapesFromInputs(), FakeQuantizationLayer::ValidateTensorShapesFromInputs(), CastLayer::ValidateTensorShapesFromInputs(), ResizeLayer::ValidateTensorShapesFromInputs(), FloorLayer::ValidateTensorShapesFromInputs(), RsqrtLayer::ValidateTensorShapesFromInputs(), ConvertFp32ToBf16Layer::ValidateTensorShapesFromInputs(), SliceLayer::ValidateTensorShapesFromInputs(), InstanceNormalizationLayer::ValidateTensorShapesFromInputs(), L2NormalizationLayer::ValidateTensorShapesFromInputs(), StackLayer::ValidateTensorShapesFromInputs(), SwitchLayer::ValidateTensorShapesFromInputs(), UnmapLayer::ValidateTensorShapesFromInputs(), MeanLayer::ValidateTensorShapesFromInputs(), PadLayer::ValidateTensorShapesFromInputs(), LogSoftmaxLayer::ValidateTensorShapesFromInputs(), ChannelShuffleLayer::ValidateTensorShapesFromInputs(), TransposeLayer::ValidateTensorShapesFromInputs(), PermuteLayer::ValidateTensorShapesFromInputs(), ReshapeLayer::ValidateTensorShapesFromInputs(), Convolution3dLayer::ValidateTensorShapesFromInputs(), GatherLayer::ValidateTensorShapesFromInputs(), StridedSliceLayer::ValidateTensorShapesFromInputs(), DetectionPostProcessLayer::ValidateTensorShapesFromInputs(), ArgMinMaxLayer::ValidateTensorShapesFromInputs(), ElementwiseUnaryLayer::ValidateTensorShapesFromInputs(), SpaceToDepthLayer::ValidateTensorShapesFromInputs(), SpaceToBatchNdLayer::ValidateTensorShapesFromInputs(), DepthToSpaceLayer::ValidateTensorShapesFromInputs(), PreluLayer::ValidateTensorShapesFromInputs(), LogicalBinaryLayer::ValidateTensorShapesFromInputs(), TransposeConvolution2dLayer::ValidateTensorShapesFromInputs(), DepthwiseConvolution2dLayer::ValidateTensorShapesFromInputs(), ComparisonLayer::ValidateTensorShapesFromInputs(), Convolution2dLayer::ValidateTensorShapesFromInputs(), ConcatLayer::ValidateTensorShapesFromInputs(), UnidirectionalSequenceLstmLayer::ValidateTensorShapesFromInputs(), LstmLayer::ValidateTensorShapesFromInputs(), BatchNormalizationLayer::ValidateTensorShapesFromInputs(), QuantizedLstmLayer::ValidateTensorShapesFromInputs(), and QLstmLayer::ValidateTensorShapesFromInputs().

353 {
354  ARMNN_ASSERT(GetNumInputSlots() == expectedConnections);
355 
356  for (unsigned int i=0; i<expectedConnections; ++i)
357  {
358  if (GetInputSlot(i).GetConnection() == nullptr)
359  {
360  throw LayerValidationException(
361  fmt::format("Input connection #{0} must be connected "
362  "for {1} layer {2} {3}",
363  i,
365  GetNameStr(),
366  location.AsString()));
367  }
368  }
369 }
unsigned int GetNumInputSlots() const override
Returns the number of connectable input slots.
Definition: Layer.hpp:318
const InputSlot & GetInputSlot(unsigned int index) const override
Get a const input slot handle by slot index.
Definition: Layer.hpp:321
const std::string & GetNameStr() const
Definition: Layer.hpp:225
LayerType GetType() const override
Returns the armnn::LayerType of this layer.
Definition: Layer.hpp:270
#define ARMNN_ASSERT(COND)
Definition: Assert.hpp:14
const char * GetLayerTypeAsCString(LayerType type)

◆ VerifyShapeInferenceType()

void VerifyShapeInferenceType ( const TensorShape outputShape,
ShapeInferenceMethod  shapeInferenceMethod 
)
protected

Definition at line 436 of file Layer.cpp.

References TensorShape::AreAllDimensionsSpecified(), TensorShape::GetDimensionality(), armnn::NotSpecified, and armnn::ValidateOnly.

Referenced by ElementwiseBaseLayer::ValidateTensorShapesFromInputs(), RankLayer::ValidateTensorShapesFromInputs(), QuantizeLayer::ValidateTensorShapesFromInputs(), ActivationLayer::ValidateTensorShapesFromInputs(), ReduceLayer::ValidateTensorShapesFromInputs(), ConvertFp32ToFp16Layer::ValidateTensorShapesFromInputs(), FillLayer::ValidateTensorShapesFromInputs(), DebugLayer::ValidateTensorShapesFromInputs(), MemCopyLayer::ValidateTensorShapesFromInputs(), MemImportLayer::ValidateTensorShapesFromInputs(), SoftmaxLayer::ValidateTensorShapesFromInputs(), DequantizeLayer::ValidateTensorShapesFromInputs(), ShapeLayer::ValidateTensorShapesFromInputs(), MergeLayer::ValidateTensorShapesFromInputs(), NormalizationLayer::ValidateTensorShapesFromInputs(), BatchToSpaceNdLayer::ValidateTensorShapesFromInputs(), AbsLayer::ValidateTensorShapesFromInputs(), Pooling2dLayer::ValidateTensorShapesFromInputs(), Pooling3dLayer::ValidateTensorShapesFromInputs(), ConvertBf16ToFp32Layer::ValidateTensorShapesFromInputs(), ConvertFp16ToFp32Layer::ValidateTensorShapesFromInputs(), FakeQuantizationLayer::ValidateTensorShapesFromInputs(), CastLayer::ValidateTensorShapesFromInputs(), ResizeLayer::ValidateTensorShapesFromInputs(), FloorLayer::ValidateTensorShapesFromInputs(), RsqrtLayer::ValidateTensorShapesFromInputs(), ConvertFp32ToBf16Layer::ValidateTensorShapesFromInputs(), SliceLayer::ValidateTensorShapesFromInputs(), InstanceNormalizationLayer::ValidateTensorShapesFromInputs(), L2NormalizationLayer::ValidateTensorShapesFromInputs(), StackLayer::ValidateTensorShapesFromInputs(), SwitchLayer::ValidateTensorShapesFromInputs(), ChannelShuffleLayer::ValidateTensorShapesFromInputs(), MeanLayer::ValidateTensorShapesFromInputs(), PadLayer::ValidateTensorShapesFromInputs(), LogSoftmaxLayer::ValidateTensorShapesFromInputs(), TransposeLayer::ValidateTensorShapesFromInputs(), PermuteLayer::ValidateTensorShapesFromInputs(), ReshapeLayer::ValidateTensorShapesFromInputs(), Convolution3dLayer::ValidateTensorShapesFromInputs(), StridedSliceLayer::ValidateTensorShapesFromInputs(), DetectionPostProcessLayer::ValidateTensorShapesFromInputs(), ArgMinMaxLayer::ValidateTensorShapesFromInputs(), ElementwiseUnaryLayer::ValidateTensorShapesFromInputs(), GatherLayer::ValidateTensorShapesFromInputs(), PreluLayer::ValidateTensorShapesFromInputs(), ComparisonLayer::ValidateTensorShapesFromInputs(), DepthToSpaceLayer::ValidateTensorShapesFromInputs(), SpaceToBatchNdLayer::ValidateTensorShapesFromInputs(), LogicalBinaryLayer::ValidateTensorShapesFromInputs(), TransposeConvolution2dLayer::ValidateTensorShapesFromInputs(), SpaceToDepthLayer::ValidateTensorShapesFromInputs(), DepthwiseConvolution2dLayer::ValidateTensorShapesFromInputs(), Convolution2dLayer::ValidateTensorShapesFromInputs(), SplitterLayer::ValidateTensorShapesFromInputs(), FullyConnectedLayer::ValidateTensorShapesFromInputs(), LstmLayer::ValidateTensorShapesFromInputs(), ConcatLayer::ValidateTensorShapesFromInputs(), UnidirectionalSequenceLstmLayer::ValidateTensorShapesFromInputs(), BatchNormalizationLayer::ValidateTensorShapesFromInputs(), QuantizedLstmLayer::ValidateTensorShapesFromInputs(), and QLstmLayer::ValidateTensorShapesFromInputs().

437 {
438  if (shapeInferenceMethod == ShapeInferenceMethod::ValidateOnly)
439  {
440  ConditionalThrow<LayerValidationException>(
441  outputShape.GetDimensionality() != Dimensionality::NotSpecified,
442  "Dimensionality can not be NotSpecified while using ShapeInferenceMethod::ValidateOnly");
443 
444  ConditionalThrow<LayerValidationException>(
445  outputShape.AreAllDimensionsSpecified(),
446  "Unspecified dimension while using ShapeInferenceMethod::ValidateOnly");
447  }
448 }
Validate all output shapes.

Friends And Related Function Documentation

◆ Graph

friend class Graph
friend

Definition at line 361 of file Layer.hpp.

Member Data Documentation

◆ m_AdditionalInfoObject

AdditionalInfoObjectPtr m_AdditionalInfoObject
protected

Definition at line 401 of file Layer.hpp.

Referenced by Layer::SetAdditionalInfo().

◆ m_OutputHandlers

std::vector<OutputHandler> m_OutputHandlers
protected

◆ m_ShapeInferenceMethod

ShapeInferenceMethod m_ShapeInferenceMethod
protected

Definition at line 415 of file Layer.hpp.

Referenced by Layer::CloneBase(), ElementwiseBaseLayer::InferOutputShapes(), ElementwiseBaseLayer::ValidateTensorShapesFromInputs(), RankLayer::ValidateTensorShapesFromInputs(), QuantizeLayer::ValidateTensorShapesFromInputs(), ActivationLayer::ValidateTensorShapesFromInputs(), FillLayer::ValidateTensorShapesFromInputs(), ReduceLayer::ValidateTensorShapesFromInputs(), ConvertFp32ToFp16Layer::ValidateTensorShapesFromInputs(), DebugLayer::ValidateTensorShapesFromInputs(), SoftmaxLayer::ValidateTensorShapesFromInputs(), DequantizeLayer::ValidateTensorShapesFromInputs(), ShapeLayer::ValidateTensorShapesFromInputs(), RsqrtLayer::ValidateTensorShapesFromInputs(), MemCopyLayer::ValidateTensorShapesFromInputs(), MemImportLayer::ValidateTensorShapesFromInputs(), MergeLayer::ValidateTensorShapesFromInputs(), NormalizationLayer::ValidateTensorShapesFromInputs(), BatchToSpaceNdLayer::ValidateTensorShapesFromInputs(), ConvertBf16ToFp32Layer::ValidateTensorShapesFromInputs(), Pooling2dLayer::ValidateTensorShapesFromInputs(), Pooling3dLayer::ValidateTensorShapesFromInputs(), ConvertFp16ToFp32Layer::ValidateTensorShapesFromInputs(), AbsLayer::ValidateTensorShapesFromInputs(), CastLayer::ValidateTensorShapesFromInputs(), FakeQuantizationLayer::ValidateTensorShapesFromInputs(), ResizeLayer::ValidateTensorShapesFromInputs(), ConvertFp32ToBf16Layer::ValidateTensorShapesFromInputs(), FloorLayer::ValidateTensorShapesFromInputs(), SliceLayer::ValidateTensorShapesFromInputs(), StackLayer::ValidateTensorShapesFromInputs(), InstanceNormalizationLayer::ValidateTensorShapesFromInputs(), SwitchLayer::ValidateTensorShapesFromInputs(), L2NormalizationLayer::ValidateTensorShapesFromInputs(), LogSoftmaxLayer::ValidateTensorShapesFromInputs(), MeanLayer::ValidateTensorShapesFromInputs(), PadLayer::ValidateTensorShapesFromInputs(), TransposeLayer::ValidateTensorShapesFromInputs(), ChannelShuffleLayer::ValidateTensorShapesFromInputs(), PermuteLayer::ValidateTensorShapesFromInputs(), ReshapeLayer::ValidateTensorShapesFromInputs(), Convolution3dLayer::ValidateTensorShapesFromInputs(), ElementwiseUnaryLayer::ValidateTensorShapesFromInputs(), StridedSliceLayer::ValidateTensorShapesFromInputs(), GatherLayer::ValidateTensorShapesFromInputs(), DetectionPostProcessLayer::ValidateTensorShapesFromInputs(), ArgMinMaxLayer::ValidateTensorShapesFromInputs(), ComparisonLayer::ValidateTensorShapesFromInputs(), DepthToSpaceLayer::ValidateTensorShapesFromInputs(), SpaceToDepthLayer::ValidateTensorShapesFromInputs(), TransposeConvolution2dLayer::ValidateTensorShapesFromInputs(), SpaceToBatchNdLayer::ValidateTensorShapesFromInputs(), PreluLayer::ValidateTensorShapesFromInputs(), DepthwiseConvolution2dLayer::ValidateTensorShapesFromInputs(), LogicalBinaryLayer::ValidateTensorShapesFromInputs(), Convolution2dLayer::ValidateTensorShapesFromInputs(), SplitterLayer::ValidateTensorShapesFromInputs(), FullyConnectedLayer::ValidateTensorShapesFromInputs(), ConcatLayer::ValidateTensorShapesFromInputs(), UnidirectionalSequenceLstmLayer::ValidateTensorShapesFromInputs(), LstmLayer::ValidateTensorShapesFromInputs(), BatchNormalizationLayer::ValidateTensorShapesFromInputs(), QuantizedLstmLayer::ValidateTensorShapesFromInputs(), and QLstmLayer::ValidateTensorShapesFromInputs().


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