Skip to content
Snippets Groups Projects
Commit e801ab6e authored by Cyril Moineau's avatar Cyril Moineau
Browse files

Merge branch 'fixWinBind' into 'main'

Fix std::sharedPtr issue with python binding

Closes aidge#20

See merge request !70
parents 63c7fe12 1245c82d
No related branches found
No related tags found
1 merge request!70Fix std::sharedPtr issue with python binding
Pipeline #37126 passed
......@@ -140,7 +140,7 @@ public:
/**
* @brief List of pair <Parent, ID of the data intput>. When an input is not
* linked to any Parent, the pair is <nullptr, gk_IODefaultIndex>.
* linked to any Parent, the pair is <nullptr, gk_IODefaultIndex>.
* Data inputs exclude inputs expecting parameters (weights or bias).
* @return std::vector<std::pair<std::shared_ptr<Node>, IOIndex_t>>
*/
......
......@@ -63,12 +63,20 @@ void init_Node(py::module& m) {
)mydelimiter")
.def("add_child",
(void (Node::*)(std::shared_ptr<GraphView>, const IOIndex_t,
std::pair<std::shared_ptr<Node>, IOIndex_t>)) &
Node::addChild,
[](Node &self, std::shared_ptr<GraphView> other_graph, const IOIndex_t out_id=0,
py::object other_in_id = py::none()) {
std::pair<NodePtr, IOIndex_t> cpp_other_in_id;
// Note: PyBind on windows does not support conversion of nullptr -> std::shared_ptr, using this trampoline to change the default arg to a py::none(). If signature change, we would be able to directly bind the function.
if (other_in_id.is_none()) {
cpp_other_in_id = std::pair<NodePtr, IOIndex_t>(nullptr, gk_IODefaultIndex);
}else{
cpp_other_in_id = other_in_id.cast<std::pair<NodePtr, IOIndex_t>>();
}
self.addChild(other_graph, out_id, cpp_other_in_id);
},
py::arg("other_graph"), py::arg("out_id") = 0,
py::arg("other_in_id") =
std::pair<std::shared_ptr<Node>, IOIndex_t>(nullptr, gk_IODefaultIndex),
py::arg("other_in_id") = py::none(),
R"mydelimiter(
Link a Node from a specific GraphView to the current Node.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment