ArmNN
 20.05
Layer Class Referenceabstract

#include <Layer.hpp>

Inheritance diagram for Layer:
IConnectableLayer AbsLayer BindableLayer ConstantLayer ConvertBf16ToFp32Layer ConvertFp16ToFp32Layer ConvertFp32ToBf16Layer ConvertFp32ToFp16Layer DebugLayer DequantizeLayer ElementwiseBaseLayer FloorLayer GatherLayer LayerWithParameters< Parameters > MemCopyLayer MemImportLayer MergeLayer PreluLayer QuantizedLstmLayer QuantizeLayer RsqrtLayer SwitchLayer LayerWithParameters< ActivationDescriptor > LayerWithParameters< ArgMinMaxDescriptor > LayerWithParameters< BatchNormalizationDescriptor > LayerWithParameters< BatchToSpaceNdDescriptor > LayerWithParameters< ComparisonDescriptor > LayerWithParameters< Convolution2dDescriptor > LayerWithParameters< DepthToSpaceDescriptor > LayerWithParameters< DepthwiseConvolution2dDescriptor > LayerWithParameters< DetectionPostProcessDescriptor > LayerWithParameters< ElementwiseUnaryDescriptor > LayerWithParameters< FakeQuantizationDescriptor > LayerWithParameters< FullyConnectedDescriptor > LayerWithParameters< InstanceNormalizationDescriptor > LayerWithParameters< L2NormalizationDescriptor > LayerWithParameters< LogSoftmaxDescriptor > LayerWithParameters< LstmDescriptor > LayerWithParameters< MeanDescriptor > LayerWithParameters< NormalizationDescriptor > LayerWithParameters< OriginsDescriptor > LayerWithParameters< PadDescriptor > LayerWithParameters< PermuteDescriptor > LayerWithParameters< Pooling2dDescriptor > LayerWithParameters< PreCompiledDescriptor > LayerWithParameters< QLstmDescriptor > 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)
 
const std::string & GetNameStr () const
 
const OutputHandlerGetOutputHandler (unsigned int i=0) const
 
OutputHandlerGetOutputHandler (unsigned int i=0)
 
const std::vector< InputSlot > & GetInputSlots () const
 
const std::vector< OutputSlot > & GetOutputSlots () const
 
std::vector< InputSlot >::iterator BeginInputSlots ()
 
std::vector< InputSlot >::iterator EndInputSlots ()
 
std::vector< OutputSlot >::iterator BeginOutputSlots ()
 
std::vector< OutputSlot >::iterator EndOutputSlots ()
 
bool IsOutputUnconnected ()
 
void ResetPriority () const
 
LayerPriority GetPriority () const
 
LayerType GetType () const
 
DataType GetDataType () const
 
const BackendIdGetBackendId () const
 
void SetBackendId (const BackendId &id)
 
virtual 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
 
- Public Member Functions inherited from IConnectableLayer
virtual void Accept (ILayerVisitor &visitor) const =0
 Apply a visitor to this layer. More...
 

Protected Types

using ConstantTensors = std::vector< std::reference_wrapper< std::unique_ptr< ScopedCpuTensorHandle > >>
 

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
 
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 ()
 
- Protected Member Functions inherited from IConnectableLayer
 ~IConnectableLayer ()
 Objects are not deletable via the handle. More...
 

Protected Attributes

std::vector< OutputHandlerm_OutputHandlers
 

Friends

class Graph
 

Detailed Description

Definition at line 209 of file Layer.hpp.

Member Typedef Documentation

◆ ConstantTensors

using ConstantTensors = std::vector<std::reference_wrapper<std::unique_ptr<ScopedCpuTensorHandle> >>
protected

Definition at line 363 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 214 of file Layer.cpp.

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

218 : Layer(numInputSlots, numOutputSlots, type, DataLayout::NCHW, name)
219 {
220 }
Layer(unsigned int numInputSlots, unsigned int numOutputSlots, LayerType type, const char *name)
Definition: Layer.cpp:214

◆ Layer() [2/2]

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

Definition at line 188 of file Layer.cpp.

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

193 : m_OutputHandlers(numOutputSlots)
194 , m_LayerName(name ? name : "")
195 , m_Type(type)
196 , m_BackendId()
197 , m_BackendHint(EmptyOptional())
199 {
200  IgnoreUnused(layout);
201  m_InputSlots.reserve(numInputSlots);
202  for (unsigned int i = 0; i < numInputSlots; ++i)
203  {
204  m_InputSlots.emplace_back(*this, i);
205  }
206 
207  m_OutputSlots.reserve(numOutputSlots);
208  for (unsigned int i = 0; i < numOutputSlots; ++i)
209  {
210  m_OutputSlots.emplace_back(*this, m_OutputHandlers[i]);
211  }
212 }
void IgnoreUnused(Ts &&...)
std::vector< OutputHandler > m_OutputHandlers
Definition: Layer.hpp:371
static ProfilingDynamicGuid GetNextGuid()

◆ ~Layer()

virtual ~Layer ( )
protectedvirtualdefault

Member Function Documentation

◆ AddRelatedLayerName()

void AddRelatedLayerName ( const std::string  layerName)
inline

Definition at line 318 of file Layer.hpp.

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

Referenced by BOOST_AUTO_TEST_CASE().

325  {
326  m_BackendHint = backend;
327  }

◆ BeginInputSlots()

◆ BeginOutputSlots()

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

Definition at line 239 of file Layer.hpp.

Referenced by Graph::Graph(), armnn::InsertDebugLayerAfter(), ConvertFp32NetworkToFp16Impl::Run(), and SquashEqualSiblingsImpl< Comparable >::Run().

239 { return m_OutputSlots.begin(); }

◆ Clone()

◆ CloneBase()

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

Definition at line 14 of file LayerCloneBase.hpp.

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

15 {
16  LayerType* const layer = graph.AddLayer<LayerType>(std::forward<Params>(params)...);
17 
18  layer->SetBackendId(GetBackendId());
19  layer->SetGuid(GetGuid());
20 
21  return layer;
22 }
const BackendId & GetBackendId() const
Definition: Layer.hpp:263
LayerGuid GetGuid() const final
Returns the unique id of the layer.
Definition: Layer.hpp:316

◆ CollectQueueDescriptorInputs()

void CollectQueueDescriptorInputs ( QueueDescriptor descriptor,
WorkloadInfo info 
) const
inlineprotected

Definition at line 336 of file Layer.hpp.

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

337  {
338  WorkloadDataCollector dataCollector(descriptor.m_Inputs, info.m_InputTensorInfos);
339  CollectWorkloadInputs(dataCollector);
340  }

◆ CollectQueueDescriptorOutputs()

void CollectQueueDescriptorOutputs ( QueueDescriptor descriptor,
WorkloadInfo info 
) const
inlineprotected

Definition at line 343 of file Layer.hpp.

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

344  {
345  WorkloadDataCollector dataCollector(descriptor.m_Outputs, info.m_OutputTensorInfos);
346  CollectWorkloadOutputs(dataCollector);
347  }

◆ CreateTensorHandles()

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

Reimplemented in SplitterLayer, ConcatLayer, and OutputLayer.

Definition at line 241 of file Layer.cpp.

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

244 {
245  for (unsigned int idx=0; idx < GetNumOutputSlots(); idx++)
246  {
247 
248  OutputSlot& slot = GetOutputSlot(idx);
249  ITensorHandleFactory::FactoryId factoryId = slot.GetTensorHandleFactoryId();
250 
251  OutputHandler& handler = GetOutputHandler(idx);
252  if (factoryId == ITensorHandleFactory::LegacyFactoryId)
253  {
254  handler.CreateTensorHandles(workloadFactory, IsMemoryManaged);
255  }
256  else
257  {
258  ITensorHandleFactory* handleFactory = registry.GetFactory(factoryId);
259  ARMNN_ASSERT(handleFactory);
260  handler.CreateTensorHandles(*handleFactory, IsMemoryManaged);
261  }
262  }
263 }
unsigned int GetNumOutputSlots() const override
Returns the number of connectable output slots.
Definition: Layer.hpp:308
#define ARMNN_ASSERT(COND)
Definition: Assert.hpp:14
const OutputHandler & GetOutputHandler(unsigned int i=0) const
Definition: Layer.hpp:221
const OutputSlot & GetOutputSlot(unsigned int index=0) const override
Get the const output slot handle by slot index.
Definition: Layer.hpp:312
static const FactoryId LegacyFactoryId

◆ CreateWorkload()

◆ EndInputSlots()

◆ EndOutputSlots()

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

Definition at line 240 of file Layer.hpp.

Referenced by armnn::InsertDebugLayerAfter(), and ConvertFp32NetworkToFp16Impl::Run().

240 { return m_OutputSlots.end(); }

◆ GetBackendHint()

Optional<BackendId> GetBackendHint ( ) const
inline

Definition at line 328 of file Layer.hpp.

328 { return m_BackendHint; }

◆ GetBackendId()

◆ GetConstantTensorsByRef()

virtual ConstantTensors GetConstantTensorsByRef ( )
inlineprotectedvirtual

Reimplemented in QLstmLayer, LstmLayer, QuantizedLstmLayer, Convolution2dLayer, DepthwiseConvolution2dLayer, FullyConnectedLayer, TransposeConvolution2dLayer, BatchNormalizationLayer, ConstantLayer, and DetectionPostProcessLayer.

Definition at line 364 of file Layer.hpp.

364 {return ConstantTensors(); };
std::vector< std::reference_wrapper< std::unique_ptr< ScopedCpuTensorHandle > >> ConstantTensors
Definition: Layer.hpp:363

◆ GetDataType()

DataType GetDataType ( ) const

Definition at line 274 of file Layer.cpp.

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

Referenced by BOOST_AUTO_TEST_CASE(), ConvertFp32NetworkToFp16Impl::Run(), ConvertFp32NetworkToBf16Impl::Run(), IsFloat32Layer::Test(), IsFloat16Layer::Test(), and IsBFloat16Layer::Test().

275 {
276  if (GetNumInputSlots() > 0) // Ignore the input layer.
277  {
279  }
281 }
unsigned int GetNumInputSlots() const override
Returns the number of connectable input slots.
Definition: Layer.hpp:307
const IOutputSlot * GetConnection() const override
Definition: Layer.hpp:199
const InputSlot & GetInputSlot(unsigned int index) const override
Get a const input slot handle by slot index.
Definition: Layer.hpp:310
DataType GetDataType() const
Definition: Tensor.hpp:95
const OutputSlot & GetOutputSlot(unsigned int index=0) const override
Get the const output slot handle by slot index.
Definition: Layer.hpp:312
virtual const TensorInfo & GetTensorInfo() const =0
const TensorInfo & GetTensorInfo() const override
Definition: Layer.cpp:63

◆ GetGuid()

LayerGuid GetGuid ( ) const
inlinefinalvirtual

Returns the unique id of the layer.

Implements IConnectableLayer.

Definition at line 316 of file Layer.hpp.

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

316 { 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 310 of file Layer.hpp.

Referenced by BOOST_AUTO_TEST_CASE(), BOOST_FIXTURE_TEST_CASE(), CreateConvolution2dGraph(), CreateDepthwiseConvolution2dGraph(), CreateGatherGraph(), CreatePooling2dGraph(), CreateResizeBilinearGraph(), DebugLayer::CreateWorkload(), ConcatLayer::CreateWorkload(), Layer::GetDataType(), Graph::Graph(), InputSlot::Insert(), armnn::InsertConvertBf16ToFp32LayersBefore(), armnn::InsertConvertFp16ToFp32LayersBefore(), armnn::InsertConvertFp32ToBf16LayersAfter(), armnn::InsertConvertFp32ToBf16LayersBefore(), armnn::InsertConvertFp32ToFp16LayersAfter(), armnn::InsertDebugLayerAfter(), IWorkloadFactory::IsLayerSupported(), PermuteAsReshapeImpl::Run(), TransposeAsReshapeImpl::Run(), OptimizeConsecutiveReshapesImpl::Run(), FoldPadIntoConvolution2dImpl::Run(), OptimizeInverseConversionsImpl::Run(), PermuteAndBatchToSpaceAsDepthToSpaceImpl< PermuteType >::Run(), MovePermuteUpImpl::Run(), OptimizeInversePermutesImpl< PermuteType >::Run(), MoveTransposeUpImpl::Run(), DepthwiseConvolution2dLayer::SerializeLayerParameters(), Convolution2dLayer::SerializeLayerParameters(), ElementwiseBaseLayer::ValidateTensorShapesFromInputs(), QuantizeLayer::ValidateTensorShapesFromInputs(), ActivationLayer::ValidateTensorShapesFromInputs(), ConvertFp32ToFp16Layer::ValidateTensorShapesFromInputs(), SoftmaxLayer::ValidateTensorShapesFromInputs(), BatchToSpaceNdLayer::ValidateTensorShapesFromInputs(), MemCopyLayer::ValidateTensorShapesFromInputs(), MemImportLayer::ValidateTensorShapesFromInputs(), MergeLayer::ValidateTensorShapesFromInputs(), NormalizationLayer::ValidateTensorShapesFromInputs(), DebugLayer::ValidateTensorShapesFromInputs(), Pooling2dLayer::ValidateTensorShapesFromInputs(), SwitchLayer::ValidateTensorShapesFromInputs(), AbsLayer::ValidateTensorShapesFromInputs(), ResizeLayer::ValidateTensorShapesFromInputs(), RsqrtLayer::ValidateTensorShapesFromInputs(), SliceLayer::ValidateTensorShapesFromInputs(), DequantizeLayer::ValidateTensorShapesFromInputs(), ConvertBf16ToFp32Layer::ValidateTensorShapesFromInputs(), StackLayer::ValidateTensorShapesFromInputs(), InstanceNormalizationLayer::ValidateTensorShapesFromInputs(), ConvertFp32ToBf16Layer::ValidateTensorShapesFromInputs(), FakeQuantizationLayer::ValidateTensorShapesFromInputs(), ConvertFp16ToFp32Layer::ValidateTensorShapesFromInputs(), FloorLayer::ValidateTensorShapesFromInputs(), L2NormalizationLayer::ValidateTensorShapesFromInputs(), LogSoftmaxLayer::ValidateTensorShapesFromInputs(), GatherLayer::ValidateTensorShapesFromInputs(), MeanLayer::ValidateTensorShapesFromInputs(), TransposeLayer::ValidateTensorShapesFromInputs(), PermuteLayer::ValidateTensorShapesFromInputs(), ElementwiseUnaryLayer::ValidateTensorShapesFromInputs(), ArgMinMaxLayer::ValidateTensorShapesFromInputs(), StridedSliceLayer::ValidateTensorShapesFromInputs(), DepthwiseConvolution2dLayer::ValidateTensorShapesFromInputs(), PreluLayer::ValidateTensorShapesFromInputs(), TransposeConvolution2dLayer::ValidateTensorShapesFromInputs(), DepthToSpaceLayer::ValidateTensorShapesFromInputs(), SpaceToDepthLayer::ValidateTensorShapesFromInputs(), ComparisonLayer::ValidateTensorShapesFromInputs(), SpaceToBatchNdLayer::ValidateTensorShapesFromInputs(), FullyConnectedLayer::ValidateTensorShapesFromInputs(), Convolution2dLayer::ValidateTensorShapesFromInputs(), ConcatLayer::ValidateTensorShapesFromInputs(), BatchNormalizationLayer::ValidateTensorShapesFromInputs(), OutputLayer::ValidateTensorShapesFromInputs(), QuantizedLstmLayer::ValidateTensorShapesFromInputs(), LstmLayer::ValidateTensorShapesFromInputs(), QLstmLayer::ValidateTensorShapesFromInputs(), and Layer::VerifyLayerConnections().

310 { 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 311 of file Layer.hpp.

311 { return m_InputSlots.at(index); }

◆ GetInputSlots()

const std::vector<InputSlot>& GetInputSlots ( ) const
inline

◆ GetName()

const char* GetName ( ) const
inlineoverridevirtual

Returns the name of the layer.

Implements IConnectableLayer.

Definition at line 305 of file Layer.hpp.

Referenced by AdditionLayer::Accept(), QuantizeLayer::Accept(), MinimumLayer::Accept(), MultiplicationLayer::Accept(), DivisionLayer::Accept(), MaximumLayer::Accept(), SubtractionLayer::Accept(), ActivationLayer::Accept(), AbsLayer::Accept(), NormalizationLayer::Accept(), DequantizeLayer::Accept(), FloorLayer::Accept(), InputLayer::Accept(), RsqrtLayer::Accept(), L2NormalizationLayer::Accept(), SoftmaxLayer::Accept(), InstanceNormalizationLayer::Accept(), SwitchLayer::Accept(), PadLayer::Accept(), GatherLayer::Accept(), LogSoftmaxLayer::Accept(), MeanLayer::Accept(), MergeLayer::Accept(), ArgMinMaxLayer::Accept(), DetectionPostProcessLayer::Accept(), ElementwiseUnaryLayer::Accept(), Pooling2dLayer::Accept(), ResizeLayer::Accept(), SliceLayer::Accept(), BatchToSpaceNdLayer::Accept(), StackLayer::Accept(), StridedSliceLayer::Accept(), PreluLayer::Accept(), SpaceToBatchNdLayer::Accept(), SpaceToDepthLayer::Accept(), DepthToSpaceLayer::Accept(), ComparisonLayer::Accept(), StandInLayer::Accept(), ConstantLayer::Accept(), BatchNormalizationLayer::Accept(), OutputLayer::Accept(), TransposeConvolution2dLayer::Accept(), FullyConnectedLayer::Accept(), DepthwiseConvolution2dLayer::Accept(), Convolution2dLayer::Accept(), ConcatLayer::Accept(), SplitterLayer::Accept(), ReshapeLayer::Accept(), TransposeLayer::Accept(), PermuteLayer::Accept(), QuantizedLstmLayer::Accept(), LstmLayer::Accept(), QLstmLayer::Accept(), Graph::AddCompatibilityLayers(), BOOST_AUTO_TEST_CASE(), armnnTfParser::CalcPadding(), QuantizeLayer::Clone(), ActivationLayer::Clone(), ConvertFp32ToFp16Layer::Clone(), RsqrtLayer::Clone(), NormalizationLayer::Clone(), StridedSliceLayer::Clone(), Pooling2dLayer::Clone(), AbsLayer::Clone(), FakeQuantizationLayer::Clone(), ConvertBf16ToFp32Layer::Clone(), StackLayer::Clone(), DequantizeLayer::Clone(), BatchToSpaceNdLayer::Clone(), ConvertFp16ToFp32Layer::Clone(), ResizeLayer::Clone(), ConvertFp32ToBf16Layer::Clone(), InputLayer::Clone(), SoftmaxLayer::Clone(), FloorLayer::Clone(), InstanceNormalizationLayer::Clone(), L2NormalizationLayer::Clone(), AdditionLayer::Clone(), DebugLayer::Clone(), SwitchLayer::Clone(), SliceLayer::Clone(), MemCopyLayer::Clone(), MemImportLayer::Clone(), MergeLayer::Clone(), ComparisonLayer::Clone(), MinimumLayer::Clone(), MultiplicationLayer::Clone(), ArgMinMaxLayer::Clone(), DivisionLayer::Clone(), StandInLayer::Clone(), PadLayer::Clone(), TransposeLayer::Clone(), MeanLayer::Clone(), DepthToSpaceLayer::Clone(), GatherLayer::Clone(), ElementwiseUnaryLayer::Clone(), PreluLayer::Clone(), SpaceToBatchNdLayer::Clone(), SpaceToDepthLayer::Clone(), LogSoftmaxLayer::Clone(), MaximumLayer::Clone(), SubtractionLayer::Clone(), ConstantLayer::Clone(), PermuteLayer::Clone(), ReshapeLayer::Clone(), PreCompiledLayer::Clone(), DetectionPostProcessLayer::Clone(), DepthwiseConvolution2dLayer::Clone(), FullyConnectedLayer::Clone(), TransposeConvolution2dLayer::Clone(), Convolution2dLayer::Clone(), ConcatLayer::Clone(), SplitterLayer::Clone(), BatchNormalizationLayer::Clone(), OutputLayer::Clone(), QuantizedLstmLayer::Clone(), LstmLayer::Clone(), QLstmLayer::Clone(), armnn::InsertConvertBf16ToFp32LayersBefore(), armnn::InsertConvertFp16ToFp32LayersBefore(), armnn::InsertConvertFp32ToBf16LayersAfter(), armnn::InsertConvertFp32ToBf16LayersBefore(), armnn::InsertConvertFp32ToFp16LayersAfter(), TransposeAsReshapeImpl::Run(), PermuteAsReshapeImpl::Run(), OptimizeConsecutiveReshapesImpl::Run(), PermuteAndBatchToSpaceAsDepthToSpaceImpl< PermuteType >::Run(), FoldPadIntoConvolution2dImpl::Run(), and ErasedLayerNamesObservable::Update().

305 { return m_LayerName.c_str(); }

◆ GetNameStr()

◆ GetNumInputSlots()

◆ GetNumOutputSlots()

◆ GetOutputHandler() [1/2]

◆ GetOutputHandler() [2/2]

OutputHandler& GetOutputHandler ( unsigned int  i = 0)
inline

Definition at line 226 of file Layer.hpp.

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

◆ 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 312 of file Layer.hpp.

Referenced by Graph::AddCompatibilityLayers(), BOOST_AUTO_TEST_CASE(), BOOST_FIXTURE_TEST_CASE(), armnnTfParser::CalcPadding(), OutputSlot::CalculateIndexOnOwner(), armnn::CheckScaleSetOnQuantizedType(), CreateConvolution2dGraph(), CreateDepthwiseConvolution2dGraph(), CreateGatherGraph(), CreatePooling2dGraph(), CreateResizeBilinearGraph(), ConcatLayer::CreateTensorHandles(), SplitterLayer::CreateTensorHandles(), Layer::CreateTensorHandles(), ConcatLayer::CreateWorkload(), SplitterLayer::CreateWorkload(), Layer::GetDataType(), InputSlot::Insert(), armnn::InsertConvertBf16ToFp32LayersBefore(), armnn::InsertConvertFp16ToFp32LayersBefore(), armnn::InsertConvertFp32ToBf16LayersAfter(), armnn::InsertConvertFp32ToBf16LayersBefore(), armnn::InsertConvertFp32ToFp16LayersAfter(), armnn::InsertDebugLayerAfter(), IsConnected(), IWorkloadFactory::IsLayerSupported(), PermuteAsReshapeImpl::Run(), TransposeAsReshapeImpl::Run(), OptimizeConsecutiveReshapesImpl::Run(), FoldPadIntoConvolution2dImpl::Run(), OptimizeInverseConversionsImpl::Run(), PermuteAndBatchToSpaceAsDepthToSpaceImpl< PermuteType >::Run(), MovePermuteUpImpl::Run(), MoveTransposeUpImpl::Run(), OptimizeInversePermutesImpl< PermuteType >::Run(), armnn::SelectTensorHandleStrategy(), ElementwiseBaseLayer::ValidateTensorShapesFromInputs(), QuantizeLayer::ValidateTensorShapesFromInputs(), ActivationLayer::ValidateTensorShapesFromInputs(), ConvertFp32ToFp16Layer::ValidateTensorShapesFromInputs(), SliceLayer::ValidateTensorShapesFromInputs(), InputLayer::ValidateTensorShapesFromInputs(), ConvertFp16ToFp32Layer::ValidateTensorShapesFromInputs(), L2NormalizationLayer::ValidateTensorShapesFromInputs(), ConvertFp32ToBf16Layer::ValidateTensorShapesFromInputs(), ConvertBf16ToFp32Layer::ValidateTensorShapesFromInputs(), MemCopyLayer::ValidateTensorShapesFromInputs(), NormalizationLayer::ValidateTensorShapesFromInputs(), BatchToSpaceNdLayer::ValidateTensorShapesFromInputs(), DebugLayer::ValidateTensorShapesFromInputs(), InstanceNormalizationLayer::ValidateTensorShapesFromInputs(), DequantizeLayer::ValidateTensorShapesFromInputs(), SoftmaxLayer::ValidateTensorShapesFromInputs(), FakeQuantizationLayer::ValidateTensorShapesFromInputs(), ResizeLayer::ValidateTensorShapesFromInputs(), RsqrtLayer::ValidateTensorShapesFromInputs(), AbsLayer::ValidateTensorShapesFromInputs(), MemImportLayer::ValidateTensorShapesFromInputs(), MergeLayer::ValidateTensorShapesFromInputs(), FloorLayer::ValidateTensorShapesFromInputs(), StackLayer::ValidateTensorShapesFromInputs(), SwitchLayer::ValidateTensorShapesFromInputs(), Pooling2dLayer::ValidateTensorShapesFromInputs(), MeanLayer::ValidateTensorShapesFromInputs(), LogSoftmaxLayer::ValidateTensorShapesFromInputs(), TransposeLayer::ValidateTensorShapesFromInputs(), GatherLayer::ValidateTensorShapesFromInputs(), ReshapeLayer::ValidateTensorShapesFromInputs(), ConstantLayer::ValidateTensorShapesFromInputs(), PermuteLayer::ValidateTensorShapesFromInputs(), StridedSliceLayer::ValidateTensorShapesFromInputs(), DetectionPostProcessLayer::ValidateTensorShapesFromInputs(), ArgMinMaxLayer::ValidateTensorShapesFromInputs(), ElementwiseUnaryLayer::ValidateTensorShapesFromInputs(), DepthToSpaceLayer::ValidateTensorShapesFromInputs(), TransposeConvolution2dLayer::ValidateTensorShapesFromInputs(), ComparisonLayer::ValidateTensorShapesFromInputs(), PreluLayer::ValidateTensorShapesFromInputs(), DepthwiseConvolution2dLayer::ValidateTensorShapesFromInputs(), FullyConnectedLayer::ValidateTensorShapesFromInputs(), SpaceToBatchNdLayer::ValidateTensorShapesFromInputs(), SpaceToDepthLayer::ValidateTensorShapesFromInputs(), Convolution2dLayer::ValidateTensorShapesFromInputs(), SplitterLayer::ValidateTensorShapesFromInputs(), BatchNormalizationLayer::ValidateTensorShapesFromInputs(), QuantizedLstmLayer::ValidateTensorShapesFromInputs(), LstmLayer::ValidateTensorShapesFromInputs(), and QLstmLayer::ValidateTensorShapesFromInputs().

312 { 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 313 of file Layer.hpp.

313 { return m_OutputSlots.at(index); }

◆ GetOutputSlots()

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

Definition at line 232 of file Layer.hpp.

Referenced by Graph::AddCompatibilityLayers(), armnn::ForEachLayerOutput(), and IWorkloadFactory::IsLayerSupported().

232 { return m_OutputSlots; }

◆ GetPriority()

LayerPriority GetPriority ( ) const

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

290 {
291  constexpr LayerPriority inputPrio = std::numeric_limits<LayerPriority>::lowest();
292  constexpr LayerPriority outputPrio = std::numeric_limits<LayerPriority>::max();
293 
294  if (GetType() == LayerType::Input)
295  {
296  m_Priority = inputPrio;
297  }
298  else if (GetType() == LayerType::Output)
299  {
300  m_Priority = outputPrio;
301  }
302  else if (m_Priority == 0)
303  {
304  if (m_Visiting)
305  {
306  throw GraphValidationException("Graph has circular dependencies: cannot walk");
307  }
308 
309  auto maxPrio = [](const LayerPriority prio, const InputSlot& slot) -> LayerPriority
310  {
311  const OutputSlot *outputSlot = slot.GetConnectedOutputSlot();
312  if (outputSlot)
313  {
314  const Layer& input = outputSlot->GetOwningLayer();
315  return std::max(prio, input.GetPriority());
316  }
317  else
318  {
319  // unconnected input slot
320  return prio;
321  }
322  };
323 
324  m_Visiting = true;
325  LayerPriority parentPrio = std::accumulate(GetInputSlots().cbegin(), GetInputSlots().cend(), 0U, maxPrio);
326  m_Visiting = false;
327 
328  if (parentPrio >= outputPrio)
329  {
330  throw GraphValidationException("Graph has too many edges");
331  }
332 
333  m_Priority = parentPrio + 1U;
334  }
335 
336  return m_Priority;
337 }
unsigned int LayerPriority
Definition: Layer.hpp:207
const std::vector< InputSlot > & GetInputSlots() const
Definition: Layer.hpp:231
Layer(unsigned int numInputSlots, unsigned int numOutputSlots, LayerType type, const char *name)
Definition: Layer.cpp:214
LayerType GetType() const
Definition: Layer.hpp:259

◆ GetRelatedLayerNames()

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

Definition at line 320 of file Layer.hpp.

Referenced by ErasedLayerNamesObservable::Update().

320 { return m_RelatedLayerNames; }

◆ GetType()

◆ 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, LstmLayer, QuantizedLstmLayer, SplitterLayer, ConcatLayer, Convolution2dLayer, DepthwiseConvolution2dLayer, FullyConnectedLayer, TransposeConvolution2dLayer, ConstantLayer, PermuteLayer, ReshapeLayer, StandInLayer, BatchToSpaceNdLayer, Pooling2dLayer, ResizeLayer, SliceLayer, StackLayer, TransposeLayer, MergeLayer, ComparisonLayer, DepthToSpaceLayer, PreluLayer, SpaceToBatchNdLayer, SpaceToDepthLayer, ArgMinMaxLayer, ElementwiseUnaryLayer, StridedSliceLayer, and ElementwiseBaseLayer.

Definition at line 372 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(), RsqrtLayer::ValidateTensorShapesFromInputs(), DequantizeLayer::ValidateTensorShapesFromInputs(), NormalizationLayer::ValidateTensorShapesFromInputs(), MemImportLayer::ValidateTensorShapesFromInputs(), MemCopyLayer::ValidateTensorShapesFromInputs(), SwitchLayer::ValidateTensorShapesFromInputs(), L2NormalizationLayer::ValidateTensorShapesFromInputs(), AbsLayer::ValidateTensorShapesFromInputs(), FloorLayer::ValidateTensorShapesFromInputs(), FakeQuantizationLayer::ValidateTensorShapesFromInputs(), DebugLayer::ValidateTensorShapesFromInputs(), ConvertBf16ToFp32Layer::ValidateTensorShapesFromInputs(), ConvertFp32ToBf16Layer::ValidateTensorShapesFromInputs(), InstanceNormalizationLayer::ValidateTensorShapesFromInputs(), ConvertFp16ToFp32Layer::ValidateTensorShapesFromInputs(), SoftmaxLayer::ValidateTensorShapesFromInputs(), LogSoftmaxLayer::ValidateTensorShapesFromInputs(), and BatchNormalizationLayer::ValidateTensorShapesFromInputs().

373 {
376 
377  // By default we return what we got, meaning the output shape(s) are the same as the input(s).
378  // This only works if the number of inputs and outputs are the same. Since we are in the Layer
379  // base class, this means the implementation needs to be overridden in the specific layers for
380  // the other cases. So the missing implementation justifies the UnimplementedException.
381 
383  {
384  throw UnimplementedException(
385  boost::str(
386  boost::format(
387  "Default implementation for InferOutputShapes can only be used for "
388  "layers with the same number of input and output slots. This doesn't "
389  "hold for %1% layer %2% (#inputs=%3% #outputs=%4%) %5%")
390  % GetLayerTypeAsCString(this->GetType())
391  % GetNameStr()
392  % GetNumInputSlots()
394  % CHECK_LOCATION().AsString()));
395  }
396  return inputShapes;
397 }
unsigned int GetNumInputSlots() const override
Returns the number of connectable input slots.
Definition: Layer.hpp:307
unsigned int GetNumOutputSlots() const override
Returns the number of connectable output slots.
Definition: Layer.hpp:308
char const * GetLayerTypeAsCString(LayerType type)
const std::string & GetNameStr() const
Definition: Layer.hpp:216
#define ARMNN_ASSERT(COND)
Definition: Assert.hpp:14
#define CHECK_LOCATION()
Definition: Exceptions.hpp:192
LayerType GetType() const
Definition: Layer.hpp:259

◆ IsOutputUnconnected()

bool IsOutputUnconnected ( )
inline

Definition at line 243 of file Layer.hpp.

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

244  {
245  unsigned int numConnections = 0;
246 
247  for (auto&& output : GetOutputSlots())
248  {
249  numConnections += output.GetNumConnections();
250  }
251 
252  return (GetNumOutputSlots() > 0) && (numConnections == 0);
253  }
unsigned int GetNumOutputSlots() const override
Returns the number of connectable output slots.
Definition: Layer.hpp:308
const std::vector< OutputSlot > & GetOutputSlots() const
Definition: Layer.hpp:232

◆ OperateOnConstantTensors()

void OperateOnConstantTensors ( Op  op)
inline

Definition at line 292 of file Layer.hpp.

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

293  {
294  for (auto constant : GetConstantTensorsByRef())
295  {
296  if (constant.get())
297  {
298  op(constant);
299  }
300  }
301  };
virtual ConstantTensors GetConstantTensorsByRef()
Definition: Layer.hpp:364

◆ PrepInfoAndDesc()

WorkloadInfo PrepInfoAndDesc ( QueueDescriptor descriptor) const
inlineprotected

Helper function to reduce duplication in *LayerCreateWorkload.

Definition at line 351 of file Layer.hpp.

References armnn::info.

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

352  {
353  WorkloadInfo info;
354  CollectQueueDescriptorInputs(descriptor, info);
355  CollectQueueDescriptorOutputs(descriptor, info);
356  return info;
357  }
void CollectQueueDescriptorInputs(QueueDescriptor &descriptor, WorkloadInfo &info) const
Definition: Layer.hpp:336
void CollectQueueDescriptorOutputs(QueueDescriptor &descriptor, WorkloadInfo &info) const
Definition: Layer.hpp:343

◆ ReleaseConstantData()

void ReleaseConstantData ( )
virtual

Reimplemented in ConstantLayer.

Definition at line 265 of file Layer.cpp.

References Layer::OperateOnConstantTensors().

Referenced by BOOST_AUTO_TEST_CASE().

266 {
267  // Now free up the static data.
268  OperateOnConstantTensors([](std::unique_ptr<ScopedCpuTensorHandle>& handle)
269  {
270  handle.reset(nullptr);
271  });
272 }
void OperateOnConstantTensors(Op op)
Definition: Layer.hpp:292

◆ Reparent()

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

◆ ResetPriority()

void ResetPriority ( ) const

Definition at line 283 of file Layer.cpp.

284 {
285  m_Priority = 0;
286  m_Visiting = false;
287 }

◆ 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, LayerWithParameters< Parameters >, LayerWithParameters< FakeQuantizationDescriptor >, LayerWithParameters< SoftmaxDescriptor >, LayerWithParameters< LstmDescriptor >, LayerWithParameters< LogSoftmaxDescriptor >, LayerWithParameters< PreCompiledDescriptor >, LayerWithParameters< BatchToSpaceNdDescriptor >, LayerWithParameters< PermuteDescriptor >, LayerWithParameters< SpaceToBatchNdDescriptor >, LayerWithParameters< DepthToSpaceDescriptor >, LayerWithParameters< ReshapeDescriptor >, LayerWithParameters< ElementwiseUnaryDescriptor >, 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< DetectionPostProcessDescriptor >, LayerWithParameters< PadDescriptor >, LayerWithParameters< L2NormalizationDescriptor >, LayerWithParameters< SliceDescriptor >, LayerWithParameters< DepthwiseConvolution2dDescriptor >, LayerWithParameters< QLstmDescriptor >, LayerWithParameters< NormalizationDescriptor >, LayerWithParameters< FullyConnectedDescriptor >, LayerWithParameters< StridedSliceDescriptor >, and LayerWithParameters< ResizeDescriptor >.

Definition at line 399 of file Layer.cpp.

References armnn::GetLayerTypeAsCString().

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

400 {
401  std::string layerType = GetLayerTypeAsCString(m_Type);
402  std::string backendId = std::string(m_BackendId);
403  if(!(m_LayerName.compare("") == 0) && !m_LayerName.empty())
404  {
405  fn("LayerName",m_LayerName);
406  }
407  if(!(layerType.compare("") == 0) && !layerType.empty())
408  {
409  fn("LayerType",layerType);
410  }
411  if(!(backendId.compare("") == 0) && !backendId.empty())
412  {
413  fn("BackendID",backendId);
414  }
415 }
char const * GetLayerTypeAsCString(LayerType type)

◆ SetBackendId()

void SetBackendId ( const BackendId id)
inline

◆ SetGuid()

void SetGuid ( LayerGuid  guid)
inline

Definition at line 315 of file Layer.hpp.

315 { m_Guid = guid; }

◆ ValidateTensorShapesFromInputs()

◆ VerifyLayerConnections()

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

Definition at line 339 of file Layer.cpp.

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

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

340 {
341  ARMNN_ASSERT(GetNumInputSlots() == expectedConnections);
342 
343  for (unsigned int i=0; i<expectedConnections; ++i)
344  {
345  if (GetInputSlot(i).GetConnection() == nullptr)
346  {
347  throw LayerValidationException(
348  boost::str(
349  boost::format(
350  "Input connection #%1% must be connected "
351  "for %2% layer %3% %4%")
352  % i
353  % GetLayerTypeAsCString(this->GetType())
354  % GetNameStr()
355  % location.AsString()));
356  }
357  if(! GetInputSlot(i).GetConnection()->IsTensorInfoSet())
358  {
359  throw LayerValidationException(
360  boost::str(
361  boost::format(
362  "TensorInfo of Input connection #%1% must be set on connected OutputSlot for "
363  "%2% layer %3% %4%")
364  % i
365  % GetLayerTypeAsCString(this->GetType())
366  % GetNameStr()
367  % location.AsString()));
368  }
369  }
370 }
unsigned int GetNumInputSlots() const override
Returns the number of connectable input slots.
Definition: Layer.hpp:307
const InputSlot & GetInputSlot(unsigned int index) const override
Get a const input slot handle by slot index.
Definition: Layer.hpp:310
char const * GetLayerTypeAsCString(LayerType type)
const std::string & GetNameStr() const
Definition: Layer.hpp:216
#define ARMNN_ASSERT(COND)
Definition: Assert.hpp:14
LayerType GetType() const
Definition: Layer.hpp:259

Friends And Related Function Documentation

◆ Graph

friend class Graph
friend

Definition at line 332 of file Layer.hpp.

Member Data Documentation

◆ m_OutputHandlers

std::vector<OutputHandler> m_OutputHandlers
protected

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