[nGraph] Add documentation strings (#5418)

This commit is contained in:
Jan Iwaszkiewicz authored and GitHub committed 2021-05-05 10:15:07 +02:00
1 parent 2867aab94d
commit 511cddb87f
12 files changed
+822 -86

No files matched your search

+8 -4
View File
@@ -18,10 +18,14 @@ void regclass_pyngraph_AxisSet(py::module m)
{
py::class_<ngraph::AxisSet, std::shared_ptr<ngraph::AxisSet>> axis_set(m, "AxisSet");
axis_set.doc() = "ngraph.impl.AxisSet wraps ngraph::AxisSet";
axis_set.def(py::init<const std::initializer_list<size_t>&>());
axis_set.def(py::init<const std::set<size_t>&>());
axis_set.def(py::init<const std::vector<size_t>&>());
axis_set.def(py::init<const ngraph::AxisSet&>());
axis_set.def(py::init<const std::initializer_list<size_t>&>(),
py::arg("axes"));
axis_set.def(py::init<const std::set<size_t>&>(),
py::arg("axes"));
axis_set.def(py::init<const std::vector<size_t>&>(),
py::arg("axes"));
axis_set.def(py::init<const ngraph::AxisSet&>(),
py::arg("axes"));
axis_set.def("__len__", [](const ngraph::AxisSet& v) { return v.size(); });
+6 -3
View File
@@ -15,7 +15,10 @@ void regclass_pyngraph_AxisVector(py::module m)
py::class_<ngraph::AxisVector, std::shared_ptr<ngraph::AxisVector>> axis_vector(m,
"AxisVector");
axis_vector.doc() = "ngraph.impl.AxisVector wraps ngraph::AxisVector";
axis_vector.def(py::init<const std::initializer_list<size_t>&>());
axis_vector.def(py::init<const std::vector<size_t>&>());
axis_vector.def(py::init<const ngraph::AxisVector&>());
axis_vector.def(py::init<const std::initializer_list<size_t>&>(),
py::arg("axes"));
axis_vector.def(py::init<const std::vector<size_t>&>(),
py::arg("axes"));
axis_vector.def(py::init<const ngraph::AxisVector&>(),
py::arg("axes"));
}
+156 -11
View File
@@ -21,13 +21,53 @@ void regclass_pyngraph_Dimension(py::module m)
py::class_<ngraph::Dimension, std::shared_ptr<ngraph::Dimension>> dim(m, "Dimension");
dim.doc() = "ngraph.impl.Dimension wraps ngraph::Dimension";
dim.def(py::init<>());
dim.def(py::init<value_type&>());
dim.def(py::init<value_type&, value_type&>());
dim.def(py::init<value_type&>(),
py::arg("dimension"),
R"(
Construct a static dimension.
Parameters
----------
dimension : int
Value of the dimension.
)");
dim.def(py::init<value_type&, value_type&>(),
py::arg("min_dimension"),
py::arg("max_dimension"),
R"(
Construct a dynamic dimension with bounded range.
Parameters
----------
min_dimension : int
The lower inclusive limit for the dimension.
max_dimension : int
The upper inclusive limit for the dimension.
)");
dim.def_static("dynamic", &ngraph::Dimension::dynamic);
dim.def_property_readonly("is_dynamic", &ngraph::Dimension::is_dynamic);
dim.def_property_readonly("is_static", &ngraph::Dimension::is_static);
dim.def_property_readonly("is_dynamic",
&ngraph::Dimension::is_dynamic,
R"(
Check if Dimension is dynamic.
Returns
----------
is_dynamic : bool
True if dynamic, else False.
)");
dim.def_property_readonly("is_static",
&ngraph::Dimension::is_static,
R"(
Check if Dimension is static.
Returns
----------
is_static : bool
True if static, else False.
)");
dim.def(
"__eq__",
@@ -39,14 +79,119 @@ void regclass_pyngraph_Dimension(py::module m)
py::is_operator());
dim.def("__len__", &ngraph::Dimension::get_length);
dim.def("get_length", &ngraph::Dimension::get_length);
dim.def("get_min_length", &ngraph::Dimension::get_min_length);
dim.def("get_max_length", &ngraph::Dimension::get_max_length);
dim.def("get_length",
&ngraph::Dimension::get_length,
R"(
Return this dimension as integer.
This dimension must be static and non-negative.
dim.def("same_scheme", &ngraph::Dimension::same_scheme);
dim.def("compatible", &ngraph::Dimension::compatible);
dim.def("relaxes", &ngraph::Dimension::relaxes);
dim.def("refines", &ngraph::Dimension::refines);
Returns
----------
get_length : int
Value of the dimension.
)");
dim.def("get_min_length",
&ngraph::Dimension::get_min_length,
R"(
Return this dimension's min_dimension as integer.
This dimension must be dynamic and non-negative.
Returns
----------
get_min_length : int
Value of the dimension.
)");
dim.def("get_max_length",
&ngraph::Dimension::get_max_length,
R"(
Return this dimension's max_dimension as integer.
This dimension must be dynamic and non-negative.
Returns
----------
get_max_length : int
Value of the dimension.
)");
dim.def("same_scheme",
&ngraph::Dimension::same_scheme,
py::arg("dim"),
R"(
Return this dimension's max_dimension as integer.
This dimension must be dynamic and non-negative.
Parameters
----------
dim : Dimension
The other dimension to compare this dimension to.
Returns
----------
same_scheme : bool
True if this dimension and dim are both dynamic,
or if they are both static and equal, otherwise False.
)");
dim.def("compatible",
&ngraph::Dimension::compatible,
py::arg("d"),
R"(
Check whether this dimension is capable of being merged
with the argument dimension.
Parameters
----------
d : Dimension
The dimension to compare this dimension with.
Returns
----------
compatible : bool
True if this dimension is compatible with d, else False.
)");
dim.def("relaxes",
&ngraph::Dimension::relaxes,
py::arg("d"),
R"(
Check whether this dimension is a relaxation of the argument.
This dimension relaxes (or is a relaxation of) d if:
(1) this and d are static and equal
(2) this dimension contains d dimension
this.relaxes(d) is equivalent to d.refines(this).
Parameters
----------
d : Dimension
The dimension to compare this dimension with.
Returns
----------
relaxes : bool
True if this dimension relaxes d, else False.
)");
dim.def("refines",
&ngraph::Dimension::refines,
py::arg("d"),
R"(
Check whether this dimension is a refinement of the argument.
This dimension refines (or is a refinement of) d if:
(1) this and d are static and equal
(2) d dimension contains this dimension
this.refines(d) is equivalent to d.relaxes(this).
Parameters
----------
d : Dimension
The dimension to compare this dimension with.
Returns
----------
relaxes : bool
True if this dimension refines d, else False.
)");
dim.def("__str__", [](const ngraph::Dimension& self) -> std::string {
std::stringstream ss;
+206 -16
View File
@@ -19,24 +19,214 @@ void regclass_pyngraph_Function(py::module m)
function.doc() = "ngraph.impl.Function wraps ngraph::Function";
function.def(py::init<const std::vector<std::shared_ptr<ngraph::Node>>&,
const std::vector<std::shared_ptr<ngraph::op::Parameter>>&,
const std::string&>());
const std::string&>(),
py::arg("results"),
py::arg("parameters"),
py::arg("name"),
R"(
Create user-defined Function which is a representation of a model.
Parameters
----------
results : List[Node]
List of Nodes to be used as results.
parameters : List[op.Parameter]
List of parameters.
name : str
String to set as function's freindly name.
)");
function.def(py::init<const std::shared_ptr<ngraph::Node>&,
const std::vector<std::shared_ptr<ngraph::op::Parameter>>&,
const std::string&>());
function.def("get_output_size", &ngraph::Function::get_output_size);
function.def("get_ops", &ngraph::Function::get_ops);
function.def("get_ordered_ops", &ngraph::Function::get_ordered_ops);
function.def("get_output_op", &ngraph::Function::get_output_op);
function.def("get_output_element_type", &ngraph::Function::get_output_element_type);
function.def("get_output_shape", &ngraph::Function::get_output_shape);
function.def("get_output_partial_shape", &ngraph::Function::get_output_partial_shape);
function.def("get_parameters", &ngraph::Function::get_parameters);
function.def("get_results", &ngraph::Function::get_results);
function.def("get_result", &ngraph::Function::get_result);
function.def("get_name", &ngraph::Function::get_name);
function.def("get_friendly_name", &ngraph::Function::get_friendly_name);
function.def("set_friendly_name", &ngraph::Function::set_friendly_name);
function.def("is_dynamic", &ngraph::Function::is_dynamic);
const std::string&>(),
py::arg("result"),
py::arg("parameters"),
py::arg("name"),
R"(
Create user-defined Function which is a representation of a model.
Parameters
----------
results : Node
Node to be used as result.
parameters : List[op.Parameter]
List of parameters.
name : str
String to set as function's freindly name.
)");
function.def("get_output_size",
&ngraph::Function::get_output_size,
R"(
Return the number of outputs for the function.
Returns
----------
get_output_size : int
Number of outputs.
)");
function.def("get_ops",
&ngraph::Function::get_ops,
R"(
Return ops used in the function.
Returns
----------
get_ops : List[Node]
List of Nodes representing ops used in function.
)");
function.def("get_ordered_ops",
&ngraph::Function::get_ordered_ops,
R"(
Return ops used in the function in topological order.
Returns
----------
get_ordered_ops : List[Node]
List of sorted Nodes representing ops used in function.
)");
function.def("get_output_op",
&ngraph::Function::get_output_op,
py::arg("i"),
R"(
Return the op that generates output i
Parameters
----------
i : int
output index
Returns
----------
get_output_op : Node
Node object that generates output i
)");
function.def("get_output_element_type",
&ngraph::Function::get_output_element_type,
py::arg("i"),
R"(
Return the element type of output i
Parameters
----------
i : int
output index
Returns
----------
get_output_op : Type
Type object of output i
)");
function.def("get_output_shape",
&ngraph::Function::get_output_shape,
py::arg("i"),
R"(
Return the shape of element i
Parameters
----------
i : int
element index
Returns
----------
get_output_shape : Shape
Shape object of element i
)");
function.def("get_output_partial_shape",
&ngraph::Function::get_output_partial_shape,
py::arg("i"),
R"(
Return the partial shape of element i
Parameters
----------
i : int
element index
Returns
----------
get_output_partial_shape : PartialShape
PartialShape object of element i
)");
function.def("get_parameters",
&ngraph::Function::get_parameters,
R"(
Return the function parameters.
Returns
----------
get_parameters : ParameterVector
ParameterVector containing function parameters.
)");
function.def("get_results",
&ngraph::Function::get_results,
R"(
Return a list of function outputs.
Returns
----------
get_results : ResultVector
ResultVector containing function parameters.
)");
function.def("get_result",
&ngraph::Function::get_result,
R"(
Return single result.
Returns
----------
get_result : Node
Node object representing result.
)");
function.def("get_name",
&ngraph::Function::get_name,
R"(
Get the unique name of the function.
Returns
----------
get_name : str
String with a name of the function.
)");
function.def("get_friendly_name",
&ngraph::Function::get_friendly_name,
R"(
Gets the friendly name for a function. If no
friendly name has been set via set_friendly_name
then the function's unique name is returned.
Returns
----------
get_friendly_name : str
String with a friendly name of the function.
)");
function.def("set_friendly_name",
&ngraph::Function::set_friendly_name,
py::arg("name"),
R"(
Sets a friendly name for a function. This does
not overwrite the unique name of the function and
is retrieved via get_friendly_name(). Used mainly
for debugging.
Parameters
----------
name : str
String to set as the friendly name.
)");
function.def("is_dynamic",
&ngraph::Function::is_dynamic,
R"(
Returns true if any of the op's defined in the function
contains partial shape.
Returns
----------
is_dynamic : bool
)");
function.def("__repr__", [](const ngraph::Function& self) {
std::string class_name = py::cast(self).get_type().attr("__name__").cast<std::string>();
std::stringstream shapes_ss;
+171 -15
View File
@@ -72,26 +72,182 @@ void regclass_pyngraph_Node(py::module m)
return "<" + type_name + ": '" + self.get_friendly_name() + "' (" + shapes_ss.str() + ")>";
});
node.def("get_element_type", &ngraph::Node::get_element_type);
node.def("get_output_size", &ngraph::Node::get_output_size);
node.def("get_output_element_type", &ngraph::Node::get_output_element_type);
node.def("get_output_shape", &ngraph::Node::get_output_shape);
node.def("get_output_partial_shape", &ngraph::Node::get_output_partial_shape);
node.def("get_type_name", &ngraph::Node::get_type_name);
node.def("get_name", &ngraph::Node::get_name);
node.def("get_friendly_name", &ngraph::Node::get_friendly_name);
node.def("set_friendly_name", &ngraph::Node::set_friendly_name);
node.def("input", (ngraph::Input<ngraph::Node>(ngraph::Node::*)(size_t)) & ngraph::Node::input);
node.def("get_element_type",
&ngraph::Node::get_element_type,
R"(
Checks that there is exactly one output and returns it's element type.
Returns
----------
get_element_type : Type
Type of the output.
)");
node.def("get_output_size",
&ngraph::Node::get_output_size,
R"(
Returns the number of outputs from the node.
Returns
----------
get_element_type : int
Number of outputs.
)");
node.def("get_output_element_type",
&ngraph::Node::get_output_element_type,
py::arg("i"),
R"(
Returns the element type for output i
Parameters
----------
i : int
Index of the output.
Returns
----------
get_output_element_type : Type
Type of the output i
)");
node.def("get_output_shape",
&ngraph::Node::get_output_shape,
py::arg("i"),
R"(
Returns the shape for output i
Parameters
----------
i : int
Index of the output.
Returns
----------
get_output_shape : Shape
Shape of the output i
)");
node.def("get_output_partial_shape",
&ngraph::Node::get_output_partial_shape,
py::arg("i"),
R"(
Returns the partial shape for output i
Parameters
----------
i : int
Index of the output.
Returns
----------
get_output_partial_shape : PartialShape
PartialShape of the output i
)");
node.def("get_type_name",
&ngraph::Node::get_type_name,
R"(
Returns Type's name from the node.
Returns
----------
get_type_name : str
String repesenting Type's name.
)");
node.def("get_name",
&ngraph::Node::get_name,
R"(
Get the unique name of the node
Returns
----------
get_name : str
Unique name of the node.
)");
node.def("get_friendly_name",
&ngraph::Node::get_friendly_name,
R"(
Gets the friendly name for a node. If no friendly name has
been set via set_friendly_name then the node's unique name
is returned.
Returns
----------
get_name : str
Friendly name of the node.
)");
node.def("set_friendly_name",
&ngraph::Node::set_friendly_name,
py::arg("name"),
R"(
Sets a friendly name for a node. This does not overwrite the unique name
of the node and is retrieved via get_friendly_name(). Used mainly for
debugging. The friendly name may be set exactly once.
Parameters
----------
name : str
Friendly name to set.
)");
node.def("input",
(ngraph::Input<ngraph::Node>(ngraph::Node::*)(size_t)) & ngraph::Node::input,
py::arg("input_index"),
R"(
A handle to the input_index input of this node.
Parameters
----------
input_index : int
Index of Input.
Returns
----------
input : Input
Input of this node.
)");
node.def("inputs",
(std::vector<ngraph::Input<ngraph::Node>>(ngraph::Node::*)()) & ngraph::Node::inputs);
(std::vector<ngraph::Input<ngraph::Node>>(ngraph::Node::*)()) & ngraph::Node::inputs,
R"(
A list containing a handle for each of this node's inputs, in order.
Returns
----------
inputs : List[Input]
List of node's inputs.
)");
node.def("output",
(ngraph::Output<ngraph::Node>(ngraph::Node::*)(size_t)) & ngraph::Node::output);
(ngraph::Output<ngraph::Node>(ngraph::Node::*)(size_t)) & ngraph::Node::output,
py::arg("output_index"),
R"(
A handle to the output_index output of this node.
Parameters
----------
output_index : int
Index of Output.
Returns
----------
input : Output
Output of this node.
)");
node.def("outputs",
(std::vector<ngraph::Output<ngraph::Node>>(ngraph::Node::*)()) &
ngraph::Node::outputs);
(std::vector<ngraph::Output<ngraph::Node>>(ngraph::Node::*)()) & ngraph::Node::outputs,
R"(
A list containing a handle for each of this node's outputs, in order.
Returns
----------
inputs : List[Output]
List of node's outputs.
)");
node.def("get_rt_info",
(PyRTMap & (ngraph::Node::*)()) & ngraph::Node::get_rt_info,
py::return_value_policy::reference_internal);
py::return_value_policy::reference_internal,
R"(
Returns PyRTMap which is a dictionary of user defined runtime info.
Returns
----------
get_rt_info : PyRTMap
A dictionary of user defined data.
)");
node.def_property_readonly("shape", &ngraph::Node::get_shape);
node.def_property_readonly("name", &ngraph::Node::get_name);
+60 -6
View File
@@ -16,10 +16,64 @@ void regclass_pyngraph_Input(py::module m)
m, "Input", py::dynamic_attr());
input.doc() = "ngraph.impl.Input wraps ngraph::Input<Node>";
input.def("get_node", &ngraph::Input<ngraph::Node>::get_node);
input.def("get_index", &ngraph::Input<ngraph::Node>::get_index);
input.def("get_element_type", &ngraph::Input<ngraph::Node>::get_element_type);
input.def("get_shape", &ngraph::Input<ngraph::Node>::get_shape);
input.def("get_partial_shape", &ngraph::Input<ngraph::Node>::get_partial_shape);
input.def("get_source_output", &ngraph::Input<ngraph::Node>::get_source_output);
input.def("get_node",
&ngraph::Input<ngraph::Node>::get_node,
R"(
Get node referenced by this input handle.
Returns
----------
get_node : Node
Node object referenced by this input handle.
)");
input.def("get_index",
&ngraph::Input<ngraph::Node>::get_index,
R"(
The index of the input referred to by this input handle.
Returns
----------
get_index : int
Index value as integer.
)");
input.def("get_element_type",
&ngraph::Input<ngraph::Node>::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.
)");
input.def("get_shape",
&ngraph::Input<ngraph::Node>::get_shape,
R"(
The shape of the input referred to by this input handle.
Returns
----------
get_shape : Shape
Shape of the input.
)");
input.def("get_partial_shape",
&ngraph::Input<ngraph::Node>::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.
)");
input.def("get_source_output",
&ngraph::Input<ngraph::Node>::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.
)");
}
+60 -6
View File
@@ -16,10 +16,64 @@ void regclass_pyngraph_Output(py::module m)
m, "Output", py::dynamic_attr());
output.doc() = "ngraph.impl.Output wraps ngraph::Output<Node>";
output.def("get_node", &ngraph::Output<ngraph::Node>::get_node);
output.def("get_index", &ngraph::Output<ngraph::Node>::get_index);
output.def("get_element_type", &ngraph::Output<ngraph::Node>::get_element_type);
output.def("get_shape", &ngraph::Output<ngraph::Node>::get_shape);
output.def("get_partial_shape", &ngraph::Output<ngraph::Node>::get_partial_shape);
output.def("get_target_inputs", &ngraph::Output<ngraph::Node>::get_target_inputs);
output.def("get_node",
&ngraph::Output<ngraph::Node>::get_node,
R"(
Get node referenced by this output handle.
Returns
----------
get_node : Node
Node object referenced by this output handle.
)");
output.def("get_index",
&ngraph::Output<ngraph::Node>::get_index,
R"(
The index of the output referred to by this output handle.
Returns
----------
get_index : int
Index value as integer.
)");
output.def("get_element_type",
&ngraph::Output<ngraph::Node>::get_element_type,
R"(
The element type of the output referred to by this output handle.
Returns
----------
get_element_type : Type
Type of the output.
)");
output.def("get_shape",
&ngraph::Output<ngraph::Node>::get_shape,
R"(
The shape of the output referred to by this output handle.
Returns
----------
get_shape : Shape
Shape of the output.
)");
output.def("get_partial_shape",
&ngraph::Output<ngraph::Node>::get_partial_shape,
R"(
The partial shape of the output referred to by this output handle.
Returns
----------
get_partial_shape : PartialShape
PartialShape of the output.
)");
output.def("get_target_inputs",
&ngraph::Output<ngraph::Node>::get_target_inputs,
R"(
A set containing handles for all inputs targeted by the output
referenced by this output handle.
Returns
----------
get_target_inputs : Set[Input]
Set of Inputs.
)");
}
+123 -12
View File
@@ -35,19 +35,130 @@ void regclass_pyngraph_PartialShape(py::module m)
shape.def_static("dynamic", &ngraph::PartialShape::dynamic, py::arg("r") = ngraph::Dimension());
shape.def_property_readonly("is_dynamic", &ngraph::PartialShape::is_dynamic);
shape.def_property_readonly("is_static", &ngraph::PartialShape::is_static);
shape.def_property_readonly("rank", &ngraph::PartialShape::rank);
shape.def_property_readonly("all_non_negative", &ngraph::PartialShape::all_non_negative);
shape.def_property_readonly("is_dynamic",
&ngraph::PartialShape::is_dynamic,
R"(
False if this shape is static, else True.
A shape is considered static if it has static rank,
and all dimensions of the shape are static.
)");
shape.def_property_readonly("is_static",
&ngraph::PartialShape::is_static,
R"(
True if this shape is static, else False.
A shape is considered static if it has static rank,
and all dimensions of the shape are static.
)");
shape.def_property_readonly("rank",
&ngraph::PartialShape::rank,
R"(
The rank of the shape.
)");
shape.def_property_readonly("all_non_negative",
&ngraph::PartialShape::all_non_negative,
R"(
True if all static dimensions of the tensor are
non-negative, else False.
)");
shape.def("compatible", &ngraph::PartialShape::compatible);
shape.def("refines", &ngraph::PartialShape::refines);
shape.def("relaxes", &ngraph::PartialShape::relaxes);
shape.def("same_scheme", &ngraph::PartialShape::same_scheme);
shape.def("get_max_shape", &ngraph::PartialShape::get_max_shape);
shape.def("get_min_shape", &ngraph::PartialShape::get_min_shape);
shape.def("get_shape", &ngraph::PartialShape::get_shape);
shape.def("to_shape", &ngraph::PartialShape::to_shape);
shape.def("compatible",
&ngraph::PartialShape::compatible,
py::arg("s"),
R"(
Check whether this shape is compatible with the argument, i.e.,
whether it is possible to merge them.
Parameters
----------
s : PartialShape
The shape to be checked for compatibility with this shape.
Returns
----------
compatible : bool
True if this shape is compatible with s, else False.
)");
shape.def("refines",
&ngraph::PartialShape::refines,
py::arg("s"),
R"(
Check whether this shape is a refinement of the argument.
Parameters
----------
s : PartialShape
The shape which is being compared against this shape.
Returns
----------
refines : bool
True if this shape refines s, else False.
)");
shape.def("relaxes",
&ngraph::PartialShape::relaxes,
py::arg("s"),
R"(
Check whether this shape is a relaxation of the argument.
Parameters
----------
s : PartialShape
The shape which is being compared against this shape.
Returns
----------
relaxes : bool
True if this shape relaxes s, else False.
)");
shape.def("same_scheme",
&ngraph::PartialShape::same_scheme,
py::arg("s"),
R"(
Check whether this shape represents the same scheme as the argument.
Parameters
----------
s : PartialShape
The shape which is being compared against this shape.
Returns
----------
same_scheme : bool
True if shape represents the same scheme as s, else False.
)");
shape.def("get_max_shape",
&ngraph::PartialShape::get_max_shape,
R"(
Returns
----------
get_max_shape : Shape
Get the max bounding shape.
)");
shape.def("get_min_shape",
&ngraph::PartialShape::get_min_shape,
R"(
Returns
----------
get_min_shape : Shape
Get the min bounding shape.
)");
shape.def("get_shape",
&ngraph::PartialShape::get_shape,
R"(
Returns
----------
get_shape : Shape
Get the unique shape.
)");
shape.def("to_shape",
&ngraph::PartialShape::to_shape,
R"(
Returns
----------
to_shapess : Shape
Get the unique shape.
)");
shape.def(
"__eq__",
+5 -5
View File
@@ -36,20 +36,19 @@ PYBIND11_MODULE(_pyngraph, m)
{
m.doc() = "Package ngraph.impl that wraps nGraph's namespace ngraph";
regclass_pyngraph_PyRTMap(m);
regmodule_pyngraph_types(m);
regclass_pyngraph_Dimension(m); // Dimension must be registered before PartialShape
regclass_pyngraph_Shape(m);
regclass_pyngraph_PartialShape(m);
regclass_pyngraph_Node(m);
regclass_pyngraph_Input(m);
regclass_pyngraph_Output(m);
regclass_pyngraph_NodeFactory(m);
regclass_pyngraph_Dimension(m); // Dimension must be registered before PartialShape
regclass_pyngraph_PartialShape(m);
regclass_pyngraph_Shape(m);
regclass_pyngraph_Strides(m);
regclass_pyngraph_CoordinateDiff(m);
regclass_pyngraph_AxisSet(m);
regclass_pyngraph_AxisVector(m);
regclass_pyngraph_Coordinate(m);
regmodule_pyngraph_types(m);
regclass_pyngraph_Function(m);
py::module m_op = m.def_submodule("op", "Package ngraph.impl.op that wraps ngraph::op");
regclass_pyngraph_op_Constant(m_op);
regclass_pyngraph_op_Parameter(m_op);
@@ -58,6 +57,7 @@ PYBIND11_MODULE(_pyngraph, m)
regmodule_pyngraph_onnx_import(m);
#endif
regmodule_pyngraph_op_util(m_op);
regclass_pyngraph_Function(m);
regmodule_pyngraph_passes(m);
regmodule_pyngraph_util(m);
regclass_pyngraph_Variant(m);
+6 -3
View File
@@ -18,9 +18,12 @@ void regclass_pyngraph_Shape(py::module m)
{
py::class_<ngraph::Shape, std::shared_ptr<ngraph::Shape>> shape(m, "Shape");
shape.doc() = "ngraph.impl.Shape wraps ngraph::Shape";
shape.def(py::init<const std::initializer_list<size_t>&>());
shape.def(py::init<const std::vector<size_t>&>());
shape.def(py::init<const ngraph::Shape&>());
shape.def(py::init<const std::initializer_list<size_t>&>(),
py::arg("axis_lengths"));
shape.def(py::init<const std::vector<size_t>&>(),
py::arg("axis_lengths"));
shape.def(py::init<const ngraph::Shape&>(),
py::arg("axis_lengths"));
shape.def("__len__", [](const ngraph::Shape& v) { return v.size(); });
shape.def("__getitem__", [](const ngraph::Shape& v, int key) { return v[key]; });
+6 -3
View File
@@ -18,9 +18,12 @@ void regclass_pyngraph_Strides(py::module m)
{
py::class_<ngraph::Strides, std::shared_ptr<ngraph::Strides>> strides(m, "Strides");
strides.doc() = "ngraph.impl.Strides wraps ngraph::Strides";
strides.def(py::init<const std::initializer_list<size_t>&>());
strides.def(py::init<const std::vector<size_t>&>());
strides.def(py::init<const ngraph::Strides&>());
strides.def(py::init<const std::initializer_list<size_t>&>(),
py::arg("axis_strides"));
strides.def(py::init<const std::vector<size_t>&>(),
py::arg("axis_strides"));
strides.def(py::init<const ngraph::Strides&>(),
py::arg("axis_strides"));
strides.def("__str__", [](const ngraph::Strides& self) -> std::string {
std::stringstream stringstream;
+15 -2
View File
@@ -52,8 +52,21 @@ extern void regclass_pyngraph_VariantWrapper(py::module m, std::string typestrin
});
variant_wrapper.def("get",
(VT & (ngraph::VariantWrapper<VT>::*)()) & ngraph::VariantWrapper<VT>::get);
variant_wrapper.def("set", &ngraph::VariantWrapper<VT>::set);
(VT & (ngraph::VariantWrapper<VT>::*)()) & ngraph::VariantWrapper<VT>::get,
R"(
Returns
----------
get : Variant
Value of Variant.
)");
variant_wrapper.def("set",
&ngraph::VariantWrapper<VT>::set,
R"(
Parameters
----------
set : str or int
Value to be set in Variant.
)");
variant_wrapper.def_property("value",
(VT & (ngraph::VariantWrapper<VT>::*)()) &