Skip to content
Snippets Groups Projects
Commit b0d95184 authored by Octave Perrin's avatar Octave Perrin
Browse files

improve pybind and hpp docs

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