ArmNN
 22.11
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.

References InputSlot::~InputSlot().

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

◆ ~InputSlot()

~InputSlot ( )
inline

Definition at line 186 of file Layer.hpp.

Referenced by InputSlot::InputSlot().

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 }
void Disconnect(InputSlot &slot)
Definition: Layer.cpp:120

Member Function Documentation

◆ GetConnectedOutputSlot() [1/2]

◆ GetConnectedOutputSlot() [2/2]

OutputSlot* GetConnectedOutputSlot ( )
inline

Definition at line 57 of file Layer.hpp.

References InputSlot::GetOwningIConnectableLayer().

57 { return m_Connection; }

◆ GetConnection() [1/2]

const IOutputSlot * GetConnection ( ) const
inlineoverridevirtual

Implements IInputSlot.

Definition at line 206 of file Layer.hpp.

References InputSlot::GetConnectedOutputSlot().

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

206 { return GetConnectedOutputSlot(); }
const OutputSlot * GetConnectedOutputSlot() const
Definition: Layer.hpp:56

◆ GetConnection() [2/2]

IOutputSlot * GetConnection ( )
inlineoverridevirtual

Implements IInputSlot.

Definition at line 207 of file Layer.hpp.

References InputSlot::GetConnectedOutputSlot().

207 { return GetConnectedOutputSlot(); }
const OutputSlot * GetConnectedOutputSlot() const
Definition: Layer.hpp:56

◆ GetOwningIConnectableLayer() [1/2]

const IConnectableLayer & GetOwningIConnectableLayer ( ) const
overridevirtual

Implements IInputSlot.

Definition at line 551 of file Layer.cpp.

Referenced by InputSlot::GetConnectedOutputSlot(), and OutputSlot::GetOwningLayer().

552 {
553  return m_OwningLayer;
554 }

◆ GetOwningIConnectableLayer() [2/2]

IConnectableLayer & GetOwningIConnectableLayer ( )
overridevirtual

Implements IInputSlot.

Definition at line 556 of file Layer.cpp.

557 {
558  return m_OwningLayer;
559 }

◆ GetOwningLayer()

◆ GetSlotIndex()

unsigned int GetSlotIndex ( ) const
inlineoverridevirtual

Implements IInputSlot.

Definition at line 54 of file Layer.hpp.

Referenced by Graph::AddCompatibilityLayers().

54 { return m_SlotIndex; }

◆ Insert()

void Insert ( Layer layer)

Definition at line 48 of file Layer.cpp.

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

Referenced by Graph::InsertNewLayer(), and InputSlot::SetConnection().

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 }
void AssertNumberOfInputSlots(Layer &layer)
Definition: Layer.cpp:28
#define ARMNN_ASSERT(COND)
Definition: Assert.hpp:14
const OutputSlot * GetConnectedOutputSlot() const
Definition: Layer.hpp:56

◆ 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.

References InputSlot::GetConnection(), and InputSlot::Insert().

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

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  }

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