24 #ifndef ARM_COMPUTE_GRAPH_GRAPH_H 25 #define ARM_COMPUTE_GRAPH_GRAPH_H 82 template <
typename NT,
typename... Ts>
112 std::string
name()
const;
131 std::vector<std::unique_ptr<INode>> &
nodes();
138 const std::vector<std::unique_ptr<INode>> &
nodes()
const;
145 const std::vector<std::unique_ptr<Edge>> &
edges()
const;
152 std::vector<std::unique_ptr<Tensor>> &
tensors();
159 const std::vector<std::unique_ptr<Tensor>> &
tensors()
const;
226 std::string _name = {};
227 std::vector<std::unique_ptr<INode>> _nodes = {};
228 std::vector<std::unique_ptr<Edge>> _edges = {};
229 std::vector<std::unique_ptr<Tensor>> _tensors = {};
230 std::map<NodeType, std::vector<NodeID>> _tagged_nodes = {};
234 template <
typename NT,
typename... Ts>
240 NodeID nid = _nodes.size();
241 auto node = std::make_unique<NT>(std::forward<Ts>(
args)...);
246 _tagged_nodes[
node->
type()].push_back(nid);
249 for(
auto &output :
node->_outputs)
251 output = create_tensor();
258 _nodes.push_back(std::move(
node));
GraphID id() const
Returns graph id.
bool remove_connection(EdgeID eid)
Removes an edge (connection)
const std::vector< std::unique_ptr< Edge > > & edges() const
Returns edges of graph.
NodeID add_node(Ts &&... args)
Adds a node to the graph.
Graph & operator=(const Graph &)=delete
Prevent instances of this class from being copy assigned (As this class contains pointers) ...
std::mutex Mutex
Wrapper of Mutex data-object.
decltype(strategy::transforms) typedef type
std::string name() const
Returns graph name.
Copyright (c) 2017-2021 Arm Limited.
std::vector< std::unique_ptr< INode > > & nodes()
Returns nodes of graph.
std::vector< std::unique_ptr< Tensor > > & tensors()
Returns tensors of graph.
void set_graph(Graph *g)
Sets the graph that this node is registered to.
bool remove_node(NodeID nid)
Remove the node with the given ID.
EdgeID add_connection(NodeID source, size_t source_idx, NodeID sink, size_t sink_idx)
Adds a connection between two nodes.
void set_id(NodeID id)
Sets the node id.
const INode * node(NodeID id) const
Get node object given its id.
const Edge * edge(EdgeID id) const
Get edge object given its id.
virtual bool forward_descriptors()=0
Forwards descriptor information to outputs if possible.
virtual NodeType type() const =0
Returns node's type.
std::lock_guard< Mutex > lock_guard
Wrapper of lock_guard data-object.
const Tensor * tensor(TensorID id) const
Get tensor object given its id.