|
nndeploy C++ API
0.2.0
nndeploy C++ API
|
Edge class in DAG graph for connecting nodes and transferring data. More...
#include <edge.h>
Public Member Functions | |
| template<typename T > | |
| bool | checkTypeInfo () |
| Check if type information matches (template version) More... | |
| bool | checkTypeInfo (std::shared_ptr< EdgeTypeInfo > type_info) |
| Check if type information matches. More... | |
| base::Status | construct () |
| Construct the Edge instance. More... | |
| template<typename T , typename... Args, typename std::enable_if< std::is_base_of< base::Param, T >::value, int >::type = 0> | |
| base::Param * | create (Args &&...args) |
| Create Param object of specified type. More... | |
| template<typename T , typename... Args> | |
| T * | create (Args &&...args) |
| Create arbitrary type data object (template version) More... | |
| device::Buffer * | create (device::Device *device, const device::BufferDesc &desc) |
| Create Buffer on specified device. More... | |
| device::Tensor * | create (device::Device *device, const device::TensorDesc &desc, std::string tensor_name="") |
| Create Tensor on specified device. More... | |
| Edge () | |
| Default constructor. More... | |
| Edge (const std::string &name) | |
| Constructor with name. More... | |
| bool | empty () |
| Check if the Edge is empty. More... | |
| template<typename T > | |
| T * | get (const Node *node) |
| Get arbitrary type data for specified node (template version) More... | |
| device::Buffer * | getBuffer (const Node *node) |
| Get Buffer data for specified node. More... | |
| std::vector< Node * > | getConsumers () |
| Get all consumer nodes. More... | |
| template<typename T > | |
| T * | getGraphOutput () |
| Get arbitrary type data for graph output (template version) More... | |
| device::Buffer * | getGraphOutputBuffer () |
| Get Buffer data for graph output. More... | |
| int64_t | getGraphOutputIndex () |
| Get data index for graph output. More... | |
| base::Param * | getGraphOutputParam () |
| Get Param data for graph output. More... | |
| int | getGraphOutputPosition () |
| Get position of graph output in queue. More... | |
| void * | getGraphOutputPtr () |
| Get raw pointer for graph output. More... | |
| device::Tensor * | getGraphOutputTensor () |
| Get Tensor data for graph output. More... | |
| int64_t | getIndex (const Node *node) |
| Get data index for specified node. More... | |
| std::string | getName () |
| Get the name of the Edge. More... | |
| base::ParallelType | getParallelType () |
| Get the current parallel type. More... | |
| base::Param * | getParam (const Node *node) |
| Get Param data for specified node. More... | |
| int | getPosition (const Node *node) |
| Get position of specified node in queue. More... | |
| std::vector< Node * > | getProducers () |
| Get all producer nodes. More... | |
| int | getQueueDropCount () |
| Get the queue drop count. More... | |
| int | getQueueMaxSize () |
| Get the maximum queue capacity. More... | |
| base::QueueOverflowPolicy | getQueueOverflowPolicy () |
| Get the current queue overflow policy. More... | |
| device::Tensor * | getTensor (const Node *node) |
| Get Tensor data for specified node. More... | |
| std::shared_ptr< EdgeTypeInfo > | getTypeInfo () |
| Get type information of Edge. More... | |
| std::string | getTypeName () |
| Get type name. More... | |
| base::Status | increaseConsumers (std::vector< Node * > &consumers) |
| Add consumer nodes. More... | |
| base::Status | increaseProducers (std::vector< Node * > &producers) |
| Add producer nodes. More... | |
| bool | markGraphOutput () |
| Mark as graph output Edge. More... | |
| bool | notifyWritten (base::Param *param) |
| Notify that Param data has been written. More... | |
| bool | notifyWritten (device::Buffer *buffer) |
| Notify that Buffer data has been written. More... | |
| bool | notifyWritten (device::Tensor *tensor) |
| Notify that Tensor data has been written. More... | |
| template<typename T > | |
| bool | notifyWritten (T *t) |
| Notify that arbitrary type data has been written (template version) More... | |
| bool | requestTerminate () |
| Request termination of Edge processing. More... | |
| void | resetIndex () |
| Reset index counter. More... | |
| base::Status | set (base::Param ¶m) |
| Set Param reference to Edge. More... | |
| base::Status | set (base::Param *param, bool is_external=true) |
| Set Param data to Edge. More... | |
| base::Status | set (device::Buffer &buffer) |
| Set Buffer reference to Edge. More... | |
| base::Status | set (device::Buffer *buffer, bool is_external=true) |
| Set Buffer data to Edge. More... | |
| base::Status | set (device::Tensor &tensor) |
| Set Tensor reference to Edge. More... | |
| base::Status | set (device::Tensor *tensor, bool is_external=true) |
| Set Tensor data to Edge. More... | |
| template<typename T > | |
| base::Status | set (T &t) |
| Set arbitrary type data reference to Edge (template version) More... | |
| template<typename T > | |
| base::Status | set (T *t, bool is_external=true) |
| Set arbitrary type data to Edge (template version) More... | |
| template<typename T > | |
| base::Status | set (T *t, std::function< void(T *)> deleter) |
| template<typename PY_WRAPPER , typename T > | |
| base::Status | set4py (PY_WRAPPER *wrapper, T *t, bool is_external=true) |
| Data setting interface dedicated for Python binding. More... | |
| base::Status | setParallelType (const base::ParallelType ¶lle_type) |
| Set the parallel type. More... | |
| base::Status | setQueueMaxSize (int queue_max_size) |
| Set the maximum queue capacity. More... | |
| base::Status | setQueueOverflowPolicy (base::QueueOverflowPolicy policy, int drop_count=1) |
| Set the queue overflow policy. More... | |
| template<typename T > | |
| base::Status | setTypeInfo () |
| Set type information of Edge (template version) More... | |
| base::Status | setTypeInfo (std::shared_ptr< EdgeTypeInfo > type_info) |
| Set type information of Edge. More... | |
| void | setTypeName (const std::string &type_name) |
| Set type name. More... | |
| base::EdgeUpdateFlag | update (const Node *node) |
| Update Edge status for specified node. More... | |
| virtual | ~Edge () |
| Virtual destructor. More... | |
Public Member Functions inherited from nndeploy::base::NonCopyable | |
| NonCopyable ()=default | |
| NonCopyable (const NonCopyable &)=delete | |
| NonCopyable (NonCopyable &&)=delete | |
| NonCopyable & | operator= (const NonCopyable &)=delete |
| NonCopyable & | operator= (NonCopyable &&)=delete |
Edge class in DAG graph for connecting nodes and transferring data.
The Edge class is one of the core components of the DAG graph in the nndeploy framework, responsible for transferring data between nodes. It provides functionality similar to std::any, capable of storing arbitrary types of data while supporting advanced features such as memory management, queue buffering, and parallel processing.
It is recommended to use template functions set/create/notifyWritten/get/getGraphOutput to set and retrieve data,
| nndeploy::dag::Edge::Edge | ( | ) |
Default constructor.
Creates an unnamed Edge instance with default configuration parameters
| nndeploy::dag::Edge::Edge | ( | const std::string & | name | ) |
Constructor with name.
| name | Name of the Edge, used for debugging and logging |
|
virtual |
Virtual destructor.
Automatically cleans up internal resources, including abstract edge instances and related data
|
inline |
| bool nndeploy::dag::Edge::checkTypeInfo | ( | std::shared_ptr< EdgeTypeInfo > | type_info | ) |
Check if type information matches.
| type_info | Type information to check |
| base::Status nndeploy::dag::Edge::construct | ( | ) |
Construct the Edge instance.
Creates concrete AbstractEdge implementation based on set parallel type and other parameters
|
inline |
Create Param object of specified type.
| T | Concrete type of Param, must inherit from base::Param |
| Args | Constructor parameter types |
| args | Constructor parameters |
|
inline |
| device::Buffer* nndeploy::dag::Edge::create | ( | device::Device * | device, |
| const device::BufferDesc & | desc | ||
| ) |
Create Buffer on specified device.
| device | Target device |
| desc | Buffer description information |
| device::Tensor* nndeploy::dag::Edge::create | ( | device::Device * | device, |
| const device::TensorDesc & | desc, | ||
| std::string | tensor_name = "" |
||
| ) |
Create Tensor on specified device.
| device | Target device |
| desc | Tensor description information |
| tensor_name | Tensor name, optional |
| bool nndeploy::dag::Edge::empty | ( | ) |
|
inline |
Get arbitrary type data for specified node (template version)
In pipeline parallel mode, waits for type information to be available before returning data
| T | Data type |
| node | Node requesting data |
| device::Buffer* nndeploy::dag::Edge::getBuffer | ( | const Node * | node | ) |
Get Buffer data for specified node.
| node | Node requesting data |
| std::vector<Node *> nndeploy::dag::Edge::getConsumers | ( | ) |
Get all consumer nodes.
|
inline |
| device::Buffer* nndeploy::dag::Edge::getGraphOutputBuffer | ( | ) |
Get Buffer data for graph output.
| int64_t nndeploy::dag::Edge::getGraphOutputIndex | ( | ) |
Get data index for graph output.
| base::Param* nndeploy::dag::Edge::getGraphOutputParam | ( | ) |
Get Param data for graph output.
| int nndeploy::dag::Edge::getGraphOutputPosition | ( | ) |
Get position of graph output in queue.
| void* nndeploy::dag::Edge::getGraphOutputPtr | ( | ) |
Get raw pointer for graph output.
| device::Tensor* nndeploy::dag::Edge::getGraphOutputTensor | ( | ) |
Get Tensor data for graph output.
| int64_t nndeploy::dag::Edge::getIndex | ( | const Node * | node | ) |
Get data index for specified node.
| node | Target node |
| std::string nndeploy::dag::Edge::getName | ( | ) |
| base::ParallelType nndeploy::dag::Edge::getParallelType | ( | ) |
Get the current parallel type.
| base::Param* nndeploy::dag::Edge::getParam | ( | const Node * | node | ) |
Get Param data for specified node.
| node | Node requesting data |
| int nndeploy::dag::Edge::getPosition | ( | const Node * | node | ) |
Get position of specified node in queue.
| node | Target node |
| std::vector<Node *> nndeploy::dag::Edge::getProducers | ( | ) |
Get all producer nodes.
| int nndeploy::dag::Edge::getQueueDropCount | ( | ) |
Get the queue drop count.
| int nndeploy::dag::Edge::getQueueMaxSize | ( | ) |
Get the maximum queue capacity.
| base::QueueOverflowPolicy nndeploy::dag::Edge::getQueueOverflowPolicy | ( | ) |
Get the current queue overflow policy.
| device::Tensor* nndeploy::dag::Edge::getTensor | ( | const Node * | node | ) |
Get Tensor data for specified node.
| node | Node requesting data |
| std::shared_ptr<EdgeTypeInfo> nndeploy::dag::Edge::getTypeInfo | ( | ) |
Get type information of Edge.
| std::string nndeploy::dag::Edge::getTypeName | ( | ) |
Get type name.
| base::Status nndeploy::dag::Edge::increaseConsumers | ( | std::vector< Node * > & | consumers | ) |
| base::Status nndeploy::dag::Edge::increaseProducers | ( | std::vector< Node * > & | producers | ) |
| bool nndeploy::dag::Edge::markGraphOutput | ( | ) |
Mark as graph output Edge.
| bool nndeploy::dag::Edge::notifyWritten | ( | base::Param * | param | ) |
Notify that Param data has been written.
| param | Written Param pointer |
| bool nndeploy::dag::Edge::notifyWritten | ( | device::Buffer * | buffer | ) |
Notify that Buffer data has been written.
| buffer | Written Buffer pointer |
| bool nndeploy::dag::Edge::notifyWritten | ( | device::Tensor * | tensor | ) |
Notify that Tensor data has been written.
| tensor | Written Tensor pointer |
|
inline |
| bool nndeploy::dag::Edge::requestTerminate | ( | ) |
Request termination of Edge processing.
| void nndeploy::dag::Edge::resetIndex | ( | ) |
Reset index counter.
| base::Status nndeploy::dag::Edge::set | ( | base::Param & | param | ) |
| base::Status nndeploy::dag::Edge::set | ( | base::Param * | param, |
| bool | is_external = true |
||
| ) |
Set Param data to Edge.
| param | Param pointer |
| is_external | Whether it's external data |
| base::Status nndeploy::dag::Edge::set | ( | device::Buffer & | buffer | ) |
Set Buffer reference to Edge.
| buffer | Buffer reference, automatically set as external data |
| base::Status nndeploy::dag::Edge::set | ( | device::Buffer * | buffer, |
| bool | is_external = true |
||
| ) |
Set Buffer data to Edge.
| buffer | Buffer pointer |
| is_external | Whether it's external data, true means not responsible for memory deallocation |
| base::Status nndeploy::dag::Edge::set | ( | device::Tensor & | tensor | ) |
Set Tensor reference to Edge.
| tensor | Tensor reference |
| base::Status nndeploy::dag::Edge::set | ( | device::Tensor * | tensor, |
| bool | is_external = true |
||
| ) |
Set Tensor data to Edge.
| tensor | Tensor pointer |
| is_external | Whether it's external data |
|
inline |
Set arbitrary type data reference to Edge (template version)
| T | Data type |
| t | Data reference |
|
inline |
Set arbitrary type data to Edge (template version)
| T | Data type |
| t | Data pointer |
| is_external | Whether it's external data |
|
inline |
|
inline |
Data setting interface dedicated for Python binding.
| PY_WRAPPER | Python wrapper type |
| T | Actual data type |
| wrapper | Python wrapper pointer |
| t | Data pointer |
| is_external | Whether it's external data |
| base::Status nndeploy::dag::Edge::setParallelType | ( | const base::ParallelType & | paralle_type | ) |
Set the parallel type.
Sets the parallel processing type of the Edge, affecting the creation and management of internal data structures
| paralle_type | Parallel type (serial, pipeline parallel, etc.) |
| base::Status nndeploy::dag::Edge::setQueueMaxSize | ( | int | queue_max_size | ) |
Set the maximum queue capacity.
Controls the maximum capacity of the edge buffer, used for data buffering in pipeline parallel processing. When the queue is full, the overflow policy determines how to handle new data.
| queue_max_size | Maximum capacity of the queue, must be greater than 0, default is 16 |
| base::Status nndeploy::dag::Edge::setQueueOverflowPolicy | ( | base::QueueOverflowPolicy | policy, |
| int | drop_count = 1 |
||
| ) |
Set the queue overflow policy.
Processing strategy when the queue is full, supports different strategies like backpressure, dropping, etc.
| policy | Overflow handling policy |
| drop_count | Number of data items to drop each time when policy is drop, default is 1 |
|
inline |
Set type information of Edge (template version)
| T | Data type |
| base::Status nndeploy::dag::Edge::setTypeInfo | ( | std::shared_ptr< EdgeTypeInfo > | type_info | ) |
Set type information of Edge.
| type_info | Type information object |
| void nndeploy::dag::Edge::setTypeName | ( | const std::string & | type_name | ) |
Set type name.
| type_name | Type name string |
| base::EdgeUpdateFlag nndeploy::dag::Edge::update | ( | const Node * | node | ) |
Update Edge status for specified node.
| node | Target node |