From 23604ca28cc3b519c9c07963a9a7907fb739f2b5 Mon Sep 17 00:00:00 2001 From: Anastasia Kuporosova Date: Fri, 11 Mar 2022 19:18:20 +0300 Subject: [PATCH] [Python API] Update doc style (#10708) * [Python API] Update doc style * apply comments Co-authored-by: Ilya Lavrenov --- .../src/pyopenvino/core/variable_state.cpp | 24 +- .../src/pyopenvino/frontend/frontend.cpp | 76 ++---- .../src/pyopenvino/frontend/input_model.cpp | 238 ++++++------------ .../src/pyopenvino/frontend/manager.cpp | 32 +-- .../python/src/pyopenvino/frontend/place.cpp | 162 ++++-------- .../pyopenvino/graph/descriptors/tensor.cpp | 66 ++--- .../src/pyopenvino/graph/node_input.cpp | 42 ++-- .../src/pyopenvino/graph/passes/manager.cpp | 49 ++-- .../graph/preprocess/pre_post_process.cpp | 128 +++------- .../test_frontend/test_frontendmanager.py | 4 +- 10 files changed, 279 insertions(+), 542 deletions(-) diff --git a/src/bindings/python/src/pyopenvino/core/variable_state.cpp b/src/bindings/python/src/pyopenvino/core/variable_state.cpp index 4550cfbb4eb..4b063e0fca8 100644 --- a/src/bindings/python/src/pyopenvino/core/variable_state.cpp +++ b/src/bindings/python/src/pyopenvino/core/variable_state.cpp @@ -19,14 +19,6 @@ void regclass_VariableState(py::module m) { R"( Reset internal variable state for relevant infer request, to a value specified as default for according node. - - Parameters - ---------- - None - - Returns - ---------- - reset : None )"); variable_st.def_property_readonly("name", @@ -34,10 +26,8 @@ void regclass_VariableState(py::module m) { R"( Gets name of current variable state. - Returns - ---------- - reset : str - A string representing a state name. + :return: A string representing a state name. + :rtype: str )"); variable_st.def_property("state", @@ -45,15 +35,5 @@ void regclass_VariableState(py::module m) { &ov::VariableState::set_state, R"( Gets/sets variable state. - - Parameters - ---------- - state : openvino.runtime.Tensor - The current state to set. - - Returns - ---------- - state : openvino.runtime.Tensor - A tensor representing a state. )"); } diff --git a/src/bindings/python/src/pyopenvino/frontend/frontend.cpp b/src/bindings/python/src/pyopenvino/frontend/frontend.cpp index 8997bb0697b..f6739881b21 100644 --- a/src/bindings/python/src/pyopenvino/frontend/frontend.cpp +++ b/src/bindings/python/src/pyopenvino/frontend/frontend.cpp @@ -29,15 +29,10 @@ void regclass_frontend_FrontEnd(py::module m) { R"( Loads an input model by specified model file path. - Parameters - ---------- - path : str - Main model file path. - - Returns - ---------- - load : InputModel - Loaded input model. + :param path: Main model file path. + :type path: str + :return: Loaded input model. + :rtype: openvino.frontend.InputModel )"); fem.def("convert", @@ -47,27 +42,22 @@ void regclass_frontend_FrontEnd(py::module m) { R"( Completely convert and normalize entire function, throws if it is not possible. - Parameters - ---------- - model : InputModel - Input model. - - Returns - ---------- - convert : Model - Fully converted nGraph function. + :param model: Input model. + :type model: openvino.frontend.InputModel + :return: Fully converted OpenVINO Model. + :rtype: openvino.runtime.Model )"); fem.def("convert", static_cast&) const>(&FrontEnd::convert), - py::arg("function"), + py::arg("model"), R"( Completely convert the remaining, not converted part of a function. - Parameters - ---------- - function : Model - Partially converted nGraph function. + :param model: Partially converted OpenVINO model. + :type model: openvino.frontend.Model + :return: Fully converted OpenVINO Model. + :rtype: openvino.runtime.Model )"); fem.def("convert_partially", @@ -79,15 +69,10 @@ void regclass_frontend_FrontEnd(py::module m) { Converted parts are not normalized by additional transformations; normalize function or another form of convert function should be called to finalize the conversion process. - Parameters - ---------- - model : InputModel - Input model. - - Returns - ---------- - convert_partially : Model - Partially converted nGraph function. + :param model : Input model. + :type model: openvino.frontend.InputModel + :return: Partially converted OpenVINO Model. + :rtype: openvino.runtime.Model )"); fem.def("decode", @@ -99,27 +84,20 @@ void regclass_frontend_FrontEnd(py::module m) { Each decoding node is an nGraph node representing a single FW operation node with all attributes represented in FW-independent way. - Parameters - ---------- - model : InputModel - Input model. - - Returns - ---------- - decode : Model - nGraph function after decoding. + :param model : Input model. + :type model: openvino.frontend.InputModel + :return: OpenVINO Model after decoding. + :rtype: openvino.runtime.Model )"); fem.def("normalize", &FrontEnd::normalize, - py::arg("function"), + py::arg("model"), R"( Runs normalization passes on function that was loaded with partial conversion. - Parameters - ---------- - function : Model - Partially converted nGraph function. + :param model : Partially converted OpenVINO model. + :type model: openvino.runtime.Model )"); fem.def("get_name", @@ -128,10 +106,8 @@ void regclass_frontend_FrontEnd(py::module m) { Gets name of this FrontEnd. Can be used by clients if frontend is selected automatically by FrontEndManager::load_by_model. - Parameters - ---------- - get_name : str - Current frontend name. Empty string if not implemented. + :return: Current frontend name. Returns empty string if not implemented. + :rtype: str )"); fem.def("add_extension", diff --git a/src/bindings/python/src/pyopenvino/frontend/input_model.cpp b/src/bindings/python/src/pyopenvino/frontend/input_model.cpp index 05312dfbcd0..9bef06ea133 100644 --- a/src/bindings/python/src/pyopenvino/frontend/input_model.cpp +++ b/src/bindings/python/src/pyopenvino/frontend/input_model.cpp @@ -25,15 +25,10 @@ void regclass_frontend_InputModel(py::module m) { Returns a tensor place by a tensor name following framework conventions, or nullptr if a tensor with this name doesn't exist. - Parameters - ---------- - tensor_name : str - Name of tensor. - - Returns - ---------- - get_place_by_tensor_name : Place - Tensor place corresponding to specified tensor name. + :param tensor_name: Name of tensor. + :type tensor_name: str + :return: Tensor place corresponding to specified tensor name. + :rtype: openvino.frontend.Place )"); im.def("get_place_by_operation_name", @@ -43,15 +38,10 @@ void regclass_frontend_InputModel(py::module m) { Returns an operation place by an operation name following framework conventions, or nullptr if an operation with this name doesn't exist. - Parameters - ---------- - operation_name : str - Name of operation. - - Returns - ---------- - get_place_by_operation_name : Place - Place representing operation. + :param operation_name: Name of operation. + :type operation_name: str + :return: Place representing operation. + :rtype: openvino.frontend.Place )"); im.def("get_place_by_operation_name_and_input_port", @@ -61,18 +51,12 @@ void regclass_frontend_InputModel(py::module m) { R"( Returns an input port place by operation name and appropriate port index. - Parameters - ---------- - operation_name : str - Name of operation. - - input_port_index : int - Index of input port for this operation. - - Returns - ---------- - get_place_by_operation_name_and_input_port : Place - Place representing input port of operation. + :param operation_name: Name of operation. + :type operation_name: str + :param input_port_index: Index of input port for this operation. + :type input_port_index: int + :return: Place representing input port of operation. + :rtype: openvino.frontend.Place )"); im.def("get_place_by_operation_name_and_output_port", @@ -82,18 +66,12 @@ void regclass_frontend_InputModel(py::module m) { R"( Returns an output port place by operation name and appropriate port index. - Parameters - ---------- - operation_name : str - Name of operation. - - output_port_index : int - Index of output port for this operation. - - Returns - ---------- - get_place_by_operation_name_and_output_port : Place - Place representing output port of operation. + :param operation_name: Name of operation. + :type operation_name: str + :param output_port_index: Index of output port for this operation. + :type output_port_index: int + :return: Place representing output port of operation. + :rtype: openvino.frontend.Place )"); im.def("set_name_for_tensor", @@ -103,13 +81,10 @@ void regclass_frontend_InputModel(py::module m) { R"( Sets name for tensor. Overwrites existing names of this place. - Parameters - ---------- - tensor : Place - Tensor place. - - new_name : str - New name for this tensor. + :param tensor: Tensor place. + :type tensor: openvino.frontend.Place + :param new_name: New name for this tensor. + :type new_name: str )"); im.def("add_name_for_tensor", @@ -119,13 +94,10 @@ void regclass_frontend_InputModel(py::module m) { R"( Adds new name for tensor - Parameters - ---------- - tensor : Place - Tensor place. - - new_name : str - New name to be added to this place. + :param tensor: Tensor place. + :type tensor: openvino.frontend.Place + :param new_name: New name to be added to this place. + :type new_name: str )"); im.def("set_name_for_operation", @@ -135,13 +107,10 @@ void regclass_frontend_InputModel(py::module m) { R"( Adds new name for tensor. - Parameters - ---------- - operation : Place - Operation place. - - new_name : str - New name for this operation. + :param operation: Operation place. + :type operation: openvino.frontend.Place + :param new_name: New name for this operation. + :type new_name: str )"); im.def("free_name_for_tensor", @@ -150,10 +119,8 @@ void regclass_frontend_InputModel(py::module m) { R"( Unassign specified name from tensor place(s). - Parameters - ---------- - name : str - Name of tensor. + :param name: Name of tensor. + :type name: str )"); im.def("free_name_for_operation", @@ -162,10 +129,8 @@ void regclass_frontend_InputModel(py::module m) { R"( Unassign specified name from operation place(s). - Parameters - ---------- - name : str - Name of operation. + :param name: Name of operation. + :type name: str )"); im.def("set_name_for_dimension", @@ -176,16 +141,12 @@ void regclass_frontend_InputModel(py::module m) { R"( Set name for a particular dimension of a place (e.g. batch dimension). - Parameters - ---------- - place : Place - Model's place. - - dim_index : int - Dimension index. - - dim_name : str - Name to assign on this dimension. + :param place: Model's place. + :type place: openvino.frontend.Place + :param dim_index: Dimension index. + :type dim_index: int + :param dim_name: Name to assign on this dimension. + :type dum_name: str )"); im.def("cut_and_add_new_input", @@ -196,13 +157,10 @@ void regclass_frontend_InputModel(py::module m) { Cut immediately before this place and assign this place as new input; prune all nodes that don't contribute to any output. - Parameters - ---------- - place : Place - New place to be assigned as input. - - new_name_optional : str - Optional new name assigned to this input place. + :param place: New place to be assigned as input. + :type place: openvino.frontend.Place + :param new_name: Optional new name assigned to this input place. + :type new_name: str )"); im.def("cut_and_add_new_output", @@ -213,13 +171,10 @@ void regclass_frontend_InputModel(py::module m) { Cut immediately before this place and assign this place as new output; prune all nodes that don't contribute to any output. - Parameters - ---------- - place : Place - New place to be assigned as output. - - new_name_optional : str - Optional new name assigned to this output place. + :param place: New place to be assigned as output. + :type place: openvino.frontend.Place + :param new_name: Optional new name assigned to this output place. + :type new_name: str )"); im.def("add_output", @@ -228,10 +183,8 @@ void regclass_frontend_InputModel(py::module m) { R"( Assign this place as new output or add necessary nodes to represent a new output. - Parameters - ---------- - place : Place - Anchor point to add an output. + :param place: Anchor point to add an output. + :type place: openvino.frontend.Place )"); im.def("remove_output", @@ -241,10 +194,8 @@ void regclass_frontend_InputModel(py::module m) { Removes any sinks directly attached to this place with all inbound data flow if it is not required by any other output. - Parameters - ---------- - place : Place - Model place + :param place: Model place. + :type place: openvino.frontend.Place )"); im.def("set_partial_shape", @@ -257,13 +208,10 @@ void regclass_frontend_InputModel(py::module m) { shape of results ngraph nodes and will define shape inference when the model is converted to ngraph. - Parameters - ---------- - place : Place - Model place. - - shape : PartialShape - Partial shape for this place. + :param place: Model place. + :type place: openvino.frontend.Place + :param shape: Partial shape for this place. + :type shape: openvino.runtime.PartialShape )"); im.def("get_partial_shape", @@ -272,15 +220,10 @@ void regclass_frontend_InputModel(py::module m) { R"( Returns current partial shape used for this place. - Parameters - ---------- - place : Place - Model place - - Returns - ---------- - get_partial_shape : PartialShape - Partial shape for this place. + :param place: Model place. + :type place: openvino.frontend.Place + :return: Partial shape for this place. + :rtype: openvino.runtime.PartialShape )"); im.def("get_inputs", @@ -288,10 +231,8 @@ void regclass_frontend_InputModel(py::module m) { R"( Returns all inputs for a model. - Returns - ---------- - get_inputs : List[Place] - A list of input places. + :return: A list of input places. + :rtype: List[openvino.frontend.Place] )"); im.def("get_outputs", @@ -299,10 +240,8 @@ void regclass_frontend_InputModel(py::module m) { R"( Returns all outputs for a model. An output is a terminal place in a graph where data escapes the flow. - Returns - ---------- - get_outputs : List[Place] - A list of output places + :return: A list of output places. + :rtype: List[openvino.frontend.Place] )"); im.def("extract_subgraph", @@ -312,13 +251,10 @@ void regclass_frontend_InputModel(py::module m) { R"( Leaves only subgraph that are defined by new inputs and new outputs. - Parameters - ---------- - inputs : List[Place] - Array of new input places. - - outputs : List[Place] - Array of new output places. + :param inputs: Array of new input places. + :type inputs: List[openvino.frontend.Place] + :param outputs: Array of new output places. + :type outputs: List[openvino.frontend.Place] )"); im.def("override_all_inputs", @@ -328,10 +264,8 @@ void regclass_frontend_InputModel(py::module m) { Modifies the graph to use new inputs instead of existing ones. New inputs should completely satisfy all existing outputs. - Parameters - ---------- - inputs : List[Place] - Array of new input places. + :param inputs: Array of new input places. + :type inputs: List[openvino.frontend.Place] )"); im.def("override_all_outputs", @@ -341,10 +275,8 @@ void regclass_frontend_InputModel(py::module m) { Replaces all existing outputs with new ones removing all data flow that is not required for new outputs. - Parameters - ---------- - outputs : List[Place] - Vector with places that will become new outputs; may intersect existing outputs. + :param outputs: Vector with places that will become new outputs; may intersect existing outputs. + :type outputs: List[openvino.frontend.Place] )"); im.def("set_element_type", @@ -354,13 +286,10 @@ void regclass_frontend_InputModel(py::module m) { R"( Sets new element type for a place. - Parameters - ---------- - place : Place - Model place. - - type : ngraph.Type - New element type. + :param place: Model place. + :type place: openvino.frontend.Place + :param type: New element type. + :type type: openvino.runtime.Type )"); im.def( @@ -375,12 +304,9 @@ void regclass_frontend_InputModel(py::module m) { R"( Sets new element type for a place. - Parameters - ---------- - place : Place - Model place. - - value : ndarray - New value to assign. + :param place: Model place. + :type place: openvino.frontend.Place + :param value: New value to assign. + :type value: numpy.ndarray )"); } diff --git a/src/bindings/python/src/pyopenvino/frontend/manager.cpp b/src/bindings/python/src/pyopenvino/frontend/manager.cpp index fa109a173ae..9970a79da56 100644 --- a/src/bindings/python/src/pyopenvino/frontend/manager.cpp +++ b/src/bindings/python/src/pyopenvino/frontend/manager.cpp @@ -34,10 +34,8 @@ void regclass_frontend_FrontEndManager(py::module m) { R"( Gets list of registered frontends. - Returns - ---------- - get_available_front_ends : List[str] - List of available frontend names. + :return: List of available frontend names. + :rtype: List[str] )"); fem.def("load_by_framework", @@ -46,15 +44,10 @@ void regclass_frontend_FrontEndManager(py::module m) { R"( Loads frontend by name of framework and capabilities. - Parameters - ---------- - framework : str - Framework name. Throws exception if name is not in list of available frontends. - - Returns - ---------- - load_by_framework : FrontEnd - Frontend interface for further loading of models. + :param framework: Framework name. Throws exception if name is not in list of available frontends. + :type framework: str + :return: Frontend interface for further loading of models. + :rtype: openvino.frontend.FrontEnd )"); fem.def( @@ -66,15 +59,10 @@ void regclass_frontend_FrontEndManager(py::module m) { R"( Selects and loads appropriate frontend depending on model file extension and other file info (header). - Parameters - ---------- - model_path : str - Path to model file/directory. - - Returns - ---------- - load_by_model : FrontEnd - Frontend interface for further loading of models. 'None' if no suitable frontend is found + :param model_path: A path to a model file/directory. + :type model_path: str + :return: Frontend interface for further loading of models. 'None' if no suitable frontend is found. + :rtype: openvino.frontend.FrontEnd )"); fem.def("__repr__", [](const ov::frontend::FrontEndManager& self) -> std::string { diff --git a/src/bindings/python/src/pyopenvino/frontend/place.cpp b/src/bindings/python/src/pyopenvino/frontend/place.cpp index c525bd5fbd1..9518c2a5036 100644 --- a/src/bindings/python/src/pyopenvino/frontend/place.cpp +++ b/src/bindings/python/src/pyopenvino/frontend/place.cpp @@ -21,10 +21,8 @@ void regclass_frontend_Place(py::module m) { R"( Returns true if this place is input for a model. - Returns - ---------- - is_input : bool - True if this place is input for a model + :return: True if this place is input for a model + :rtype: bool )"); place.def("is_output", @@ -32,10 +30,8 @@ void regclass_frontend_Place(py::module m) { R"( Returns true if this place is output for a model. - Returns - ---------- - is_output : bool - True if this place is output for a model. + :return: True if this place is output for a model. + :rtype: bool )"); place.def("get_names", @@ -43,11 +39,9 @@ void regclass_frontend_Place(py::module m) { R"( All associated names (synonyms) that identify this place in the graph in a framework specific way. - Returns - ---------- - get_names : List[str] - A vector of strings each representing a name that identifies this place in the graph. - Can be empty if there are no names associated with this place or name cannot be attached. + :return: A vector of strings each representing a name that identifies this place in the graph. + Can be empty if there are no names associated with this place or name cannot be attached. + :rtype: List[str] )"); place.def("is_equal", @@ -56,15 +50,10 @@ void regclass_frontend_Place(py::module m) { R"( Returns true if another place is the same as this place. - Parameters - ---------- - other : Place - Another place object. - - Returns - ---------- - is_equal : bool - True if another place is the same as this place. + :param other: Another place object. + :type other: openvino.frontend.Place + :return: True if another place is the same as this place. + :rtype: bool )"); place.def("is_equal_data", @@ -75,15 +64,10 @@ void regclass_frontend_Place(py::module m) { Note: The same data means all places on path: output port -> output edge -> tensor -> input edge -> input port. - Parameters - ---------- - other : Place - Another place object. - - Returns - ---------- - is_equal_data : bool - True if another place points to the same data. + :param other: Another place object. + :type other: openvino.frontend.Place + :return: True if another place points to the same data. + :rtype: bool )"); place.def( @@ -110,18 +94,13 @@ void regclass_frontend_Place(py::module m) { Returns references to all operation nodes that consume data from this place for specified output port. Note: It can be called for any kind of graph place searching for the first consuming operations. - Parameters - ---------- - output_name : str - Name of output port group. May not be set if node has one output port group. - output_port_index : int - If place is an operational node it specifies which output port should be considered + :param output_name: Name of output port group. May not be set if node has one output port group. + :type output_name: str + :param output_port_index: If place is an operational node it specifies which output port should be considered May not be set if node has only one output port. - - Returns - ---------- - get_consuming_operations : List[Place] - A list with all operation node references that consumes data from this place + :type output_port_index: int + :return: A list with all operation node references that consumes data from this place + :rtype: List[openvino.frontend.Place] )"); place.def( @@ -147,18 +126,13 @@ void regclass_frontend_Place(py::module m) { Returns a tensor place that gets data from this place; applicable for operations, output ports and output edges. - Parameters - ---------- - output_name : str - Name of output port group. May not be set if node has one output port group. - output_port_index : int - Output port index if the current place is an operation node and has multiple output ports. + :param output_name: Name of output port group. May not be set if node has one output port group. + :type output_name: str + :param output_port_index: Output port index if the current place is an operation node and has multiple output ports. May not be set if place has only one output port. - - Returns - ---------- - get_consuming_operations : Place - A tensor place which hold the resulting value for this place. + :type output_port_index: int + :return: A tensor place which hold the resulting value for this place. + :rtype: openvino.frontend.Place )"); place.def( @@ -184,18 +158,13 @@ void regclass_frontend_Place(py::module m) { R"( Get an operation node place that immediately produces data for this place. - Parameters - ---------- - input_name : str - Name of port group. May not be set if node has one input port group. - input_port_index : int - If a given place is itself an operation node, this specifies a port index. + :param input_name: Name of port group. May not be set if node has one input port group. + :type input_name: str + :param input_port_index: If a given place is itself an operation node, this specifies a port index. May not be set if place has only one input port. - - Returns - ---------- - get_producing_operation : Place - An operation place that produces data for this place. + :type input_port_index: int + :return: An operation place that produces data for this place. + :rtype: openvino.frontend.Place )"); place.def("get_producing_port", @@ -203,10 +172,8 @@ void regclass_frontend_Place(py::module m) { R"( Returns a port that produces data for this place. - Returns - ---------- - get_producing_port : Place - A port place that produces data for this place. + :return: A port place that produces data for this place. + :rtype: openvino.frontend.Place )"); place.def( @@ -231,18 +198,12 @@ void regclass_frontend_Place(py::module m) { R"( For operation node returns reference to an input port with specified name and index. - Parameters - ---------- - input_name : str - Name of port group. May not be set if node has one input port group. - - input_port_index : int - Input port index in a group. May not be set if node has one input port in a group. - - Returns - ---------- - get_input_port : Place - Appropriate input port place. + :param input_name: Name of port group. May not be set if node has one input port group. + :type input_name: str + :param input_port_index: Input port index in a group. May not be set if node has one input port in a group. + :type input_port_index: int + :return: Appropriate input port place. + :rtype: openvino.frontend.Place )"); place.def( @@ -267,18 +228,12 @@ void regclass_frontend_Place(py::module m) { R"( For operation node returns reference to an output port with specified name and index. - Parameters - ---------- - output_name : str - Name of output port group. May not be set if node has one output port group. - - output_port_index : int - Output port index. May not be set if node has one output port in a group. - - Returns - ---------- - get_output_port : Place - Appropriate output port place. + :param output_name: Name of output port group. May not be set if node has one output port group. + :type output_name: str + :param output_port_index: Output port index. May not be set if node has one output port in a group. + :type output_port_index: int + :return: Appropriate output port place. + :rtype: openvino.frontend.Place )"); place.def("get_consuming_ports", @@ -286,10 +241,8 @@ void regclass_frontend_Place(py::module m) { R"( Returns all input ports that consume data flows through this place. - Returns - ---------- - get_consuming_ports : List[Place] - Input ports that consume data flows through this place. + :return: Input ports that consume data flows through this place. + :rtype: List[openvino.frontend.Place] )"); place.def( @@ -315,16 +268,11 @@ void regclass_frontend_Place(py::module m) { Returns a tensor place that supplies data for this place; applicable for operations, input ports and input edges. - Parameters - ---------- - input_name : str - Name of port group. May not be set if node has one input port group. - input_port_index : int - Input port index for operational node. May not be specified if place has only one input port. - - Returns - ---------- - get_source_tensor : Place - A tensor place which supplies data for this place. + :param input_name : Name of port group. May not be set if node has one input port group. + :type input_name: str + :param input_port_index: Input port index for operational node. May not be specified if place has only one input port. + :type input_port_index: int + :return: A tensor place which supplies data for this place. + :rtype: openvino.frontend.Place )"); } diff --git a/src/bindings/python/src/pyopenvino/graph/descriptors/tensor.cpp b/src/bindings/python/src/pyopenvino/graph/descriptors/tensor.cpp index 6f28ea5619f..3b6fded4057 100644 --- a/src/bindings/python/src/pyopenvino/graph/descriptors/tensor.cpp +++ b/src/bindings/python/src/pyopenvino/graph/descriptors/tensor.cpp @@ -27,10 +27,8 @@ void regclass_graph_descriptor_Tensor(py::module m) { R"( Returns the shape description. - Returns - ---------- - get_shape : Shape - The shape description. + :return: The shape description. + :rtype: openvino.runtime.Shape )"); tensor.def("get_rt_info", @@ -39,66 +37,54 @@ void regclass_graph_descriptor_Tensor(py::module m) { R"( Returns PyRTMap which is a dictionary of user defined runtime info. - Returns - ---------- - get_rt_info : PyRTMap - A dictionary of user defined data. + :return: A dictionary of user defined data. + :rtype: openvino.runtime.RTMap )"); tensor.def("size", &ov::descriptor::Tensor::size, R"( - Returns the size description + Returns the size description. - Returns - ---------- - size : size_t - The size description. + :return: The size description. + :rtype: size_t )"); tensor.def("get_partial_shape", &ov::descriptor::Tensor::get_partial_shape, R"( - Returns the partial shape description + Returns the partial shape description. - Returns - ---------- - get_partial_shape : PartialShape - PartialShape description. + :return: PartialShape description. + :rtype: openvino.runtime.PartialShape )"); tensor.def("get_element_type", &ov::descriptor::Tensor::get_element_type, R"( - Returns the element type description + Returns the element type description. - Returns - ---------- - get_element_type : Type - Type description + :return: Type description. + :rtype: openvino.runtime.Type )"); tensor.def("get_names", &ov::descriptor::Tensor::get_names, R"( - Returns names + Returns names. - Returns - ---------- - get_names : set - Set of names + :return: Get names. + :rtype: set )"); tensor.def("set_names", &ov::descriptor::Tensor::set_names, py::arg("names"), R"( - Set names for tensor + Set names for tensor. - Parameters - ---------- - names : set - Set of names + :param names: Set of names. + :type names: set )"); tensor.def("add_names", @@ -107,21 +93,17 @@ void regclass_graph_descriptor_Tensor(py::module m) { R"( Adds names for tensor. - Parameters - ---------- - names : set - Set of names + :param names: Add names. + :type names: set )"); tensor.def("get_any_name", &ov::descriptor::Tensor::get_any_name, R"( - Returns any of set name + Returns any of set name. - Returns - ---------- - get_any_name : string - Any name + :return: Any name. + :rtype: string )"); tensor.def_property_readonly("shape", &ov::descriptor::Tensor::get_shape); diff --git a/src/bindings/python/src/pyopenvino/graph/node_input.cpp b/src/bindings/python/src/pyopenvino/graph/node_input.cpp index 01bd812721a..b1bbd8d9e56 100644 --- a/src/bindings/python/src/pyopenvino/graph/node_input.cpp +++ b/src/bindings/python/src/pyopenvino/graph/node_input.cpp @@ -24,60 +24,48 @@ void regclass_graph_Input(py::module m) { R"( Get node referenced by this input handle. - Returns - ---------- - get_node : Node - Node object referenced by this input handle. + :return: Node object referenced by this input handle. + :rtype: openvino.runtime.Node )"); input.def("get_index", &ov::Input::get_index, R"( The index of the input referred to by this input handle. - Returns - ---------- - get_index : int - Index value as integer. + :return: Index value as integer. + :rtype: int )"); input.def("get_element_type", &ov::Input::get_element_type, R"( The element type of the input referred to by this input handle. - Returns - ---------- - get_element_type : Type - Type of the input. + :return: Type of the input. + :rtype: openvino.runtime.Type )"); input.def("get_shape", &ov::Input::get_shape, R"( The shape of the input referred to by this input handle. - Returns - ---------- - get_shape : Shape - Shape of the input. + :return: Shape of the input. + :rtype: openvino.runtime.Shape )"); input.def("get_partial_shape", &ov::Input::get_partial_shape, R"( The partial shape of the input referred to by this input handle. - Returns - ---------- - get_partial_shape : PartialShape - PartialShape of the input. + :return: PartialShape of the input. + :rtype: openvino.runtime.PartialShape )"); input.def("get_source_output", &ov::Input::get_source_output, R"( A handle to the output that is connected to this input. - Returns - ---------- - get_source_output : Output - Output that is connected to the input. + :return: Output that is connected to the input. + :rtype: openvino.runtime.Output )"); input.def("get_rt_info", @@ -86,10 +74,8 @@ void regclass_graph_Input(py::module m) { R"( Returns RTMap which is a dictionary of user defined runtime info. - Returns - ---------- - get_rt_info : RTMap - A dictionary of user defined data. + :return: A dictionary of user defined data. + :rtype: openvino.runtime.RTMap )"); input.def_property_readonly("rt_info", (ov::RTMap & (ov::Input::*)()) & ov::Input::get_rt_info); input.def_property_readonly("rt_info", diff --git a/src/bindings/python/src/pyopenvino/graph/passes/manager.cpp b/src/bindings/python/src/pyopenvino/graph/passes/manager.cpp index 4b9d86590fa..34211baeca7 100644 --- a/src/bindings/python/src/pyopenvino/graph/passes/manager.cpp +++ b/src/bindings/python/src/pyopenvino/graph/passes/manager.cpp @@ -76,10 +76,9 @@ void regclass_graph_passes_Manager(py::module m) { py::arg("pass_name"), R"( Set the type of register pass for pass manager. - Parameters - ---------- - pass_name : str - string to set the type of a pass + + :param pass_name : String to set the type of a pass. + :type pass_name: str // )"); manager.def("register_pass", @@ -90,18 +89,17 @@ void regclass_graph_passes_Manager(py::module m) { py::arg("version") = "UNSPECIFIED", R"( Set the type of register pass for pass manager. - Parameters - ---------- - pass_name : str - string to set the type of a pass - output_files : Tuple[str, str] - tuple which contains paths where .xml and .bin files will be saved - version : str - sets the version of the IR which will be generated. - Supported versions are: - - "UNSPECIFIED" (default) : Use the latest or function version - - "IR_V10" : v10 IR - - "IR_V11" : v11 IR + + :param pass_name: String to set the type of a pass. + :type pass_name: str + :param output_files: Tuple which contains paths where .xml and .bin files will be saved. + :type output_files: Tuple[str, str] + :param version: Sets the version of the IR which will be generated. + Supported versions are: + - "UNSPECIFIED" (default) : Use the latest or function version + - "IR_V10" : v10 IR + - "IR_V11" : v11 IR + :type version: str Examples ---------- 1. Default Version @@ -121,20 +119,19 @@ void regclass_graph_passes_Manager(py::module m) { py::arg("version") = "UNSPECIFIED", R"( Set the type of register pass for pass manager. - Parameters - ---------- - pass_name : str - string to set the type of a pass - xml_path : str - path where .xml file will be saved - bin_path : str - path where .bin file will be saved - version : str - sets the version of the IR which will be generated. + + :param pass_name: String to set the type of a pass. + :type pass_name: str + :param xml_path: Path where *.xml file will be saved. + :type xml_path: str + :param bin_path: Path where *.bin file will be saved. + :type bin_path: str + :param version: Sets the version of the IR which will be generated. Supported versions are: - "UNSPECIFIED" (default) : Use the latest or function version - "IR_V10" : v10 IR - "IR_V11" : v11 IR + :type version: str Examples ---------- 1. Default Version diff --git a/src/bindings/python/src/pyopenvino/graph/preprocess/pre_post_process.cpp b/src/bindings/python/src/pyopenvino/graph/preprocess/pre_post_process.cpp index d7ec912524f..05fd5a389e7 100644 --- a/src/bindings/python/src/pyopenvino/graph/preprocess/pre_post_process.cpp +++ b/src/bindings/python/src/pyopenvino/graph/preprocess/pre_post_process.cpp @@ -33,15 +33,10 @@ static void regclass_graph_PreProcessSteps(py::module m) { Subtracts single float value from each element in input tensor. Input tensor must have ov.Type.f32 data type. - Parameters - ---------- - value : float - Value to subtract. - - Returns - ---------- - selfan : PreProcessSteps - Reference to itself to allow chaining of calls in client's code in a builder-like manner. + :param value: Value to subtract. + :type value: float + :return: Reference to itself to allow chaining of calls in client's code in a builder-like manner. + :rtype: openvino.runtime.preprocess.PreProcessSteps )"); steps.def( @@ -54,15 +49,10 @@ static void regclass_graph_PreProcessSteps(py::module m) { Subtracts a given single float value from each element in a given channel from input tensor. Input tensor must have ov.Type.f32 data type. - Parameters - ---------- - values : List[float] - Values to subtract. - - Returns - ---------- - selfan : PreProcessSteps - Reference to itself to allow chaining of calls in client's code in a builder-like manner. + :param values: Values to subtract. + :type values: List[float] + :return: Reference to itself to allow chaining of calls in client's code in a builder-like manner. + :rtype: openvino.runtime.preprocess.PreProcessSteps )"); steps.def( @@ -75,15 +65,10 @@ static void regclass_graph_PreProcessSteps(py::module m) { Divides each element in input tensor by specified constant float value. Input tensor must have ov.Type.f32 data type. - Parameters - ---------- - value : float - Value to divide. - - Returns - ---------- - scale : PreProcessSteps - Reference to itself to allow chaining of calls in client's code in a builder-like manner. + :param value: Value used in division. + :type value: float + :return: Reference to itself to allow chaining of calls in client's code in a builder-like manner. + :rtype: openvino.runtime.preprocess.PreProcessSteps )"); steps.def( @@ -96,15 +81,10 @@ static void regclass_graph_PreProcessSteps(py::module m) { Divides each element in a given channel from input tensor by a given single float value. Input tensor must have ov.Type.f32 data type. - Parameters - ---------- - value : List[float] - Value to divide. - - Returns - ---------- - scale : PreProcessSteps - Reference to itself to allow chaining of calls in client's code in a builder-like manner. + :param values: Values which are used in division. + :type values: List[float] + :return: Reference to itself to allow chaining of calls in client's code in a builder-like manner. + :rtype: openvino.runtime.preprocess.PreProcessSteps )"); steps.def( @@ -117,15 +97,10 @@ static void regclass_graph_PreProcessSteps(py::module m) { Converts input tensor element type to specified type. Input tensor must have openvino.Type data type. - Parameters - ---------- - type : openvino.runtime.Type - Destination type. If not specified, type will be taken from model input's element type. - - Returns - ---------- - convert_element_type : PreProcessSteps - Reference to itself to allow chaining of calls in client's code in a builder-like manner. + :param type: Destination type. If not specified, type will be taken from model input's element type + :type type: openvino.runtime.Type + :return: Reference to itself to allow chaining of calls in client's code in a builder-like manner. + :rtype: openvino.runtime.preprocess.PreProcessSteps )"); steps.def( @@ -137,14 +112,10 @@ static void regclass_graph_PreProcessSteps(py::module m) { R"( Adds custom preprocessing operation. - Parameters - ---------- - operation : function taking Output as input argument and returning Output after preprocessing. - - Returns - ---------- - custom : PreProcessSteps - Reference to itself to allow chaining of calls in client's code in a builder-like manner. + :param operation: Python's function which takes `openvino.runtime.Output` as input argument and returns`openvino.runtime.Output`. + :type operation: function + :return: Reference to itself, allows chaining of calls in client's code in a builder-like manner. + :rtype: openvino.runtime.preprocess.PreProcessSteps )"); steps.def( @@ -208,15 +179,10 @@ static void regclass_graph_PostProcessSteps(py::module m) { Converts tensor element type to specified type. Tensor must have openvino.Type data type. - Parameters - ---------- - type : Type - Destination type. If not specified, type will be taken from model output's element type. - - Returns - ---------- - convert_element_type : PostProcessSteps - Reference to itself to allow chaining of calls in client's code in a builder-like manner. + :param type: Destination type. If not specified, type will be taken from model output's element type. + :type type: openvino.runtime.Type + :return: Reference to itself to allow chaining of calls in client's code in a builder-like manner. + :rtype: openvino.runtime.preprocess.PostProcessSteps )"); steps.def( @@ -242,14 +208,10 @@ static void regclass_graph_PostProcessSteps(py::module m) { R"( Adds custom postprocessing operation. - Parameters - ---------- - operation : function taking Output as input argument and returning Output after postprocessing. - - Returns - ---------- - custom : PostProcessSteps - Reference to itself to allow chaining of calls in client's code in a builder-like manner. + :param operation: Python's function which takes `openvino.runtime.Output` as input argument and returns`openvino.runtime.Output`. + :type operation: function + :return: Reference to itself, allows chaining of calls in client's code in a builder-like manner. + :rtype: openvino.runtime.preprocess.PreProcessSteps )"); } @@ -269,15 +231,10 @@ static void regclass_graph_InputTensorInfo(py::module m) { Set initial client's tensor element type. If type is not the same as model's element type, conversion of element type will be done automatically. - Parameters - ---------- - type : Type - Client's input tensor element type. - - Returns - ---------- - tensor : InputTensorInfo - Reference to itself to allow chaining of calls in client's code in a builder-like manner. + :param type: Client's input tensor element type. + :type type: openvino.runtime.Type + :return: Reference to itself, allows chaining of calls in client's code in a builder-like manner. + :rtype: openvino.runtime.preprocess.InputTensorInfo )"); info.def( @@ -347,14 +304,11 @@ static void regclass_graph_OutputTensorInfo(py::module m) { R"( Set client's output tensor element type. If type is not the same as model's element type, conversion of element type will be done automatically. - Parameters - ---------- - type : Type - Client's output tensor element type. - Returns - ---------- - tensor : OutputTensorInfo - Reference to itself to allow chaining of calls in client's code in a builder-like manner. + + :param type: Client's output tensor element type. + :type type: openvino.runtime.Type + :return: Reference to itself to allow chaining of calls in client's code in a builder-like manner. + :rtype: openvino.runtime.preprocess.OutputTensorInfo )"); info.def( diff --git a/src/bindings/python/tests/test_frontend/test_frontendmanager.py b/src/bindings/python/tests/test_frontend/test_frontendmanager.py index 518e29def54..1c4bf3dca3f 100644 --- a/src/bindings/python/tests/test_frontend/test_frontendmanager.py +++ b/src/bindings/python/tests/test_frontend/test_frontendmanager.py @@ -92,7 +92,7 @@ def test_convert_partially(): func = fe.convert_partially(model=model) stat = get_fe_stat() assert stat.convert_partially == 1 - fe.convert(function=func) + fe.convert(model=func) stat = get_fe_stat() assert stat.convert == 1 @@ -106,7 +106,7 @@ def test_decode_and_normalize(): func = fe.decode(model=model) stat = get_fe_stat() assert stat.decode == 1 - fe.normalize(function=func) + fe.normalize(model=func) stat = get_fe_stat() assert stat.normalize == 1 assert stat.decode == 1