From 5b97a6a5c31dee6af1c7db7a236215e4c86ee49d Mon Sep 17 00:00:00 2001 From: NAUD Maxence <maxence.naud@cea.fr> Date: Tue, 7 Nov 2023 14:34:23 +0000 Subject: [PATCH] [Upd] replace() python binding --- python_binding/graph/pybind_GraphView.cpp | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/python_binding/graph/pybind_GraphView.cpp b/python_binding/graph/pybind_GraphView.cpp index 555540045..5ee8ec865 100644 --- a/python_binding/graph/pybind_GraphView.cpp +++ b/python_binding/graph/pybind_GraphView.cpp @@ -26,7 +26,7 @@ void init_GraphView(py::module& m) { .def("save", &GraphView::save, py::arg("path"), py::arg("verbose") = false, R"mydelimiter( Save the GraphView as a Mermaid graph in a .md file at the specified location. - + :param path: save location :type path: str )mydelimiter") @@ -34,14 +34,14 @@ void init_GraphView(py::module& m) { .def("get_output_nodes", &GraphView::outputNodes, R"mydelimiter( Get set of output Nodes. - + :rtype: list[Node] )mydelimiter") .def("get_input_nodes", &GraphView::inputNodes, R"mydelimiter( Get set of input Nodes. - + :rtype: list[Node] )mydelimiter") @@ -49,7 +49,7 @@ void init_GraphView(py::module& m) { py::arg("other_node"), py::arg("include_learnable_parameters") = true, R"mydelimiter( Include a Node to the current GraphView object. - + :param other_node: Node to add :type oth_Node: Node :param includeLearnableParameter: include non-data inputs, like weights and biases. Default True. @@ -66,18 +66,20 @@ void init_GraphView(py::module& m) { py::arg("fromTensor") = 0U, py::arg("toTensor") = gk_IODefaultIndex, R"mydelimiter( Include a Node to the current GraphView object. - + :param other_node: Node to add :type oth_Node: Node :param includeLearnableParameter: include non-data inputs, like weights and biases. Default True. :type includeLearnableParameter )mydelimiter") - - .def("replace_with", &GraphView::replaceWith, py::arg("new_nodes"), + + .def_static("replace", &GraphView::replace, py::args("old_nodes"), py::arg("new_nodes"), R"mydelimiter( - Replace the current GraphView with the set of given Nodes if possible. - - :param new_nodes: Nodes with connections already taken care of. + Replace the old set of Nodes with the new set of given Nodes if possible in every GraphView. + + :param old_nodes: Nodes actually connected in GraphViews. + :type old_nodes: Node + :param new_nodes: Nodes with inner connections already taken care of. :type new_nodes: Node :return: Whether any replacement has been made. :rtype: bool -- GitLab