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

#include <Layer.hpp>

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

Public Member Functions

 OutputSlot (Layer &owner, OutputHandler &outputHandler)
 OutputSlot (const OutputSlot &)=delete
OutputSlotoperator= (const OutputSlot &)=delete
OutputSlotoperator= (OutputSlot &&)=delete
 OutputSlot (OutputSlot &&)=default
 ~OutputSlot ()
LayerGetOwningLayer () const
const IConnectableLayerGetOwningIConnectableLayer () const override
IConnectableLayerGetOwningIConnectableLayer () override
LayerGuid GetOwningLayerGuid () const override
const OutputHandlerGetOutputHandler () const
OutputHandlerGetOutputHandler ()
int Connect (InputSlot &destination)
void Disconnect (InputSlot &slot)
const std::vector< InputSlot * > & GetConnections () const
const std::vector< EdgeStrategy > & GetEdgeStrategies () const
bool ValidateTensorShape (const TensorShape &shape) const
void DisconnectAll ()
void MoveAllConnections (OutputSlot &destination)
 Moves all connections to another OutputSlot.
unsigned int GetNumConnections () const override
const InputSlotGetConnection (unsigned int index) const override
InputSlotGetConnection (unsigned int index) override
void SetTensorInfo (const TensorInfo &tensorInfo) override
const TensorInfoGetTensorInfo () const override
bool IsTensorInfoSet () const override
int Connect (IInputSlot &destination) override
void Disconnect (IInputSlot &slot) override
unsigned int CalculateIndexOnOwner () const override
bool operator== (const OutputSlot &other) const
void SetTensorHandleFactory (const ITensorHandleFactory::FactoryId &id)
ITensorHandleFactory::FactoryId GetTensorHandleFactoryId () const
void SetEdgeStrategy (unsigned int connectionIndex, EdgeStrategy strategy)
EdgeStrategy GetEdgeStrategyForConnection (unsigned int connectionIdx) const

Additional Inherited Members

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

Detailed Description

Definition at line 100 of file Layer.hpp.

Constructor & Destructor Documentation

◆ OutputSlot() [1/3]

OutputSlot ( Layer & owner,
OutputHandler & outputHandler )
inlineexplicit

Definition at line 103 of file Layer.hpp.

104 : m_OwningLayer(owner)
105 , m_OutputHandler(outputHandler)
106 , m_TensorHandleFactoryId(ITensorHandleFactory::LegacyFactoryId)
107 {}

Referenced by MoveAllConnections(), operator=(), operator=(), operator==(), OutputSlot(), and OutputSlot().

◆ OutputSlot() [2/3]

OutputSlot ( const OutputSlot & )
delete

References OutputSlot().

◆ OutputSlot() [3/3]

OutputSlot ( OutputSlot && )
default

References OutputSlot().

◆ ~OutputSlot()

~OutputSlot ( )
inline

Definition at line 115 of file Layer.hpp.

116 {
117 try
118 {
119 // Coverity fix: DisconnectAll() may throw uncaught exceptions.
120 DisconnectAll();
121 }
122 catch (const std::exception& e)
123 {
124 // Coverity fix: BOOST_LOG_TRIVIAL (typically used to report errors) may throw an
125 // exception of type std::length_error.
126 // Using stderr instead in this context as there is no point in nesting try-catch blocks here.
127 std::cerr << "WARNING: An error has occurred when disconnecting all output slots: "
128 << e.what() << std::endl;
129 }
130 }

References DisconnectAll().

Member Function Documentation

◆ CalculateIndexOnOwner()

unsigned int CalculateIndexOnOwner ( ) const
overridevirtual

Implements IOutputSlot.

Definition at line 172 of file Layer.cpp.

173{
174 for (unsigned int i = 0; i < GetOwningLayer().GetNumOutputSlots(); i++)
175 {
176 if (GetOwningLayer().GetOutputSlot(i) == (*this))
177 {
178 return i;
179 }
180 }
181 throw armnn::Exception("Did not find slot on owner.");
182 return 0; // Error
183}

References Layer::GetNumOutputSlots(), and GetOwningLayer().

Referenced by DebugLayer::CreateWorkload(), and GenerateUniqueInputName().

◆ Connect() [1/2]

int Connect ( IInputSlot & destination)
inlineoverridevirtual

Implements IOutputSlot.

Definition at line 166 of file Layer.hpp.

167 {
168 return Connect(*PolymorphicDowncast<InputSlot*>(&destination));
169 }
void Connect(armnn::IConnectableLayer *from, armnn::IConnectableLayer *to, const armnn::TensorInfo &tensorInfo, unsigned int fromIndex, unsigned int toIndex)
Definition TestUtils.cpp:14

References Connect(), and armnn::PolymorphicDowncast().

◆ Connect() [2/2]

int Connect ( InputSlot & destination)
Examples
SimpleSample.cpp.

Definition at line 123 of file Layer.cpp.

124{
125 destination.SetConnection(this);
126 m_Connections.push_back(&destination);
127 m_EdgeStrategies.push_back(EdgeStrategy::Undefined);
128 return armnn::numeric_cast<int>(m_Connections.size() - 1);
129}
std::enable_if_t< std::is_unsigned< Source >::value &&std::is_unsigned< Dest >::value, Dest > numeric_cast(Source source)

References armnn::numeric_cast(), InputSlot::SetConnection(), and armnn::Undefined.

Referenced by armnn::ApplyBackendOptimizations(), Connect(), armnn::optimizations::pad_fold::FoldPadIntoLayer2dImpl(), InputSlot::Insert(), Graph::InsertNewLayer(), MoveAllConnections(), and FuseBatchNorm< ConvLayer, ArmnnType, T >::Run().

◆ Disconnect() [1/2]

void Disconnect ( IInputSlot & slot)
inlineoverridevirtual

Implements IOutputSlot.

Definition at line 171 of file Layer.hpp.

172 {
173 return Disconnect(*PolymorphicDowncast<InputSlot*>(&slot));
174 }

References Disconnect(), and armnn::PolymorphicDowncast().

◆ Disconnect() [2/2]

void Disconnect ( InputSlot & slot)

Definition at line 131 of file Layer.cpp.

132{
133 slot.SetConnection(nullptr);
134 auto it = std::find(m_Connections.begin(), m_Connections.end(), &slot);
135
136 if (it == m_Connections.end())
137 {
138 return;
139 }
140
141 auto idx = std::distance(m_Connections.begin(), it);
142 m_Connections.erase(std::remove(m_Connections.begin(), m_Connections.end(), &slot), m_Connections.end());
143
144 m_EdgeStrategies.erase(m_EdgeStrategies.begin() + idx);
145}

References InputSlot::SetConnection().

Referenced by armnn::ApplyBackendOptimizations(), Disconnect(), DisconnectAll(), armnn::optimizations::pad_fold::FoldPadIntoLayer2dImpl(), InputSlot::Insert(), MoveAllConnections(), and FuseBatchNorm< ConvLayer, ArmnnType, T >::Run().

◆ DisconnectAll()

void DisconnectAll ( )

Definition at line 147 of file Layer.cpp.

148{
149 while (GetNumConnections() > 0)
150 {
151 InputSlot& connection = *GetConnection(0);
152 Disconnect(connection);
153 }
154}

References Disconnect(), GetConnection(), and GetNumConnections().

Referenced by ~OutputSlot().

◆ GetConnection() [1/2]

◆ GetConnection() [2/2]

InputSlot * GetConnection ( unsigned int index)
overridevirtual

Implements IOutputSlot.

Definition at line 89 of file Layer.cpp.

90{
91 ValidateConnectionIndex(index);
92 return m_Connections[index];
93}

◆ GetConnections()

const std::vector< InputSlot * > & GetConnections ( ) const
inline

◆ GetEdgeStrategies()

const std::vector< EdgeStrategy > & GetEdgeStrategies ( ) const
inline

Definition at line 146 of file Layer.hpp.

146{ return m_EdgeStrategies; }

Referenced by Graph::AddCompatibilityLayers().

◆ GetEdgeStrategyForConnection()

EdgeStrategy GetEdgeStrategyForConnection ( unsigned int connectionIdx) const

Definition at line 228 of file Layer.cpp.

229{
230 return m_EdgeStrategies[connectionIdx];
231}

◆ GetNumConnections()

◆ GetOutputHandler() [1/2]

OutputHandler & GetOutputHandler ( )
inline

Definition at line 140 of file Layer.hpp.

140{ return m_OutputHandler; }

◆ GetOutputHandler() [2/2]

const OutputHandler & GetOutputHandler ( ) const
inline

Definition at line 139 of file Layer.hpp.

139{ return m_OutputHandler; }

Referenced by GetTensorInfo(), IsTensorInfoSet(), MoveAllConnections(), DeleteBroadcastToImpl::Run(), and SetTensorInfo().

◆ GetOwningIConnectableLayer() [1/2]

const IConnectableLayer & GetOwningIConnectableLayer ( ) const
overridevirtual

Implements IOutputSlot.

Definition at line 589 of file Layer.cpp.

590{
591 return m_OwningLayer;
592}

◆ GetOwningIConnectableLayer() [2/2]

IConnectableLayer & GetOwningIConnectableLayer ( )
overridevirtual

Implements IOutputSlot.

Definition at line 594 of file Layer.cpp.

595{
596 return m_OwningLayer;
597}

◆ GetOwningLayer()

◆ GetOwningLayerGuid()

LayerGuid GetOwningLayerGuid ( ) const
overridevirtual

Implements IOutputSlot.

Definition at line 208 of file Layer.cpp.

209{
210 return GetOwningLayer().GetGuid();
211}

References Layer::GetGuid(), and GetOwningLayer().

◆ GetTensorHandleFactoryId()

ITensorHandleFactory::FactoryId GetTensorHandleFactoryId ( ) const

Definition at line 218 of file Layer.cpp.

219{
220 return m_TensorHandleFactoryId;
221}

Referenced by Graph::AddCompatibilityLayers(), ConcatLayer::CreateTensorHandles(), Layer::CreateTensorHandles(), and SplitterLayer::CreateTensorHandles().

◆ GetTensorInfo()

const TensorInfo & GetTensorInfo ( ) const
overridevirtual

Implements IOutputSlot.

Definition at line 100 of file Layer.cpp.

101{
102 return GetOutputHandler().GetTensorInfo();
103}

References GetOutputHandler(), and OutputHandler::GetTensorInfo().

Referenced by armnn::BuildAddMulAddTensorInfoLists(), armnn::CheckScaleSetOnQuantizedType(), armnn::optimizations::pad_fold::FoldPadIntoLayer2dImpl(), Layer::GetDataType(), armnn::GetLayerInOutDatatype(), InputSlot::Insert(), armnn::InsertConvertFp16ToFp32LayersBefore(), armnn::InsertConvertFp32ToFp16LayersAfter(), armnn::InsertDebugLayerAfter(), MoveAllConnections(), ClBackend::OptimizeSubgraphView(), NeonBackend::OptimizeSubgraphView(), RefBackend::OptimizeSubgraphView(), armnn::RemoveReshapeLayer(), AddBroadcastReshapeLayerImpl::Run(), DeleteBroadcastToImpl::Run(), FuseBatchNorm< ConvLayer, ArmnnType, T >::Run(), MovePermuteUpImpl::Run(), MoveTransposeUpImpl::Run(), OptimizeConsecutiveReshapesImpl::Run(), PermuteAndBatchToSpaceAsDepthToSpaceImpl< PermuteType >::Run(), Graph::SerializeToDot(), Layer::ValidateAndCopyShape(), AbsLayer::ValidateTensorShapesFromInputs(), ActivationLayer::ValidateTensorShapesFromInputs(), ArgMinMaxLayer::ValidateTensorShapesFromInputs(), BatchMatMulLayer::ValidateTensorShapesFromInputs(), BatchNormalizationLayer::ValidateTensorShapesFromInputs(), BatchToSpaceNdLayer::ValidateTensorShapesFromInputs(), BroadcastToLayer::ValidateTensorShapesFromInputs(), CastLayer::ValidateTensorShapesFromInputs(), ChannelShuffleLayer::ValidateTensorShapesFromInputs(), ComparisonLayer::ValidateTensorShapesFromInputs(), ConcatLayer::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(), RankLayer::ValidateTensorShapesFromInputs(), ReduceLayer::ValidateTensorShapesFromInputs(), ReshapeLayer::ValidateTensorShapesFromInputs(), ResizeLayer::ValidateTensorShapesFromInputs(), ReverseV2Layer::ValidateTensorShapesFromInputs(), RsqrtLayer::ValidateTensorShapesFromInputs(), ScatterNdLayer::ValidateTensorShapesFromInputs(), ShapeLayer::ValidateTensorShapesFromInputs(), SliceLayer::ValidateTensorShapesFromInputs(), SoftmaxLayer::ValidateTensorShapesFromInputs(), SpaceToBatchNdLayer::ValidateTensorShapesFromInputs(), SpaceToDepthLayer::ValidateTensorShapesFromInputs(), SplitterLayer::ValidateTensorShapesFromInputs(), StackLayer::ValidateTensorShapesFromInputs(), StridedSliceLayer::ValidateTensorShapesFromInputs(), SwitchLayer::ValidateTensorShapesFromInputs(), TileLayer::ValidateTensorShapesFromInputs(), TransposeConvolution2dLayer::ValidateTensorShapesFromInputs(), TransposeLayer::ValidateTensorShapesFromInputs(), UnidirectionalSequenceLstmLayer::ValidateTensorShapesFromInputs(), ConvertConstDequantisationLayersToConstLayersImpl::~ConvertConstDequantisationLayersToConstLayersImpl(), ConvertConstPermuteLayersToConstLayers::~ConvertConstPermuteLayersToConstLayers(), PermuteDepthwiseConv2dWeightsImpl::~PermuteDepthwiseConv2dWeightsImpl(), and TurboConvertConstDequantisationLayersToConstLayersImpl::~TurboConvertConstDequantisationLayersToConstLayersImpl().

◆ IsTensorInfoSet()

bool IsTensorInfoSet ( ) const
overridevirtual

Implements IOutputSlot.

Definition at line 105 of file Layer.cpp.

106{
107 if (GetOwningLayer().GetShapeInferenceMethod() == ShapeInferenceMethod::InferAndValidate)
108 {
109 GetOwningLayer().ValidateTensorShapesFromInputs();
110 }
111 return GetOutputHandler().IsTensorInfoSet();
112}

References GetOutputHandler(), GetOwningLayer(), armnn::InferAndValidate, OutputHandler::IsTensorInfoSet(), and Layer::ValidateTensorShapesFromInputs().

Referenced by AddBroadcastReshapeLayerImpl::Run(), and ValidateTensorShape().

◆ MoveAllConnections()

void MoveAllConnections ( OutputSlot & destination)

Moves all connections to another OutputSlot.

Definition at line 156 of file Layer.cpp.

157{
158 while (GetNumConnections() > 0)
159 {
160 if (m_EdgeStrategies[0] != EdgeStrategy::Undefined)
161 {
162 throw armnn::Exception("Cannot move connections once memory strategies have be established.");
163 }
164
165 InputSlot& connection = *GetConnection(0);
166 Disconnect(connection);
167 destination.Connect(connection);
168 destination.GetOutputHandler().SetTensorInfo(GetOutputHandler().GetTensorInfo());
169 }
170}
armnn::TensorInfo GetTensorInfo(unsigned int numberOfBatches, unsigned int numberOfChannels, unsigned int height, unsigned int width, const armnn::DataLayout dataLayout, const armnn::DataType dataType)

References Connect(), Disconnect(), GetConnection(), GetNumConnections(), GetOutputHandler(), GetTensorInfo(), OutputSlot(), OutputHandler::SetTensorInfo(), and armnn::Undefined.

Referenced by Graph::InsertNewLayer(), DeleteBroadcastToImpl::Run(), FuseBatchNorm< ConvLayer, ArmnnType, T >::Run(), OptimizeConsecutiveReshapesImpl::Run(), OptimizeInverseConversionsImpl::Run(), PermuteAsReshapeImpl::Run(), TransposeAsReshapeImpl::Run(), ConvertConstDequantisationLayersToConstLayersImpl::~ConvertConstDequantisationLayersToConstLayersImpl(), ConvertConstPermuteLayersToConstLayers::~ConvertConstPermuteLayersToConstLayers(), and TurboConvertConstDequantisationLayersToConstLayersImpl::~TurboConvertConstDequantisationLayersToConstLayersImpl().

◆ operator=() [1/2]

OutputSlot & operator= ( const OutputSlot & )
delete

References OutputSlot().

◆ operator=() [2/2]

OutputSlot & operator= ( OutputSlot && )
delete

References OutputSlot().

◆ operator==()

bool operator== ( const OutputSlot & other) const

Definition at line 185 of file Layer.cpp.

186{
187 bool isSame = other.GetNumConnections() == GetNumConnections();
188 if (!isSame)
189 {
190 return false;
191 }
192
193 for (unsigned int i = 0; i < GetNumConnections(); i++)
194 {
195 isSame &= other.GetConnection(i) == GetConnection(i);
196 }
197 return isSame;
198}

References GetConnection(), GetNumConnections(), and OutputSlot().

◆ SetEdgeStrategy()

void SetEdgeStrategy ( unsigned int connectionIndex,
EdgeStrategy strategy )

Definition at line 223 of file Layer.cpp.

224{
225 m_EdgeStrategies[connectionIndex] = strategy;
226}

Referenced by Graph::AddCompatibilityLayers(), InputSlot::Insert(), and armnn::SelectTensorHandleStrategy().

◆ SetTensorHandleFactory()

void SetTensorHandleFactory ( const ITensorHandleFactory::FactoryId & id)

Definition at line 213 of file Layer.cpp.

214{
215 m_TensorHandleFactoryId = id;
216}

Referenced by Graph::AddCompatibilityLayers(), and armnn::SelectTensorHandleStrategy().

◆ SetTensorInfo()

◆ ValidateTensorShape()

bool ValidateTensorShape ( const TensorShape & shape) const

Definition at line 114 of file Layer.cpp.

115{
116 if (!IsTensorInfoSet())
117 {
118 throw armnn::Exception("TensorInfo must be set in order to validate the shape.");
119 }
120 return shape == m_OutputHandler.GetTensorInfo().GetShape();
121}

References IsTensorInfoSet().


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