nndeploy C++ API  0.2.0
nndeploy C++ API
Classes | Typedefs | Enumerations | Functions
nndeploy::dag Namespace Reference

Classes

class  Comment
 
class  CompositeNode
 Composite node Composite node is a special type of node in nndeploy that enhances the capabilities of one or more existing nodes by wrapping them. This composite node executes in sequential mode by default internally. More...
 
class  Condition
 
class  ConstNode
 
class  Edge
 Edge class in DAG graph for connecting nodes and transferring data. More...
 
class  EdgeTypeInfo
 输入输出类型信息 More...
 
class  EdgeWrapper
 
class  Executor
 
class  FixedLoop
 
class  Graph
 Directed Acyclic Graph Node. More...
 
class  GraphRunner
 GraphRunner类,用于运行图计算 More...
 
struct  GraphRunnerResult
 
class  Loop
 
class  Node
 Node base class. More...
 
class  NodeCreator
 Node creator base class. More...
 
class  NodeDesc
 Node description class. More...
 
class  NodeFactory
 Node factory class. More...
 
class  NodeWrapper
 
class  RunningCondition
 
struct  RunStatus
 
class  TypeGraphRegister
 
class  TypeNodeCreator
 Typed node creator. More...
 

Typedefs

using createGraphFunc = std::function< Graph *(const std::string &name, base::InferenceType inference_type, base::DeviceType device_type, Edge *input, Edge *output, base::ModelType model_type, bool is_path, std::vector< std::string > model_value)>
 
using NodeFunc = std::function< base::Status(std::vector< Edge * > inputs, std::vector< Edge * > outputs, base::Param *param)>
 Node function type definition. More...
 

Enumerations

enum class  EdgeTypeFlag {
  kBuffer = 1 , kCvMat = 2 , kTensor = 4 , kParam = 8 ,
  kAny = 1 << 30 , kNone = 1 << 31
}
 
enum class  IOType {
  kIOTypeNone = 0 , kIOTypeBool = 1 , kIOTypeNum = 2 , kIOTypeString = 3 ,
  kIOTypeText = 10 , kIOTypeJson = 11 , kIOTypeXml = 12 , kIOTypeCsv = 13 ,
  kIOTypeYaml = 14 , kIOTypeBinary = 15 , kIOTypeImage = 20 , kIOTypeVideo = 21 ,
  kIOTypeAudio = 22 , kIOTypeCamera = 23 , kIOTypeMicrophone = 24 , kIOTypeModel = 30 ,
  kIOTypeDir = 31 , kIOTypeAny = 100
}
 
enum class  NodeType { kNodeTypeInput = 1 , kNodeTypeOutput = 2 , kNodeTypeIntermediate = 3 }
 

Functions

bool checkEdge (const std::vector< Edge * > &src_edges, const std::vector< Edge * > &dst_edges)
 
std::vector< EdgeWrapper * > checkUnuseEdge (std::vector< NodeWrapper * > &node_repository, std::vector< EdgeWrapper * > &edge_repository)
 
std::vector< NodeWrapper * > checkUnuseNode (std::vector< NodeWrapper * > &node_repository)
 
GraphcreateGraph (const std::string &name, base::InferenceType inference_type, base::DeviceType device_type, Edge *input, Edge *output, base::ModelType model_type, bool is_path, std::vector< std::string > model_value)
 
NodecreateNode (const std::string &node_key, const std::string &node_name)
 Create node. More...
 
NodecreateNode (const std::string &node_key, const std::string &node_name, std::initializer_list< Edge * > inputs, std::initializer_list< Edge * > outputs)
 Create node. More...
 
NodecreateNode (const std::string &node_key, const std::string &node_name, std::vector< Edge * > inputs, std::vector< Edge * > outputs)
 Create node. More...
 
std::shared_ptr< NodecreateNodeSharedPtr (const std::string &node_key, const std::string &node_name)
 Create node (shared pointer) More...
 
std::shared_ptr< NodecreateNodeSharedPtr (const std::string &node_key, const std::string &node_name, std::initializer_list< Edge * > inputs, std::initializer_list< Edge * > outputs)
 Create node (shared pointer) More...
 
std::shared_ptr< NodecreateNodeSharedPtr (const std::string &node_key, const std::string &node_name, std::vector< Edge * > inputs, std::vector< Edge * > outputs)
 Create node (shared pointer) More...
 
Graphdeserialize (const std::string &json_str)
 
Graphdeserialize (rapidjson::Value &json)
 
base::Status dumpDag (std::vector< EdgeWrapper * > &edge_repository, std::vector< NodeWrapper * > &node_repository, std::vector< Edge * > &graph_inputs, std::vector< Edge * > &graph_outputs, const std::string &name, std::ostream &oss)
 
void findConsumerNode (EdgeWrapper *edge_wrapper, std::vector< Node * > &consumers)
 
EdgeWrapperfindEdgeWrapper (std::vector< EdgeWrapper * > &edge_repository, const std::string &edge_name)
 
EdgeWrapperfindEdgeWrapper (std::vector< EdgeWrapper * > &edge_repository, Edge *edge)
 
std::vector< EdgeWrapper * > findEndEdges (std::vector< EdgeWrapper * > &edge_repository)
 
std::vector< NodeWrapper * > findEndNodes (std::vector< NodeWrapper * > &node_repository)
 
NodeWrapperfindNodeWrapper (std::vector< NodeWrapper * > &node_repository, const std::string &node_name)
 
NodeWrapperfindNodeWrapper (std::vector< NodeWrapper * > &node_repository, Node *node)
 
void findProducerNode (EdgeWrapper *edge_wrapper, std::vector< Node * > &producers)
 
std::vector< EdgeWrapper * > findStartEdges (std::vector< EdgeWrapper * > &edge_repository)
 
std::vector< NodeWrapper * > findStartNodes (std::vector< NodeWrapper * > &node_repository)
 
EdgegetEdge (std::vector< EdgeWrapper * > &edge_repository, const std::string &edge_name)
 
std::map< std::string, createGraphFunc > & getGlobalGraphCreatorMap ()
 
NodeFactorygetGlobalNodeFactory ()
 Get global node factory. More...
 
NodegetNode (std::vector< NodeWrapper * > &node_repository, const std::string &node_name)
 
std::set< std::string > getNodeKeys ()
 Get all node keys. More...
 
template<typename T >
void insertUnique (std::vector< T > &vec, const T &val)
 对vector插入不在vector中的元素,即类似集合的作用 More...
 
std::string ioTypeToString (IOType io_type)
 
GraphloadFile (const std::string &path)
 
std::string nodeTypeToString (NodeType node_type)
 
std::string removeNamespace (const std::string &type_name_with_namespace)
 
void replaceGraphJsonObj (std::map< std::string, std::map< std::string, std::string >> node_value_map, rapidjson::Value &json, rapidjson::Document::AllocatorType &allocator)
 
std::string replaceGraphJsonStr (std::map< std::string, std::map< std::string, std::string >> node_value_map, const std::string &json_str)
 
base::Status saveFile (Graph *graph, const std::string &path)
 
std::string serialize (Graph *graph)
 
base::Status serialize (Graph *graph, rapidjson::Value &json, rapidjson::Document::AllocatorType &allocator)
 
base::Status setColor (std::vector< NodeWrapper * > &node_repository, base::NodeColorType color)
 
IOType stringToIoType (const std::string &io_type_str)
 
NodeType stringToNodeType (const std::string &node_type_str)
 
base::Status topoSort (std::vector< NodeWrapper * > &node_repository, base::TopoSortType topo_sort_type, std::vector< NodeWrapper * > &topo_sort_node)
 
base::Status topoSortBFS (std::vector< NodeWrapper * > &node_repository, std::vector< NodeWrapper * > &topo_sort_node)
 
base::Status topoSortDFS (std::vector< NodeWrapper * > &node_repository, std::vector< NodeWrapper * > &topo_sort_node)
 
template<typename T >
std::string typeName ()
 

Typedef Documentation

◆ createGraphFunc

using nndeploy::dag::createGraphFunc = typedef std::function<Graph *( const std::string &name, base::InferenceType inference_type, base::DeviceType device_type, Edge *input, Edge *output, base::ModelType model_type, bool is_path, std::vector<std::string> model_value)>

Definition at line 2561 of file graph.h.

◆ NodeFunc

using nndeploy::dag::NodeFunc = typedef std::function<base::Status(std::vector<Edge *> inputs, std::vector<Edge *> outputs, base::Param *param)>

Node function type definition.

Function type for functional node callbacks

Definition at line 1593 of file node.h.

Enumeration Type Documentation

◆ EdgeTypeFlag

Enumerator
kBuffer 
kCvMat 
kTensor 
kParam 
kAny 
kNone 

Definition at line 65 of file base.h.

◆ IOType

enum nndeploy::dag::IOType
strong
Enumerator
kIOTypeNone 
kIOTypeBool 
kIOTypeNum 
kIOTypeString 
kIOTypeText 
kIOTypeJson 
kIOTypeXml 
kIOTypeCsv 
kIOTypeYaml 
kIOTypeBinary 
kIOTypeImage 
kIOTypeVideo 
kIOTypeAudio 
kIOTypeCamera 
kIOTypeMicrophone 
kIOTypeModel 
kIOTypeDir 
kIOTypeAny 

Definition at line 32 of file base.h.

◆ NodeType

Enumerator
kNodeTypeInput 
kNodeTypeOutput 
kNodeTypeIntermediate 

Definition at line 26 of file base.h.

Function Documentation

◆ checkEdge()

bool nndeploy::dag::checkEdge ( const std::vector< Edge * > &  src_edges,
const std::vector< Edge * > &  dst_edges 
)

◆ checkUnuseEdge()

std::vector<EdgeWrapper *> nndeploy::dag::checkUnuseEdge ( std::vector< NodeWrapper * > &  node_repository,
std::vector< EdgeWrapper * > &  edge_repository 
)

◆ checkUnuseNode()

std::vector<NodeWrapper *> nndeploy::dag::checkUnuseNode ( std::vector< NodeWrapper * > &  node_repository)

◆ createGraph()

Graph* nndeploy::dag::createGraph ( const std::string &  name,
base::InferenceType  inference_type,
base::DeviceType  device_type,
Edge input,
Edge output,
base::ModelType  model_type,
bool  is_path,
std::vector< std::string >  model_value 
)

◆ createNode() [1/3]

Node* nndeploy::dag::createNode ( const std::string &  node_key,
const std::string &  node_name 
)

Create node.

Parameters
node_keyNode key
node_nameNode name
Returns
Node pointer

◆ createNode() [2/3]

Node* nndeploy::dag::createNode ( const std::string &  node_key,
const std::string &  node_name,
std::initializer_list< Edge * >  inputs,
std::initializer_list< Edge * >  outputs 
)

Create node.

Parameters
node_keyNode key
node_nameNode name
inputsInput edge list
outputsOutput edge list
Returns
Node pointer

◆ createNode() [3/3]

Node* nndeploy::dag::createNode ( const std::string &  node_key,
const std::string &  node_name,
std::vector< Edge * >  inputs,
std::vector< Edge * >  outputs 
)

Create node.

Parameters
node_keyNode key
node_nameNode name
inputsInput edge vector
outputsOutput edge vector
Returns
Node pointer

◆ createNodeSharedPtr() [1/3]

std::shared_ptr<Node> nndeploy::dag::createNodeSharedPtr ( const std::string &  node_key,
const std::string &  node_name 
)

Create node (shared pointer)

Parameters
node_keyNode key
node_nameNode name
Returns
Node shared pointer

◆ createNodeSharedPtr() [2/3]

std::shared_ptr<Node> nndeploy::dag::createNodeSharedPtr ( const std::string &  node_key,
const std::string &  node_name,
std::initializer_list< Edge * >  inputs,
std::initializer_list< Edge * >  outputs 
)

Create node (shared pointer)

Parameters
node_keyNode key
node_nameNode name
inputsInput edge list
outputsOutput edge list
Returns
Node shared pointer

◆ createNodeSharedPtr() [3/3]

std::shared_ptr<Node> nndeploy::dag::createNodeSharedPtr ( const std::string &  node_key,
const std::string &  node_name,
std::vector< Edge * >  inputs,
std::vector< Edge * >  outputs 
)

Create node (shared pointer)

Parameters
node_keyNode key
node_nameNode name
inputsInput edge vector
outputsOutput edge vector
Returns
Node shared pointer

◆ deserialize() [1/2]

Graph* nndeploy::dag::deserialize ( const std::string &  json_str)

◆ deserialize() [2/2]

Graph* nndeploy::dag::deserialize ( rapidjson::Value &  json)

◆ dumpDag()

base::Status nndeploy::dag::dumpDag ( std::vector< EdgeWrapper * > &  edge_repository,
std::vector< NodeWrapper * > &  node_repository,
std::vector< Edge * > &  graph_inputs,
std::vector< Edge * > &  graph_outputs,
const std::string &  name,
std::ostream &  oss 
)

◆ findConsumerNode()

void nndeploy::dag::findConsumerNode ( EdgeWrapper edge_wrapper,
std::vector< Node * > &  consumers 
)

◆ findEdgeWrapper() [1/2]

EdgeWrapper* nndeploy::dag::findEdgeWrapper ( std::vector< EdgeWrapper * > &  edge_repository,
const std::string &  edge_name 
)

◆ findEdgeWrapper() [2/2]

EdgeWrapper* nndeploy::dag::findEdgeWrapper ( std::vector< EdgeWrapper * > &  edge_repository,
Edge edge 
)

◆ findEndEdges()

std::vector<EdgeWrapper *> nndeploy::dag::findEndEdges ( std::vector< EdgeWrapper * > &  edge_repository)

◆ findEndNodes()

std::vector<NodeWrapper *> nndeploy::dag::findEndNodes ( std::vector< NodeWrapper * > &  node_repository)

◆ findNodeWrapper() [1/2]

NodeWrapper* nndeploy::dag::findNodeWrapper ( std::vector< NodeWrapper * > &  node_repository,
const std::string &  node_name 
)

◆ findNodeWrapper() [2/2]

NodeWrapper* nndeploy::dag::findNodeWrapper ( std::vector< NodeWrapper * > &  node_repository,
Node node 
)

◆ findProducerNode()

void nndeploy::dag::findProducerNode ( EdgeWrapper edge_wrapper,
std::vector< Node * > &  producers 
)

◆ findStartEdges()

std::vector<EdgeWrapper *> nndeploy::dag::findStartEdges ( std::vector< EdgeWrapper * > &  edge_repository)

◆ findStartNodes()

std::vector<NodeWrapper *> nndeploy::dag::findStartNodes ( std::vector< NodeWrapper * > &  node_repository)

◆ getEdge()

Edge* nndeploy::dag::getEdge ( std::vector< EdgeWrapper * > &  edge_repository,
const std::string &  edge_name 
)

◆ getGlobalGraphCreatorMap()

std::map<std::string, createGraphFunc>& nndeploy::dag::getGlobalGraphCreatorMap ( )

◆ getGlobalNodeFactory()

NodeFactory* nndeploy::dag::getGlobalNodeFactory ( )

Get global node factory.

Returns
Global node factory pointer

◆ getNode()

Node* nndeploy::dag::getNode ( std::vector< NodeWrapper * > &  node_repository,
const std::string &  node_name 
)

◆ getNodeKeys()

std::set<std::string> nndeploy::dag::getNodeKeys ( )

Get all node keys.

Returns
Node key set

◆ insertUnique()

template<typename T >
void nndeploy::dag::insertUnique ( std::vector< T > &  vec,
const T &  val 
)

对vector插入不在vector中的元素,即类似集合的作用

Template Parameters
T
Parameters
vecMy Param doc
valMy Param doc

Definition at line 96 of file util.h.

◆ ioTypeToString()

std::string nndeploy::dag::ioTypeToString ( IOType  io_type)

◆ loadFile()

Graph* nndeploy::dag::loadFile ( const std::string &  path)

◆ nodeTypeToString()

std::string nndeploy::dag::nodeTypeToString ( NodeType  node_type)

◆ removeNamespace()

std::string nndeploy::dag::removeNamespace ( const std::string &  type_name_with_namespace)

◆ replaceGraphJsonObj()

void nndeploy::dag::replaceGraphJsonObj ( std::map< std::string, std::map< std::string, std::string >>  node_value_map,
rapidjson::Value &  json,
rapidjson::Document::AllocatorType &  allocator 
)

◆ replaceGraphJsonStr()

std::string nndeploy::dag::replaceGraphJsonStr ( std::map< std::string, std::map< std::string, std::string >>  node_value_map,
const std::string &  json_str 
)

◆ saveFile()

base::Status nndeploy::dag::saveFile ( Graph graph,
const std::string &  path 
)

◆ serialize() [1/2]

std::string nndeploy::dag::serialize ( Graph graph)

◆ serialize() [2/2]

base::Status nndeploy::dag::serialize ( Graph graph,
rapidjson::Value &  json,
rapidjson::Document::AllocatorType &  allocator 
)

◆ setColor()

base::Status nndeploy::dag::setColor ( std::vector< NodeWrapper * > &  node_repository,
base::NodeColorType  color 
)

◆ stringToIoType()

IOType nndeploy::dag::stringToIoType ( const std::string &  io_type_str)

◆ stringToNodeType()

NodeType nndeploy::dag::stringToNodeType ( const std::string &  node_type_str)

◆ topoSort()

base::Status nndeploy::dag::topoSort ( std::vector< NodeWrapper * > &  node_repository,
base::TopoSortType  topo_sort_type,
std::vector< NodeWrapper * > &  topo_sort_node 
)

◆ topoSortBFS()

base::Status nndeploy::dag::topoSortBFS ( std::vector< NodeWrapper * > &  node_repository,
std::vector< NodeWrapper * > &  topo_sort_node 
)

◆ topoSortDFS()

base::Status nndeploy::dag::topoSortDFS ( std::vector< NodeWrapper * > &  node_repository,
std::vector< NodeWrapper * > &  topo_sort_node 
)

◆ typeName()

template<typename T >
std::string nndeploy::dag::typeName ( )

Definition at line 75 of file base.h.