24.02
|
#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 135 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 329 of file Graph.cpp.
References ARMNN_ASSERT, ARMNN_ASSERT_MSG, 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 456 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_ASSERT, ARMNN_SCOPED_PROFILING_EVENT, armnn::Constant, ITensorHandle::GetParent(), ITensorHandle::Manage(), armnn::Success, and armnn::Undefined.
|
inline |
Definition at line 219 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 169 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 179 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 181 of file Graph.hpp.
References Graph::end().
|
inline |
Definition at line 223 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 171 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 504 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 512 of file Graph.hpp.
References ARMNN_ASSERT, 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 192 of file Graph.hpp.
Referenced by LoadedNetwork::EnqueueWorkload(), and LoadedNetwork::ImportInputs().
|
inline |
Definition at line 187 of file Graph.hpp.
Referenced by Graph::InputLayersAccessor::end(), LoadedNetwork::EnqueueWorkload(), and LoadedNetwork::Execute().
|
inline |
Definition at line 198 of file Graph.hpp.
Referenced by LoadedNetwork::EnqueueWorkload().
|
inline |
Definition at line 188 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 196 of file Graph.hpp.
Referenced by LoadedNetwork::EnqueueWorkload(), and LoadedNetwork::ImportOutputs().
|
inline |
Gets the position of a layer in the graph.
Definition at line 448 of file Graph.hpp.
References ARMNN_ASSERT.
Referenced by Graph::EraseLayer(), Graph::InsertNewLayer(), and Optimizer::Pass().
const std::shared_ptr< IProfiler > & GetProfiler | ( | ) | const |
Definition at line 692 of file Graph.cpp.
Referenced by armnn::Optimize().
void InferTensorInfos | ( | ) |
Definition at line 604 of file Graph.cpp.
References armnn::GetLayerTypeAsCString(), IOutputSlot::IsTensorInfoSet(), Graph::TopologicalSort(), and armnn::ValidateOnly.
Referenced by armnn::Optimize().
|
inline |
Inserts a new layer between the output slot currently connected to insertBefore and insertBefore itself.
Definition at line 471 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(), OptimizeConsecutiveReshapesImpl::Run(), MovePermuteUpImpl::Run(), MoveTransposeUpImpl::Run(), FuseBatchNorm< ConvLayer, ArmnnType, T >::Run(), and AddBroadcastReshapeLayerImpl::Run().
|
inline |
Inserts a new layer between insertAfter and the input slot(s) currently connected to it.
Definition at line 487 of file Graph.hpp.
References ARMNN_ASSERT, 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 472 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 461 of file Graph.cpp.
References ARMNN_ASSERT.
Referenced by armnn::ApplyBackendOptimizations().
|
inline |
Sorts layers in topological order and return this.
Definition at line 184 of file Graph.hpp.
References Graph::TopologicalSort().
Referenced by CheckOrder(), Graph::InferTensorInfos(), Optimizer::Pass(), Graph::Print(), Graph::SubstituteSubgraph(), Graph::TopologicalSort(), and Graph::VerifyConstantLayerSetTensorInfo().
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 581 of file Graph.cpp.
References armnn::Constant, armnn::GetLayerTypeAsCString(), and Graph::TopologicalSort().
Referenced by armnn::Optimize().
|
friend |