diff --git a/include/aidge/graph/GraphView.hpp b/include/aidge/graph/GraphView.hpp index 343079185c4f4f238e026c8a6467b0b0d64658cd..c55e7cfe8f822f53d3ec1fc1a87e75d891b5018c 100644 --- a/include/aidge/graph/GraphView.hpp +++ b/include/aidge/graph/GraphView.hpp @@ -42,7 +42,7 @@ enum class DataType; * - mName: The name of the GraphView * - mRootNode: The root of the GraphView, an arbitrary Node of the GraphView * - mNodes: The set of Nodes included in the GraphView - * - : Set of nodes included in the graphview with names + * - mNodeRegistry : Set of nodes included in the graphview with names * - mInputNodes: GraphView inputs IOIndex_t designates the input number * - mOutputNodes: GraphView outputs IOIndex_t designates the output number */ @@ -287,14 +287,14 @@ public: * @brief Assert Datatype, Backend, data format and dimensions along the GraphView are coherent. * If not, apply the required transformations. * @details Sets the GraphView ready for computation in four steps: - * 1 - Assert input Tensors' datatype is compatible with each Operator's datatype. + * - Assert input Tensors' datatype is compatible with each Operator's datatype. * If not, a conversion Operator is inserted. - * 2 - Assert input Tensors' backend is compatible with each Operator's backend. + * - Assert input Tensors' backend is compatible with each Operator's backend. * If not, add a Transmitter Operator. - * 3 - Assert data format (NCHW, NHWC, ...) of each Operator's input Tensor is + * - Assert data format (NCHW, NHWC, ...) of each Operator's input Tensor is * compatible with the selected kernel. * If not, add a Transpose Operator. - * 4 - Propagate Tensor dimensions through the consecutive Operators. + * - Propagate Tensor dimensions through the consecutive Operators. @params backend: Backend used, default is cpu @params Aidge Datatype: datatype used, default is float32 @params device: Device to be set diff --git a/python_binding/graph/pybind_GraphView.cpp b/python_binding/graph/pybind_GraphView.cpp index ae530308d808bfa0e54ab8f19ebfa3ae50511230..d6a79db1da6bc4614e8f96385e04e8df1b478e88 100644 --- a/python_binding/graph/pybind_GraphView.cpp +++ b/python_binding/graph/pybind_GraphView.cpp @@ -36,6 +36,7 @@ void init_GraphView(py::module& m) { List outside input connections of the GraphView. The vector size is guaranteed to match the number of outside inputs of the GraphView. If there is no external connection to a given input, a pair of nullptr and gk_IODefaultIndex is returned. + :return: A list containing the pairs Node, input indexes. :rtype: List[Node, int] )mydelimiter") @@ -44,6 +45,7 @@ void init_GraphView(py::module& m) { R"mydelimiter( List outside output connections of the GraphView. The vector size is guaranteed to match the number of outputs of the GraphView. + If there is no connection to a given output, the corresponding sub-vector will be empty. :return: A list containing the pairs Node, output indexes. :rtype: List[Node, int] @@ -52,6 +54,7 @@ void init_GraphView(py::module& m) { .def("in_view", (bool (GraphView::*)(const NodePtr&) const) &GraphView::inView, R"mydelimiter( Check that a node is in the current GraphView. + :param NodePtr: The Node that is checked :type Node: Node that is checked :return: True if the Node is in the GraphView, False otherwise @@ -61,6 +64,7 @@ void init_GraphView(py::module& m) { .def("in_view", (bool (GraphView::*)(const std::string&) const) &GraphView::inView, R"mydelimiter( Check that a node is in the current GraphView based on its name. + :param nodeName: The name of the Node that is checked :type nodeName: Node :return: True if the Node is in the GraphView, False otherwise @@ -70,6 +74,7 @@ void init_GraphView(py::module& m) { .def("root_node", &GraphView::rootNode, R"mydelimiter( Returns the rootNode of the GraphView + :return: The root Node of the GraphView :rtype: Node )mydelimiter") @@ -77,6 +82,7 @@ void init_GraphView(py::module& m) { .def("set_root_node", &GraphView::setRootNode, py::arg("node"), R"mydelimiter( Changes the rootNode of the GraphView + :param node: The Node of the GraphView that will become the new rootNode :type node: Node )mydelimiter") @@ -84,6 +90,7 @@ void init_GraphView(py::module& m) { .def("__repr__", &GraphView::repr, R"mydelimiter( returns information about the graphView: its name, number of nodes, of inputs and of outputs. + :return: a chain of caracter describing the graphView :rtype: string )mydelimiter") @@ -91,6 +98,7 @@ void init_GraphView(py::module& m) { .def("__len__", [](const GraphView& g){ return g.getNodes().size(); }, R"mydelimiter( returns the number of Nodes of the GraphView + :param g: The observed graphView :type g: graphView :return: the number of Nodes of the graphView g @@ -103,14 +111,15 @@ void init_GraphView(py::module& m) { In the specified directory, it will create a subdirectory for each Node of the GraphView In that sub-directory, each output of the Node will be saved in a different .log file - :param path: The path to the folder where we wish to stock the logs - :type path: string + :param path: The path to the folder where we wish to stock the logs + :type path: string )mydelimiter") .def("get_ordered_inputs", &GraphView::getOrderedInputs, R"mydelimiter( Get inputs of the current GraphView with their associated id. The rank of the nodes are their rank in the vector. + :return: The pairs Node, inputId of each input of the graphView :rtype: List[(Node, int)] )mydelimiter") @@ -119,6 +128,7 @@ void init_GraphView(py::module& m) { R"mydelimiter( Get outputs of the current GraphView with their associated id. The rank of the nodes are their rank in the vector. + :return: The pairs Node, outputId of each output of the graphView :rtype: List[(Node, int)] )mydelimiter") @@ -232,8 +242,6 @@ void init_GraphView(py::module& m) { the graph and connects it if that makes sense without ambiguity (effectively treating the removed Node as an identity operation). - :param cloneNode: Callback function to clone a node - :type cloneNode: Node :return: Cloned GraphView :rtype: GraphView )mydelimiter") @@ -265,6 +273,7 @@ void init_GraphView(py::module& m) { - Updates are made in node dependencies order, because if dims have changed at any point in the graph, it must de propagated correctly to all succeeding nodes; - It handles cyclic dependencies correctly (currently only induced by the Memorize_Op). + :param dims: List of list of dimensions of the inputs of the graphView :type dims: List[List[int]] :return: Whether it succeeded or not (failure can either raise an exception or return false) @@ -276,14 +285,11 @@ void init_GraphView(py::module& m) { Assert Datatype, Backend, data format and dimensions along the GraphView are coherent. If not, apply the required transformations. Sets the GraphView ready for computation in four steps: - 1 - Assert input Tensors' datatype is compatible with each Operator's datatype. - If not, a conversion Operator is inserted. - 2 - Assert input Tensors' backend is compatible with each Operator's backend. - If not, add a Transmitter Operator. - 3 - Assert data format (NCHW, NHWC, ...) of each Operator's input Tensor is - compatible with the selected kernel. - If not, add a Transpose Operator. - 4 - Propagate Tensor dimensions through the consecutive Operators. + - Assert input Tensors' datatype is compatible with each Operator's datatype. If not, a conversion Operator is inserted. + - Assert input Tensors' backend is compatible with each Operator's backend. If not, add a Transmitter Operator. + - Assert data format (NCHW, NHWC, ...) of each Operator's input Tensor iscompatible with the selected kernel. If not, add a Transpose Operator. + - Propagate Tensor dimensions through the consecutive Operators. + :param backend: Backend used, default is cpu :type backend: string :param datatype: Aidge Datatype used, default is float32 @@ -297,6 +303,7 @@ void init_GraphView(py::module& m) { .def("__call__", &GraphView::operator(), py::arg("connectors"), R"mydelimiter( Functional operator for user-friendly connection interface using an ordered set of Connectors. + :parm connectors: The connector be added to current connection :type connectors: Connector :return: The new connector @@ -306,13 +313,15 @@ void init_GraphView(py::module& m) { .def("set_datatype", &GraphView::setDataType, py::arg("datatype"), R"mydelimiter( Set the same data type for each Operator of the GraphView object's Nodes. + :param datatype: DataType to be set :type datatype: DataType )mydelimiter") .def("set_backend", &GraphView::setBackend, py::arg("backend"), py::arg("device") = 0, R"mydelimiter( - Set the same backend for each Operator of the GraphView object's Nodes. + Set the same backend for each Operator of the GraphView object's Nodes.* + :param backend: Backen used, default is cpu :type backend: string :param device: Device to be set @@ -365,24 +374,29 @@ void init_GraphView(py::module& m) { :rtype: (Node, int) )mydelimiter") - .def("get_ranked_nodes_name", &GraphView::getRankedNodesName, py::arg("format"), py::arg("mark_non_unicity") = true, + .def("get_ranked_nodes_name", &GraphView::getRankedNodesName, py::arg("format"), py::arg("mark_non_unicity") = true, R"mydelimiter( Get the nodes name according to the GraphView nodes ranking. - :param format: The formatting string to be used in the output f-string - The usable positional arguments are the following: - {0} node name, {1} node type, {2} rank, {3} type rank + :param format: The formatting string to be used in the output f-string.The usable positional arguments are the following: {0} node name, {1} node type, {2} rank, {3} type rank :type format: string :param markNonUnicity: If true, non unique ranking is prefixed with "?" :type markNonUnicity: bool :return: map(Node, string) A map with the corresponding names )mydelimiter") - .def("set_dataformat", &GraphView::setDataFormat, py::arg("dataformat")); + .def("set_dataformat", &GraphView::setDataFormat, py::arg("dataformat"), + R"mydelimiter( + Set the same data format for each Operator of the GraphView object's Nodes. + + :param dataformat: DataFormat to be set on the Node's operators' + :type dataformat: DataFormat + )mydelimiter"); m.def("get_connected_graph_view", &getConnectedGraphView, R"mydelimiter( Create a GraphView containing all nodes with a path to given Node. + :param node: Initial node to construct the graph. :type node: Node :return: GraphView GraphView containing all nodes with a path to node.