24.08
|
#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. More... | |
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. More... | |
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. More... | |
void | EraseLayer (Iterator pos) |
Deletes the layer at the specified position. More... | |
template<typename LayerT > | |
void | EraseLayer (LayerT *&layer) |
Deletes the layer. More... | |
Iterator | begin () |
Returns iterator pointing to the beginning of the list. Lowercase for range-based for loops. More... | |
Iterator | end () |
Returns iterator pointing to the end of the list. Lowercase for range-based for loops. More... | |
ConstIterator | begin () const |
Returns const iterator pointing to the beginning of the list. Lowercase for range-based for loops. More... | |
ConstIterator | end () const |
Returns const iterator pointing to the end of the list. Lowercase for range-based for loops. More... | |
ConstIterator | cbegin () const |
Returns const iterator pointing to the beginning of the list. Lowercase for range-based for loops. More... | |
ConstIterator | cend () const |
Returns const iterator pointing to the end of the list. Lowercase for range-based for loops. More... | |
Graph & | TopologicalSort () |
Sorts layers in topological order and return this. More... | |
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. More... | |
OutputLayersAccessor | GetOutputLayers () const |
Returns a wrapper object with begin(), end() methods to iterate over the output layers in a range-based for loop. More... | |
size_t | GetNumLayers () const |
Status | AllocateDynamicBuffers () |
Allocates memory for all tensors under output tensor handers of each layer. More... | |
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. More... | |
void | SubstituteSubgraph (SubgraphView &subgraph, IConnectableLayer *substituteLayer) |
Substitutes the given sub-graph with either a new layer or a new sub-graph. More... | |
void | SubstituteSubgraph (SubgraphView &subgraph, const SubgraphView &substituteSubgraph) |
void | VerifyConstantLayerSetTensorInfo () const |
For each ConstantLayer in Graph, ensures TensorInfo is set on all output slots. More... | |
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. More... | |
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.
Definition at line 27 of file Graph.cpp.
References Layer::BeginOutputSlots(), Layer::Clone(), Layer::GetInputSlot(), and InputSlot::SetTensorInfo().
|
inline |
Definition at line 142 of file Graph.hpp.
References Graph::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 ARMNN_THROW_INVALIDARG_MSG_IF_FALSE, armnn::CopyToTarget, armnn::DirectCompatibility, armnn::ExportToTarget, Graph::ForEachLayer(), Layer::GetBackendId(), OutputSlot::GetConnections(), OutputSlot::GetEdgeStrategies(), TensorHandleFactoryRegistry::GetFactory(), Layer::GetInputSlot(), Layer::GetName(), Layer::GetOutputSlot(), Layer::GetOutputSlots(), InputSlot::GetOwningLayer(), InputSlot::GetSlotIndex(), OutputSlot::GetTensorHandleFactoryId(), ITensorHandleFactory::LegacyFactoryId, armnn::MemCopy, armnn::MemImport, Layer::SetBackendId(), OutputSlot::SetEdgeStrategy(), OutputSlot::SetTensorHandleFactory(), and armnn::Undefined.
Referenced by armnn::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, 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(), ARMNN_SCOPED_PROFILING_EVENT, ARMNN_THROW_INVALIDARG_MSG_IF_FALSE, armnn::Constant, ITensorHandle::GetParent(), ITensorHandle::Manage(), armnn::Success, and armnn::Undefined.
|
inline |
Definition at line 226 of file Graph.hpp.
Referenced by GraphObservable< std::string >::GraphObservable().
|
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 Graph::cbegin(), armnn::Optimize(), and Optimizer::Pass().
|
inline |
|
inline |
Returns const iterator pointing to the beginning of the list. Lowercase for range-based for loops.
Definition at line 186 of file Graph.hpp.
References Graph::begin().
|
inline |
Returns const iterator pointing to the end of the list. Lowercase for range-based for loops.
Definition at line 188 of file Graph.hpp.
References Graph::end().
|
inline |
Definition at line 230 of file Graph.hpp.
Referenced by GraphObservable< std::string >::~GraphObservable().
|
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 Graph::cend(), armnn::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(), Graph::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 Graph::EraseLayer(), and Graph::GetPosInGraph().
|
inline |
Definition at line 40 of file Graph.hpp.
Referenced by Graph::AddCompatibilityLayers(), armnn::SelectTensorHandleStrategy(), and Graph::~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 Graph::InputLayersAccessor::end(), LoadedNetwork::EnqueueWorkload(), and LoadedNetwork::Execute().
|
inline |
Definition at line 205 of file Graph.hpp.
Referenced by LoadedNetwork::EnqueueWorkload().
|
inline |
Definition at line 195 of file Graph.hpp.
Referenced by Graph::OutputLayersAccessor::begin(), LoadedNetwork::EnqueueWorkload(), and LoadedNetwork::Execute().
|
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 Graph::EraseLayer(), Graph::InsertNewLayer(), and Optimizer::Pass().
const std::shared_ptr< IProfiler > & GetProfiler | ( | ) | const |
Definition at line 733 of file Graph.cpp.
Referenced by armnn::Optimize().
void InferTensorInfos | ( | ) |
Definition at line 645 of file Graph.cpp.
References armnn::GetLayerTypeAsCString(), and IOutputSlot::IsTensorInfoSet().
Referenced by armnn::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(), Graph::GetPosInGraph(), InputSlot::Insert(), and armnn::LayerAdded.
Referenced by armnn::optimizations::pad_fold::FoldPadIntoLayer2dImpl(), armnn::InsertConvertFp16ToFp32LayersBefore(), armnn::InsertConvertFp32ToFp16LayersAfter(), armnn::InsertDebugLayerAfter(), PermuteAsReshapeImpl::Run(), TransposeAsReshapeImpl::Run(), MaxMinIntoBoundedReluImpl::Run(), OptimizeConsecutiveReshapesImpl::Run(), MoveTransposeUpImpl::Run(), MovePermuteUpImpl::Run(), AddBroadcastReshapeLayerImpl::Run(), and FuseBatchNorm< ConvLayer, ArmnnType, T >::Run().
|
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(), Graph::GetPosInGraph(), armnn::LayerAdded, and OutputSlot::MoveAllConnections().
Status Print | ( | bool | extended = false | ) | const |
Definition at line 68 of file Graph.cpp.
References ARMNN_LOG, armnn::GetLayerTypeAsCString(), Layer::GetOutputSlots(), armnn::info, armnn::Success, and Graph::TopologicalSort().
Referenced by CheckOrder().
Status SerializeToDot | ( | std::ostream & | stream | ) |
Definition at line 146 of file Graph.cpp.
References DotAttributeSet::AddAttribute(), NodeContent::AddContent(), armnn::Failure, DotEdge::GetAttributeSet(), DotDefaults::GetAttributeSet(), DotNode::GetContents(), Layer::GetGuid(), armnn::GetLayerTypeAsCString(), OutputSlot::GetOwningLayer(), TensorInfo::GetShape(), OutputSlot::GetTensorInfo(), and armnn::Success.
void SetLayersOutOfOrder | ( | ) |
void SubstituteSubgraph | ( | SubgraphView & | subgraph, |
const SubgraphView & | substituteSubgraph | ||
) |
Definition at line 486 of file Graph.cpp.
References SubgraphView::ForEachIConnectableLayer(), and Graph::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.
Referenced by armnn::ApplyBackendOptimizations().
|
inline |
Sorts layers in topological order and return this.
Definition at line 191 of file Graph.hpp.
References Graph::TopologicalSort().
Referenced by CheckOrder(), Optimizer::Pass(), Graph::Print(), Graph::SubstituteSubgraph(), and Graph::TopologicalSort().
const Graph& TopologicalSort | ( | ) | const |
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, and armnn::GetLayerTypeAsCString().
Referenced by armnn::Optimize().
|
friend |