From 0f62031991d60b049783faea8834c1f06492569e Mon Sep 17 00:00:00 2001 From: Jan Iwaszkiewicz Date: Thu, 30 Jul 2020 13:25:42 +0200 Subject: [PATCH] [nGraph] Matching names of functions (#1524) --- ngraph/python/src/pyngraph/function.cpp | 9 +++++++-- ngraph/python/src/pyngraph/node.cpp | 2 +- .../src/pyngraph/ops/util/arithmetic_reduction.cpp | 10 ++++++++-- .../python/src/pyngraph/ops/util/index_reduction.cpp | 18 ++++++++++++++---- ngraph/python/tests/test_ngraph/test_basic.py | 2 +- 5 files changed, 31 insertions(+), 10 deletions(-) diff --git a/ngraph/python/src/pyngraph/function.cpp b/ngraph/python/src/pyngraph/function.cpp index 9e37bfc..5248c25 100644 --- a/ngraph/python/src/pyngraph/function.cpp +++ b/ngraph/python/src/pyngraph/function.cpp @@ -45,8 +45,8 @@ void regclass_pyngraph_Function(py::module m) 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_unique_name", &ngraph::Function::get_name); - function.def("get_name", &ngraph::Function::get_friendly_name); + 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); function.def("__repr__", [](const ngraph::Function& self) { @@ -99,4 +99,9 @@ void regclass_pyngraph_Function(py::module m) return pybind_capsule; }); + + function.def_property_readonly("name", &ngraph::Function::get_name); + function.def_property("friendly_name", + &ngraph::Function::get_friendly_name, + &ngraph::Function::set_friendly_name); } diff --git a/ngraph/python/src/pyngraph/node.cpp b/ngraph/python/src/pyngraph/node.cpp index 1b8bc0f..dcaa80b 100644 --- a/ngraph/python/src/pyngraph/node.cpp +++ b/ngraph/python/src/pyngraph/node.cpp @@ -76,7 +76,7 @@ void regclass_pyngraph_Node(py::module m) 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_unique_name", &ngraph::Node::get_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::*)(size_t)) & ngraph::Node::input); diff --git a/ngraph/python/src/pyngraph/ops/util/arithmetic_reduction.cpp b/ngraph/python/src/pyngraph/ops/util/arithmetic_reduction.cpp index 8c40d1e..df67fe4 100644 --- a/ngraph/python/src/pyngraph/ops/util/arithmetic_reduction.cpp +++ b/ngraph/python/src/pyngraph/ops/util/arithmetic_reduction.cpp @@ -31,6 +31,12 @@ void regclass_pyngraph_op_util_ArithmeticReduction(py::module m) // arithmeticReduction.def(py::init&, // const ngraph::AxisSet& >()); - arithmeticReduction.def_property_readonly( - "reduction_axes", &ngraph::op::util::ArithmeticReduction::get_reduction_axes); + arithmeticReduction.def("get_reduction_axes", + &ngraph::op::util::ArithmeticReduction::get_reduction_axes); + arithmeticReduction.def("set_reduction_axes", + &ngraph::op::util::ArithmeticReduction::set_reduction_axes); + + arithmeticReduction.def_property("reduction_axes", + &ngraph::op::util::ArithmeticReduction::get_reduction_axes, + &ngraph::op::util::ArithmeticReduction::set_reduction_axes); } diff --git a/ngraph/python/src/pyngraph/ops/util/index_reduction.cpp b/ngraph/python/src/pyngraph/ops/util/index_reduction.cpp index fbfc51c..5093b2c 100644 --- a/ngraph/python/src/pyngraph/ops/util/index_reduction.cpp +++ b/ngraph/python/src/pyngraph/ops/util/index_reduction.cpp @@ -27,8 +27,18 @@ void regclass_pyngraph_op_util_IndexReduction(py::module m) { py::class_> indexReduction(m, "IndexRedection"); - indexReduction.def_property_readonly("reduction_axis", - &ngraph::op::util::IndexReduction::get_reduction_axis); - indexReduction.def_property_readonly("index_element_type", - &ngraph::op::util::IndexReduction::get_index_element_type); + + indexReduction.def("get_reduction_axis", &ngraph::op::util::IndexReduction::get_reduction_axis); + indexReduction.def("set_reduction_axis", &ngraph::op::util::IndexReduction::set_reduction_axis); + indexReduction.def("get_index_element_type", + &ngraph::op::util::IndexReduction::get_index_element_type); + indexReduction.def("set_index_element_type", + &ngraph::op::util::IndexReduction::set_index_element_type); + + indexReduction.def_property("reduction_axis", + &ngraph::op::util::IndexReduction::get_reduction_axis, + &ngraph::op::util::IndexReduction::set_reduction_axis); + indexReduction.def_property("index_element_type", + &ngraph::op::util::IndexReduction::get_index_element_type, + &ngraph::op::util::IndexReduction::set_index_element_type); } diff --git a/ngraph/python/tests/test_ngraph/test_basic.py b/ngraph/python/tests/test_ngraph/test_basic.py index 3369057..c25635f 100644 --- a/ngraph/python/tests/test_ngraph/test_basic.py +++ b/ngraph/python/tests/test_ngraph/test_basic.py @@ -43,7 +43,7 @@ def test_ngraph_function_api(): assert list(function.get_output_shape(0)) == [2, 2] assert len(function.get_parameters()) == 3 assert len(function.get_results()) == 1 - assert function.get_name() == "TestFunction" + assert function.get_friendly_name() == "TestFunction" @pytest.mark.parametrize( -- 2.7.4