ArmNN
NotReleased
|
#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 = boost::transform_iterator< decltype(&PtrCast< const Layer >), Iterator > |
using | ConstIteratorInputs = boost::transform_iterator< decltype(&PtrCast< const InputLayer >), Iterator > |
using | ConstIteratorOutputs = boost::transform_iterator< decltype(&PtrCast< const OutputLayer >), Iterator > |
Public Member Functions | |
template<typename Func > | |
void | ForEachLayer (Func func) const |
Graph () | |
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) |
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) |
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 |
OutputLayersAccessor | GetOutputLayers () const |
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) |
void | SubstituteSubgraph (SubgraphView &subgraph, IConnectableLayer *substituteLayer) |
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 = boost::transform_iterator<decltype(&PtrCast<const Layer>), Iterator> |
using ConstIteratorInputs = boost::transform_iterator<decltype(&PtrCast<const InputLayer>), Iterator> |
using ConstIteratorOutputs = boost::transform_iterator<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 124 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 263 of file Graph.cpp.
References 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 BOOST_AUTO_TEST_CASE(), BOOST_FIXTURE_TEST_CASE(), and Graph::GetNumLayers().
|
inline |
Adds a new layer, of type LayerType, to the graph constructed with the arguments passed.
Definition at line 397 of file Graph.hpp.
References armnn::Input, armnn::LayerAdded, and armnn::Output.
Referenced by ArgMinMaxInferOutputShapeImpl(), BatchToSpaceInferOutputShapeTest(), BOOST_AUTO_TEST_CASE(), BOOST_FIXTURE_TEST_CASE(), Layer::CloneBase(), Convolution2dInferOutputShapeTest(), CreateConvolution2dGraph(), CreateDepthwiseConvolution2dGraph(), CreateGatherGraph(), CreatePooling2dGraph(), CreatePreluLayerHelper(), CreateResizeBilinearGraph(), CreateStackLayerHelper(), DepthwiseConvolution2dInferOutputShapeTest(), MockBackend::OptimizeSubgraphView(), PreluInferOutputShapeImpl(), QuantizedLstmInferOutputShapeImpl(), SpaceToDepthInferOutputShapeTest(), StackInferOutputShapeImpl(), TransposeConvolution2dInferOutputShapeTest(), and Graph::~Graph().
Status AllocateDynamicBuffers | ( | ) |
Allocates memory for all tensors under output tensor handers of each layer.
Definition at line 142 of file Graph.cpp.
References ITensorHandle::Allocate(), armnn::Constant, ITensorHandle::GetParent(), ITensorHandle::Manage(), and armnn::Success.
Referenced by Graph::GetNumLayers().
|
inline |
Definition at line 204 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 158 of file Graph.hpp.
Referenced by BOOST_AUTO_TEST_CASE(), and Optimizer::Pass().
|
inline |
|
inline |
Returns const iterator pointing to the beginning of the list. Lowercase for range-based for loops.
Definition at line 168 of file Graph.hpp.
References Graph::InputLayersAccessor::begin().
Referenced by BOOST_AUTO_TEST_CASE().
|
inline |
Returns const iterator pointing to the end of the list. Lowercase for range-based for loops.
Definition at line 170 of file Graph.hpp.
References Graph::InputLayersAccessor::end().
Referenced by BOOST_AUTO_TEST_CASE().
|
inline |
Definition at line 208 of file Graph.hpp.
References Graph::GetPosInGraph(), armnn::Input, Graph::InputLayersAccessor::m_Graph, armnn::Output, and armnnUtils::Filesystem::Remove().
Referenced by GraphObservable< Layer *>::~GraphObservable().
|
inline |
Returns iterator pointing to the end of the list. Lowercase for range-based for loops.
Definition at line 160 of file Graph.hpp.
Referenced by Optimizer::Pass().
|
inline |
|
inline |
Deletes the layer at the specified position.
Definition at line 442 of file Graph.hpp.
References armnn::LayerErased.
Referenced by BOOST_AUTO_TEST_CASE(), Graph::EraseLayer(), DynamicQuantizationVisitor::FinishVisit(), Optimizer::Pass(), OptimizeForConnectionImpl< BaseType, ChildType, Wrapped >::Run(), Graph::SubstituteSubgraph(), and Graph::~Graph().
|
inline |
Deletes the layer. Sets layer to nullptr on return. Templated to support pointers to any layer type.
Definition at line 450 of file Graph.hpp.
References Graph::EraseLayer(), and Graph::GetPosInGraph().
|
inline |
Definition at line 39 of file Graph.hpp.
Referenced by Graph::AddCompatibilityLayers(), BOOST_AUTO_TEST_CASE(), Graph::operator=(), 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 181 of file Graph.hpp.
References Graph::InputLayersAccessor::InputLayersAccessor().
Referenced by armnn::BOOST_AUTO_TEST_CASE(), LoadedNetwork::EnqueueWorkload(), armnn::GetInputTensorInfo(), and NetworkQuantizer::OverrideInputRange().
|
inline |
Definition at line 176 of file Graph.hpp.
Referenced by Graph::InputLayersAccessor::end(), and LoadedNetwork::EnqueueWorkload().
|
inline |
Definition at line 187 of file Graph.hpp.
References Graph::AddCompatibilityLayers(), Graph::AllocateDynamicBuffers(), Graph::InferTensorInfos(), and Graph::SubstituteSubgraph().
Referenced by BOOST_AUTO_TEST_CASE(), and LoadedNetwork::EnqueueWorkload().
|
inline |
Definition at line 177 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 185 of file Graph.hpp.
Referenced by LoadedNetwork::EnqueueWorkload().
|
inline |
Gets the position of a layer in the graph.
Definition at line 389 of file Graph.hpp.
Referenced by Graph::DetachObservable(), Graph::EraseLayer(), Graph::InsertNewLayer(), and Optimizer::Pass().
void InferTensorInfos | ( | ) |
Definition at line 493 of file Graph.cpp.
References armnn::GetLayerTypeAsCString(), IOutputSlot::IsTensorInfoSet(), and Graph::TopologicalSort().
Referenced by BOOST_AUTO_TEST_CASE(), Graph::GetNumLayers(), PreluValidateTensorShapesFromInputsMatchTest(), PreluValidateTensorShapesFromInputsNoMatchTest(), StackValidateTensorShapesFromInputsMatchTest(), and StackValidateTensorShapesFromInputsNoMatchTest().
|
inline |
Inserts a new layer between the output slot currently connected to insertBefore and insertBefore itself.
Definition at line 409 of file Graph.hpp.
References InputSlot::GetConnectedOutputSlot(), InputSlot::GetOwningLayer(), OutputSlot::GetOwningLayer(), Graph::GetPosInGraph(), InputSlot::Insert(), and armnn::LayerAdded.
Referenced by BOOST_AUTO_TEST_CASE(), armnn::InsertConvertFp16ToFp32LayersBefore(), armnn::InsertConvertFp32ToFp16LayersAfter(), armnn::InsertDebugLayerAfter(), PermuteAsReshapeImpl::Run(), FoldPadIntoConvolution2dImpl::Run(), OptimizeConsecutiveReshapesImpl::Run(), MovePermuteUpImpl::Run(), and Graph::~Graph().
|
inline |
Inserts a new layer between insertAfter and the input slot(s) currently connected to it.
Definition at line 425 of file Graph.hpp.
References OutputSlot::Connect(), OutputSlot::GetOwningLayer(), Graph::GetPosInGraph(), armnn::LayerAdded, and OutputSlot::MoveAllConnections().
Referenced by Graph::Graph().
Status Print | ( | ) | const |
Definition at line 61 of file Graph.cpp.
References ARMNN_LOG, armnn::GetLayerTypeAsCString(), armnn::info, armnn::Success, and Graph::TopologicalSort().
Referenced by CheckOrder(), and Graph::~Graph().
Status SerializeToDot | ( | std::ostream & | stream | ) |
Definition at line 81 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 BOOST_AUTO_TEST_CASE(), 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 396 of file Graph.cpp.
Referenced by armnn::ApplyBackendOptimizations(), BOOST_AUTO_TEST_CASE(), and Graph::GetNumLayers().
void SubstituteSubgraph | ( | SubgraphView & | subgraph, |
const SubgraphView & | substituteSubgraph | ||
) |
Definition at line 404 of file Graph.cpp.
References SubgraphView::Clear(), IOutputSlot::Connect(), IOutputSlot::Disconnect(), Graph::EraseLayer(), SubgraphView::ForEachLayer(), InputSlot::GetConnection(), SubgraphView::GetInputSlots(), SubgraphView::GetLayers(), SubgraphView::GetOutputSlots(), OutputSlot::MoveAllConnections(), Layer::Reparent(), and Graph::TopologicalSort().
|
inline |
Sorts layers in topological order and return this.
Definition at line 173 of file Graph.hpp.
References Graph::TopologicalSort().
Referenced by BOOST_AUTO_TEST_CASE(), CheckOrder(), NetworkQuantizer::ExportNetwork(), Graph::InferTensorInfos(), LoadedNetwork::MakeLoadedNetwork(), Optimizer::Pass(), Graph::Print(), NetworkQuantizer::Refine(), Graph::SubstituteSubgraph(), and Graph::TopologicalSort().
const Graph & TopologicalSort | ( | ) | const |