From 317a60545b144ead32a5a6ee64f003f111d127a4 Mon Sep 17 00:00:00 2001 From: Ilya Churaev Date: Thu, 16 Jul 2020 06:03:59 +0300 Subject: [PATCH] remove nGraph deprecated methods (part 1) (#1314) * Remove remove_goe * Remove traverse_nodes * Removed deprecated constructors * Removed deprecated tensor methods * Fixed IE build * Fixed code style --- .../src/legacy_api/include/ie_ngraph_utils.hpp | 2 +- inference-engine/src/plugin_api/generic_ie.hpp | 2 +- .../src/readers/ir_reader/ie_ir_parser.cpp | 2 +- .../src/ngraph/operations/static_shape_nonzero.cpp | 4 +- ngraph/src/ngraph/dimension.hpp | 10 -- ngraph/src/ngraph/graph_util.cpp | 14 -- ngraph/src/ngraph/graph_util.hpp | 12 -- ngraph/src/ngraph/node.hpp | 7 - ngraph/src/ngraph/node_output.cpp | 28 +--- ngraph/src/ngraph/op/batch_norm.cpp | 13 -- ngraph/src/ngraph/op/batch_norm.hpp | 27 --- ngraph/src/ngraph/op/op.hpp | 6 - ngraph/src/ngraph/pass/core_fusion.cpp | 2 +- ngraph/src/ngraph/pass/manager_state.hpp | 6 - ngraph/src/ngraph/pass/nop_elimination.cpp | 2 +- ngraph/src/ngraph/runtime/tensor.cpp | 18 -- ngraph/src/ngraph/runtime/tensor.hpp | 6 - ngraph/src/ngraph/type/element_type.hpp | 4 - ngraph/src/ngraph/validation_util.cpp | 2 +- ngraph/test/backend/api.in.cpp | 19 --- ngraph/test/backend/fused_op.in.cpp | 181 --------------------- ngraph/test/runtime/dynamic/dynamic_backend.cpp | 7 - ngraph/test/runtime/dynamic/dynamic_backend.hpp | 1 - ngraph/test/util.cpp | 14 -- ngraph/test/util/test_tools.hpp | 13 -- 25 files changed, 14 insertions(+), 388 deletions(-) diff --git a/inference-engine/src/legacy_api/include/ie_ngraph_utils.hpp b/inference-engine/src/legacy_api/include/ie_ngraph_utils.hpp index e850101..8bb7a7b 100644 --- a/inference-engine/src/legacy_api/include/ie_ngraph_utils.hpp +++ b/inference-engine/src/legacy_api/include/ie_ngraph_utils.hpp @@ -88,7 +88,7 @@ inline ::ngraph::element::Type convertPrecision(const std::string& precision) { } inline Precision convertPrecision(const ::ngraph::element::Type& precision) { - switch (precision.get_type_enum()) { + switch (precision) { case ::ngraph::element::Type_t::undefined: return Precision(Precision::UNSPECIFIED); case ::ngraph::element::Type_t::f16: diff --git a/inference-engine/src/plugin_api/generic_ie.hpp b/inference-engine/src/plugin_api/generic_ie.hpp index dd0874a..bad38b2 100644 --- a/inference-engine/src/plugin_api/generic_ie.hpp +++ b/inference-engine/src/plugin_api/generic_ie.hpp @@ -71,7 +71,7 @@ public: genNode->doReshape(false); genericOps.emplace_back(genNode); } - }, true, nParams); + }, nParams); } } }; diff --git a/inference-engine/src/readers/ir_reader/ie_ir_parser.cpp b/inference-engine/src/readers/ir_reader/ie_ir_parser.cpp index b3c25a1..e3ddad0 100644 --- a/inference-engine/src/readers/ir_reader/ie_ir_parser.cpp +++ b/inference-engine/src/readers/ir_reader/ie_ir_parser.cpp @@ -381,7 +381,7 @@ std::shared_ptr V10Parser::createNode(const std::vectorget_data_ptr(); const auto totalInputSize = shape_size(inputShape); - const auto inputRank = static_cast(nonZeroOutput->get_partial_shape()[0]); - const auto nonZeroCount = static_cast(nonZeroOutput->get_partial_shape()[1]); + const auto inputRank = nonZeroOutput->get_partial_shape()[0].get_length(); + const auto nonZeroCount = nonZeroOutput->get_partial_shape()[1].get_length(); for (size_t i = 0; i < inputRank; ++i) { for (size_t j = 0; j < nonZeroCount; j++) { diff --git a/ngraph/src/ngraph/dimension.hpp b/ngraph/src/ngraph/dimension.hpp index 0c2d21b..0b905b4 100644 --- a/ngraph/src/ngraph/dimension.hpp +++ b/ngraph/src/ngraph/dimension.hpp @@ -62,16 +62,6 @@ namespace ngraph /// \brief Check whether this dimension is dynamic. /// \return `false` if the dimension is static, else `true`. bool is_dynamic() const { return m_dimension.size() != 1; } - /// \brief Convert this dimension to `value-type`. This dimension must be static. - /// \throws std::invalid_argument If this dimension is dynamic. - explicit operator value_type() const NGRAPH_DEPRECATED("use get_length() instead") - { - if (is_dynamic()) - { - throw std::invalid_argument("Cannot convert dynamic dimension to value_type"); - } - return m_dimension.get_min_val(); - } /// \brief Convert this dimension to `value_type`. This dimension must be static and /// non-negative. /// \throws std::invalid_argument If this dimension is dynamic or negative. diff --git a/ngraph/src/ngraph/graph_util.cpp b/ngraph/src/ngraph/graph_util.cpp index 4b5e5e8..e1d4dec 100644 --- a/ngraph/src/ngraph/graph_util.cpp +++ b/ngraph/src/ngraph/graph_util.cpp @@ -96,14 +96,6 @@ void ngraph::traverse_nodes(const NodeVector& subgraph_results, } } -void ngraph::traverse_nodes(const NodeVector& subgraph_results, - std::function)> f, - bool, - const NodeVector& subgraph_params) -{ - traverse_nodes(subgraph_results, f, subgraph_params); -} - NodeVector ngraph::find_common_args(std::shared_ptr node1, std::shared_ptr node2) { std::unordered_set> node1_args; @@ -877,12 +869,6 @@ bool ngraph::check_for_cycles(const ngraph::Function* func, return false; } -void ngraph::traverse_functions(std::shared_ptr p, - std::function)> f) -{ - f(p); -} - bool ngraph::replace_output_update_name(Output output, const Output& replacement) { bool has_result_output = false; diff --git a/ngraph/src/ngraph/graph_util.hpp b/ngraph/src/ngraph/graph_util.hpp index f51a3a5..5d70dd2 100644 --- a/ngraph/src/ngraph/graph_util.hpp +++ b/ngraph/src/ngraph/graph_util.hpp @@ -71,18 +71,6 @@ namespace ngraph std::function)> f, const NodeVector& subgraph_params = {}); - NGRAPH_API - void traverse_nodes(const NodeVector& subgraph_results, - std::function)> f, - bool, - const NodeVector& subgraph_params = {}) - NGRAPH_DEPRECATED("Use traverse_nodes without control-deps option"); - - NGRAPH_API - void traverse_functions(std::shared_ptr p, - std::function)> f) - NGRAPH_DEPRECATED("Replace with f(p)"); - /// \brief Replace the node `target` with the node `replacement`, i.e., /// redirect all users and control dependencies of `target` to /// `replacement`. diff --git a/ngraph/src/ngraph/node.hpp b/ngraph/src/ngraph/node.hpp index 80386fd..6db50d8 100644 --- a/ngraph/src/ngraph/node.hpp +++ b/ngraph/src/ngraph/node.hpp @@ -68,13 +68,6 @@ namespace ngraph using HostTensorPtr = std::shared_ptr; using HostTensorVector = std::vector; - // Intermal, controls whether GetOutputElement nodes are elided - // Defaults to being elided. Transformer should set to false if - // it has passes that depend on GetOutputElement. - NGRAPH_API void set_remove_goe(bool value) - NGRAPH_DEPRECATED("Remove dependencies on GetOrderedOutput"); - NGRAPH_API bool get_remove_goe() NGRAPH_DEPRECATED("Remove dependencies on GetOrderedOutput"); - namespace op { struct AutoBroadcastSpec; diff --git a/ngraph/src/ngraph/node_output.cpp b/ngraph/src/ngraph/node_output.cpp index 3f45f90..23d32c5 100644 --- a/ngraph/src/ngraph/node_output.cpp +++ b/ngraph/src/ngraph/node_output.cpp @@ -21,16 +21,6 @@ namespace ngraph { - namespace - { - static bool remove_goe = true; - } - void set_remove_goe(bool value) - { - NGRAPH_DEBUG << "Remove GOE set: " << value; - remove_goe = value; - } - bool get_remove_goe() { return remove_goe; } Output::Output(Node* node, size_t index) : m_node(node->shared_from_this()) , m_index(index) @@ -128,12 +118,9 @@ namespace ngraph bool Output::operator>=(const Output& other) const { return !(*this < other); } void Output::eliminate_goe() { - if (remove_goe) + while (is_type(m_node)) { - while (is_type(m_node)) - { - *this = m_node->input_value(0); - } + *this = m_node->input_value(0); } } @@ -212,14 +199,11 @@ namespace ngraph bool Output::operator>=(const Output& other) const { return !(*this < other); } void Output::eliminate_goe() { - if (remove_goe) + while (is_type(m_node)) { - while (is_type(m_node)) - { - auto value = m_node->input_value(0); - m_node = value.get_node_shared_ptr(); - m_index = value.get_index(); - } + auto value = m_node->input_value(0); + m_node = value.get_node_shared_ptr(); + m_index = value.get_index(); } } diff --git a/ngraph/src/ngraph/op/batch_norm.cpp b/ngraph/src/ngraph/op/batch_norm.cpp index c634c2c..2bbdfc3 100644 --- a/ngraph/src/ngraph/op/batch_norm.cpp +++ b/ngraph/src/ngraph/op/batch_norm.cpp @@ -38,19 +38,6 @@ op::BatchNormInference::BatchNormInference(const Output& input, constructor_validate_and_infer_types(); } -// DEPRECATED -op::BatchNormInference::BatchNormInference(double eps, - const Output& gamma, - const Output& beta, - const Output& input, - const Output& mean, - const Output& variance) - : Op({gamma, beta, input, mean, variance}) - , m_epsilon(eps) -{ - constructor_validate_and_infer_types(); -} - bool op::BatchNormInference::visit_attributes(AttributeVisitor& visitor) { visitor.on_attribute("epsilon", m_epsilon); diff --git a/ngraph/src/ngraph/op/batch_norm.hpp b/ngraph/src/ngraph/op/batch_norm.hpp index 6e476d2..a81870d 100644 --- a/ngraph/src/ngraph/op/batch_norm.hpp +++ b/ngraph/src/ngraph/op/batch_norm.hpp @@ -49,33 +49,6 @@ namespace ngraph bool visit_attributes(AttributeVisitor& visitor) override; - NGRAPH_DEPRECATED_DOC - /// In this version of BatchNorm: - /// - /// MEAN AND VARIANCE: provided by the 'mean' and 'variance' parameters. - /// - /// OUTPUT VALUE: a single tensor with the normalized value of 'input'. - /// - /// AUTODIFF SUPPORT: - /// - 'generate_adjoints(...) may throw an exception. - /// - /// SHAPE DETAILS: - /// gamma: must have rank 1, with the same span as input's channel axis. - /// beta: must have rank 1, with the same span as input's channel axis. - /// input: must have rank >= 2. The second dimension represents the channel - /// axis - /// and must have a span of at least 1. - /// mean: must have rank 1, with the same span as input's channel axis. - /// variance: must have rank 1, with the same span as input's channel axis. - /// output: shall have the same shape as 'input'. - NGRAPH_DEPRECATED("Use another constructor") - BatchNormInference(double eps, - const Output& gamma, - const Output& beta, - const Output& input, - const Output& mean, - const Output& variance); - void validate_and_infer_types() override; double get_eps_value() const { return m_epsilon; } diff --git a/ngraph/src/ngraph/op/op.hpp b/ngraph/src/ngraph/op/op.hpp index aa0f083..88d006c 100644 --- a/ngraph/src/ngraph/op/op.hpp +++ b/ngraph/src/ngraph/op/op.hpp @@ -35,12 +35,6 @@ namespace ngraph { } Op(const OutputVector& arguments); - // To only be removed by OpenVINO - NGRAPH_DEPRECATED("Use OutputVector constructor instead") - Op(const NodeVector& nodes) - : Op(as_output_vector(nodes)) - { - } }; } } diff --git a/ngraph/src/ngraph/pass/core_fusion.cpp b/ngraph/src/ngraph/pass/core_fusion.cpp index 31c387f..7cb6a09 100644 --- a/ngraph/src/ngraph/pass/core_fusion.cpp +++ b/ngraph/src/ngraph/pass/core_fusion.cpp @@ -197,7 +197,7 @@ void pass::CoreFusion::construct_folded_batch_norm() auto beta = make_shared(element::f32, beta_shape); double eps = 0.001; auto shape_r = Shape{1, 2, 2, 2}; - auto bn = make_shared(eps, gamma, beta, pconv, mean, var); + auto bn = make_shared(pconv, gamma, beta, mean, var, eps); auto callback = [input, filters, mean, var, gamma, beta](pattern::Matcher& m) { NGRAPH_DEBUG << "In callback for folded batch norm against node = " diff --git a/ngraph/src/ngraph/pass/manager_state.hpp b/ngraph/src/ngraph/pass/manager_state.hpp index 672f6a5..e974c85 100644 --- a/ngraph/src/ngraph/pass/manager_state.hpp +++ b/ngraph/src/ngraph/pass/manager_state.hpp @@ -54,12 +54,6 @@ public: void set_function(const std::shared_ptr function) { m_function = function; } std::shared_ptr get_function() const { return m_function; } - std::vector> get_functions() const - NGRAPH_DEPRECATED("Use get_function()") - { - return {m_function}; - } - private: visualize_tree_ops_map_t m_visualize_tree_ops_map; std::shared_ptr m_function; diff --git a/ngraph/src/ngraph/pass/nop_elimination.cpp b/ngraph/src/ngraph/pass/nop_elimination.cpp index e6cc18a..2be6453 100644 --- a/ngraph/src/ngraph/pass/nop_elimination.cpp +++ b/ngraph/src/ngraph/pass/nop_elimination.cpp @@ -171,7 +171,7 @@ static bool replace_squeeze_unsqueeze(const std::shared_ptr& node) } else { - target_shape.emplace_back(shape_ps[i]); + target_shape.emplace_back(shape_ps[i].get_length()); } } diff --git a/ngraph/src/ngraph/runtime/tensor.cpp b/ngraph/src/ngraph/runtime/tensor.cpp index 03c5530..946167c 100644 --- a/ngraph/src/ngraph/runtime/tensor.cpp +++ b/ngraph/src/ngraph/runtime/tensor.cpp @@ -77,21 +77,3 @@ void runtime::Tensor::set_stale(bool val) { m_stale = val; } - -void runtime::Tensor::copy_from(const ngraph::runtime::Tensor& source) -{ - if (get_element_count() != source.get_element_count()) - { - throw invalid_argument("runtime::Tensor::copy_from element count must match"); - } - if (get_element_type() != source.get_element_type()) - { - throw invalid_argument("runtime::Tensor::copy_from element types must match"); - } - // This is potentially inefficient but is supplied only to get things going - // This is be replaced with more optimial implementations in later PRs - auto size = get_size_in_bytes(); - AlignedBuffer buffer{size, 64}; - source.read(buffer.get_ptr(), size); - write(buffer.get_ptr(), size); -} diff --git a/ngraph/src/ngraph/runtime/tensor.hpp b/ngraph/src/ngraph/runtime/tensor.hpp index ade430f..eb2f50c 100644 --- a/ngraph/src/ngraph/runtime/tensor.hpp +++ b/ngraph/src/ngraph/runtime/tensor.hpp @@ -103,12 +103,6 @@ namespace ngraph /// \brief notify tensor of new data, call may block. /// backends may use this as indication of new data in tensor. virtual void wait_for_write_ready() {} - /// \brief copy bytes directly from source to this tensor - /// \param source The source tensor - virtual void copy_from(const ngraph::runtime::Tensor& source) NGRAPH_DEPRECATED( - "Allocate buf_ptr with size=get_size_in_bytes(), then use source.read(buf_ptr, " - "size) followed by this->write(buf_ptr, size)"); - protected: std::shared_ptr m_descriptor; bool m_stale; diff --git a/ngraph/src/ngraph/type/element_type.hpp b/ngraph/src/ngraph/type/element_type.hpp index 6365629..8b5783f 100644 --- a/ngraph/src/ngraph/type/element_type.hpp +++ b/ngraph/src/ngraph/type/element_type.hpp @@ -76,10 +76,6 @@ namespace ngraph const std::string& cname); ~Type() {} Type& operator=(const Type&) = default; - NGRAPH_DEPRECATED("Use operator Type_t()") Type_t get_type_enum() const - { - return m_type; - } const std::string& c_type_string() const; size_t size() const; size_t hash() const; diff --git a/ngraph/src/ngraph/validation_util.cpp b/ngraph/src/ngraph/validation_util.cpp index 738c252..828841f 100644 --- a/ngraph/src/ngraph/validation_util.cpp +++ b/ngraph/src/ngraph/validation_util.cpp @@ -646,7 +646,7 @@ bool ngraph::try_apply_auto_padding(const PartialShape& image_shape, for (size_t i = 0; i < static_cast(filter_shape.size()); i++) { - int64_t image_size = static_cast(image_dims[i + 2]); + int64_t image_size = static_cast(image_dims[i + 2].get_length()); int64_t filter_size = (static_cast(filter_shape[i]) - 1) * filter_dilations[i] + 1; int64_t filter_stride = static_cast(filter_strides[i]); auto output_size = (image_size + filter_stride - 1) / filter_stride; diff --git a/ngraph/test/backend/api.in.cpp b/ngraph/test/backend/api.in.cpp index 33203d7..15f3dc8 100644 --- a/ngraph/test/backend/api.in.cpp +++ b/ngraph/test/backend/api.in.cpp @@ -55,25 +55,6 @@ NGRAPH_TEST(${BACKEND_NAME}, create_tensor_1) EXPECT_TRUE(test::all_close_f(read_vector(result), expected, MIN_FLOAT_TOLERANCE_BITS)); } -// This tests a backend's implementation of the copy_from for tensor -NGRAPH_TEST(${BACKEND_NAME}, tensor_copy_from) -{ - Shape shape{2, 2}; - - auto backend = runtime::Backend::create("${BACKEND_NAME}"); - - // Create some tensors for input/output - vector av = {1, 2, 3, 4}; - vector bv = {5, 6, 7, 8}; - shared_ptr a = backend->create_tensor(element::f32, shape); - shared_ptr b = backend->create_tensor(element::f32, shape); - copy_data(a, av); - copy_data(b, bv); - - a->copy_from(*b); - EXPECT_TRUE(test::all_close_f(bv, read_vector(a), MIN_FLOAT_TOLERANCE_BITS)); -} - NGRAPH_TEST(${BACKEND_NAME}, get_parameters_and_results) { Shape shape{2, 2}; diff --git a/ngraph/test/backend/fused_op.in.cpp b/ngraph/test/backend/fused_op.in.cpp index f017d9b..ccd63ff 100644 --- a/ngraph/test/backend/fused_op.in.cpp +++ b/ngraph/test/backend/fused_op.in.cpp @@ -2053,69 +2053,6 @@ NGRAPH_TEST(${BACKEND_NAME}, split_var_len_parts) test_case.run(); } -NGRAPH_TEST(${BACKEND_NAME}, lstm_cell_no_bias_no_peepholes) -{ - DisableRemoveGOE nogoe; - const size_t batch_size = 2; - const size_t input_size = 3; - const size_t hidden_size = 3; - const size_t gates_count = 4; - - const auto X = make_shared(element::f32, Shape{batch_size, input_size}); - const auto W = - make_shared(element::f32, Shape{gates_count * hidden_size, input_size}); - const auto R = - make_shared(element::f32, Shape{gates_count * hidden_size, hidden_size}); - const auto H_t = make_shared(element::f32, Shape{batch_size, hidden_size}); - const auto C_t = make_shared(element::f32, Shape{batch_size, hidden_size}); - - const auto lstm_cell = - make_shared(X, H_t, C_t, W, R, hidden_size, op::LSTMWeightsFormat::IOFC); - - auto ht_function = make_shared(make_shared(lstm_cell, 0), - ParameterVector{X, H_t, C_t, W, R}); - auto ht_test_case = test::TestCase(ht_function); - // X - vector in_X{0.81342685f, 0.84108883f, 0.8152282f, 0.46893653f, 0.0901856f, 0.37088776f}; - // W - vector in_W{3.3330739e-01f, 3.6229487e-04f, 4.6773660e-01f, 4.3046016e-01f, - 7.3950343e-02f, 3.8063636e-01f, 9.6921772e-01f, 9.6897459e-01f, - 6.2964785e-01f, 3.1134409e-01f, 8.4709978e-01f, 9.4928098e-01f, - 6.1676943e-01f, 6.6020679e-01f, 1.9072217e-01f, 8.8032126e-02f, - 4.0472135e-01f, 6.8342745e-01f, 8.3432144e-01f, 4.4928190e-01f, - 7.9524308e-01f, 5.3966165e-01f, 8.5936421e-01f, 8.3136767e-01f, - 5.5125546e-02f, 4.7791195e-01f, 3.5788772e-01f, 6.7507404e-01f, - 2.1716513e-01f, 2.7473119e-01f, 3.3999152e-02f, 9.6835363e-01f, - 3.7581277e-01f, 2.4026000e-01f, 6.7418844e-01f, 3.4199652e-01f}; - // R - vector in_R{ - 0.0987983f, 0.52032113f, 0.5848073f, 0.5356095f, 0.74497133f, 0.73260087f, - 0.1700787f, 0.45684233f, 0.1495722f, 0.42734373f, 0.4433832f, 0.25906256f, - 0.03854987f, 0.47480518f, 0.37215272f, 0.99890584f, 0.74019486f, 0.3518967f, - 0.6881257f, 0.8170279f, 0.54088944f, 0.81225616f, 0.14619833f, 0.42941234f, - 0.86843914f, 0.45967972f, 0.6237719f, 0.11074839f, 0.6029616f, 0.3149305f, - 0.46504205f, 0.5843412f, 0.8733427f, 0.7687243f, 0.07074859f, 0.39188156f}; - // Ht - vector in_Ht{0.77956f, 0.5331557f, 0.04297554f, 0.7962175f, 0.7635707f, 0.11989366f}; - // Ct - vector in_Ct{0.8488452f, 0.18851636f, 0.5020695f, 0.29716516f, 0.06740791f, 0.45384037f}; - - ht_test_case.add_multiple_inputs(vector>{in_X, in_Ht, in_Ct, in_W, in_R}); - ht_test_case.add_expected_output( - Shape{batch_size, hidden_size}, - {0.81457126f, 0.61109227f, 0.769522f, 0.52239674f, 0.4324641f, 0.63183f}); - ht_test_case.run(); - - auto ct_function = make_shared(make_shared(lstm_cell, 1), - ParameterVector{X, H_t, C_t, W, R}); - auto ct_test_case = test::TestCase(ct_function); - ct_test_case.add_multiple_inputs(vector>{in_X, in_Ht, in_Ct, in_W, in_R}); - ct_test_case.add_expected_output( - Shape{batch_size, hidden_size}, - {1.4444952f, 0.9635685f, 1.2875274f, 0.8053419f, 0.7184521f, 0.95803297f}); - ct_test_case.run(); -} - NGRAPH_TEST(${BACKEND_NAME}, lstm_cell_zero_bias_peepholes) { const size_t batch_size = 2; @@ -2187,124 +2124,6 @@ NGRAPH_TEST(${BACKEND_NAME}, lstm_cell_zero_bias_peepholes) ct_test_case.run(); } -NGRAPH_TEST(${BACKEND_NAME}, lstm_cell_zero_bias_peepholes_constant) -{ - DisableRemoveGOE nogoe; - const size_t batch_size = 2; - const size_t input_size = 3; - const size_t hidden_size = 3; - const size_t gates_count = 4; - - const auto X = make_shared(element::f32, Shape{batch_size, input_size}); - const auto W = - make_shared(element::f32, Shape{gates_count * hidden_size, input_size}); - const auto R = - make_shared(element::f32, Shape{gates_count * hidden_size, hidden_size}); - const auto H_t = make_shared(element::f32, Shape{batch_size, hidden_size}); - const auto C_t = make_shared(element::f32, Shape{batch_size, hidden_size}); - const auto B = make_shared( - element::f32, Shape{gates_count * hidden_size}, std::vector{0.f}); - const auto P = - make_shared(element::f32, Shape{3 * hidden_size}, std::vector{0.f}); - - const auto lstm_cell = make_shared( - X, H_t, C_t, W, R, B, P, hidden_size, op::LSTMWeightsFormat::IOFC); - - auto ht_function = make_shared(make_shared(lstm_cell, 0), - ParameterVector{X, H_t, C_t, W, R}); - auto ht_test_case = test::TestCase(ht_function); - - // X - vector in_X{0.81342685f, 0.84108883f, 0.8152282f, 0.46893653f, 0.0901856f, 0.37088776f}; - // W - vector in_W{3.3330739e-01f, 3.6229487e-04f, 4.6773660e-01f, 4.3046016e-01f, - 7.3950343e-02f, 3.8063636e-01f, 9.6921772e-01f, 9.6897459e-01f, - 6.2964785e-01f, 3.1134409e-01f, 8.4709978e-01f, 9.4928098e-01f, - 6.1676943e-01f, 6.6020679e-01f, 1.9072217e-01f, 8.8032126e-02f, - 4.0472135e-01f, 6.8342745e-01f, 8.3432144e-01f, 4.4928190e-01f, - 7.9524308e-01f, 5.3966165e-01f, 8.5936421e-01f, 8.3136767e-01f, - 5.5125546e-02f, 4.7791195e-01f, 3.5788772e-01f, 6.7507404e-01f, - 2.1716513e-01f, 2.7473119e-01f, 3.3999152e-02f, 9.6835363e-01f, - 3.7581277e-01f, 2.4026000e-01f, 6.7418844e-01f, 3.4199652e-01f}; - // R - vector in_R{ - 0.0987983f, 0.52032113f, 0.5848073f, 0.5356095f, 0.74497133f, 0.73260087f, - 0.1700787f, 0.45684233f, 0.1495722f, 0.42734373f, 0.4433832f, 0.25906256f, - 0.03854987f, 0.47480518f, 0.37215272f, 0.99890584f, 0.74019486f, 0.3518967f, - 0.6881257f, 0.8170279f, 0.54088944f, 0.81225616f, 0.14619833f, 0.42941234f, - 0.86843914f, 0.45967972f, 0.6237719f, 0.11074839f, 0.6029616f, 0.3149305f, - 0.46504205f, 0.5843412f, 0.8733427f, 0.7687243f, 0.07074859f, 0.39188156f}; - // Ht - vector in_Ht{0.77956f, 0.5331557f, 0.04297554f, 0.7962175f, 0.7635707f, 0.11989366f}; - // Ct - vector in_Ct{0.8488452f, 0.18851636f, 0.5020695f, 0.29716516f, 0.06740791f, 0.45384037f}; - - ht_test_case.add_multiple_inputs(vector>{in_X, in_Ht, in_Ct, in_W, in_R}); - ht_test_case.add_expected_output( - Shape{batch_size, hidden_size}, - {0.81457126f, 0.61109227f, 0.769522f, 0.52239674f, 0.4324641f, 0.63183f}); - ht_test_case.run(); - - auto ct_function = make_shared(make_shared(lstm_cell, 1), - ParameterVector{X, H_t, C_t, W, R}); - auto ct_test_case = test::TestCase(ct_function); - ct_test_case.add_multiple_inputs(vector>{in_X, in_Ht, in_Ct, in_W, in_R}); - ct_test_case.add_expected_output( - Shape{batch_size, hidden_size}, - {1.4444952f, 0.9635685f, 1.2875274f, 0.8053419f, 0.7184521f, 0.95803297f}); - ct_test_case.run(); -} - -NGRAPH_TEST(${BACKEND_NAME}, lstm_cell_fixed_no_bias_no_peepholes) -{ - DisableRemoveGOE nogoe; - const size_t batch_size = 2; - const size_t input_size = 3; - const size_t hidden_size = 3; - const size_t gates_count = 4; - - const auto X = make_shared(element::f32, Shape{batch_size, input_size}); - const auto W = - make_shared(element::f32, Shape{gates_count * hidden_size, input_size}); - const auto R = - make_shared(element::f32, Shape{gates_count * hidden_size, hidden_size}); - const auto H_t = make_shared(element::f32, Shape{batch_size, hidden_size}); - const auto C_t = make_shared(element::f32, Shape{batch_size, hidden_size}); - - const auto lstm_cell = - make_shared(X, H_t, C_t, W, R, hidden_size, op::LSTMWeightsFormat::IOFC); - - auto ht_function = make_shared(make_shared(lstm_cell, 0), - ParameterVector{X, H_t, C_t, W, R}); - auto ht_test_case = test::TestCase(ht_function); - - // X - vector in_X(batch_size * input_size, 0.5f); - // W - vector in_W(gates_count * hidden_size * input_size, 0.25f); - // R - vector in_R(gates_count * hidden_size * hidden_size, 0.25f); - // Ht - vector in_Ht(batch_size * hidden_size, 0.75f); - // Ct - vector in_Ct(batch_size * hidden_size, 0.75f); - - ht_test_case.add_multiple_inputs(vector>{in_X, in_Ht, in_Ct, in_W, in_R}); - ht_test_case.add_expected_output( - Shape{batch_size, hidden_size}, - {0.56633735f, 0.56633735f, 0.56633735f, 0.56633735f, 0.56633735f, 0.56633735f}); - ht_test_case.run(); - - auto ct_function = make_shared(make_shared(lstm_cell, 1), - ParameterVector{X, H_t, C_t, W, R}); - auto ct_test_case = test::TestCase(ct_function); - ct_test_case.add_multiple_inputs(vector>{in_X, in_Ht, in_Ct, in_W, in_R}); - ct_test_case.add_expected_output( - Shape{batch_size, hidden_size}, - {1.0664454f, 1.0664454f, 1.0664454f, 1.0664454f, 1.0664454f, 1.0664454f}); - ct_test_case.run(); -} - NGRAPH_TEST(${BACKEND_NAME}, lstm_cell_bias_peepholes) { const size_t batch_size = 2; diff --git a/ngraph/test/runtime/dynamic/dynamic_backend.cpp b/ngraph/test/runtime/dynamic/dynamic_backend.cpp index 86fad29..7941b48 100644 --- a/ngraph/test/runtime/dynamic/dynamic_backend.cpp +++ b/ngraph/test/runtime/dynamic/dynamic_backend.cpp @@ -383,13 +383,6 @@ void runtime::dynamic::DynamicTensor::read(void* p, size_t n) const m_wrapped_tensor->read(p, n); } -void runtime::dynamic::DynamicTensor::copy_from(const ngraph::runtime::Tensor& source) -{ - NGRAPH_CHECK(m_wrapped_tensor != nullptr, - "tried to copy_from to a dynamic tensor with no allocated storage"); - m_wrapped_tensor->copy_from(source); -} - bool runtime::dynamic::DynamicTensor::has_storage() const { return m_wrapped_tensor != nullptr; diff --git a/ngraph/test/runtime/dynamic/dynamic_backend.hpp b/ngraph/test/runtime/dynamic/dynamic_backend.hpp index c4446e5..e127f10 100644 --- a/ngraph/test/runtime/dynamic/dynamic_backend.hpp +++ b/ngraph/test/runtime/dynamic/dynamic_backend.hpp @@ -139,7 +139,6 @@ public: virtual const ngraph::Shape& get_shape() const override; virtual void write(const void* p, size_t n) override; virtual void read(void* p, size_t n) const override; - virtual void copy_from(const ngraph::runtime::Tensor& source) override; bool has_storage() const; void release_storage(); void make_storage(const element::Type& element_type, const Shape& shape); diff --git a/ngraph/test/util.cpp b/ngraph/test/util.cpp index 3ccced1..46b21b0 100644 --- a/ngraph/test/util.cpp +++ b/ngraph/test/util.cpp @@ -165,20 +165,6 @@ TEST(util, all_close) } #endif -TEST(util, traverse_functions) -{ - // First create "f(A,B,C) = (A+B)*C". - Shape shape{2, 2}; - auto A = make_shared(element::f32, shape); - auto B = make_shared(element::f32, shape); - auto C = make_shared(element::f32, shape); - auto f = make_shared((A + B) * C, ParameterVector{A, B, C}, "f"); - - vector functions; - traverse_functions(f, [&](shared_ptr fp) { functions.push_back(fp.get()); }); - ASSERT_EQ(1, functions.size()); -} - class CloneTest : public ::testing::Test { public: diff --git a/ngraph/test/util/test_tools.hpp b/ngraph/test/util/test_tools.hpp index f1065a2..3d8ec1a 100644 --- a/ngraph/test/util/test_tools.hpp +++ b/ngraph/test/util/test_tools.hpp @@ -68,19 +68,6 @@ namespace ngraph }; } -class DisableRemoveGOE -{ -public: - DisableRemoveGOE() - : m_saved_remove_goe(ngraph::get_remove_goe()) - { - ngraph::set_remove_goe(false); - } - ~DisableRemoveGOE() { ngraph::set_remove_goe(m_saved_remove_goe); } -private: - bool m_saved_remove_goe; -}; - bool validate_list(const std::vector>& nodes); std::shared_ptr make_test_graph(); #ifndef NGRAPH_JSON_DISABLE -- 2.7.4