|
25.11
|
#include <Graph.hpp>
Classes | |
| struct | InputLayersAccessor |
| Wrapper class returned by Graph::GetInputLayers() More... | |
| class | LayerInGraph< ConstantLayer > |
| class | LayerInGraph< InputLayer > |
| Inputs add/remove their binding id to m_InputIds in the graph. More... | |
| class | LayerInGraph< OutputLayer > |
| Outputs add/remove their binding id to m_OutputIds in the graph. More... | |
| struct | OutputLayersAccessor |
| Wrapper class returned by Graph::GetOutputLayers() More... | |
Public Types | |
| using | LayerList = std::list<Layer*> |
| using | Iterator = LayerList::const_iterator |
| using | IteratorDifference = Iterator::difference_type |
| using | ConstIterator = TransformIterator<decltype(&PtrCast<const Layer>), Iterator> |
| using | ConstIteratorInputs = TransformIterator<decltype(&PtrCast<const InputLayer>), Iterator> |
| using | ConstIteratorOutputs = TransformIterator<decltype(&PtrCast<const OutputLayer>), Iterator> |
Public Member Functions | |
| template<typename Func> | |
| void | ForEachLayer (Func func) const |
| Graph (bool shapeInferenceMethod=false, bool allowExpandedDims=false) | |
| Graph (const Graph &other) | |
| Graph & | operator= (const Graph &other)=delete |
| Graph (Graph &&other) | |
| Graph & | operator= (Graph &&other) |
| ~Graph () | |
| Status | Print (bool extended=false) const |
| Status | SerializeToDot (std::ostream &stream) |
| template<typename LayerT, typename... Args> | |
| LayerT * | AddLayer (Args &&... args) |
| Adds a new layer, of type LayerType, to the graph constructed with the arguments passed. | |
| template<typename LayerT, typename... Args> | |
| LayerT * | InsertNewLayer (InputSlot &insertBefore, Args &&... args) |
| Inserts a new layer between the output slot currently connected to insertBefore and insertBefore itself. | |
| template<typename LayerT, typename... Args> | |
| LayerT * | InsertNewLayer (OutputSlot &insertAfter, Args &&... args) |
| Inserts a new layer between insertAfter and the input slot(s) currently connected to it. | |
| void | EraseLayer (Iterator pos) |
| Deletes the layer at the specified position. | |
| template<typename LayerT> | |
| void | EraseLayer (LayerT *&layer) |
| Deletes the layer. | |
| Iterator | begin () |
| Returns iterator pointing to the beginning of the list. Lowercase for range-based for loops. | |
| Iterator | end () |
| Returns iterator pointing to the end of the list. Lowercase for range-based for loops. | |
| ConstIterator | begin () const |
| Returns const iterator pointing to the beginning of the list. Lowercase for range-based for loops. | |
| ConstIterator | end () const |
| Returns const iterator pointing to the end of the list. Lowercase for range-based for loops. | |
| ConstIterator | cbegin () const |
| Returns const iterator pointing to the beginning of the list. Lowercase for range-based for loops. | |
| ConstIterator | cend () const |
| Returns const iterator pointing to the end of the list. Lowercase for range-based for loops. | |
| Graph & | TopologicalSort () |
| Sorts layers in topological order and return this. | |
| const Graph & | TopologicalSort () const |
| size_t | GetNumInputs () const |
| size_t | GetNumOutputs () const |
| InputLayersAccessor | GetInputLayers () const |
| Returns a wrapper object with begin(), end() methods to iterate over the input layers in a range-based for loop. | |
| OutputLayersAccessor | GetOutputLayers () const |
| Returns a wrapper object with begin(), end() methods to iterate over the output layers in a range-based for loop. | |
| size_t | GetNumLayers () const |
| Status | AllocateDynamicBuffers () |
| Allocates memory for all tensors under output tensor handers of each layer. | |
| void | AddCompatibilityLayers (std::map< BackendId, std::unique_ptr< class IBackendInternal > > &backends, TensorHandleFactoryRegistry ®istry) |
| Modifies the graph in-place, removing edges connecting layers using different compute devices, and relinking them via an intermediary copy layers. | |
| void | SubstituteSubgraph (SubgraphView &subgraph, IConnectableLayer *substituteLayer) |
| Substitutes the given sub-graph with either a new layer or a new sub-graph. | |
| void | SubstituteSubgraph (SubgraphView &subgraph, const SubgraphView &substituteSubgraph) |
| void | VerifyConstantLayerSetTensorInfo () const |
| For each ConstantLayer in Graph, ensures TensorInfo is set on all output slots. | |
| void | InferTensorInfos () |
| void | AttachObservable (IGraphObservable *const observable, GraphEvent notifyOnEvent) |
| void | DetachObservable (IGraphObservable *const observable, GraphEvent notifyOnEvent) |
| Iterator | GetPosInGraph (Layer &layer) |
| Gets the position of a layer in the graph. | |
| const std::shared_ptr< IProfiler > & | GetProfiler () const |
| void | SetLayersOutOfOrder () |
Static Public Member Functions | |
| template<typename LayerType> | |
| static LayerType * | PtrCast (Layer *const layer) |
Friends | |
| class | SubgraphView |
| using ConstIterator = TransformIterator<decltype(&PtrCast<const Layer>), Iterator> |
| using ConstIteratorInputs = TransformIterator<decltype(&PtrCast<const InputLayer>), Iterator> |
| using ConstIteratorOutputs = TransformIterator<decltype(&PtrCast<const OutputLayer>), Iterator> |
| using IteratorDifference = Iterator::difference_type |
|
inline |
Definition at line 98 of file Graph.hpp.
References armnn::InferAndValidate, and armnn::ValidateOnly.
Referenced by Graph(), Graph(), Graph::InputLayersAccessor::InputLayersAccessor(), Graph::LayerInGraph< ConstantLayer >::LayerInGraph(), Graph::LayerInGraph< ConstantLayer >::LayerInGraph(), Graph::LayerInGraph< InputLayer >::LayerInGraph(), Graph::LayerInGraph< InputLayer >::LayerInGraph(), Graph::LayerInGraph< OutputLayer >::LayerInGraph(), operator=(), operator=(), Graph::OutputLayersAccessor::OutputLayersAccessor(), TopologicalSort(), and TopologicalSort().
Definition at line 27 of file Graph.cpp.
References Graph().
|
inline |
Definition at line 142 of file Graph.hpp.
References ForEachLayer().
| void AddCompatibilityLayers | ( | std::map< BackendId, std::unique_ptr< class IBackendInternal > > & | backends, |
| TensorHandleFactoryRegistry & | registry ) |
Modifies the graph in-place, removing edges connecting layers using different compute devices, and relinking them via an intermediary copy layers.
Definition at line 330 of file Graph.cpp.
References AddCompatibilityLayers(), ARMNN_THROW_INVALIDARG_MSG_IF_FALSE, armnn::CopyToTarget, armnn::DirectCompatibility, armnn::ExportToTarget, ForEachLayer(), Layer::GetBackendId(), OutputSlot::GetConnections(), OutputSlot::GetEdgeStrategies(), TensorHandleFactoryRegistry::GetFactory(), Layer::GetInputSlot(), Layer::GetName(), Layer::GetOutputSlot(), Layer::GetOutputSlots(), InputSlot::GetOwningLayer(), InputSlot::GetSlotIndex(), OutputSlot::GetTensorHandleFactoryId(), InsertNewLayer(), ITensorHandleFactory::LegacyFactoryId, armnn::MemCopy, armnn::MemImport, armnn::numeric_cast(), Layer::SetBackendId(), OutputSlot::SetEdgeStrategy(), OutputSlot::SetTensorHandleFactory(), and armnn::Undefined.
Referenced by AddCompatibilityLayers(), and IOptimizedNetwork::Optimize.
|
inline |
Adds a new layer, of type LayerType, to the graph constructed with the arguments passed.
Definition at line 466 of file Graph.hpp.
References armnn::Input, armnn::LayerAdded, armnn::LayerEnumOf(), and armnn::Output.
Referenced by Layer::CloneBase(), and FuseBatchNorm< ConvLayer, ArmnnType, T >::Run().
| Status AllocateDynamicBuffers | ( | ) |
Allocates memory for all tensors under output tensor handers of each layer.
Definition at line 207 of file Graph.cpp.
References ITensorHandle::Allocate(), AllocateDynamicBuffers(), ARMNN_SCOPED_PROFILING_EVENT, ARMNN_THROW_INVALIDARG_MSG_IF_FALSE, armnn::Constant, ITensorHandle::GetParent(), ITensorHandle::Manage(), armnn::Success, and armnn::Undefined.
Referenced by AllocateDynamicBuffers().
|
inline |
|
inline |
Returns iterator pointing to the beginning of the list. Lowercase for range-based for loops.
Definition at line 176 of file Graph.hpp.
Referenced by cbegin(), armnn::IsTfLiteTurboModel(), Graph::LayerInGraph< ConstantLayer >::LayerInGraph(), Graph::LayerInGraph< InputLayer >::LayerInGraph(), IOptimizedNetwork::Optimize, and Optimizer::Pass().
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Returns iterator pointing to the end of the list. Lowercase for range-based for loops.
Definition at line 178 of file Graph.hpp.
Referenced by cend(), armnn::IsTfLiteTurboModel(), Graph::LayerInGraph< OutputLayer >::LayerInGraph(), IOptimizedNetwork::Optimize, and Optimizer::Pass().
|
inline |
|
inline |
Deletes the layer at the specified position.
Definition at line 517 of file Graph.hpp.
References armnn::LayerErased.
Referenced by armnn::ApplyBackendOptimizations(), EraseLayer(), Optimizer::Pass(), OptimizeForConnectionImpl< BaseType, ChildType, Wrapped >::Run(), and OptimizeForExclusiveConnectionImpl< BaseType, ChildType, Wrapped >::Run().
|
inline |
Deletes the layer.
Sets layer to nullptr on return. Templated to support pointers to any layer type.
Definition at line 525 of file Graph.hpp.
References EraseLayer(), and GetPosInGraph().
|
inline |
Definition at line 40 of file Graph.hpp.
Referenced by AddCompatibilityLayers(), armnn::SelectTensorHandleStrategy(), and ~Graph().
|
inline |
Returns a wrapper object with begin(), end() methods to iterate over the input layers in a range-based for loop.
Definition at line 199 of file Graph.hpp.
Referenced by LoadedNetwork::EnqueueWorkload(), and LoadedNetwork::ImportInputs().
|
inline |
Definition at line 194 of file Graph.hpp.
Referenced by LoadedNetwork::EnqueueWorkload(), Graph::LayerInGraph< ConstantLayer >::LayerInGraph(), and Graph::LayerInGraph< InputLayer >::LayerInGraph().
|
inline |
Definition at line 205 of file Graph.hpp.
Referenced by LoadedNetwork::EnqueueWorkload().
|
inline |
Definition at line 195 of file Graph.hpp.
Referenced by LoadedNetwork::EnqueueWorkload().
|
inline |
Returns a wrapper object with begin(), end() methods to iterate over the output layers in a range-based for loop.
Definition at line 203 of file Graph.hpp.
Referenced by LoadedNetwork::EnqueueWorkload(), and LoadedNetwork::ImportOutputs().
|
inline |
Gets the position of a layer in the graph.
Definition at line 455 of file Graph.hpp.
Referenced by EraseLayer(), InsertNewLayer(), InsertNewLayer(), and Optimizer::Pass().
| const std::shared_ptr< IProfiler > & GetProfiler | ( | ) | const |
Definition at line 733 of file Graph.cpp.
References GetProfiler().
Referenced by GetProfiler(), and IOptimizedNetwork::Optimize.
| void InferTensorInfos | ( | ) |
Definition at line 645 of file Graph.cpp.
References armnn::GetLayerTypeAsCString(), InferTensorInfos(), IOutputSlot::IsTensorInfoSet(), TopologicalSort(), and armnn::ValidateOnly.
Referenced by InferTensorInfos(), and IOptimizedNetwork::Optimize.
|
inline |
Inserts a new layer between the output slot currently connected to insertBefore and insertBefore itself.
Definition at line 481 of file Graph.hpp.
References InputSlot::GetConnectedOutputSlot(), InputSlot::GetOwningLayer(), OutputSlot::GetOwningLayer(), GetPosInGraph(), InputSlot::Insert(), and armnn::LayerAdded.
Referenced by AddCompatibilityLayers(), armnn::optimizations::pad_fold::FoldPadIntoLayer2dImpl(), armnn::InsertConvertFp16ToFp32LayersBefore(), armnn::InsertConvertFp32ToFp16LayersAfter(), armnn::InsertDebugLayerAfter(), AddBroadcastReshapeLayerImpl::Run(), FuseBatchNorm< ConvLayer, ArmnnType, T >::Run(), MaxMinIntoBoundedReluImpl::Run(), MovePermuteUpImpl::Run(), MoveTransposeUpImpl::Run(), OptimizeConsecutiveReshapesImpl::Run(), PermuteAsReshapeImpl::Run(), TransposeAsReshapeImpl::Run(), and PermuteDepthwiseConv2dWeightsImpl::~PermuteDepthwiseConv2dWeightsImpl().
|
inline |
Inserts a new layer between insertAfter and the input slot(s) currently connected to it.
Definition at line 497 of file Graph.hpp.
References OutputSlot::Connect(), OutputSlot::GetOwningLayer(), GetPosInGraph(), armnn::LayerAdded, and OutputSlot::MoveAllConnections().
Definition at line 115 of file Graph.hpp.
References Graph(), and Layer::Reparent().
| Status Print | ( | bool | extended = false | ) | const |
Definition at line 68 of file Graph.cpp.
References ARMNN_LOG, armnn::GetLayerTypeAsCString(), Layer::GetOutputSlots(), armnn::info, Print(), armnn::Success, and TopologicalSort().
Referenced by CheckOrder(), and Print().
Definition at line 34 of file Graph.hpp.
References armnn::PolymorphicDowncast().
Referenced by begin(), Graph::InputLayersAccessor::begin(), Graph::OutputLayersAccessor::begin(), end(), Graph::InputLayersAccessor::end(), and Graph::OutputLayersAccessor::end().
| Status SerializeToDot | ( | std::ostream & | stream | ) |
Definition at line 146 of file Graph.cpp.
References DotAttributeSet::AddAttribute(), NodeContent::AddContent(), armnn::Failure, DotDefaults::GetAttributeSet(), DotEdge::GetAttributeSet(), DotNode::GetContents(), Layer::GetGuid(), armnn::GetLayerTypeAsCString(), OutputSlot::GetOwningLayer(), TensorInfo::GetShape(), OutputSlot::GetTensorInfo(), SerializeToDot(), and armnn::Success.
Referenced by SerializeToDot().
| void SetLayersOutOfOrder | ( | ) |
Definition at line 738 of file Graph.cpp.
References SetLayersOutOfOrder().
Referenced by SetLayersOutOfOrder().
| void SubstituteSubgraph | ( | SubgraphView & | subgraph, |
| const SubgraphView & | substituteSubgraph ) |
Definition at line 486 of file Graph.cpp.
References SubgraphView::ForEachIConnectableLayer(), armnn::PolymorphicDowncast(), SubgraphView, SubstituteSubgraph(), and TopologicalSort().
| void SubstituteSubgraph | ( | SubgraphView & | subgraph, |
| IConnectableLayer * | substituteLayer ) |
Substitutes the given sub-graph with either a new layer or a new sub-graph.
In either case, the given layer or all the layers in the given sub-graph must belong to this graph.
Definition at line 475 of file Graph.cpp.
References ARMNN_THROW_INVALIDARG_MSG_IF_FALSE, SubgraphView, and SubstituteSubgraph().
Referenced by armnn::ApplyBackendOptimizations(), SubstituteSubgraph(), and SubstituteSubgraph().
|
inline |
Sorts layers in topological order and return this.
Definition at line 191 of file Graph.hpp.
References Graph(), and TopologicalSort().
Referenced by CheckOrder(), LoadedNetwork::ImportInputs(), LoadedNetwork::ImportOutputs(), InferTensorInfos(), Optimizer::Pass(), Print(), LoadedNetwork::SendNetworkStructure(), SubstituteSubgraph(), TopologicalSort(), TopologicalSort(), and VerifyConstantLayerSetTensorInfo().
| const Graph & TopologicalSort | ( | ) | const |
Definition at line 307 of file Graph.cpp.
References Graph(), and TopologicalSort().
| void VerifyConstantLayerSetTensorInfo | ( | ) | const |
For each ConstantLayer in Graph, ensures TensorInfo is set on all output slots.
LayerValidationException thrown if no TensorInfo is set.
LayerValidationException thrown if no TensorInfo is set.
| LayerValidationException |
Definition at line 622 of file Graph.cpp.
References armnn::Constant, armnn::GetLayerTypeAsCString(), TopologicalSort(), and VerifyConstantLayerSetTensorInfo().
Referenced by IOptimizedNetwork::Optimize, and VerifyConstantLayerSetTensorInfo().
|
friend |
Definition at line 307 of file Graph.hpp.
References SubgraphView.
Referenced by SubgraphView, SubstituteSubgraph(), and SubstituteSubgraph().