nndeploy.dag.node¶
Functions
|
Add a path to the global import library. |
|
Add a class to the global import library. |
|
Add a function to the global import library. |
|
Add a module to the global import library. |
|
Add node keys to the removal list. |
|
Create a node instance using the registered creator. |
Get JSON representation of all registered nodes organized in a tree structure. |
|
|
Get the JSON representation of a node type. |
Get all registered node keys. |
|
Import all items in the global import library. |
|
|
Register a node creator with a specific key. |
|
Remove node keys from the removal list. |
Classes
Library import manager for handling dynamic library and Python module imports. |
|
|
Main Node class that wraps the C++ Node implementation. |
Abstract base class for creating nodes. |
|
|
Node description class that wraps the C++ NodeDesc. |
- class nndeploy.dag.node.NodeDesc(name: str = '', inputs: list[str] = None, outputs: list[str] = None, key: str = None)[源代码]¶
基类:
NodeDescNode description class that wraps the C++ NodeDesc.
This class provides a Python interface for node descriptions, including name, inputs, outputs, and optional key.
- __init__(name: str = '', inputs: list[str] = None, outputs: list[str] = None, key: str = None)[源代码]¶
Initialize the node description.
- 参数:
name – Node name
inputs – List of input names
outputs – List of output names
key – Optional node key
- class nndeploy.dag.node.Node(name: str, inputs=None, outputs=None)[源代码]¶
基类:
NodeMain Node class that wraps the C++ Node implementation.
This class provides a Python interface for graph nodes, including initialization, execution, parameter management, and I/O handling.
- __init__(name: str, inputs=None, outputs=None)[源代码]¶
Initialize the node.
- 参数:
name – The name of the node
inputs – List of input edges or None
outputs – List of output edges or None
- set_device_type(device_type: DeviceType)[源代码]¶
Set the device type for node execution.
- get_device_type() DeviceType[源代码]¶
Get the device type of the node.
- create_resource_with_state(key: str) Edge[源代码]¶
Create stateful resources and return an edge pointer.
- set_output_data(output, index: int = 0, is_external: bool = True)[源代码]¶
Set output data at the specified index.
- set_parallel_type(parallel_type: ParallelType)[源代码]¶
Set the parallel execution type for the node.
- get_parallel_type() ParallelType[源代码]¶
Get the parallel execution type of the node.
- set_input_type_info(input_type_info: EdgeTypeInfo, desc: str = '')[源代码]¶
Set the input type information for the node.
- set_input_type(input_type: type, desc: str = '')[源代码]¶
Set the input type for the node.
- 参数:
input_type – The input type
- 返回:
Status code
- get_input_type_info() EdgeTypeInfo[源代码]¶
Get the input type information of the node.
- set_output_type_info(output_type_info: EdgeTypeInfo, desc: str = '')[源代码]¶
Set the output type information for the node.
- get_output_type_info() EdgeTypeInfo[源代码]¶
Get the output type information of the node.
- create_internal_output_edge(self: nndeploy._nndeploy_internal.dag.Node, name: str) nndeploy::dag::Edge¶
- default_param(self: nndeploy._nndeploy_internal.dag.Node) nndeploy._nndeploy_internal.base.Status¶
- forward(*args, **kwargs)¶
Overloaded function.
forward(self: nndeploy._nndeploy_internal.dag.Node, inputs: list[nndeploy::dag::Edge]) -> list[nndeploy::dag::Edge]
forward(self: nndeploy._nndeploy_internal.dag.Node) -> list[nndeploy::dag::Edge]
forward(self: nndeploy._nndeploy_internal.dag.Node, input: nndeploy::dag::Edge) -> list[nndeploy::dag::Edge]
- get_composite_node(self: nndeploy._nndeploy_internal.dag.Node) nndeploy::dag::CompositeNode¶
- is_inputs_changed(self: nndeploy._nndeploy_internal.dag.Node, inputs: list[nndeploy::dag::Edge]) bool¶
- set_composite_node(self: nndeploy._nndeploy_internal.dag.Node, composite_node: nndeploy::dag::CompositeNode) nndeploy._nndeploy_internal.base.Status¶
- set_input_name(self: nndeploy._nndeploy_internal.dag.Node, name: str, index: int = 0) nndeploy._nndeploy_internal.base.Status¶
- set_input_names(self: nndeploy._nndeploy_internal.dag.Node, names: list[str]) nndeploy._nndeploy_internal.base.Status¶
- set_output_name(self: nndeploy._nndeploy_internal.dag.Node, name: str, index: int = 0) nndeploy._nndeploy_internal.base.Status¶
- set_output_names(self: nndeploy._nndeploy_internal.dag.Node, names: list[str]) nndeploy._nndeploy_internal.base.Status¶
- to_static_graph(self: nndeploy._nndeploy_internal.dag.Node) nndeploy._nndeploy_internal.base.Status¶
- class nndeploy.dag.node.NodeCreator[源代码]¶
基类:
NodeCreatorAbstract base class for creating nodes.
This class should be subclassed to implement specific node creation logic.
- create_node(name: str, inputs: list[nndeploy.dag.edge.Edge], outputs: list[nndeploy.dag.edge.Edge])[源代码]¶
Create a new node instance.
This method must be implemented by subclasses.
- 参数:
name – The name of the node
inputs – List of input edges
outputs – List of output edges
- 返回:
The created node instance
- nndeploy.dag.node.register_node(node_key: str, node_creator: NodeCreator)[源代码]¶
Register a node creator with a specific key.
- 参数:
node_key – The unique key for the node type
node_creator – The creator instance for this node type
- nndeploy.dag.node.create_node(node_key: str, node_name: str, inputs: list[nndeploy.dag.edge.Edge] = None, outputs: list[nndeploy.dag.edge.Edge] = None)[源代码]¶
Create a node instance using the registered creator.
- 参数:
node_key – The key of the node type to create
node_name – The name for the new node instance
inputs – Optional list of input edges
outputs – Optional list of output edges
- 返回:
The created node instance
- nndeploy.dag.node.get_node_json(node_key: str)[源代码]¶
Get the JSON representation of a node type.
This function creates a temporary node instance, initializes it with default parameters, and serializes it to JSON format.
- 参数:
node_key – The key of the node type
- 返回:
JSON string representation of the node, or empty string if failed
- class nndeploy.dag.node.ImportLib[源代码]¶
基类:
objectLibrary import manager for handling dynamic library and Python module imports.
This class manages the import of various types of libraries and modules, including dynamic libraries (.so, .dll, .dylib), Python files, and modules.
- add_path(path: str, update: bool = False)[源代码]¶
Add a path for import (library, Python file, or directory).
- 参数:
path – The path to add
update – Whether to update if already exists
- add_module(module_name: str, update: bool = False)[源代码]¶
Add a module name for import.
- 参数:
module_name – The name of the module to import
update – Whether to update if already exists
- add_class(module_name: str, class_name: str, update: bool = False)[源代码]¶
Add a class to import from a specific module.
- 参数:
module_name – The name of the module containing the class
class_name – The name of the class to import
update – Whether to update if already exists
- add_function(module_name: str, function_name: str, update: bool = False)[源代码]¶
Add a function to import from a specific module.
- 参数:
module_name – The name of the module containing the function
function_name – The name of the function to import
update – Whether to update if already exists
- nndeploy.dag.node.add_global_import_lib(path: str)[源代码]¶
Add a path to the global import library.
- 参数:
path – The path to add (file or directory)
- nndeploy.dag.node.add_global_import_lib_module(module_name: str)[源代码]¶
Add a module to the global import library.
- nndeploy.dag.node.add_global_import_lib_class(module_name: str, class_name: str)[源代码]¶
Add a class to the global import library.
- nndeploy.dag.node.add_global_import_lib_function(module_name: str, function_name: str)[源代码]¶
Add a function to the global import library.
- nndeploy.dag.node.add_remove_node_keys(node_keys: list[str])[源代码]¶
Add node keys to the removal list.
- 参数:
node_keys – List of node keys to exclude
- nndeploy.dag.node.sub_remove_node_keys(node_keys: list[str])[源代码]¶
Remove node keys from the removal list.
- 参数:
node_keys – List of node keys to include back
- nndeploy.dag.node.get_all_node_json()[源代码]¶
Get JSON representation of all registered nodes organized in a tree structure.
This function creates a hierarchical representation of all nodes based on their namespace structure, with branch nodes representing namespaces and leaf nodes representing actual node implementations.
- 返回:
JSON string containing all nodes in tree format