ArmNN
 25.11
Loading...
Searching...
No Matches
InputSlot Class Referencefinal

#include <Layer.hpp>

Inheritance diagram for InputSlot:
[legend]
Collaboration diagram for InputSlot:
[legend]

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.
void Insert (Layer &layer)
const IOutputSlotGetConnection () const override
IOutputSlotGetConnection () override
void SetTensorInfo (const TensorInfo tensorInfo) override
 Sets the TensorInfo for this InputSlot.
const TensorInfoGetTensorInfo () const override
 Gets the TensorInfo for this InputSlot.
bool IsTensorInfoSet () const override
 Returns true if this InputSlot either has an overridden TensorInfo for this InputSlot that was set through a call to SetTensorInfo() or is Connected to an OutputSlot that has its TensorInfo set.
bool IsTensorInfoOverridden () const override
 Returns true if this InputSlot has an overridden TensorInfo that was set through a call to SetTensorInfo().

Additional Inherited Members

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

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

200{
201 if (m_Connection != nullptr)
202 {
203 try
204 {
205 // Coverity fix: Disconnect() may throw uncaught exceptions.
206 m_Connection->Disconnect(*this);
207 }
208 catch (const std::exception& e)
209 {
210 // Coverity fix: BOOST_LOG_TRIVIAL (typically used to report errors) may throw an
211 // exception of type std::length_error.
212 // Using stderr instead in this context as there is no point in nesting try-catch blocks here.
213 std::cerr << "WARNING: An error has occurred when disconnecting an input slot: "
214 << e.what() << std::endl;
215 }
216 }
217}

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

Definition at line 56 of file Layer.hpp.

56{ return m_Connection; }

Referenced by armnn::BuildAddMulAddTensorInfoLists(), armnn::ConnectedToLayerType(), armnn::ConnectedToLayerWithNCHW(), ConvertSquaredDifferenceToTosaOperator(), DebugLayer::CreateWorkload(), armnn::optimizations::pad_fold::FoldPadIntoLayer2dImpl(), GenerateUniqueInputName(), LayerWithParameters< Parameters >::GetConnectedConstantAsInputTensors(), GetConnection(), GetConnection(), armnn::GetLayerInOutDatatype(), Insert(), armnn::InsertConvertFp16ToFp32LayersBefore(), armnn::InsertConvertFp32ToFp16LayersAfter(), armnn::InsertDebugLayerAfter(), Graph::InsertNewLayer(), ClBackend::OptimizeSubgraphView(), NeonBackend::OptimizeSubgraphView(), RefBackend::OptimizeSubgraphView(), armnn::RemoveReshapeLayer(), AddBroadcastReshapeLayerImpl::Run(), ConvertConstDequantisationLayersToConstLayersImpl::Run(), ConvertConstPermuteLayersToConstLayers::Run(), FuseBatchNorm< ConvLayer, ArmnnType, T >::Run(), MaxMinIntoBoundedReluImpl::Run(), MovePermuteUpImpl::Run(), MoveTransposeUpImpl::Run(), OptimizeConsecutiveReshapesImpl::Run(), OptimizeInverseConversionsImpl::Run(), OptimizeInversePermutesImpl< PermuteType >::Run(), PermuteAndBatchToSpaceAsDepthToSpaceImpl< PermuteType >::Run(), SquashEqualSiblingsImpl< Comparable >::Run(), TurboConvertConstDequantisationLayersToConstLayersImpl::Run(), ConvertConstDequantisationLayersToConstLayersImpl::~ConvertConstDequantisationLayersToConstLayersImpl(), PermuteDepthwiseConv2dWeightsImpl::~PermuteDepthwiseConv2dWeightsImpl(), and TurboConvertConstDequantisationLayersToConstLayersImpl::~TurboConvertConstDequantisationLayersToConstLayersImpl().

◆ GetConnection() [1/2]

const IOutputSlot * GetConnection ( ) const
inlineoverridevirtual

Implements IInputSlot.

Definition at line 219 of file Layer.hpp.

219{ return GetConnectedOutputSlot(); }

References GetConnectedOutputSlot().

Referenced by GetTensorInfo(), and IsTensorInfoSet().

◆ GetConnection() [2/2]

IOutputSlot * GetConnection ( )
inlineoverridevirtual

Implements IInputSlot.

Definition at line 220 of file Layer.hpp.

220{ return GetConnectedOutputSlot(); }

References GetConnectedOutputSlot().

◆ GetOwningIConnectableLayer() [1/2]

const IConnectableLayer & GetOwningIConnectableLayer ( ) const
overridevirtual

Implements IInputSlot.

Definition at line 599 of file Layer.cpp.

600{
601 return m_OwningLayer;
602}

◆ GetOwningIConnectableLayer() [2/2]

IConnectableLayer & GetOwningIConnectableLayer ( )
overridevirtual

Implements IInputSlot.

Definition at line 604 of file Layer.cpp.

605{
606 return m_OwningLayer;
607}

◆ 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(), GetTosaMapping(), and armnn::RemoveReshapeLayer().

◆ GetTensorInfo()

const TensorInfo & GetTensorInfo ( ) const
overridevirtual

Gets the TensorInfo for this InputSlot.

If the InputSlot's TensorInfo has not been set then this will get the TensorInfo from the Connected TensorInfo.

Implements IInputSlot.

Definition at line 614 of file Layer.cpp.

615{
616 if (m_OverriddenTensorInfo.has_value())
617 {
618 return m_OverriddenTensorInfo.value();
619 }
620 else
621 {
622 return GetConnection()->GetTensorInfo();
623 }
624}

References GetConnection(), and IOutputSlot::GetTensorInfo().

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

◆ Insert()

void Insert ( Layer & layer)

Definition at line 53 of file Layer.cpp.

54{
55 if (layer.GetNumOutputSlots() != 1)
56 {
57 throw armnn::Exception("layer must have one output slot.");
58 }
59
60 OutputSlot* const prevSlot = GetConnectedOutputSlot();
61
62 if (prevSlot != nullptr)
63 {
64 // Disconnects parent from this.
65 prevSlot->Disconnect(*this);
66
68
69 // Connects inserted layer to parent.
70 int idx = prevSlot->Connect(layer.GetInputSlot(0));
71 prevSlot->SetEdgeStrategy(armnn::numeric_cast<unsigned int>(idx), EdgeStrategy::Undefined);
72
73 // Sets tensor info for inserted layer.
74 const TensorInfo& tensorInfo = prevSlot->GetTensorInfo();
75 layer.GetOutputHandler().SetTensorInfo(tensorInfo);
76 }
77
78 // Connects inserted layer to this.
79 layer.GetOutputSlot(0).Connect(*this);
80 layer.GetOutputSlot(0).SetEdgeStrategy(0, EdgeStrategy::Undefined);
81}
void AssertNumberOfInputSlots(Layer &layer)
Definition Layer.cpp:28
std::enable_if_t< std::is_unsigned< Source >::value &&std::is_unsigned< Dest >::value, Dest > numeric_cast(Source source)

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

Referenced by Graph::InsertNewLayer().

◆ IsTensorInfoOverridden()

bool IsTensorInfoOverridden ( ) const
overridevirtual

Returns true if this InputSlot has an overridden TensorInfo that was set through a call to SetTensorInfo().

Implements IInputSlot.

Definition at line 631 of file Layer.cpp.

632{
633 return m_OverriddenTensorInfo.has_value();
634}

◆ IsTensorInfoSet()

bool IsTensorInfoSet ( ) const
overridevirtual

Returns true if this InputSlot either has an overridden TensorInfo for this InputSlot that was set through a call to SetTensorInfo() or is Connected to an OutputSlot that has its TensorInfo set.

Implements IInputSlot.

Definition at line 626 of file Layer.cpp.

627{
628 return m_OverriddenTensorInfo.has_value() || (GetConnection() && GetConnection()->IsTensorInfoSet());
629}

References GetConnection(), and IOutputSlot::IsTensorInfoSet().

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

◆ SetTensorInfo()

void SetTensorInfo ( const TensorInfo tensorInfo)
overridevirtual

Sets the TensorInfo for this InputSlot.

This can be used to override the TensorInfo and if set will be returned instead of the TensorInfo for the Connected OutputSlot.

Implements IInputSlot.

Definition at line 609 of file Layer.cpp.

610{
611 m_OverriddenTensorInfo = Optional<TensorInfo>(tensorInfo);
612}

Referenced by armnn::RemoveReshapeLayer().


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