ArmNN
 20.02
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
 
const OutputSlotGetConnectedOutputSlot () const
 
OutputSlotGetConnectedOutputSlot ()
 
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 41 of file Layer.hpp.

Constructor & Destructor Documentation

◆ InputSlot()

InputSlot ( Layer owner,
unsigned int  slotIndex 
)
inlineexplicit

Definition at line 44 of file Layer.hpp.

References InputSlot::~InputSlot().

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

◆ ~InputSlot()

~InputSlot ( )
inline

Definition at line 179 of file Layer.hpp.

Referenced by InputSlot::InputSlot().

180 {
181  if (m_Connection != nullptr)
182  {
183  try
184  {
185  // Coverity fix: Disconnect() may throw uncaught exceptions.
186  m_Connection->Disconnect(*this);
187  }
188  catch (const std::exception& e)
189  {
190  // Coverity fix: BOOST_LOG_TRIVIAL (typically used to report errors) may throw an
191  // exception of type std::length_error.
192  // Using stderr instead in this context as there is no point in nesting try-catch blocks here.
193  std::cerr << "WARNING: An error has occurred when disconnecting an input slot: "
194  << e.what() << std::endl;
195  }
196  }
197 }
void Disconnect(InputSlot &slot)
Definition: Layer.cpp:87

Member Function Documentation

◆ GetConnectedOutputSlot() [1/2]

◆ GetConnectedOutputSlot() [2/2]

OutputSlot* GetConnectedOutputSlot ( )
inline

Definition at line 56 of file Layer.hpp.

56 { return m_Connection; }

◆ GetConnection() [1/2]

const IOutputSlot * GetConnection ( ) const
inlineoverridevirtual

Implements IInputSlot.

Definition at line 199 of file Layer.hpp.

References InputSlot::GetConnectedOutputSlot().

Referenced by BOOST_AUTO_TEST_CASE(), OutputSlot::DisconnectAll(), Layer::GetDataType(), OutputSlot::GetNumConnections(), IWorkloadFactory::IsLayerSupported(), OutputSlot::MoveAllConnections(), OutputSlot::operator==(), PermuteAndBatchToSpaceAsDepthToSpaceImpl< PermuteType >::Run(), DepthwiseConvolution2dLayer::SerializeLayerParameters(), Convolution2dLayer::SerializeLayerParameters(), InputSlot::SetConnection(), Graph::SubstituteSubgraph(), ElementwiseBaseLayer::ValidateTensorShapesFromInputs(), QuantizeLayer::ValidateTensorShapesFromInputs(), ActivationLayer::ValidateTensorShapesFromInputs(), TransposeLayer::ValidateTensorShapesFromInputs(), StackLayer::ValidateTensorShapesFromInputs(), AbsLayer::ValidateTensorShapesFromInputs(), MemCopyLayer::ValidateTensorShapesFromInputs(), MemImportLayer::ValidateTensorShapesFromInputs(), DebugLayer::ValidateTensorShapesFromInputs(), MergeLayer::ValidateTensorShapesFromInputs(), NormalizationLayer::ValidateTensorShapesFromInputs(), PermuteLayer::ValidateTensorShapesFromInputs(), SliceLayer::ValidateTensorShapesFromInputs(), SoftmaxLayer::ValidateTensorShapesFromInputs(), Pooling2dLayer::ValidateTensorShapesFromInputs(), ResizeLayer::ValidateTensorShapesFromInputs(), L2NormalizationLayer::ValidateTensorShapesFromInputs(), RsqrtLayer::ValidateTensorShapesFromInputs(), DequantizeLayer::ValidateTensorShapesFromInputs(), BatchToSpaceNdLayer::ValidateTensorShapesFromInputs(), FakeQuantizationLayer::ValidateTensorShapesFromInputs(), SwitchLayer::ValidateTensorShapesFromInputs(), FloorLayer::ValidateTensorShapesFromInputs(), InstanceNormalizationLayer::ValidateTensorShapesFromInputs(), ConvertFp32ToFp16Layer::ValidateTensorShapesFromInputs(), MeanLayer::ValidateTensorShapesFromInputs(), ConvertFp16ToFp32Layer::ValidateTensorShapesFromInputs(), GatherLayer::ValidateTensorShapesFromInputs(), LogSoftmaxLayer::ValidateTensorShapesFromInputs(), ArgMinMaxLayer::ValidateTensorShapesFromInputs(), ElementwiseUnaryLayer::ValidateTensorShapesFromInputs(), StridedSliceLayer::ValidateTensorShapesFromInputs(), DepthToSpaceLayer::ValidateTensorShapesFromInputs(), ComparisonLayer::ValidateTensorShapesFromInputs(), SpaceToDepthLayer::ValidateTensorShapesFromInputs(), PreluLayer::ValidateTensorShapesFromInputs(), FullyConnectedLayer::ValidateTensorShapesFromInputs(), DepthwiseConvolution2dLayer::ValidateTensorShapesFromInputs(), TransposeConvolution2dLayer::ValidateTensorShapesFromInputs(), SpaceToBatchNdLayer::ValidateTensorShapesFromInputs(), Convolution2dLayer::ValidateTensorShapesFromInputs(), BatchNormalizationLayer::ValidateTensorShapesFromInputs(), OutputLayer::ValidateTensorShapesFromInputs(), QuantizedLstmLayer::ValidateTensorShapesFromInputs(), and LstmLayer::ValidateTensorShapesFromInputs().

199 { return GetConnectedOutputSlot(); }
const OutputSlot * GetConnectedOutputSlot() const
Definition: Layer.hpp:55

◆ GetConnection() [2/2]

IOutputSlot * GetConnection ( )
inlineoverridevirtual

Implements IInputSlot.

Definition at line 200 of file Layer.hpp.

References InputSlot::GetConnectedOutputSlot().

200 { return GetConnectedOutputSlot(); }
const OutputSlot * GetConnectedOutputSlot() const
Definition: Layer.hpp:55

◆ GetOwningLayer()

◆ GetSlotIndex()

unsigned int GetSlotIndex ( ) const
inline

Definition at line 53 of file Layer.hpp.

Referenced by Graph::AddCompatibilityLayers().

53 { return m_SlotIndex; }

◆ Insert()

void Insert ( Layer layer)

Definition at line 20 of file Layer.cpp.

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

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

21 {
22  BOOST_ASSERT(layer.GetNumOutputSlots() == 1);
23 
24  OutputSlot* const prevSlot = GetConnectedOutputSlot();
25 
26  if (prevSlot != nullptr)
27  {
28  // Disconnects parent from this.
29  prevSlot->Disconnect(*this);
30 
31  // Connects inserted layer to parent.
32  BOOST_ASSERT(layer.GetNumInputSlots() == 1);
33  int idx = prevSlot->Connect(layer.GetInputSlot(0));
34  prevSlot->SetEdgeStrategy(boost::numeric_cast<unsigned int>(idx), EdgeStrategy::Undefined);
35 
36  // Sets tensor info for inserted layer.
37  const TensorInfo& tensorInfo = prevSlot->GetTensorInfo();
38  layer.GetOutputHandler().SetTensorInfo(tensorInfo);
39  }
40 
41  // Connects inserted layer to this.
42  layer.GetOutputSlot(0).Connect(*this);
43  layer.GetOutputSlot(0).SetEdgeStrategy(0, EdgeStrategy::Undefined);
44 }
const OutputSlot * GetConnectedOutputSlot() const
Definition: Layer.hpp:55

◆ SetConnection()

void SetConnection ( OutputSlot source)
inline

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

Definition at line 59 of file Layer.hpp.

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

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

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

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