ArmNN
 22.05.01
Layer Class Referenceabstract

#include <Layer.hpp>

Inheritance diagram for Layer:
IConnectableLayer AbsLayer BindableLayer CastLayer ConstantLayer ConvertBf16ToFp32Layer ConvertFp16ToFp32Layer ConvertFp32ToBf16Layer ConvertFp32ToFp16Layer DebugLayer DequantizeLayer ElementwiseBaseLayer FloorLayer GatherNdLayer 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
 
bool GetAllowExpandedDims () 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)
 
void SetAllowExpandedDims (bool allowExpandedDims)
 
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 247 of file Layer.cpp.

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

251 : Layer(numInputSlots, numOutputSlots, type, DataLayout::NCHW, name)
252 {
253 }
Layer(unsigned int numInputSlots, unsigned int numOutputSlots, LayerType type, const char *name)
Definition: Layer.cpp:247

◆ Layer() [2/2]

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

Definition at line 220 of file Layer.cpp.

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

225 : m_OutputHandlers(numOutputSlots)
227 , m_LayerName(name ? name : "")
228 , m_Type(type)
229 , m_BackendId()
230 , m_BackendHint(EmptyOptional())
231 , m_Guid(arm::pipe::IProfilingService::GetNextGuid())
232 {
233  IgnoreUnused(layout);
234  m_InputSlots.reserve(numInputSlots);
235  for (unsigned int i = 0; i < numInputSlots; ++i)
236  {
237  m_InputSlots.emplace_back(*this, i);
238  }
239 
240  m_OutputSlots.reserve(numOutputSlots);
241  for (unsigned int i = 0; i < numOutputSlots; ++i)
242  {
243  m_OutputSlots.emplace_back(*this, m_OutputHandlers[i]);
244  }
245 }
void IgnoreUnused(Ts &&...)
Validate all output shapes.
std::vector< OutputHandler > m_OutputHandlers
Definition: Layer.hpp:420
ShapeInferenceMethod m_ShapeInferenceMethod
Definition: Layer.hpp:421

◆ ~Layer()

virtual ~Layer ( )
protectedvirtualdefault

Member Function Documentation

◆ AddRelatedLayerName()

void AddRelatedLayerName ( const std::string  layerName)
inline

Definition at line 330 of file Layer.hpp.

330 { 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 336 of file Layer.hpp.

Referenced by TEST_SUITE().

337  {
338  m_BackendHint = backend;
339  }

◆ 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  layer->SetAllowExpandedDims(m_AllowExpandedDims);
23 
24  return layer;
25 }
Optional< BackendId > GetBackendHint() const
Definition: Layer.hpp:340
const BackendId & GetBackendId() const
Definition: Layer.hpp:275
ShapeInferenceMethod m_ShapeInferenceMethod
Definition: Layer.hpp:421
LayerType
When adding a new layer, adapt also the LastLayer enum value in the enum class LayerType below...
Definition: Types.hpp:467
LayerGuid GetGuid() const final
Returns the unique id of the layer.
Definition: Layer.hpp:328

◆ CollectQueueDescriptorInputs()

void CollectQueueDescriptorInputs ( QueueDescriptor descriptor,
WorkloadInfo info 
) const
inlineprotected

Definition at line 371 of file Layer.hpp.

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

372  {
373  WorkloadDataCollector dataCollector(descriptor.m_Inputs, info.m_InputTensorInfos);
374  CollectWorkloadInputs(dataCollector);
375  }

◆ CollectQueueDescriptorOutputs()

void CollectQueueDescriptorOutputs ( QueueDescriptor descriptor,
WorkloadInfo info 
) const
inlineprotected

Definition at line 378 of file Layer.hpp.

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

379  {
380  WorkloadDataCollector dataCollector(descriptor.m_Outputs, info.m_OutputTensorInfos);
381  CollectWorkloadOutputs(dataCollector);
382  }

◆ CreateTensorHandles()

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

Reimplemented in ConcatLayer, OutputLayer, and SplitterLayer.

Definition at line 279 of file Layer.cpp.

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

282 {
283  for (unsigned int idx=0; idx < GetNumOutputSlots(); idx++)
284  {
285 
286  OutputSlot& slot = GetOutputSlot(idx);
287  ITensorHandleFactory::FactoryId factoryId = slot.GetTensorHandleFactoryId();
288 
289  OutputHandler& handler = GetOutputHandler(idx);
290  if (factoryId == ITensorHandleFactory::LegacyFactoryId)
291  {
292  handler.CreateTensorHandles(workloadFactory, IsMemoryManaged);
293  }
294  else
295  {
296  ITensorHandleFactory* handleFactory;
297  handleFactory = registry.GetFactory(factoryId);
298  ARMNN_ASSERT(handleFactory);
299  handler.CreateTensorHandles(*handleFactory, IsMemoryManaged);
300  }
301  }
302 }
unsigned int GetNumOutputSlots() const override
Returns the number of connectable output slots.
Definition: Layer.hpp:320
#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:324
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 >, 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 >, UnidirectionalSequenceLstmLayer, Convolution2dLayer, LstmLayer, DepthwiseConvolution2dLayer, FullyConnectedLayer, TransposeConvolution2dLayer, BatchNormalizationLayer, ConstantLayer, Convolution3dLayer, ShapeLayer, DetectionPostProcessLayer, PreCompiledLayer, FakeQuantizationLayer, MemCopyLayer, MemImportLayer, ElementwiseBaseLayer, and RankLayer.

Definition at line 536 of file Layer.cpp.

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

537 {
538  strategy.ExecuteStrategy(this, BaseDescriptor(), {}, GetName());
539 }
const char * GetName() const override
Returns the name of the layer.
Definition: Layer.hpp:317

◆ GetAdditionalInformation()

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

Definition at line 353 of file Layer.hpp.

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

354  {
355  return std::static_pointer_cast<T>(m_AdditionalInfoObject);
356  }
AdditionalInfoObjectPtr m_AdditionalInfoObject
Definition: Layer.hpp:407

◆ GetAllowExpandedDims()

bool GetAllowExpandedDims ( ) const
inline

Definition at line 241 of file Layer.hpp.

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

241 { return m_AllowExpandedDims; };

◆ GetBackendHint()

Optional<BackendId> GetBackendHint ( ) const
inline

Definition at line 340 of file Layer.hpp.

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

340 { return m_BackendHint; }

◆ GetBackendId()

◆ GetConstantTensorsByRef()

virtual ConstantTensors GetConstantTensorsByRef ( )
inlineoverrideprotectedvirtual

◆ GetDataType()

DataType GetDataType ( ) const

Definition at line 313 of file Layer.cpp.

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

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

314 {
315  if (GetNumInputSlots() > 0) // Ignore the input layer.
316  {
318  }
320 }
unsigned int GetNumInputSlots() const override
Returns the number of connectable input slots.
Definition: Layer.hpp:319
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:322
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:324
virtual const TensorInfo & GetTensorInfo() const =0
const TensorInfo & GetTensorInfo() const override
Definition: Layer.cpp:92

◆ GetGuid()

LayerGuid GetGuid ( ) const
inlinefinalvirtual

Returns the unique id of the layer.

Implements IConnectableLayer.

Definition at line 328 of file Layer.hpp.

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

328 { 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 322 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(), ConvertConstDequantisationLayersToConstLayersImpl::Run(), TransposeAsReshapeImpl::Run(), PermuteAsReshapeImpl::Run(), OptimizeConsecutiveReshapesImpl::Run(), OptimizeInverseConversionsImpl::Run(), PermuteAndBatchToSpaceAsDepthToSpaceImpl< PermuteType >::Run(), PermuteDepthwiseConv2dWeightsImpl::Run(), OptimizeInversePermutesImpl< PermuteType >::Run(), MovePermuteUpImpl::Run(), MoveTransposeUpImpl::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(), ConvertBf16ToFp32Layer::ValidateTensorShapesFromInputs(), FakeQuantizationLayer::ValidateTensorShapesFromInputs(), StackLayer::ValidateTensorShapesFromInputs(), ConvertFp16ToFp32Layer::ValidateTensorShapesFromInputs(), FloorLayer::ValidateTensorShapesFromInputs(), MemCopyLayer::ValidateTensorShapesFromInputs(), MemImportLayer::ValidateTensorShapesFromInputs(), L2NormalizationLayer::ValidateTensorShapesFromInputs(), BatchToSpaceNdLayer::ValidateTensorShapesFromInputs(), ConvertFp32ToBf16Layer::ValidateTensorShapesFromInputs(), InstanceNormalizationLayer::ValidateTensorShapesFromInputs(), SwitchLayer::ValidateTensorShapesFromInputs(), MergeLayer::ValidateTensorShapesFromInputs(), CastLayer::ValidateTensorShapesFromInputs(), AbsLayer::ValidateTensorShapesFromInputs(), DebugLayer::ValidateTensorShapesFromInputs(), Pooling2dLayer::ValidateTensorShapesFromInputs(), NormalizationLayer::ValidateTensorShapesFromInputs(), Pooling3dLayer::ValidateTensorShapesFromInputs(), SoftmaxLayer::ValidateTensorShapesFromInputs(), DequantizeLayer::ValidateTensorShapesFromInputs(), ResizeLayer::ValidateTensorShapesFromInputs(), RsqrtLayer::ValidateTensorShapesFromInputs(), ShapeLayer::ValidateTensorShapesFromInputs(), SliceLayer::ValidateTensorShapesFromInputs(), TransposeLayer::ValidateTensorShapesFromInputs(), MeanLayer::ValidateTensorShapesFromInputs(), LogSoftmaxLayer::ValidateTensorShapesFromInputs(), PadLayer::ValidateTensorShapesFromInputs(), ChannelShuffleLayer::ValidateTensorShapesFromInputs(), ReshapeLayer::ValidateTensorShapesFromInputs(), PermuteLayer::ValidateTensorShapesFromInputs(), Convolution3dLayer::ValidateTensorShapesFromInputs(), GatherNdLayer::ValidateTensorShapesFromInputs(), ArgMinMaxLayer::ValidateTensorShapesFromInputs(), GatherLayer::ValidateTensorShapesFromInputs(), StridedSliceLayer::ValidateTensorShapesFromInputs(), ElementwiseUnaryLayer::ValidateTensorShapesFromInputs(), DepthToSpaceLayer::ValidateTensorShapesFromInputs(), SpaceToDepthLayer::ValidateTensorShapesFromInputs(), LogicalBinaryLayer::ValidateTensorShapesFromInputs(), TransposeConvolution2dLayer::ValidateTensorShapesFromInputs(), SpaceToBatchNdLayer::ValidateTensorShapesFromInputs(), ComparisonLayer::ValidateTensorShapesFromInputs(), PreluLayer::ValidateTensorShapesFromInputs(), FullyConnectedLayer::ValidateTensorShapesFromInputs(), DepthwiseConvolution2dLayer::ValidateTensorShapesFromInputs(), Convolution2dLayer::ValidateTensorShapesFromInputs(), ConcatLayer::ValidateTensorShapesFromInputs(), UnidirectionalSequenceLstmLayer::ValidateTensorShapesFromInputs(), LstmLayer::ValidateTensorShapesFromInputs(), BatchNormalizationLayer::ValidateTensorShapesFromInputs(), OutputLayer::ValidateTensorShapesFromInputs(), QuantizedLstmLayer::ValidateTensorShapesFromInputs(), QLstmLayer::ValidateTensorShapesFromInputs(), and Layer::VerifyLayerConnections().

322 { 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 323 of file Layer.hpp.

323 { return m_InputSlots.at(index); }

◆ GetInputSlots()

◆ GetName()

const char* GetName ( ) const
inlineoverridevirtual

Returns the name of the layer.

Implements IConnectableLayer.

Definition at line 317 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(), InstanceNormalizationLayer::Accept(), L2NormalizationLayer::Accept(), InputLayer::Accept(), SwitchLayer::Accept(), DequantizeLayer::Accept(), NormalizationLayer::Accept(), AbsLayer::Accept(), FloorLayer::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(), GatherLayer::Accept(), ResizeLayer::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(), SplitterLayer::Accept(), DepthwiseConvolution2dLayer::Accept(), FullyConnectedLayer::Accept(), LstmLayer::Accept(), ConcatLayer::Accept(), Convolution2dLayer::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(), SoftmaxLayer::Clone(), L2NormalizationLayer::Clone(), CastLayer::Clone(), StackLayer::Clone(), StridedSliceLayer::Clone(), DebugLayer::Clone(), SwitchLayer::Clone(), MapLayer::Clone(), UnmapLayer::Clone(), DequantizeLayer::Clone(), MemCopyLayer::Clone(), MemImportLayer::Clone(), MergeLayer::Clone(), AbsLayer::Clone(), NormalizationLayer::Clone(), InputLayer::Clone(), AdditionLayer::Clone(), Pooling2dLayer::Clone(), Pooling3dLayer::Clone(), ConvertFp32ToBf16Layer::Clone(), ConvertBf16ToFp32Layer::Clone(), FakeQuantizationLayer::Clone(), ConvertFp16ToFp32Layer::Clone(), FloorLayer::Clone(), SliceLayer::Clone(), ReduceLayer::Clone(), ResizeLayer::Clone(), RsqrtLayer::Clone(), GatherNdLayer::Clone(), ShapeLayer::Clone(), BatchToSpaceNdLayer::Clone(), SpaceToBatchNdLayer::Clone(), SpaceToDepthLayer::Clone(), StandInLayer::Clone(), PreluLayer::Clone(), LogicalBinaryLayer::Clone(), GatherLayer::Clone(), DepthToSpaceLayer::Clone(), TransposeLayer::Clone(), MaximumLayer::Clone(), ComparisonLayer::Clone(), MeanLayer::Clone(), ArgMinMaxLayer::Clone(), DivisionLayer::Clone(), MinimumLayer::Clone(), MultiplicationLayer::Clone(), LogSoftmaxLayer::Clone(), PadLayer::Clone(), ElementwiseUnaryLayer::Clone(), SubtractionLayer::Clone(), ReshapeLayer::Clone(), ConstantLayer::Clone(), PermuteLayer::Clone(), Convolution3dLayer::Clone(), PreCompiledLayer::Clone(), DetectionPostProcessLayer::Clone(), TransposeConvolution2dLayer::Clone(), SplitterLayer::Clone(), FullyConnectedLayer::Clone(), DepthwiseConvolution2dLayer::Clone(), LstmLayer::Clone(), ConcatLayer::Clone(), UnidirectionalSequenceLstmLayer::Clone(), Convolution2dLayer::Clone(), BatchNormalizationLayer::Clone(), OutputLayer::Clone(), QuantizedLstmLayer::Clone(), QLstmLayer::Clone(), RankLayer::ExecuteStrategy(), ElementwiseBaseLayer::ExecuteStrategy(), DetectionPostProcessLayer::ExecuteStrategy(), ShapeLayer::ExecuteStrategy(), Convolution3dLayer::ExecuteStrategy(), BatchNormalizationLayer::ExecuteStrategy(), ConstantLayer::ExecuteStrategy(), TransposeConvolution2dLayer::ExecuteStrategy(), DepthwiseConvolution2dLayer::ExecuteStrategy(), FullyConnectedLayer::ExecuteStrategy(), LstmLayer::ExecuteStrategy(), Convolution2dLayer::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(), armnn::IsLayerOptimizable(), NeonBackend::OptimizeSubgraphView(), ClBackend::OptimizeSubgraphView(), PermuteAsReshapeImpl::Run(), TransposeAsReshapeImpl::Run(), OptimizeConsecutiveReshapesImpl::Run(), PermuteAndBatchToSpaceAsDepthToSpaceImpl< PermuteType >::Run(), FuseBatchNorm< ConvLayer, ArmnnType, T >::Run(), TEST_SUITE(), and ErasedLayerNamesObservable::Update().

317 { 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:247
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.

Definition at line 324 of file Layer.hpp.

Referenced by Graph::AddCompatibilityLayers(), NetworkImpl::AddConvolution2dLayer(), NetworkImpl::AddDepthwiseConvolution2dLayer(), NetworkImpl::AddFullyConnectedLayer(), armnn::AttemptBackendAssignment(), OutputSlot::CalculateIndexOnOwner(), armnn::ChainReduceLayers(), armnn::CheckScaleSetOnQuantizedType(), SplitterLayer::CreateTensorHandles(), ConcatLayer::CreateTensorHandles(), Layer::CreateTensorHandles(), 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(), ConvertConstDequantisationLayersToConstLayersImpl::Run(), PermuteAsReshapeImpl::Run(), TransposeAsReshapeImpl::Run(), OptimizeConsecutiveReshapesImpl::Run(), ConvertConstPermuteLayersToConstLayers::Run(), PermuteAndBatchToSpaceAsDepthToSpaceImpl< PermuteType >::Run(), OptimizeInverseConversionsImpl::Run(), MovePermuteUpImpl::Run(), MoveTransposeUpImpl::Run(), OptimizeInversePermutesImpl< PermuteType >::Run(), PermuteDepthwiseConv2dWeightsImpl::Run(), FuseBatchNorm< ConvLayer, ArmnnType, T >::Run(), AddBroadcastReshapeLayerImpl::Run(), armnn::SelectTensorHandleStrategy(), TEST_SUITE(), Layer::ValidateAndCopyShape(), ElementwiseBaseLayer::ValidateTensorShapesFromInputs(), RankLayer::ValidateTensorShapesFromInputs(), QuantizeLayer::ValidateTensorShapesFromInputs(), ActivationLayer::ValidateTensorShapesFromInputs(), FillLayer::ValidateTensorShapesFromInputs(), ConvertFp32ToFp16Layer::ValidateTensorShapesFromInputs(), ReduceLayer::ValidateTensorShapesFromInputs(), FakeQuantizationLayer::ValidateTensorShapesFromInputs(), MemImportLayer::ValidateTensorShapesFromInputs(), NormalizationLayer::ValidateTensorShapesFromInputs(), FloorLayer::ValidateTensorShapesFromInputs(), StackLayer::ValidateTensorShapesFromInputs(), SwitchLayer::ValidateTensorShapesFromInputs(), ConvertBf16ToFp32Layer::ValidateTensorShapesFromInputs(), Pooling2dLayer::ValidateTensorShapesFromInputs(), InstanceNormalizationLayer::ValidateTensorShapesFromInputs(), DebugLayer::ValidateTensorShapesFromInputs(), ShapeLayer::ValidateTensorShapesFromInputs(), ConvertFp32ToBf16Layer::ValidateTensorShapesFromInputs(), ConvertFp16ToFp32Layer::ValidateTensorShapesFromInputs(), MemCopyLayer::ValidateTensorShapesFromInputs(), BatchToSpaceNdLayer::ValidateTensorShapesFromInputs(), MergeLayer::ValidateTensorShapesFromInputs(), L2NormalizationLayer::ValidateTensorShapesFromInputs(), CastLayer::ValidateTensorShapesFromInputs(), Pooling3dLayer::ValidateTensorShapesFromInputs(), SoftmaxLayer::ValidateTensorShapesFromInputs(), DequantizeLayer::ValidateTensorShapesFromInputs(), ResizeLayer::ValidateTensorShapesFromInputs(), AbsLayer::ValidateTensorShapesFromInputs(), RsqrtLayer::ValidateTensorShapesFromInputs(), SliceLayer::ValidateTensorShapesFromInputs(), TransposeLayer::ValidateTensorShapesFromInputs(), PadLayer::ValidateTensorShapesFromInputs(), MeanLayer::ValidateTensorShapesFromInputs(), LogSoftmaxLayer::ValidateTensorShapesFromInputs(), ChannelShuffleLayer::ValidateTensorShapesFromInputs(), PermuteLayer::ValidateTensorShapesFromInputs(), ConstantLayer::ValidateTensorShapesFromInputs(), ReshapeLayer::ValidateTensorShapesFromInputs(), Convolution3dLayer::ValidateTensorShapesFromInputs(), GatherNdLayer::ValidateTensorShapesFromInputs(), ElementwiseUnaryLayer::ValidateTensorShapesFromInputs(), DetectionPostProcessLayer::ValidateTensorShapesFromInputs(), ArgMinMaxLayer::ValidateTensorShapesFromInputs(), GatherLayer::ValidateTensorShapesFromInputs(), StridedSliceLayer::ValidateTensorShapesFromInputs(), SpaceToBatchNdLayer::ValidateTensorShapesFromInputs(), LogicalBinaryLayer::ValidateTensorShapesFromInputs(), PreluLayer::ValidateTensorShapesFromInputs(), TransposeConvolution2dLayer::ValidateTensorShapesFromInputs(), ComparisonLayer::ValidateTensorShapesFromInputs(), DepthToSpaceLayer::ValidateTensorShapesFromInputs(), SpaceToDepthLayer::ValidateTensorShapesFromInputs(), DepthwiseConvolution2dLayer::ValidateTensorShapesFromInputs(), FullyConnectedLayer::ValidateTensorShapesFromInputs(), SplitterLayer::ValidateTensorShapesFromInputs(), Convolution2dLayer::ValidateTensorShapesFromInputs(), ConcatLayer::ValidateTensorShapesFromInputs(), LstmLayer::ValidateTensorShapesFromInputs(), UnidirectionalSequenceLstmLayer::ValidateTensorShapesFromInputs(), BatchNormalizationLayer::ValidateTensorShapesFromInputs(), QuantizedLstmLayer::ValidateTensorShapesFromInputs(), and QLstmLayer::ValidateTensorShapesFromInputs().

324 { 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 325 of file Layer.hpp.

325 { 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 363 of file Layer.hpp.

363 { return m_NullDescriptor; }

◆ GetPriority()

LayerPriority GetPriority ( ) const

Definition at line 328 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().

329 {
330  constexpr LayerPriority inputPrio = std::numeric_limits<LayerPriority>::lowest();
331  constexpr LayerPriority outputPrio = std::numeric_limits<LayerPriority>::max();
332 
333  if (GetType() == LayerType::Input)
334  {
335  m_Priority = inputPrio;
336  }
337  else if (GetType() == LayerType::Output)
338  {
339  m_Priority = outputPrio;
340  }
341  else if (m_Priority == 0)
342  {
343  if (m_Visiting)
344  {
345  throw GraphValidationException("Graph has circular dependencies: cannot walk");
346  }
347 
348  auto maxPrio = [](const LayerPriority prio, const InputSlot& slot) -> LayerPriority
349  {
350  const OutputSlot *outputSlot = slot.GetConnectedOutputSlot();
351  if (outputSlot)
352  {
353  const Layer& input = outputSlot->GetOwningLayer();
354  return std::max(prio, input.GetPriority());
355  }
356  else
357  {
358  // unconnected input slot
359  return prio;
360  }
361  };
362 
363  m_Visiting = true;
364  LayerPriority parentPrio = std::accumulate(GetInputSlots().cbegin(), GetInputSlots().cend(), 0U, maxPrio);
365  m_Visiting = false;
366 
367  if (parentPrio >= outputPrio)
368  {
369  throw GraphValidationException("Graph has too many edges");
370  }
371 
372  m_Priority = parentPrio + 1U;
373  }
374 
375  return m_Priority;
376 }
unsigned int LayerPriority
Definition: Layer.hpp:212
const std::vector< InputSlot > & GetInputSlots() const
Definition: Layer.hpp:243
LayerType GetType() const override
Returns the armnn::LayerType of this layer.
Definition: Layer.hpp:271
Layer(unsigned int numInputSlots, unsigned int numOutputSlots, LayerType type, const char *name)
Definition: Layer.cpp:247

◆ GetRelatedLayerNames()

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

Definition at line 332 of file Layer.hpp.

Referenced by ErasedLayerNamesObservable::Update().

332 { 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:421

◆ GetType()

LayerType GetType ( ) const
inlineoverridevirtual

Returns the armnn::LayerType of this layer.

Implements IConnectableLayer.

Definition at line 271 of file Layer.hpp.

Referenced by armnn::ApplyBackendOptimizations(), armnn::AssertNumberOfInputSlots(), armnn::AttemptBackendAssignment(), armnn::CalculateEdgeStrategy(), armnn::CalculateSlotOption(), armnn::CalculateSlotOptionForInput(), armnn::CheckScaleSetOnQuantizedType(), ConcatLayer::CreateWorkload(), SplitterLayer::CreateWorkload(), armnn::optimizations::pad_fold::FoldPadIntoLayer2dImpl(), Layer::GetPriority(), LoadedNetwork::ImportInputs(), LoadedNetwork::ImportOutputs(), ElementwiseBaseLayer::InferOutputShapes(), Layer::InferOutputShapes(), Graph::InferTensorInfos(), armnn::InsertConvertFp32ToBf16LayersBefore(), ReshapeLayer::IsEqual(), TransposeLayer::IsEqual(), PermuteLayer::IsEqual(), TransposeLayer::IsInverse(), PermuteLayer::IsInverse(), IsLayerOfType(), armnn::IsLayerSupported(), NeonBackend::OptimizeSubgraphView(), ClBackend::OptimizeSubgraphView(), LoadedNetwork::RegisterDebugCallback(), armnn::ReturnWithError(), ConvertFp32NetworkToFp16Impl::Run(), ConvertConstDequantisationLayersToConstLayersImpl::Run(), AddDebugImpl::Run(), OptimizeConsecutiveReshapesImpl::Run(), ConvertConstPermuteLayersToConstLayers::Run(), OptimizeInverseConversionsImpl::Run(), PermuteAndBatchToSpaceAsDepthToSpaceImpl< PermuteType >::Run(), RedirectMembersToConstantInputsImpl::Run(), MovePermuteUpImpl::Run(), PermuteDepthwiseConv2dWeightsImpl::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().

271 { 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, Convolution2dLayer, LstmLayer, UnidirectionalSequenceLstmLayer, DepthwiseConvolution2dLayer, FullyConnectedLayer, SplitterLayer, 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, GatherNdLayer, and ElementwiseBaseLayer.

Definition at line 397 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().

398 {
401 
402  // By default we return what we got, meaning the output shape(s) are the same as the input(s).
403  // This only works if the number of inputs and outputs are the same. Since we are in the Layer
404  // base class, this means the implementation needs to be overridden in the specific layers for
405  // the other cases. So the missing implementation justifies the UnimplementedException.
406 
408  {
409  throw UnimplementedException(
410  fmt::format("Default implementation for InferOutputShapes can only be used for "
411  "layers with the same number of input and output slots. This doesn't "
412  "hold for {0} layer {1} (#inputs={2} #outputs={3}) {4}",
414  GetNameStr(),
417  CHECK_LOCATION().AsString()));
418  }
419  return inputShapes;
420 }
unsigned int GetNumInputSlots() const override
Returns the number of connectable input slots.
Definition: Layer.hpp:319
unsigned int GetNumOutputSlots() const override
Returns the number of connectable output slots.
Definition: Layer.hpp:320
const std::string & GetNameStr() const
Definition: Layer.hpp:225
LayerType GetType() const override
Returns the armnn::LayerType of this layer.
Definition: Layer.hpp:271
#define ARMNN_ASSERT(COND)
Definition: Assert.hpp:14
#define CHECK_LOCATION()
Definition: Exceptions.hpp:203
const char * GetLayerTypeAsCString(LayerType type)

◆ IsOutputUnconnected()

bool IsOutputUnconnected ( )
inline

Definition at line 255 of file Layer.hpp.

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

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

◆ OperateOnConstantTensors()

void OperateOnConstantTensors ( Op  op)
inline

Definition at line 304 of file Layer.hpp.

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

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

◆ PrepInfoAndDesc()

WorkloadInfo PrepInfoAndDesc ( QueueDescriptor descriptor) const
inlineprotected

Helper function to reduce duplication in *LayerCreateWorkload.

Definition at line 394 of file Layer.hpp.

References armnn::info.

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

395  {
396  WorkloadInfo info;
397  CollectQueueDescriptorInputs(descriptor, info);
398  CollectQueueDescriptorOutputs(descriptor, info);
399  return info;
400  }
void CollectQueueDescriptorInputs(QueueDescriptor &descriptor, WorkloadInfo &info) const
Definition: Layer.hpp:371
void CollectQueueDescriptorOutputs(QueueDescriptor &descriptor, WorkloadInfo &info) const
Definition: Layer.hpp:378

◆ ReleaseConstantData()

void ReleaseConstantData ( )
virtual

Reimplemented in ConstantLayer.

Definition at line 304 of file Layer.cpp.

References Layer::OperateOnConstantTensors().

Referenced by TEST_SUITE().

305 {
306  // Now free up the static data.
307  OperateOnConstantTensors([](std::shared_ptr<ConstTensorHandle>& handle)
308  {
309  handle.reset();
310  });
311 }
void OperateOnConstantTensors(Op op)
Definition: Layer.hpp:304

◆ 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 322 of file Layer.cpp.

323 {
324  m_Priority = 0;
325  m_Visiting = false;
326 }

◆ 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 505 of file Layer.cpp.

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

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

506 {
507  std::string guid = std::to_string(m_Guid);
508  std::string layerType = GetLayerTypeAsCString(m_Type);
509  std::string backendId = std::string(m_BackendId);
510  if (!(guid.compare("") == 0) && !guid.empty())
511  {
512  fn("Guid", guid);
513  }
514  if(!(m_LayerName.compare("") == 0) && !m_LayerName.empty())
515  {
516  fn("LayerName",m_LayerName);
517  }
518  if(!(layerType.compare("") == 0) && !layerType.empty())
519  {
520  fn("LayerType",layerType);
521  }
522  if(!(backendId.compare("") == 0) && !backendId.empty())
523  {
524  fn("BackendID",backendId);
525  }
526  std::shared_ptr<ActivationDescriptor>
527  activationDescPtr = GetAdditionalInformation<ActivationDescriptor>();
528 
529  if (activationDescPtr)
530  {
531  StringifyLayerParameters<ActivationDescriptor>::Serialize(fn, *activationDescPtr.get());
532  }
533 }
static void Serialize(ParameterStringifyFunction &, const LayerParameter &)
const char * GetLayerTypeAsCString(LayerType type)

◆ SetAdditionalInfo()

void SetAdditionalInfo ( QueueDescriptor descriptor) const
protected

Definition at line 274 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(), StridedSliceLayer::CreateWorkload(), StackLayer::CreateWorkload(), SplitterLayer::CreateWorkload(), SwitchLayer::CreateWorkload(), UnmapLayer::CreateWorkload(), SoftmaxLayer::CreateWorkload(), SliceLayer::CreateWorkload(), MemCopyLayer::CreateWorkload(), RsqrtLayer::CreateWorkload(), MemImportLayer::CreateWorkload(), ConcatLayer::CreateWorkload(), ReduceLayer::CreateWorkload(), DequantizeLayer::CreateWorkload(), NormalizationLayer::CreateWorkload(), Pooling2dLayer::CreateWorkload(), Pooling3dLayer::CreateWorkload(), FakeQuantizationLayer::CreateWorkload(), BatchToSpaceNdLayer::CreateWorkload(), QuantizeLayer::CreateWorkload(), ConvertBf16ToFp32Layer::CreateWorkload(), ConvertFp16ToFp32Layer::CreateWorkload(), FloorLayer::CreateWorkload(), ResizeLayer::CreateWorkload(), AdditionLayer::CreateWorkload(), ConvertFp32ToBf16Layer::CreateWorkload(), ShapeLayer::CreateWorkload(), GatherNdLayer::CreateWorkload(), CastLayer::CreateWorkload(), InstanceNormalizationLayer::CreateWorkload(), L2NormalizationLayer::CreateWorkload(), GatherLayer::CreateWorkload(), SubtractionLayer::CreateWorkload(), ComparisonLayer::CreateWorkload(), DepthToSpaceLayer::CreateWorkload(), TransposeLayer::CreateWorkload(), LogSoftmaxLayer::CreateWorkload(), SpaceToBatchNdLayer::CreateWorkload(), ArgMinMaxLayer::CreateWorkload(), SpaceToDepthLayer::CreateWorkload(), MultiplicationLayer::CreateWorkload(), PadLayer::CreateWorkload(), DivisionLayer::CreateWorkload(), PreluLayer::CreateWorkload(), MaximumLayer::CreateWorkload(), MinimumLayer::CreateWorkload(), MeanLayer::CreateWorkload(), ReshapeLayer::CreateWorkload(), PermuteLayer::CreateWorkload(), ConstantLayer::CreateWorkload(), Convolution3dLayer::CreateWorkload(), ChannelShuffleLayer::CreateWorkload(), DetectionPostProcessLayer::CreateWorkload(), TransposeConvolution2dLayer::CreateWorkload(), PreCompiledLayer::CreateWorkload(), DepthwiseConvolution2dLayer::CreateWorkload(), FullyConnectedLayer::CreateWorkload(), Convolution2dLayer::CreateWorkload(), UnidirectionalSequenceLstmLayer::CreateWorkload(), LstmLayer::CreateWorkload(), BatchNormalizationLayer::CreateWorkload(), QuantizedLstmLayer::CreateWorkload(), and QLstmLayer::CreateWorkload().

275 {
276  descriptor.m_AdditionalInfoObject = m_AdditionalInfoObject.get();
277 }
AdditionalInfoObjectPtr m_AdditionalInfoObject
Definition: Layer.hpp:407

◆ SetAdditionalInfoForObject()

void SetAdditionalInfoForObject ( const AdditionalInfoObjectPtr additionalInfo)
inline

Definition at line 358 of file Layer.hpp.

359  {
360  m_AdditionalInfoObject = additionalInfo;
361  }
AdditionalInfoObjectPtr m_AdditionalInfoObject
Definition: Layer.hpp:407

◆ SetAllowExpandedDims()

void SetAllowExpandedDims ( bool  allowExpandedDims)
inline

Definition at line 347 of file Layer.hpp.

348  {
349  m_AllowExpandedDims = allowExpandedDims;
350  }

◆ SetBackendId()

void SetBackendId ( const BackendId id)
inline

◆ SetGuid()

void SetGuid ( LayerGuid  guid)
inline

Definition at line 327 of file Layer.hpp.

327 { m_Guid = guid; }

◆ SetShapeInferenceMethod()

void SetShapeInferenceMethod ( ShapeInferenceMethod  shapeInferenceMethod)
inline

Definition at line 342 of file Layer.hpp.

343  {
344  m_ShapeInferenceMethod = shapeInferenceMethod;
345  }
ShapeInferenceMethod m_ShapeInferenceMethod
Definition: Layer.hpp:421

◆ 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 422 of file Layer.cpp.

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

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

427 {
428  if (shapeInferenceMethod == ShapeInferenceMethod::ValidateOnly)
429  {
430  if (m_AllowExpandedDims)
431  {
432  std::vector<unsigned int> outputDims = armnnUtils::SqueezeDims(outputShape);
433  std::vector<unsigned int> inferredDims = armnnUtils::SqueezeDims(inferredShape);
434 
435  if (outputDims.size() != inferredDims.size())
436  {
437  std::stringstream ss;
438  ss << layerName << ": TensorShape set on OutputSlot[" << outputSlotIndex <<
439  "] does not match the inferred shape. ";
440  ss << outputShape << " != " << inferredShape;
441  throw LayerValidationException(ss.str());
442  }
443  for (unsigned int i = 0; i < outputDims.size(); ++i)
444  {
445  if (outputDims[i] != inferredDims[i])
446  {
447  std::stringstream ss;
448  ss << layerName << ": TensorShape set on OutputSlot[" << outputSlotIndex <<
449  "] does not match the inferred shape at dimension index [";
450  ss << i << "] " << outputShape << " != " << inferredShape;
451  throw LayerValidationException(ss.str());
452  }
453  }
454  return;
455  }
456  else
457  {
458  ConditionalThrowIfNotEqual<LayerValidationException>(
459  layerName + ": TensorShape set on OutputSlot[0] does not match the inferred shape.",
460  outputShape,
461  inferredShape);
462  return;
463  }
464  }
465 
466  if (outputShape.GetDimensionality() == Dimensionality::Specified)
467  {
468  for (unsigned int i = 0; i < outputShape.GetNumDimensions(); ++i)
469  {
470  if (outputShape.GetDimensionSpecificity(i) && outputShape[i] != inferredShape[i])
471  {
472  std::stringstream ss;
473  ss << layerName << ": TensorShape set on OutputSlot[" << outputSlotIndex <<
474  "] does not match the inferred shape at dimension index [";
475  ss << i << "] " << outputShape << " != " << inferredShape;
476  throw LayerValidationException(ss.str());
477  }
478  }
479  }
480 
481  TensorInfo info = GetOutputSlot(outputSlotIndex).GetTensorInfo();
482 
483  armnn::TensorInfo inferredTensorInfo(inferredShape,
484  info.GetDataType(),
485  info.GetQuantizationScale(),
486  info.GetQuantizationOffset());
487 
488  GetOutputSlot(outputSlotIndex).SetTensorInfo(inferredTensorInfo);
489 }
std::vector< unsigned int > SqueezeDims(const armnn::TensorShape &tensorShape)
Validate all output shapes.
void SetTensorInfo(const TensorInfo &tensorInfo) override
Definition: Layer.cpp:87
const OutputSlot & GetOutputSlot(unsigned int index=0) const override
Get the const output slot handle by slot index.
Definition: Layer.hpp:324
const TensorInfo & GetTensorInfo() const override
Definition: Layer.cpp:92

◆ ValidateTensorShapesFromInputs()

◆ VerifyLayerConnections()

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

Definition at line 378 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(), ConvertFp32ToFp16Layer::ValidateTensorShapesFromInputs(), FillLayer::ValidateTensorShapesFromInputs(), ReduceLayer::ValidateTensorShapesFromInputs(), DebugLayer::ValidateTensorShapesFromInputs(), MapLayer::ValidateTensorShapesFromInputs(), MemCopyLayer::ValidateTensorShapesFromInputs(), DequantizeLayer::ValidateTensorShapesFromInputs(), SliceLayer::ValidateTensorShapesFromInputs(), MemImportLayer::ValidateTensorShapesFromInputs(), MergeLayer::ValidateTensorShapesFromInputs(), NormalizationLayer::ValidateTensorShapesFromInputs(), BatchToSpaceNdLayer::ValidateTensorShapesFromInputs(), Pooling2dLayer::ValidateTensorShapesFromInputs(), ConvertFp16ToFp32Layer::ValidateTensorShapesFromInputs(), ConvertBf16ToFp32Layer::ValidateTensorShapesFromInputs(), Pooling3dLayer::ValidateTensorShapesFromInputs(), AbsLayer::ValidateTensorShapesFromInputs(), FakeQuantizationLayer::ValidateTensorShapesFromInputs(), CastLayer::ValidateTensorShapesFromInputs(), FloorLayer::ValidateTensorShapesFromInputs(), ResizeLayer::ValidateTensorShapesFromInputs(), RsqrtLayer::ValidateTensorShapesFromInputs(), ConvertFp32ToBf16Layer::ValidateTensorShapesFromInputs(), ShapeLayer::ValidateTensorShapesFromInputs(), SoftmaxLayer::ValidateTensorShapesFromInputs(), InstanceNormalizationLayer::ValidateTensorShapesFromInputs(), L2NormalizationLayer::ValidateTensorShapesFromInputs(), StackLayer::ValidateTensorShapesFromInputs(), SwitchLayer::ValidateTensorShapesFromInputs(), UnmapLayer::ValidateTensorShapesFromInputs(), MeanLayer::ValidateTensorShapesFromInputs(), PadLayer::ValidateTensorShapesFromInputs(), ChannelShuffleLayer::ValidateTensorShapesFromInputs(), TransposeLayer::ValidateTensorShapesFromInputs(), LogSoftmaxLayer::ValidateTensorShapesFromInputs(), PermuteLayer::ValidateTensorShapesFromInputs(), ReshapeLayer::ValidateTensorShapesFromInputs(), Convolution3dLayer::ValidateTensorShapesFromInputs(), GatherNdLayer::ValidateTensorShapesFromInputs(), StridedSliceLayer::ValidateTensorShapesFromInputs(), GatherLayer::ValidateTensorShapesFromInputs(), DetectionPostProcessLayer::ValidateTensorShapesFromInputs(), ArgMinMaxLayer::ValidateTensorShapesFromInputs(), ElementwiseUnaryLayer::ValidateTensorShapesFromInputs(), ComparisonLayer::ValidateTensorShapesFromInputs(), SpaceToDepthLayer::ValidateTensorShapesFromInputs(), SpaceToBatchNdLayer::ValidateTensorShapesFromInputs(), LogicalBinaryLayer::ValidateTensorShapesFromInputs(), TransposeConvolution2dLayer::ValidateTensorShapesFromInputs(), PreluLayer::ValidateTensorShapesFromInputs(), DepthToSpaceLayer::ValidateTensorShapesFromInputs(), DepthwiseConvolution2dLayer::ValidateTensorShapesFromInputs(), LstmLayer::ValidateTensorShapesFromInputs(), Convolution2dLayer::ValidateTensorShapesFromInputs(), ConcatLayer::ValidateTensorShapesFromInputs(), UnidirectionalSequenceLstmLayer::ValidateTensorShapesFromInputs(), BatchNormalizationLayer::ValidateTensorShapesFromInputs(), QuantizedLstmLayer::ValidateTensorShapesFromInputs(), and QLstmLayer::ValidateTensorShapesFromInputs().

379 {
380  ARMNN_ASSERT(GetNumInputSlots() == expectedConnections);
381 
382  for (unsigned int i=0; i<expectedConnections; ++i)
383  {
384  if (GetInputSlot(i).GetConnection() == nullptr)
385  {
386  throw LayerValidationException(
387  fmt::format("Input connection #{0} must be connected "
388  "for {1} layer {2} {3}",
389  i,
391  GetNameStr(),
392  location.AsString()));
393  }
394  }
395 }
unsigned int GetNumInputSlots() const override
Returns the number of connectable input slots.
Definition: Layer.hpp:319
const InputSlot & GetInputSlot(unsigned int index) const override
Get a const input slot handle by slot index.
Definition: Layer.hpp:322
const std::string & GetNameStr() const
Definition: Layer.hpp:225
LayerType GetType() const override
Returns the armnn::LayerType of this layer.
Definition: Layer.hpp:271
#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 491 of file Layer.cpp.

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

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

492 {
493  if (shapeInferenceMethod == ShapeInferenceMethod::ValidateOnly)
494  {
495  ConditionalThrow<LayerValidationException>(
496  outputShape.GetDimensionality() != Dimensionality::NotSpecified,
497  "Dimensionality can not be NotSpecified while using ShapeInferenceMethod::ValidateOnly");
498 
499  ConditionalThrow<LayerValidationException>(
500  outputShape.AreAllDimensionsSpecified(),
501  "Unspecified dimension while using ShapeInferenceMethod::ValidateOnly");
502  }
503 }
Validate all output shapes.

Friends And Related Function Documentation

◆ Graph

friend class Graph
friend

Definition at line 367 of file Layer.hpp.

Member Data Documentation

◆ m_AdditionalInfoObject

AdditionalInfoObjectPtr m_AdditionalInfoObject
protected

Definition at line 407 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 421 of file Layer.hpp.

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


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