ArmNN
 23.05
InputSlot Class Referencefinal

#include <Layer.hpp>

Inheritance diagram for InputSlot:
IInputSlot

Public Member Functions

 InputSlot (Layer &owner, unsigned int slotIndex)
 
 ~InputSlot ()
 
LayerGetOwningLayer () const
 
unsigned int GetSlotIndex () const override
 
const OutputSlotGetConnectedOutputSlot () const
 
OutputSlotGetConnectedOutputSlot ()
 
const IConnectableLayerGetOwningIConnectableLayer () const override
 
IConnectableLayerGetOwningIConnectableLayer () override
 
void SetConnection (OutputSlot *source)
 Links the slot to an output slot or breaks an existing link if passing nullptr. More...
 
void Insert (Layer &layer)
 
const IOutputSlotGetConnection () const override
 
IOutputSlotGetConnection () override
 

Additional Inherited Members

- Protected Member Functions inherited from IInputSlot
 ~IInputSlot ()
 Not user deletable. More...
 

Detailed Description

Definition at line 42 of file Layer.hpp.

Constructor & Destructor Documentation

◆ InputSlot()

InputSlot ( Layer owner,
unsigned int  slotIndex 
)
inlineexplicit

Definition at line 45 of file Layer.hpp.

46  : m_OwningLayer(owner)
47  , m_Connection(nullptr)
48  , m_SlotIndex(slotIndex)
49  {}

◆ ~InputSlot()

~InputSlot ( )
inline

Definition at line 186 of file Layer.hpp.

187 {
188  if (m_Connection != nullptr)
189  {
190  try
191  {
192  // Coverity fix: Disconnect() may throw uncaught exceptions.
193  m_Connection->Disconnect(*this);
194  }
195  catch (const std::exception& e)
196  {
197  // Coverity fix: BOOST_LOG_TRIVIAL (typically used to report errors) may throw an
198  // exception of type std::length_error.
199  // Using stderr instead in this context as there is no point in nesting try-catch blocks here.
200  std::cerr << "WARNING: An error has occurred when disconnecting an input slot: "
201  << e.what() << std::endl;
202  }
203  }
204 }

References OutputSlot::Disconnect().

Member Function Documentation

◆ GetConnectedOutputSlot() [1/2]

OutputSlot* GetConnectedOutputSlot ( )
inline

Definition at line 57 of file Layer.hpp.

57 { return m_Connection; }

◆ GetConnectedOutputSlot() [2/2]

const OutputSlot* GetConnectedOutputSlot ( ) const
inline

◆ GetConnection() [1/2]

IOutputSlot * GetConnection ( ) const
inlineoverridevirtual

Implements IInputSlot.

Definition at line 206 of file Layer.hpp.

206 { return GetConnectedOutputSlot(); }

References InputSlot::GetConnectedOutputSlot().

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

◆ GetConnection() [2/2]

IOutputSlot* GetConnection ( )
overridevirtual

Implements IInputSlot.

◆ GetOwningIConnectableLayer() [1/2]

IConnectableLayer & GetOwningIConnectableLayer ( ) const
overridevirtual

Implements IInputSlot.

Definition at line 564 of file Layer.cpp.

565 {
566  return m_OwningLayer;
567 }

◆ GetOwningIConnectableLayer() [2/2]

IConnectableLayer& GetOwningIConnectableLayer ( )
overridevirtual

Implements IInputSlot.

◆ GetOwningLayer()

◆ GetSlotIndex()

unsigned int GetSlotIndex ( ) const
inlineoverridevirtual

Implements IInputSlot.

Definition at line 54 of file Layer.hpp.

54 { return m_SlotIndex; }

Referenced by Graph::AddCompatibilityLayers().

◆ Insert()

void Insert ( Layer layer)

Definition at line 48 of file Layer.cpp.

49 {
50  ARMNN_ASSERT(layer.GetNumOutputSlots() == 1);
51 
52  OutputSlot* const prevSlot = GetConnectedOutputSlot();
53 
54  if (prevSlot != nullptr)
55  {
56  // Disconnects parent from this.
57  prevSlot->Disconnect(*this);
58 
60 
61  // Connects inserted layer to parent.
62  int idx = prevSlot->Connect(layer.GetInputSlot(0));
63  prevSlot->SetEdgeStrategy(armnn::numeric_cast<unsigned int>(idx), EdgeStrategy::Undefined);
64 
65  // Sets tensor info for inserted layer.
66  const TensorInfo& tensorInfo = prevSlot->GetTensorInfo();
67  layer.GetOutputHandler().SetTensorInfo(tensorInfo);
68  }
69 
70  // Connects inserted layer to this.
71  layer.GetOutputSlot(0).Connect(*this);
72  layer.GetOutputSlot(0).SetEdgeStrategy(0, EdgeStrategy::Undefined);
73 }

References ARMNN_ASSERT, armnn::AssertNumberOfInputSlots(), OutputSlot::Connect(), OutputSlot::Disconnect(), InputSlot::GetConnectedOutputSlot(), Layer::GetInputSlot(), Layer::GetNumOutputSlots(), Layer::GetOutputHandler(), Layer::GetOutputSlot(), OutputSlot::GetTensorInfo(), OutputSlot::SetEdgeStrategy(), OutputHandler::SetTensorInfo(), and armnn::Undefined.

Referenced by Graph::InsertNewLayer().

◆ SetConnection()

void SetConnection ( OutputSlot source)
inline

Links the slot to an output slot or breaks an existing link if passing nullptr.

Definition at line 63 of file Layer.hpp.

64  {
65  if (m_Connection != nullptr && source != nullptr)
66  {
67  throw InvalidArgumentException("Tried to connect an output slot to an input slot, "
68  "but the latter already has a connection");
69  }
70  m_Connection = source;
71  }

Referenced by OutputSlot::Connect(), and OutputSlot::Disconnect().


The documentation for this class was generated from the following files:
armnn::EdgeStrategy::Undefined
@ Undefined
armnn::InputSlot::GetConnectedOutputSlot
const OutputSlot * GetConnectedOutputSlot() const
Definition: Layer.hpp:56
armnn::AssertNumberOfInputSlots
void AssertNumberOfInputSlots(Layer &layer)
Definition: Layer.cpp:28
ARMNN_ASSERT
#define ARMNN_ASSERT(COND)
Definition: Assert.hpp:14
armnn::OutputSlot::Disconnect
void Disconnect(InputSlot &slot)
Definition: Layer.cpp:120