nndeploy.dag.node

Functions

add_global_import_lib(path)

Add a path to the global import library.

add_global_import_lib_class(module_name, ...)

Add a class to the global import library.

add_global_import_lib_function(module_name, ...)

Add a function to the global import library.

add_global_import_lib_module(module_name)

Add a module to the global import library.

add_remove_node_keys(node_keys)

Add node keys to the removal list.

create_node(node_key, node_name[, inputs, ...])

Create a node instance using the registered creator.

get_all_node_json()

Get JSON representation of all registered nodes organized in a tree structure.

get_node_json(node_key)

Get the JSON representation of a node type.

get_node_keys()

Get all registered node keys.

import_global_import_lib()

Import all items in the global import library.

register_node(node_key, node_creator)

Register a node creator with a specific key.

sub_remove_node_keys(node_keys)

Remove node keys from the removal list.

Classes

ImportLib()

Library import manager for handling dynamic library and Python module imports.

Node(name[, inputs, outputs])

Main Node class that wraps the C++ Node implementation.

NodeCreator()

Abstract base class for creating nodes.

NodeDesc([name, inputs, outputs, key])

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)[源代码]

基类:NodeDesc

Node 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

get_key() str[源代码]

Get the unique key of the node.

get_name() str[源代码]

Get the node name.

get_inputs() list[str][源代码]

Get the list of input names.

get_outputs() list[str][源代码]

Get the list of output names.

serialize(target: str)[源代码]

Serialize the node description to a string.

deserialize(target: str)[源代码]

Deserialize the node description from a string.

load_file(self: nndeploy._nndeploy_internal.dag.NodeDesc, path: str) nndeploy._nndeploy_internal.base.Status
save_file(self: nndeploy._nndeploy_internal.dag.NodeDesc, path: str) nndeploy._nndeploy_internal.base.Status
class nndeploy.dag.node.Node(name: str, inputs=None, outputs=None)[源代码]

基类:Node

Main 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_key(key: str)[源代码]

Set the unique key for the node.

get_key() str[源代码]

Get the unique key of the node.

set_name(name: str)[源代码]

Set the name of the node.

get_name() str[源代码]

Get the name of the node.

set_developer(developer: str)[源代码]

Set the developer information for the node.

get_developer() str[源代码]

Get the developer information of the node.

set_source(source: str)[源代码]

Set the source code repository information for the node.

get_source() str[源代码]

Get the source code repository information of the node.

set_desc(desc: str)[源代码]

Set the description of the node.

get_desc() str[源代码]

Get the description of the node.

set_graph(graph)[源代码]

Set the parent graph for this node.

get_graph()[源代码]

Get the parent graph of this node.

set_device_type(device_type: DeviceType)[源代码]

Set the device type for node execution.

get_device_type() DeviceType[源代码]

Get the device type of the node.

set_param(param)[源代码]

Set the parameters for the node.

get_param()[源代码]

Get the parameters of the node.

set_external_param(key: str, external_param)[源代码]

Set external parameters using key-value pairs.

get_external_param(key: str)[源代码]

Get external parameters by key.

add_resource_without_state(key: str, value)[源代码]

Add stateless resources using key-value pairs.

get_resource_without_state(key: str)[源代码]

Get stateless resources by key.

create_resource_with_state(key: str) Edge[源代码]

Create stateful resources and return an edge pointer.

add_resource_with_state(key: str, edge: Edge)[源代码]

Add stateful resources using key and edge.

get_resource_with_state(key: str) Edge[源代码]

Get stateful resource edge by key.

set_version(version: str)[源代码]

Set the version of the node.

get_version() str[源代码]

Get the version of the node.

set_required_params(required_params: list)[源代码]

Set the list of required parameters.

add_required_param(required_param: str)[源代码]

Add a required parameter.

remove_required_param(required_param: str)[源代码]

Remove a required parameter.

clear_required_params()[源代码]

Clear the list of required parameters.

get_required_params() list[源代码]

Get the list of required parameters.

set_ui_params(ui_params: list)[源代码]

Set the list of UI parameters.

add_ui_param(ui_param: str)[源代码]

Add a UI parameter.

remove_ui_param(ui_param: str)[源代码]

Remove a UI parameter.

clear_ui_params()[源代码]

Clear the list of UI parameters.

get_ui_params() list[源代码]

Get the list of UI parameters.

set_io_params(io_params: list)[源代码]

Set the list of IO parameters.

add_io_param(io_param: str)[源代码]

Add an IO parameter.

remove_io_param(io_param: str)[源代码]

Remove an IO parameter.

clear_io_params()[源代码]

Clear the list of IO parameters.

get_io_params() list[源代码]

Get the list of IO parameters.

set_dropdown_params(dropdown_params: dict)[源代码]

Set the list of dropdown parameters.

add_dropdown_param(dropdown_param: str, dropdown_values: list)[源代码]

Add a dropdown parameter.

remove_dropdown_param(dropdown_param: str)[源代码]

Remove a dropdown parameter.

clear_dropdown_params()[源代码]

Clear the list of dropdown parameters.

set_input(input, index: int = -1)[源代码]

Set input at the specified index.

set_iter_input(input, index: int = -1)[源代码]

Set iterative input at the specified index.

set_output(output, index: int = -1)[源代码]

Set output at the specified index.

set_inputs(inputs)[源代码]

Set all inputs for the node.

set_outputs(outputs)[源代码]

Set all outputs for the node.

get_input(index: int = 0)[源代码]

Get input at the specified index.

get_output(index: int = 0)[源代码]

Get output at the specified index.

get_input_data(index: int = 0)[源代码]

Get input data at the specified index.

set_output_data(output, index: int = 0, is_external: bool = True)[源代码]

Set output data at the specified index.

get_all_input()[源代码]

Get all inputs of the node.

get_all_output()[源代码]

Get all outputs of the node.

get_constructed() bool[源代码]

Check if the node has been constructed.

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_inner_flag(flag: bool)[源代码]

Set the inner flag for the node.

set_initialized_flag(flag: bool)[源代码]

Set the initialization flag for the node.

get_initialized() bool[源代码]

Check if the node has been initialized.

set_time_profile_flag(flag: bool)[源代码]

Enable or disable time profiling for the node.

get_time_profile_flag() bool[源代码]

Check if time profiling is enabled.

set_debug_flag(flag: bool)[源代码]

Enable or disable debug mode for the node.

get_debug_flag() bool[源代码]

Check if debug mode is enabled.

set_running_flag(flag: bool)[源代码]

Set the running flag for the node.

is_running() bool[源代码]

Check if the node is currently running.

get_run_size() int[源代码]

Get the run size of the node.

get_completed_size() int[源代码]

Get the completed size of the node.

get_run_status() RunStatus[源代码]

Get the run status of the node.

set_trace_flag(flag: bool)[源代码]

Enable or disable tracing for the node.

get_trace_flag() bool[源代码]

Check if tracing is enabled.

set_graph_flag(flag: bool)[源代码]

Set the graph flag for the node.

get_graph_flag() bool[源代码]

Check if the graph flag is set.

set_node_type(node_type)[源代码]

Set the node type.

get_node_type()[源代码]

Get the node type.

set_io_type(io_type)[源代码]

Set the I/O type for the node.

get_io_type()[源代码]

Get the I/O type of the node.

set_loop_count(loop_count: int)[源代码]

Set the loop count for the node.

get_loop_count() int[源代码]

Get the loop count of the node.

set_stream(stream)[源代码]

Set the execution stream for the node.

get_stream()[源代码]

Get the execution stream 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.

set_output_type(output_type: type, desc: str = '')[源代码]

Set the output type for the node.

get_output_type_info() EdgeTypeInfo[源代码]

Get the output type information of the node.

init()[源代码]

Initialize the node.

deinit()[源代码]

Deinitialize the node and clean up resources.

get_memory_size() int[源代码]

Get the memory size required by the node.

set_memory(buffer: Buffer)[源代码]

Set the memory buffer for the node.

update_input()[源代码]

Update the input data for the node.

run()[源代码]

Execute the node’s main computation.

synchronize() bool[源代码]

Synchronize the node execution.

check_inputs(inputs) bool[源代码]

Validate the input data.

check_outputs(outputs_name) bool[源代码]

Validate the output names.

get_real_outputs_name()[源代码]

Get the actual output names.

serialize() str[源代码]

Serialize the node to a JSON string.

save_file(path: str)[源代码]

Save the node configuration to a file.

deserialize(target: str)[源代码]

Deserialize the node from a JSON string.

load_file(path: str)[源代码]

Load the node configuration from a file.

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.

  1. forward(self: nndeploy._nndeploy_internal.dag.Node, inputs: list[nndeploy::dag::Edge]) -> list[nndeploy::dag::Edge]

  2. forward(self: nndeploy._nndeploy_internal.dag.Node) -> list[nndeploy::dag::Edge]

  3. 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
get_dropdown_params(self: nndeploy._nndeploy_internal.dag.Node) dict[str, list[str]]
get_input_count(self: nndeploy._nndeploy_internal.dag.Node) int
get_input_index(self: nndeploy._nndeploy_internal.dag.Node, name: str) int
get_input_name(self: nndeploy._nndeploy_internal.dag.Node, index: int = 0) str
get_input_names(self: nndeploy._nndeploy_internal.dag.Node) list[str]
get_output_count(self: nndeploy._nndeploy_internal.dag.Node) int
get_output_index(self: nndeploy._nndeploy_internal.dag.Node, name: str) int
get_output_name(self: nndeploy._nndeploy_internal.dag.Node, index: int = 0) str
get_output_names(self: nndeploy._nndeploy_internal.dag.Node) list[str]
is_dynamic_input(self: nndeploy._nndeploy_internal.dag.Node) bool
is_dynamic_output(self: nndeploy._nndeploy_internal.dag.Node) bool
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_dynamic_input(self: nndeploy._nndeploy_internal.dag.Node, is_dynamic_input: bool) None
set_dynamic_output(self: nndeploy._nndeploy_internal.dag.Node, is_dynamic_output: bool) None
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_input_shared_ptr(self: nndeploy._nndeploy_internal.dag.Node, input: nndeploy::dag::Edge, index: int = -1) nndeploy._nndeploy_internal.base.Status
set_inputs_shared_ptr(self: nndeploy._nndeploy_internal.dag.Node, inputs: list[nndeploy::dag::Edge]) 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
set_output_shared_ptr(self: nndeploy._nndeploy_internal.dag.Node, output: nndeploy::dag::Edge, index: int = -1) nndeploy._nndeploy_internal.base.Status
set_outputs_shared_ptr(self: nndeploy._nndeploy_internal.dag.Node, outputs: list[nndeploy::dag::Edge]) nndeploy._nndeploy_internal.base.Status
to_static_graph(self: nndeploy._nndeploy_internal.dag.Node) nndeploy._nndeploy_internal.base.Status
class nndeploy.dag.node.NodeCreator[源代码]

基类:NodeCreator

Abstract base class for creating nodes.

This class should be subclassed to implement specific node creation logic.

__init__(self: nndeploy._nndeploy_internal.dag.NodeCreator) None[源代码]
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

create_node_shared_ptr(self: nndeploy._nndeploy_internal.dag.NodeCreator, arg0: str, arg1: list[nndeploy::dag::Edge], arg2: list[nndeploy::dag::Edge]) nndeploy._nndeploy_internal.dag.Node[源代码]
nndeploy.dag.node.get_node_keys()[源代码]

Get all registered node keys.

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[源代码]

基类:object

Library 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.

__init__()[源代码]
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

import_all()[源代码]

Import all registered libraries, modules, classes, and functions.

load_py_file(py_file_path: str)[源代码]

Load a Python file directly as a module.

参数:

py_file_path – Path to the Python file

返回:

The loaded module or None if failed

import_module(module_name: str)[源代码]

Import a module by name.

import_class(module_name: str, class_name: str)[源代码]

Import a class from a module.

import_function(module_name: str, function_name: str)[源代码]

Import a function from a module.

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.import_global_import_lib()[源代码]

Import all items in 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