21.08
|
#include <Graph.hpp>
Classes | |
struct | InputLayersAccessor |
Wrapper class returned by Graph::GetInputLayers() More... | |
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) | |
Graph (const Graph &other) | |
Graph & | operator= (const Graph &other)=delete |
Graph (Graph &&other) | |
Graph & | operator= (Graph &&other) |
~Graph () | |
Status | Print () 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 | 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... | |
Static Public Member Functions | |
template<typename LayerType > | |
static LayerType * | PtrCast (Layer *const layer) |
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 95 of file Graph.hpp.
References Graph::operator=().
Definition at line 28 of file Graph.cpp.
References Layer::BeginOutputSlots(), Layer::Clone(), and Layer::GetInputSlot().
|
inline |
Definition at line 128 of file Graph.hpp.
References Graph::AddLayer(), Graph::EraseLayer(), Graph::ForEachLayer(), Graph::InsertNewLayer(), Graph::Print(), and Graph::SerializeToDot().
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 300 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::GetName(), Layer::GetOutputSlot(), Layer::GetOutputSlots(), InputSlot::GetOwningLayer(), InputSlot::GetSlotIndex(), OutputSlot::GetTensorHandleFactoryId(), ITensorHandleFactory::LegacyFactoryId, armnn::MemCopy, armnn::MemImport, OutputSlot::SetEdgeStrategy(), OutputSlot::SetTensorHandleFactory(), and armnn::Undefined.
Referenced by Graph::GetNumLayers(), armnn::Optimize(), and TEST_SUITE().
|
inline |
Adds a new layer, of type LayerType, to the graph constructed with the arguments passed.
Definition at line 402 of file Graph.hpp.
References armnn::Input, armnn::LayerAdded, and armnn::Output.
Referenced by ArgMinMaxInferOutputShapeImpl(), BatchToSpaceInferOutputShapeTest(), armnn::ChainReduceLayers(), Layer::CloneBase(), Convolution2dInferOutputShapeTest(), CreatePreluLayerHelper(), CreateStackLayerHelper(), DepthwiseConvolution2dInferOutputShapeTest(), armnn::FuseLayerWithoutParameters(), armnn::FuseLayerWithParameters(), MockBackend::OptimizeSubgraphView(), PreluInferOutputShapeImpl(), QLstmInferOutputShapeImpl(), QuantizedLstmInferOutputShapeImpl(), SpaceToDepthInferOutputShapeTest(), StackInferOutputShapeImpl(), TEST_SUITE(), TransposeConvolution2dInferOutputShapeTest(), and Graph::~Graph().
Status AllocateDynamicBuffers | ( | ) |
Allocates memory for all tensors under output tensor handers of each layer.
Definition at line 179 of file Graph.cpp.
References ITensorHandle::Allocate(), ARMNN_ASSERT, armnn::Constant, ITensorHandle::GetParent(), ITensorHandle::Manage(), and armnn::Success.
Referenced by Graph::GetNumLayers(), and TEST_SUITE().
|
inline |
Definition at line 208 of file Graph.hpp.
Referenced by GraphObservable< Layer *>::GraphObservable().
|
inline |
Returns iterator pointing to the beginning of the list. Lowercase for range-based for loops.
Definition at line 162 of file Graph.hpp.
Referenced by armnn::Optimize(), Optimizer::Pass(), and TEST_SUITE().
|
inline |
|
inline |
Returns const iterator pointing to the beginning of the list. Lowercase for range-based for loops.
Definition at line 172 of file Graph.hpp.
References Graph::InputLayersAccessor::begin().
Referenced by TEST_SUITE().
|
inline |
Returns const iterator pointing to the end of the list. Lowercase for range-based for loops.
Definition at line 174 of file Graph.hpp.
References Graph::InputLayersAccessor::end().
Referenced by TEST_SUITE().
|
inline |
Definition at line 212 of file Graph.hpp.
References ARMNN_ASSERT, Graph::GetPosInGraph(), armnn::IgnoreUnused(), armnn::Input, Graph::InputLayersAccessor::m_Graph, and armnn::Output.
Referenced by GraphObservable< Layer *>::~GraphObservable().
|
inline |
Returns iterator pointing to the end of the list. Lowercase for range-based for loops.
Definition at line 164 of file Graph.hpp.
Referenced by armnn::Optimize(), Optimizer::Pass(), and TEST_SUITE().
|
inline |
|
inline |
Deletes the layer at the specified position.
Definition at line 449 of file Graph.hpp.
References armnn::LayerErased.
Referenced by Graph::EraseLayer(), Optimizer::Pass(), OptimizeForConnectionImpl< BaseType, ChildType, Wrapped >::Run(), OptimizeForExclusiveConnectionImpl< BaseType, ChildType, Wrapped >::Run(), Graph::SubstituteSubgraph(), TEST_SUITE(), and Graph::~Graph().
|
inline |
Deletes the layer.
Sets layer to nullptr on return. Templated to support pointers to any layer type.
Definition at line 457 of file Graph.hpp.
References ARMNN_ASSERT, Graph::EraseLayer(), and Graph::GetPosInGraph().
|
inline |
Definition at line 39 of file Graph.hpp.
Referenced by Graph::AddCompatibilityLayers(), Graph::operator=(), armnn::SelectTensorHandleStrategy(), TEST_SUITE(), 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 185 of file Graph.hpp.
References Graph::InputLayersAccessor::InputLayersAccessor().
Referenced by LoadedNetwork::EnqueueWorkload(), and LoadedNetwork::Execute().
|
inline |
Definition at line 180 of file Graph.hpp.
Referenced by Graph::InputLayersAccessor::end(), LoadedNetwork::EnqueueWorkload(), and LoadedNetwork::Execute().
|
inline |
Definition at line 191 of file Graph.hpp.
References Graph::AddCompatibilityLayers(), Graph::AllocateDynamicBuffers(), Graph::InferTensorInfos(), and Graph::SubstituteSubgraph().
Referenced by LoadedNetwork::EnqueueWorkload(), LoadedNetwork::Execute(), and TEST_SUITE().
|
inline |
Definition at line 181 of file Graph.hpp.
Referenced by Graph::OutputLayersAccessor::begin(), and 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 189 of file Graph.hpp.
Referenced by LoadedNetwork::EnqueueWorkload(), and LoadedNetwork::Execute().
|
inline |
Gets the position of a layer in the graph.
Definition at line 394 of file Graph.hpp.
References ARMNN_ASSERT.
Referenced by Graph::DetachObservable(), Graph::EraseLayer(), Graph::InsertNewLayer(), and Optimizer::Pass().
void InferTensorInfos | ( | ) |
Definition at line 529 of file Graph.cpp.
References armnn::GetLayerTypeAsCString(), IOutputSlot::IsTensorInfoSet(), Graph::TopologicalSort(), and armnn::ValidateOnly.
Referenced by Graph::GetNumLayers(), armnn::Optimize(), PreluValidateTensorShapesFromInputsMatchTest(), PreluValidateTensorShapesFromInputsNoMatchTest(), StackValidateTensorShapesFromInputsMatchTest(), StackValidateTensorShapesFromInputsNoMatchTest(), and TEST_SUITE().
|
inline |
Inserts a new layer between the output slot currently connected to insertBefore and insertBefore itself.
Definition at line 416 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::InsertConvertBf16ToFp32LayersBefore(), armnn::InsertConvertFp16ToFp32LayersBefore(), armnn::InsertConvertFp32ToBf16LayersAfter(), armnn::InsertConvertFp32ToBf16LayersBefore(), armnn::InsertConvertFp32ToFp16LayersAfter(), armnn::InsertDebugLayerAfter(), PermuteAsReshapeImpl::Run(), TransposeAsReshapeImpl::Run(), OptimizeConsecutiveReshapesImpl::Run(), MoveTransposeUpImpl::Run(), MovePermuteUpImpl::Run(), FuseBatchNorm< ConvLayer, ArmnnType, T >::Run(), AddBroadcastReshapeLayerImpl::Run(), TEST_SUITE(), and Graph::~Graph().
|
inline |
Inserts a new layer between insertAfter and the input slot(s) currently connected to it.
Definition at line 432 of file Graph.hpp.
References ARMNN_ASSERT, OutputSlot::Connect(), OutputSlot::GetOwningLayer(), Graph::GetPosInGraph(), armnn::LayerAdded, and OutputSlot::MoveAllConnections().
Referenced by Graph::Graph().
Definition at line 110 of file Graph.hpp.
References ARMNN_ASSERT, Graph::ForEachLayer(), and Layer::Reparent().
Status Print | ( | ) | const |
Definition at line 61 of file Graph.cpp.
References ARMNN_LOG, armnn::GetLayerTypeAsCString(), Layer::GetOutputSlots(), armnn::info, armnn::Success, and Graph::TopologicalSort().
Referenced by CheckOrder(), and Graph::~Graph().
Status SerializeToDot | ( | std::ostream & | stream | ) |
Definition at line 118 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.
Referenced by TEST_SUITE(), and Graph::~Graph().
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 432 of file Graph.cpp.
References ARMNN_ASSERT.
Referenced by armnn::ApplyBackendOptimizations(), Graph::GetNumLayers(), and TEST_SUITE().
void SubstituteSubgraph | ( | SubgraphView & | subgraph, |
const SubgraphView & | substituteSubgraph | ||
) |
Definition at line 440 of file Graph.cpp.
References ARMNN_ASSERT, ARMNN_ASSERT_MSG, SubgraphView::Clear(), IOutputSlot::Connect(), IOutputSlot::Disconnect(), Graph::EraseLayer(), SubgraphView::ForEachLayer(), InputSlot::GetConnection(), SubgraphView::GetInputSlots(), SubgraphView::GetLayers(), SubgraphView::GetOutputSlots(), armnn::IgnoreUnused(), OutputSlot::MoveAllConnections(), armnn::numeric_cast(), Layer::Reparent(), and Graph::TopologicalSort().
|
inline |
Sorts layers in topological order and return this.
Definition at line 177 of file Graph.hpp.
References Graph::TopologicalSort().
Referenced by CheckOrder(), Graph::InferTensorInfos(), LoadedNetwork::MakeLoadedNetwork(), Optimizer::Pass(), Graph::Print(), LoadedNetwork::SendNetworkStructure(), Graph::SubstituteSubgraph(), TEST_SUITE(), and Graph::TopologicalSort().
const Graph & TopologicalSort | ( | ) | const |