From faeaf045a99d288a364bc7bf574e10bbe903e6be Mon Sep 17 00:00:00 2001 From: Ilya Churaev Date: Fri, 1 Oct 2021 07:24:28 +0300 Subject: [PATCH] Graph comparator to ngraph util (#7729) * Moved FrameworkNode to nGraph * Moved graph comparator to ngraph test util * Fixed build * Try to fix centos * Fix export target * Moved engine utils to separate library * Removed ONNX util from common library * Fixed build * Fixed code style --- .../include/ngraph_ops/framework_node.hpp | 99 -- .../src/transformations/serialize.cpp | 8 +- .../transformations/framework_node_test.cpp | 59 -- .../behavior/caching_tests.cpp | 1 - .../common_test_utils/CMakeLists.txt | 1 + .../common_test_utils/ngraph_test_utils.hpp | 843 +----------------- .../include/ngraph/op/util/framework_node.hpp | 15 + .../openvino/op/util/framework_node.hpp | 121 +++ .../core/src/op/util}/framework_node.cpp | 50 +- ngraph/frontend/ir/src/ir_deserializer.cpp | 2 +- ngraph/frontend/ir/src/model.cpp | 2 +- .../onnx/frontend/src/onnx_framework_node.hpp | 8 +- .../paddlepaddle/src/pdpd_fw_node.hpp | 8 +- ngraph/test/CMakeLists.txt | 9 +- ngraph/test/backend/abc.in.cpp | 4 +- ngraph/test/backend/abs.in.cpp | 4 +- ngraph/test/backend/adaptive_avg_pool.in.cpp | 4 +- ngraph/test/backend/adaptive_max_pool.in.cpp | 4 +- ngraph/test/backend/add.in.cpp | 4 +- ngraph/test/backend/aliased_output.in.cpp | 4 +- ngraph/test/backend/api.in.cpp | 4 +- ngraph/test/backend/auto_broadcast.in.cpp | 2 +- ngraph/test/backend/avg_pool.in.cpp | 4 +- ngraph/test/backend/batch_norm.in.cpp | 4 +- ngraph/test/backend/batch_to_space.in.cpp | 4 +- ngraph/test/backend/binary_convolution.in.cpp | 1 + ngraph/test/backend/broadcast.in.cpp | 2 +- ngraph/test/backend/bucketize.in.cpp | 4 +- .../backend/builder_reduce_ops_opset1.in.cpp | 6 +- ngraph/test/backend/ceiling.in.cpp | 4 +- ngraph/test/backend/clamp.in.cpp | 4 +- ngraph/test/backend/concat.in.cpp | 2 +- ngraph/test/backend/constant.in.cpp | 2 +- ngraph/test/backend/convolution.in.cpp | 6 +- .../test/backend/convolution_backprop.in.cpp | 6 +- ngraph/test/backend/ctc_greedy_decoder.in.cpp | 4 +- .../backend/ctc_greedy_decoder_seq_len.in.cpp | 6 +- .../backend/deformable_convolution.in.cpp | 6 +- .../deformable_convolution_opset8.in.cpp | 6 +- .../backend/deformable_psroi_pooling.in.cpp | 4 +- ngraph/test/backend/depth_to_space.in.cpp | 4 +- ngraph/test/backend/detection_output.in.cpp | 4 +- ngraph/test/backend/dft.in.cpp | 6 +- ngraph/test/backend/divide.in.cpp | 2 +- ngraph/test/backend/dyn_reshape.in.cpp | 2 +- ngraph/test/backend/dynamic.in.cpp | 2 +- ngraph/test/backend/elu.in.cpp | 6 +- ngraph/test/backend/exp.in.cpp | 6 +- ...rimental_detectron_detection_output.in.cpp | 4 +- ...mental_detectron_generate_proposals.in.cpp | 4 +- .../experimental_detectron_prior_grid.in.cpp | 4 +- .../experimental_detectron_topk_rois.in.cpp | 6 +- ngraph/test/backend/fake_quantize.in.cpp | 4 +- ngraph/test/backend/floor.in.cpp | 4 +- ngraph/test/backend/floor_mod.in.cpp | 4 +- ngraph/test/backend/function_name.in.cpp | 2 +- ngraph/test/backend/gather.in.cpp | 4 +- ngraph/test/backend/gather_elements.in.cpp | 4 +- ngraph/test/backend/gather_nd.in.cpp | 6 +- ngraph/test/backend/gelu.in.cpp | 4 +- ngraph/test/backend/group_convolution.in.cpp | 6 +- .../group_convolution_backprop_data.in.cpp | 6 +- ngraph/test/backend/hard_sigmoid.in.cpp | 4 +- ngraph/test/backend/idft.in.cpp | 6 +- ngraph/test/backend/interpolate.in.cpp | 6 +- ngraph/test/backend/layer_norm.in.cpp | 5 +- ngraph/test/backend/log.in.cpp | 4 +- ngraph/test/backend/log_softmax.in.cpp | 2 +- ngraph/test/backend/lrn.in.cpp | 4 +- ngraph/test/backend/matmul.in.cpp | 6 +- ngraph/test/backend/matrix_nms.in.cpp | 4 +- ngraph/test/backend/max_pool.in.cpp | 4 +- ngraph/test/backend/maximum.in.cpp | 4 +- ngraph/test/backend/mish.in.cpp | 4 +- ngraph/test/backend/mod.in.cpp | 6 +- ngraph/test/backend/multiclass_nms.in.cpp | 4 +- ngraph/test/backend/multiple_backends.in.cpp | 2 +- ngraph/test/backend/multiple_result.in.cpp | 2 +- ngraph/test/backend/multiply.in.cpp | 4 +- ngraph/test/backend/negative.in.cpp | 4 +- ngraph/test/backend/node_name.in.cpp | 2 +- .../test/backend/non_max_suppression.in.cpp | 2 +- ngraph/test/backend/non_zero.in.cpp | 2 +- ngraph/test/backend/normalize_l2.in.cpp | 8 +- ngraph/test/backend/one_hot.in.cpp | 4 +- ngraph/test/backend/pad.in.cpp | 2 +- .../test/backend/parameter_as_output.in.cpp | 2 +- ngraph/test/backend/partial_slice.in.cpp | 26 +- ngraph/test/backend/power.in.cpp | 6 +- ngraph/test/backend/prelu.in.cpp | 4 +- ngraph/test/backend/prior_box.in.cpp | 4 +- .../test/backend/prior_box_clustered.in.cpp | 4 +- ngraph/test/backend/proposal.in.cpp | 6 +- ngraph/test/backend/psroi_pooling.in.cpp | 4 +- .../test/backend/quantize_dequantize.in.cpp | 198 ++-- ngraph/test/backend/range.in.cpp | 6 +- ngraph/test/backend/recurrent_cells.in.cpp | 6 +- ngraph/test/backend/region_yolo.in.cpp | 4 +- ngraph/test/backend/relu.in.cpp | 2 +- ngraph/test/backend/reorg_yolo.in.cpp | 4 +- ngraph/test/backend/reshape.in.cpp | 6 +- ngraph/test/backend/result.in.cpp | 4 +- ngraph/test/backend/reverse.in.cpp | 2 +- ngraph/test/backend/roll.in.cpp | 1 + ngraph/test/backend/round.in.cpp | 2 +- ngraph/test/backend/scatter_nd_update.in.cpp | 2 +- ngraph/test/backend/selu.in.cpp | 4 +- ngraph/test/backend/shape_of.in.cpp | 2 +- ngraph/test/backend/shuffle_channels.in.cpp | 6 +- ngraph/test/backend/sigmoid.in.cpp | 2 +- ngraph/test/backend/slice.in.cpp | 67 +- ngraph/test/backend/softmax.in.cpp | 2 +- ngraph/test/backend/softplus.in.cpp | 4 +- ngraph/test/backend/space_to_batch.in.cpp | 4 +- ngraph/test/backend/space_to_depth.in.cpp | 4 +- ngraph/test/backend/split.in.cpp | 4 +- ngraph/test/backend/sqrt.in.cpp | 6 +- ngraph/test/backend/squared_difference.in.cpp | 4 +- ngraph/test/backend/squeeze.in.cpp | 4 +- ngraph/test/backend/strided_slice.in.cpp | 2 +- ngraph/test/backend/subtract.in.cpp | 2 +- ngraph/test/backend/swish.in.cpp | 4 +- ngraph/test/backend/tile.in.cpp | 2 +- ngraph/test/backend/topk.in.cpp | 6 +- ngraph/test/backend/transpose.in.cpp | 6 +- ngraph/test/backend/unsqueeze.in.cpp | 4 +- ngraph/test/backend/validate_call.in.cpp | 2 +- ngraph/test/backend/variadic_split.in.cpp | 6 +- ngraph/test/backend/zero_sized.in.cpp | 2 +- ngraph/test/builder.cpp | 2 +- ngraph/test/control_dependencies.cpp | 2 +- ngraph/test/engines_util/CMakeLists.txt | 17 + .../engine_factory.hpp | 2 +- .../engine => engines_util}/engine_traits.hpp | 0 .../execute_tools.cpp} | 2 +- ngraph/test/engines_util/execute_tools.hpp | 217 +++++ .../engine => engines_util}/ie_engines.cpp | 0 .../engine => engines_util}/ie_engines.hpp | 8 +- .../interpreter_engine.cpp | 0 .../interpreter_engine.hpp | 10 +- ngraph/test/{util => engines_util}/random.hpp | 3 +- .../engine => engines_util}/shared_utils.cpp | 0 .../engine => engines_util}/shared_utils.hpp | 0 .../test/{util => engines_util}/test_case.cpp | 0 .../test/{util => engines_util}/test_case.hpp | 3 +- .../test_case_engine.hpp | 0 .../engine => engines_util}/test_engines.hpp | 0 ngraph/test/eval.cpp | 1 + .../test/frontend/paddlepaddle/op_fuzzy.cpp | 2 +- ngraph/test/frontend/shared/CMakeLists.txt | 2 +- ngraph/test/frontend/shared/src/op_fuzzy.cpp | 4 +- ngraph/test/onnx/onnx_editor.cpp | 6 +- ngraph/test/onnx/onnx_import.in.cpp | 4 +- .../test/onnx/onnx_import_controlflow.in.cpp | 4 +- ngraph/test/onnx/onnx_import_convpool.in.cpp | 4 +- .../test/onnx/onnx_import_deprecated.in.cpp | 4 +- .../test/onnx/onnx_import_dyn_shapes.in.cpp | 4 +- .../onnx/onnx_import_external_data.in.cpp | 4 +- .../test/onnx/onnx_import_org_openvino.in.cpp | 4 +- ngraph/test/onnx/onnx_import_quant.in.cpp | 4 +- ngraph/test/onnx/onnx_import_reshape.in.cpp | 5 +- ngraph/test/onnx/onnx_import_rnn.in.cpp | 4 +- .../test/onnx/onnx_import_with_editor.in.cpp | 4 +- ngraph/test/onnx/onnx_tensor_names.cpp | 2 +- ngraph/test/onnx/onnx_test_utils.in.cpp | 4 +- ngraph/test/onnx_test_util/CMakeLists.txt | 16 + .../onnx_test_util.cpp | 0 .../onnx_test_util.hpp | 0 ngraph/test/op_eval/binary_convolution.cpp | 1 + ngraph/test/op_eval/bucketize.cpp | 6 +- ngraph/test/op_eval/clamp.cpp | 6 +- ngraph/test/op_eval/einsum.cpp | 6 +- ngraph/test/op_eval/floor_mod.cpp | 6 +- ngraph/test/op_eval/gelu.cpp | 1 + ngraph/test/op_eval/hsigmoid.cpp | 1 + ngraph/test/op_eval/hswish.cpp | 1 + ngraph/test/op_eval/interpolate.cpp | 1 + ngraph/test/op_eval/matmul.cpp | 1 + ngraph/test/op_eval/memory.cpp | 1 + ngraph/test/op_eval/mish.cpp | 1 + ngraph/test/op_eval/non_zero.cpp | 1 + ngraph/test/op_eval/roi_align.cpp | 1 + ngraph/test/op_eval/roi_pooling.cpp | 6 +- ngraph/test/op_eval/round.cpp | 1 + ngraph/test/op_eval/softplus.cpp | 1 + ngraph/test/op_eval/split.cpp | 1 + ngraph/test/op_eval/strided_slice.cpp | 1 + ngraph/test/op_eval/swish.cpp | 1 + ngraph/test/op_eval/transpose.cpp | 1 + ngraph/test/op_eval/variadic_split.cpp | 2 +- ngraph/test/pass_manager.cpp | 1 + ngraph/test/type_prop/framework_node.cpp | 52 ++ ngraph/test/util.cpp | 1 + ngraph/test/util/CMakeLists.txt | 37 +- ngraph/test/util/all_close.hpp | 2 - ngraph/test/util/all_close_f.cpp | 2 +- ngraph/test/util/all_close_f.hpp | 2 +- ngraph/test/util/float_util.cpp | 2 +- .../test/util/graph_comparator.cpp | 515 +++++------ ngraph/test/util/graph_comparator.hpp | 796 +++++++++++++++++ ngraph/test/util/matcher.hpp | 9 +- ngraph/test/util/test_control.cpp | 2 +- ngraph/test/util/test_tools.hpp | 210 +---- 203 files changed, 1954 insertions(+), 2035 deletions(-) delete mode 100644 inference-engine/src/transformations/include/ngraph_ops/framework_node.hpp delete mode 100644 inference-engine/tests/functional/inference_engine/transformations/framework_node_test.cpp create mode 100644 ngraph/core/include/ngraph/op/util/framework_node.hpp create mode 100644 ngraph/core/include/openvino/op/util/framework_node.hpp rename {inference-engine/src/transformations/src/ngraph_ops => ngraph/core/src/op/util}/framework_node.cpp (63%) create mode 100644 ngraph/test/engines_util/CMakeLists.txt rename ngraph/test/{util/engine => engines_util}/engine_factory.hpp (97%) rename ngraph/test/{util/engine => engines_util}/engine_traits.hpp (100%) rename ngraph/test/{util/test_tools.cpp => engines_util/execute_tools.cpp} (99%) create mode 100644 ngraph/test/engines_util/execute_tools.hpp rename ngraph/test/{util/engine => engines_util}/ie_engines.cpp (100%) rename ngraph/test/{util/engine => engines_util}/ie_engines.hpp (97%) rename ngraph/test/{util/engine => engines_util}/interpreter_engine.cpp (100%) rename ngraph/test/{util/engine => engines_util}/interpreter_engine.hpp (93%) rename ngraph/test/{util => engines_util}/random.hpp (95%) rename ngraph/test/{util/engine => engines_util}/shared_utils.cpp (100%) rename ngraph/test/{util/engine => engines_util}/shared_utils.hpp (100%) rename ngraph/test/{util => engines_util}/test_case.cpp (100%) rename ngraph/test/{util => engines_util}/test_case.hpp (98%) rename ngraph/test/{util/engine => engines_util}/test_case_engine.hpp (100%) rename ngraph/test/{util/engine => engines_util}/test_engines.hpp (100%) create mode 100644 ngraph/test/onnx_test_util/CMakeLists.txt rename ngraph/test/{util => onnx_test_util}/onnx_test_util.cpp (100%) rename ngraph/test/{util => onnx_test_util}/onnx_test_util.hpp (100%) create mode 100644 ngraph/test/type_prop/framework_node.cpp rename inference-engine/tests/ie_test_utils/common_test_utils/ngraph_test_utils.cpp => ngraph/test/util/graph_comparator.cpp (56%) create mode 100644 ngraph/test/util/graph_comparator.hpp diff --git a/inference-engine/src/transformations/include/ngraph_ops/framework_node.hpp b/inference-engine/src/transformations/include/ngraph_ops/framework_node.hpp deleted file mode 100644 index f74952802c0..00000000000 --- a/inference-engine/src/transformations/include/ngraph_ops/framework_node.hpp +++ /dev/null @@ -1,99 +0,0 @@ -// Copyright (C) 2021 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include - -#include - - -#include "ngraph/op/op.hpp" -#include "ngraph/strides.hpp" -#include "ngraph/partial_shape.hpp" - -namespace ngraph { -namespace op { - -class TRANSFORMATIONS_API FrameworkNodeAttrs { -public: - using attrs_t = std::unordered_map; - - void set_opset_name(const std::string& opset_name) { m_opset_name = opset_name; } - - void set_type_name(const std::string& type_name) { m_type_name = type_name; } - - const std::string& get_opset_name() const { return m_opset_name; } - - const std::string& get_type_name() const { return m_type_name; } - - attrs_t::iterator begin() { return m_attrs.begin(); } - - attrs_t::iterator end() { return m_attrs.end(); } - - attrs_t::const_iterator begin() const { return m_attrs.begin(); } - - attrs_t::const_iterator end() const { return m_attrs.end(); } - - std::string operator[](const std::string & key) { return m_attrs[key]; } - - std::string at(const std::string & key) const { return m_attrs.at(key); } - - bool operator== (const FrameworkNodeAttrs & other) const { - return m_type_name == other.m_type_name && m_opset_name == other.m_opset_name && m_attrs == m_attrs; - } - -private: - std::string m_type_name; - std::string m_opset_name; - - std::unordered_map m_attrs; -}; - -class TRANSFORMATIONS_API FrameworkNode : public Op { -public: - OPENVINO_OP("FrameworkNode", "util"); - BWDCMP_RTTI_DECLARATION; - - FrameworkNode() = default; - - explicit FrameworkNode(const OutputVector& inputs, size_t output_size = 1); - - void validate_and_infer_types() override; - - bool visit_attributes(AttributeVisitor& visitor) override { - visitor.on_attribute("framework_node_attrs", m_attrs); - return true; - } - - const FrameworkNodeAttrs & get_attrs() const { return m_attrs; } - - void set_attrs(const FrameworkNodeAttrs & attrs) { m_attrs = attrs; } - - std::shared_ptr - clone_with_new_inputs(const OutputVector& new_args) const override; - - void cache_output_descriptor(); - -private: - std::vector> m_inputs_desc; - std::vector> m_output_desc; - - FrameworkNodeAttrs m_attrs; -}; -} // namespace op -} // namespace ngraph - -namespace ov { - -template <> -class TRANSFORMATIONS_API AttributeAdapter - : public DirectValueAccessor { -public: - AttributeAdapter(ngraph::op::FrameworkNodeAttrs& value); - - OPENVINO_RTTI("AttributeAdapter"); -}; - -} // namespace ov diff --git a/inference-engine/src/transformations/src/transformations/serialize.cpp b/inference-engine/src/transformations/src/transformations/serialize.cpp index b992d2f4978..2608c2b7352 100644 --- a/inference-engine/src/transformations/src/transformations/serialize.cpp +++ b/inference-engine/src/transformations/src/transformations/serialize.cpp @@ -15,7 +15,7 @@ #include "ngraph/ops.hpp" #include "ngraph/opsets/opset.hpp" #include "ngraph/opsets/opset1.hpp" -#include "ngraph_ops/framework_node.hpp" +#include "openvino/op/util/framework_node.hpp" #include "ngraph_ops/type_relaxed.hpp" #include "pugixml.hpp" #include "transformations/serialize.hpp" @@ -65,7 +65,7 @@ std::string translate_type_name(const std::string& name) { size_t hash_combine(const void* v, int64_t size) { constexpr auto cel_size = sizeof(size_t); - size_t seed = static_cast(size); + auto seed = static_cast(size); const auto data = static_cast(v); const auto d_end = std::next(data, size / cel_size); // The constant value used as a magic number has been @@ -272,7 +272,7 @@ class XmlSerializer : public ngraph::AttributeVisitor { std::vector output; for (pugi::xml_node node : xml_node.child("body").child("layers")) { if (!map_type.compare(node.attribute("type").value())) { - output.push_back(node.attribute("id").value()); + output.emplace_back(node.attribute("id").value()); } } @@ -408,7 +408,7 @@ public: m_xml_node.append_attribute("offset").set_value(offset); m_xml_node.append_attribute("size").set_value(size); } - } else if (const auto& a = ngraph::as_type>(&adapter)) { + } else if (const auto& a = ngraph::as_type>(&adapter)) { const auto & attrs = a->get(); // Update type and version attributes diff --git a/inference-engine/tests/functional/inference_engine/transformations/framework_node_test.cpp b/inference-engine/tests/functional/inference_engine/transformations/framework_node_test.cpp deleted file mode 100644 index a87bb245856..00000000000 --- a/inference-engine/tests/functional/inference_engine/transformations/framework_node_test.cpp +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright (C) 2021 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include - -#include -#include -#include - -#include -#include - -#include "common_test_utils/ngraph_test_utils.hpp" - - -using namespace testing; -using namespace ngraph; - - -TEST(TransformationTests, FrameworkNode) { - auto param = std::make_shared(element::i64, Shape{1, 64}); - auto f_node = std::make_shared(OutputVector{param}); - f_node->set_output_type(0, element::i64, Shape{1, 64}); - - // Set partially dynamic shape - param->set_partial_shape(PartialShape{Dimension::dynamic(), 64}); - param->validate_and_infer_types(); - - ASSERT_NO_THROW(f_node->validate_and_infer_types()); - ASSERT_EQ(f_node->get_output_partial_shape(0), PartialShape::dynamic()); - - // Set dynamic shape - param->set_partial_shape(PartialShape::dynamic(2)); - param->validate_and_infer_types(); - - ASSERT_NO_THROW(f_node->validate_and_infer_types()); - ASSERT_EQ(f_node->get_output_partial_shape(0), PartialShape::dynamic()); - - // Set fully dynamic shape - param->set_partial_shape(PartialShape::dynamic()); - param->validate_and_infer_types(); - - ASSERT_NO_THROW(f_node->validate_and_infer_types()); - ASSERT_EQ(f_node->get_output_partial_shape(0), PartialShape::dynamic()); - - // Set original static shape - param->set_partial_shape(Shape{1, 64}); - param->validate_and_infer_types(); - - ASSERT_NO_THROW(f_node->validate_and_infer_types()); - ASSERT_EQ(f_node->get_output_partial_shape(0), PartialShape({1, 64})); - - // Set different static shape - param->set_partial_shape(Shape{2, 64}); - param->validate_and_infer_types(); - - ASSERT_THROW(f_node->validate_and_infer_types(), ngraph_error::exception); -} \ No newline at end of file diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/behavior/caching_tests.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/behavior/caching_tests.cpp index faed828191b..b2abd7610a0 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/behavior/caching_tests.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/behavior/caching_tests.cpp @@ -4,7 +4,6 @@ #include "behavior/caching/caching_tests.hpp" #include -#include #include using namespace LayerTestsDefinitions; diff --git a/inference-engine/tests/ie_test_utils/common_test_utils/CMakeLists.txt b/inference-engine/tests/ie_test_utils/common_test_utils/CMakeLists.txt index 833950c3d98..07f7242493f 100644 --- a/inference-engine/tests/ie_test_utils/common_test_utils/CMakeLists.txt +++ b/inference-engine/tests/ie_test_utils/common_test_utils/CMakeLists.txt @@ -19,6 +19,7 @@ function(add_common_utils ADD_TARGET_NAME) gtest gtest_main inference_engine_transformations + ngraph_test_util PRIVATE openvino::util ) diff --git a/inference-engine/tests/ie_test_utils/common_test_utils/ngraph_test_utils.hpp b/inference-engine/tests/ie_test_utils/common_test_utils/ngraph_test_utils.hpp index 690c595852b..ed7ccec0e41 100644 --- a/inference-engine/tests/ie_test_utils/common_test_utils/ngraph_test_utils.hpp +++ b/inference-engine/tests/ie_test_utils/common_test_utils/ngraph_test_utils.hpp @@ -13,850 +13,15 @@ #include #include #include +#include #include "ie_common.h" -#include #include "test_common.hpp" +#include "graph_comparator.hpp" +#include "test_tools.hpp" + #define DYN ngraph::Dimension::dynamic() using TransformationTests = CommonTestUtils::TestsCommon; - -class FunctionsComparator { -public: - enum CmpValues { - NONE = 0, - CONST_VALUES = 1 << 0, - NAMES = 1 << 1, - RUNTIME_KEYS = 1 << 2, - PRECISIONS = 1 << 3, - ATTRIBUTES = 1 << 4, - }; - - struct Result { - bool valid; - std::string message; - - static Result ok(std::string msg = {}) { - return {true, std::move(msg)}; - } - static Result error(std::string msg) { - return {false, std::move(msg)}; - } - }; - - static constexpr FunctionsComparator no_default() noexcept { - return FunctionsComparator{NONE}; - } - static constexpr FunctionsComparator with_default() noexcept { - return FunctionsComparator{PRECISIONS}; - } - FunctionsComparator& enable(CmpValues f) noexcept { - m_comparition_flags = static_cast(m_comparition_flags | f); - return *this; - } - constexpr bool should_compare(CmpValues f) const noexcept { - return m_comparition_flags & f; - } - Result compare( - const std::shared_ptr& f1, - const std::shared_ptr& f2) const; - - Result operator()( - const std::shared_ptr& f1, - const std::shared_ptr& f2) const { - return compare(f1, f2); - } - -private: - constexpr explicit FunctionsComparator(CmpValues f) noexcept : m_comparition_flags(f) {} - CmpValues m_comparition_flags; -}; - -/// -/// \deprecated -/// \brief compare_functions is obsolete function use FunctionsComparator instead. -/// -inline std::pair compare_functions( - const std::shared_ptr& f1, - const std::shared_ptr& f2, - const bool compareConstValues = false, - const bool compareNames = false, - const bool compareRuntimeKeys = false, - const bool comparePrecisions = true, - const bool compareAttributes = false) { - auto fc = FunctionsComparator::no_default(); - - using Cmp = FunctionsComparator::CmpValues; - if (compareConstValues) fc.enable(Cmp::CONST_VALUES); - if (compareNames) fc.enable(Cmp::NAMES); - if (compareRuntimeKeys) fc.enable(Cmp::RUNTIME_KEYS); - if (comparePrecisions) fc.enable(Cmp::PRECISIONS); - if (compareAttributes) fc.enable(Cmp::ATTRIBUTES); - - const auto r = fc(f1, f2); - return {r.valid, r.message}; -} - -void check_rt_info(const std::shared_ptr& f); - -void set_tensor_name(ngraph::Output output, const std::string & name); - -void set_tensor_names(ngraph::Output output, const std::unordered_set & names); - -namespace ngraph { -namespace pass { -class InjectionPass; - -} // namespace pass -} // namespace ngraph - -class ngraph::pass::InjectionPass : public ngraph::pass::FunctionPass { -public: - using injection_callback = std::function)>; - - explicit InjectionPass(injection_callback callback) - : FunctionPass(), m_callback(std::move(callback)) {} - - bool run_on_function(std::shared_ptr f) override { - m_callback(f); - return false; - } - -private: - injection_callback m_callback; -}; - -template -size_t count_ops_of_type(std::shared_ptr f) { - size_t count = 0; - for (auto op : f->get_ops()) { - if (ngraph::is_type(op)) { - count++; - } - } - - return count; -} - -class TestOpMultiOut : public ngraph::op::Op { -public: - NGRAPH_RTTI_DECLARATION; - TestOpMultiOut() = default; - - TestOpMultiOut(const ngraph::Output& output_1, const ngraph::Output& output_2) - : Op({output_1, output_2}) { - validate_and_infer_types(); - } - void validate_and_infer_types() override { - set_output_size(2); - set_output_type(0, get_input_element_type(0), get_input_partial_shape(0)); - set_output_type(1, get_input_element_type(1), get_input_partial_shape(1)); - } - - std::shared_ptr clone_with_new_inputs( - const ngraph::OutputVector& new_args) const override { - return std::make_shared(new_args.at(0), new_args.at(1)); - } -}; -class Comparator { -public: - using CmpValues = FunctionsComparator::CmpValues; - using Result = FunctionsComparator::Result; - using ComparedNodes = std::pair; - - explicit Comparator(CmpValues f) : m_comparition_flags(f) {} - - Result compare( - const std::shared_ptr& f1, const std::shared_ptr& f2); - - Result compare(ngraph::Node* node1, ngraph::Node* node2) { - std::stringstream errors; - const auto result = compare(node1, node2, errors); - if (!result.valid) { - return result; - } - const auto msg = errors.str(); - return msg.empty() ? Result::ok() : Result::error(msg); - } - - Comparator recreate() const { - return Comparator(m_comparition_flags); - } - - void compare_inputs(ngraph::Node* node1, ngraph::Node* node2, std::ostream& err_log); - - void compare_outputs(ngraph::Node* node1, ngraph::Node* node2, std::ostream& err_log); - -private: - bool should_compare(CmpValues f) const noexcept { - return m_comparition_flags & f; - } - - /// - /// \param err_log - will be fill by minor errors if happen - /// \return only fatality error if some minor one appears it will be add to err_log - /// - Result compare(ngraph::Node* node1, ngraph::Node* node2, std::ostream& err_log); - - void add_nodes_inputs_to_queue(ngraph::Node* node1, ngraph::Node* node2); - - //-- DATA -- - CmpValues m_comparition_flags; - - std::queue q; - std::unordered_set used; -}; - -inline namespace tools { -template -std::string to_str(const T &v) { - using std::to_string; - return to_string(v); -} -template -std::string name(const Node &n) { - return n->get_friendly_name(); -} -} -namespace attributes { - -namespace detail { - -using AttrName = std::string; - -class Result { -public: - explicit Result(std::string m = {}) : m_message(std::move(m)) {} - - const std::string& message() const { - return m_message; - } - - bool has_error() const { - return !m_message.empty(); - } - - Result& operator+=(const std::string& msg) { - m_message.append(m_break_line_no, '\n').append(msg); - m_break_line_no = 1; - return *this; - } - -private: - std::string m_message; - int m_break_line_no{0}; -}; - -using SubGraphOpInputDescription = -std::vector>; - -using SubGraphOpOutputDescription = -std::vector>; - -using SpecialBodyPorts = ngraph::opset6::Loop::SpecialBodyPorts; - -namespace storage { - -class MemoryChunk { -public: - using Data = std::vector; - MemoryChunk(Data data) : m_data{std::move(data)} {} - - Data::const_pointer data() const { - return m_data.data(); - } - - size_t size() const { - return m_data.size(); - } - -private: - Data m_data; -}; - -template -class AttributeStorage { -public: - bool insert_value(AttrName name, AttrValue value) { - return m_attributes.insert({std::move(name), std::move(value)}).second; - } - - const AttrValue* get_value(const AttrName& name) const { - const auto found = m_attributes.find(name); - if (found != end(m_attributes)) { - return std::addressof(found->second); - } - return {}; - } - - std::size_t get_attributes_number() const { - return m_attributes.size(); - } - -private: - std::map m_attributes; -}; - -class Storage : private AttributeStorage, - private AttributeStorage, - private AttributeStorage, - private AttributeStorage, - private AttributeStorage, - private AttributeStorage, - private AttributeStorage, - private AttributeStorage, - private AttributeStorage, - private AttributeStorage, - private AttributeStorage, - private AttributeStorage, - private AttributeStorage, - private AttributeStorage>, - private AttributeStorage>, - private AttributeStorage>, - private AttributeStorage>, - private AttributeStorage>, - private AttributeStorage>, - private AttributeStorage>, - private AttributeStorage>, - private AttributeStorage>, - private AttributeStorage>, - private AttributeStorage>, - private AttributeStorage>, - private AttributeStorage, - private AttributeStorage, - private AttributeStorage, - private AttributeStorage> { -public: - template - const AttributeStorage& storage() const { - return *static_cast*>(this); - } - template - AttributeStorage& storage() { - return *static_cast*>(this); - } - - size_t stored_attributes_number() const { - return storage().get_attributes_number() + - storage().get_attributes_number() + - storage().get_attributes_number() + - storage().get_attributes_number() + - storage().get_attributes_number() + - storage().get_attributes_number() + - storage().get_attributes_number() + - storage().get_attributes_number() + - storage().get_attributes_number() + - storage().get_attributes_number() + - storage().get_attributes_number() + - storage().get_attributes_number() + - storage().get_attributes_number() + - storage>().get_attributes_number() + - storage>().get_attributes_number() + - storage>().get_attributes_number() + - storage>().get_attributes_number() + - storage>().get_attributes_number() + - storage>().get_attributes_number() + - storage>().get_attributes_number() + - storage>().get_attributes_number() + - storage>().get_attributes_number() + - storage>().get_attributes_number() + - storage>().get_attributes_number() + - storage>().get_attributes_number() + - storage().get_attributes_number() + - storage().get_attributes_number() + - storage().get_attributes_number() + - storage>().get_attributes_number(); - } -}; - -} // namespace storage - -class ReadAndStoreAttributes : public ngraph::AttributeVisitor, protected storage::Storage { -public: - void on_adapter(const std::string& name, ngraph::ValueAccessor& adapter) override; - -#define ON_ADAPTER(TYPE) \ - void on_adapter(const std::string& name, ngraph::ValueAccessor& adapter) override { \ - insert(name, adapter.get()); \ - } - - ON_ADAPTER(bool) - ON_ADAPTER(std::string) - ON_ADAPTER(int8_t) - ON_ADAPTER(int16_t) - ON_ADAPTER(int32_t) - ON_ADAPTER(int64_t) - ON_ADAPTER(uint8_t) - ON_ADAPTER(uint16_t) - ON_ADAPTER(uint32_t) - ON_ADAPTER(uint64_t) - ON_ADAPTER(float) - ON_ADAPTER(double) - ON_ADAPTER(std::vector) - ON_ADAPTER(std::vector) - ON_ADAPTER(std::vector) - ON_ADAPTER(std::vector) - ON_ADAPTER(std::vector) - ON_ADAPTER(std::vector) - ON_ADAPTER(std::vector) - ON_ADAPTER(std::vector) - ON_ADAPTER(std::vector) - ON_ADAPTER(std::vector) - ON_ADAPTER(std::vector) - ON_ADAPTER(std::shared_ptr) - -#undef ON_ADAPTER - - template - const AttrValue* get(const AttrName& name) const { - return storage().get_value(name); - } - - template - bool insert(AttrName name, AttrValue value) { - return storage().insert_value(std::move(name), std::move(value)); - } - - size_t attributes_number() const { - return stored_attributes_number(); - } - - const Result read_result() const { - return m_read_result; - } - -private: - Result m_read_result; -}; - -namespace equal { - -template -struct Equal { - static bool equal_value(const Value& lhs, const Value& rhs) { - return lhs == rhs; - } -}; - -template <> -struct Equal { - static bool equal_value(ngraph::bfloat16 lhs, ngraph::bfloat16 rhs) { - if (lhs.to_bits() == rhs.to_bits()) { - return true; - } - return std::abs(lhs - rhs) < 1e-3; - } -}; - -template <> -struct Equal { - static bool equal_value(ngraph::float16 lhs, ngraph::float16 rhs) { - if (lhs.to_bits() == rhs.to_bits()) { - return true; - } - return std::abs(lhs - rhs) < 1e-3; - } -}; - -template <> -struct Equal { - static bool equal_value(float lhs, float rhs) { - if (std::isfinite(lhs) && std::isfinite(rhs)) { - return std::abs(lhs - rhs) < 1e-4; - } - return (std::isinf(lhs) && std::isinf(rhs)) || - (std::isnan(lhs) && std::isnan(rhs)); - } -}; - -template <> -struct Equal { - static bool equal_value(double lhs, double rhs) { - if (std::isfinite(lhs) && std::isfinite(rhs)) { - return std::abs(lhs - rhs) < 1e-5; - } - return (std::isinf(lhs) && std::isinf(rhs)) || - (std::isnan(lhs) && std::isnan(rhs)); - } -}; - -template -struct Equal> { - static bool equal_value(const std::vector& lhs, const std::vector& rhs) { - return lhs.size() == rhs.size() && - std::equal(begin(lhs), end(lhs), begin(rhs), Equal::equal_value); - } -}; - -template <> -struct Equal { - static bool equal_value( - SubGraphOpInputDescription::const_reference lhs, - SubGraphOpInputDescription::const_reference rhs) { - const auto& lhs_type_info = lhs->get_type_info(); - const auto& rhs_type_info = rhs->get_type_info(); - if (lhs_type_info != rhs_type_info) { - return false; - } - using SubGraphOp = ngraph::op::util::SubGraphOp; - if (lhs_type_info == SubGraphOp::SliceInputDescription::get_type_info_static()) { - const auto& l_input = static_cast(*lhs); - const auto& r_input = static_cast(*rhs); - return l_input.m_start == r_input.m_start && l_input.m_stride == r_input.m_stride && - l_input.m_part_size == r_input.m_part_size && l_input.m_end == r_input.m_end && - l_input.m_axis == r_input.m_axis; - } else if (lhs_type_info == SubGraphOp::MergedInputDescription::get_type_info_static()) { - return true; - } else if (lhs_type_info == SubGraphOp::InvariantInputDescription::get_type_info_static()) { - return true; - } - return false; - } -}; - -template <> -struct Equal { - static bool equal_value( - const SubGraphOpInputDescription& lhs, const SubGraphOpInputDescription& rhs) { - if (lhs.size() != rhs.size()) { - return false; - } - return std::is_permutation( - begin(lhs), end(lhs), begin(rhs), - Equal::equal_value); - } -}; - -template <> -struct Equal { - static bool equal_value( - SubGraphOpOutputDescription::const_reference lhs, - SubGraphOpOutputDescription::const_reference rhs) { - const auto& lhs_type_info = lhs->get_type_info(); - const auto& rhs_type_info = rhs->get_type_info(); - if (lhs_type_info != rhs_type_info) { - return false; - } - using SubGraphOp = ngraph::op::util::SubGraphOp; - if (lhs_type_info == SubGraphOp::ConcatOutputDescription::get_type_info_static()) { - const auto& l_output = static_cast(*lhs); - const auto& r_output = static_cast(*rhs); - return l_output.m_start == r_output.m_start && l_output.m_stride == r_output.m_stride && - l_output.m_part_size == r_output.m_part_size && - l_output.m_end == r_output.m_end && l_output.m_axis == r_output.m_axis; - } else if (lhs_type_info == SubGraphOp::BodyOutputDescription::get_type_info_static()) { - const auto& l_output = static_cast(*lhs); - const auto& r_output = static_cast(*rhs); - return l_output.m_iteration == r_output.m_iteration; - } - return false; - } -}; - -template <> -struct Equal { - static bool equal_value( - const SubGraphOpOutputDescription& lhs, const SubGraphOpOutputDescription& rhs) { - if (lhs.size() != rhs.size()) { - return false; - } - return std::is_permutation( - begin(lhs), end(lhs), begin(rhs), - Equal::equal_value); - } -}; - -template <> -struct Equal> { - static bool equal_value( - const std::shared_ptr& lhs, const std::shared_ptr& rhs) { - return lhs->get_info() == rhs->get_info(); - } -}; - -template <> -struct Equal { - static constexpr uint8_t BITS_IN_BYTE_COUNT = 8; - - static inline uint8_t extract_bit(uint8_t val, uint8_t bit) { - return (val >> bit) & 0x01; - } - - static bool equal_value(const uint8_t* lhs, const uint8_t* rhs, - size_t lhs_bit_size, size_t rhs_bit_size) { - if (lhs_bit_size != rhs_bit_size) return false; - - for (size_t bit_idx = 0; bit_idx < lhs_bit_size; bit_idx++) { - const auto byte_idx_result(bit_idx / BITS_IN_BYTE_COUNT); - if (byte_idx_result > std::numeric_limits::max()) - IE_THROW() << "(bit_idx / BITS_IN_BYTE_COUNT) bigger than uint8_t::max_value"; - - const uint8_t byte_idx(static_cast(byte_idx_result)); - const uint8_t bit_in_byte_idx = 7 - (bit_idx % BITS_IN_BYTE_COUNT); - - if (extract_bit(lhs[byte_idx], bit_in_byte_idx) != - extract_bit(rhs[byte_idx], bit_in_byte_idx)) { - return false; - } - } - - return true; - } -}; - -using Constant = ngraph::opset1::Constant; -template <> -struct Equal> { - static bool equal_value( - const std::shared_ptr& lhs, const std::shared_ptr& rhs) { - const auto lhs_t = lhs->get_element_type(); - const auto rhs_t = rhs->get_element_type(); - if (lhs_t != rhs_t) { - return false; - } - - switch (lhs_t) { - case ngraph::element::Type_t::u1: { - const auto lhs_v = static_cast(lhs->get_data_ptr()); - const auto rhs_v = static_cast(rhs->get_data_ptr()); - const auto lhs_bit_size = shape_size(lhs->get_shape()); - const auto rhs_bit_size = shape_size(rhs->get_shape()); - return Equal::equal_value(lhs_v, rhs_v, lhs_bit_size, - rhs_bit_size); - } - case ngraph::element::Type_t::bf16: { - auto lhs_v = lhs->cast_vector(); - auto rhs_v = rhs->cast_vector(); - return Equal>::equal_value(lhs_v, rhs_v); - break; - } - case ngraph::element::Type_t::f16: { - const auto& lhs_v = lhs->cast_vector(); - const auto& rhs_v = rhs->cast_vector(); - return Equal>::equal_value(lhs_v, rhs_v); - break; - } - case ngraph::element::Type_t::f32: { - const auto& lhs_v = lhs->cast_vector(); - const auto& rhs_v = rhs->cast_vector(); - return Equal>::equal_value(lhs_v, rhs_v); - break; - } - default: { - const auto& lhs_v = lhs->cast_vector(); - const auto& rhs_v = rhs->cast_vector(); - return Equal>::equal_value(lhs_v, rhs_v); - break; - } - } - return false; - } -}; -} // namespace equal - -namespace str { -template -struct Void_t { - using type = void; -}; - -template -struct Get { - static std::string value(const T&) { - return std::string("[Ups can't convert this to value: ") + typeid(T).name() + "]"; - } -}; - -template -struct Get()))>::type> { - static std::string value(const T& v) { - return "[" + std::to_string(v) + "]"; - } -}; - -template <> -struct Get { - static std::string value(const std::string& v) { - return "[" + v + "]"; - } -}; - -template -struct Get< - T, - typename Void_t())), decltype(end(std::declval()))>::type> { - template - static std::string join(const Container& c, const char* glue = ", ") { - std::stringstream oss; - const char* s = ""; - for (const auto& v : c) { - oss << s << v; - s = glue; - } - return oss.str(); - } - - static std::string value(const T& v) { - return "[" + join(v) + "]"; - } -}; - -template <> -struct Get { - static std::string value(const ngraph::op::FrameworkNodeAttrs& attrs) { - std::stringstream oss; - const auto & a = attrs; - oss << "version=" << attrs.get_opset_name() << ", "; - oss << "type=" << attrs.get_type_name() << ", "; - oss << "attrs["; - for (const auto & item : a) { - oss << item.first << "=" << item.second << " "; - } - oss << "]"; - return "[" + oss.str() + "]"; - } -}; - -template <> -struct Get, void> { - static std::string value(const std::shared_ptr& variable) { - std::stringstream oss; - const auto variable_info = variable->get_info(); - oss << "["; - oss << "data_shape=" << variable_info.data_shape << ", "; - oss << "data_type=" << variable_info.data_type << ", "; - oss << "variable_id=" << variable_info.variable_id; - oss << "]"; - return oss.str(); - } -}; - -} // namespace str - -class ReadAndCompareAttributes : public ngraph::AttributeVisitor { -public: - ReadAndCompareAttributes(const ReadAndStoreAttributes& ref, Comparator::CmpValues check_flags) - : m_attr_ref(ref), m_cmp_result{ref.read_result()}, m_check_flags(check_flags) {} - - void on_adapter(const std::string& name, ngraph::ValueAccessor& adapter) override { - verify_others(name, adapter); - } - -#define ON_ADAPTER(TYPE) \ - void on_adapter(const std::string& name, ngraph::ValueAccessor& adapter) override { \ - verify(name, adapter.get()); \ - } - - ON_ADAPTER(bool) - ON_ADAPTER(std::string) - ON_ADAPTER(int8_t) - ON_ADAPTER(int16_t) - ON_ADAPTER(int32_t) - ON_ADAPTER(int64_t) - ON_ADAPTER(uint8_t) - ON_ADAPTER(uint16_t) - ON_ADAPTER(uint32_t) - ON_ADAPTER(uint64_t) - ON_ADAPTER(float) - ON_ADAPTER(double) - ON_ADAPTER(std::vector) - ON_ADAPTER(std::vector) - ON_ADAPTER(std::vector) - ON_ADAPTER(std::vector) - ON_ADAPTER(std::vector) - ON_ADAPTER(std::vector) - ON_ADAPTER(std::vector) - ON_ADAPTER(std::vector) - ON_ADAPTER(std::vector) - ON_ADAPTER(std::vector) - ON_ADAPTER(std::vector) - -#undef ON_ADAPTER - - void on_adapter( - const std::string& name, - ngraph::ValueAccessor>& adapter) override { - verify_function(name, adapter); - } - - bool all_attr_was_compared() const { - return m_visited_attributes.size() == m_attr_ref.attributes_number(); - } - - size_t compared_attr_number() const { - return m_visited_attributes.size(); - } - - const Result& cmp_result() const { - return m_cmp_result; - } - -private: - bool should_return() const { - return m_fast_exit && m_cmp_result.has_error(); - } - - template - void verify(const std::string& name, const AttrValue& attr_value); - - void verify_mem_buf( - const std::string& name, const std::shared_ptr& buffer); - - using FunctionAccessor = ngraph::ValueAccessor>; - - void verify_function(const std::string& name, FunctionAccessor& adapter); - - void verify_others(const std::string& name, ngraph::ValueAccessor& adapter); - //-- DATA -- - const ReadAndStoreAttributes& m_attr_ref; - Result m_cmp_result; - Comparator::CmpValues m_check_flags; - std::set m_visited_attributes; - static constexpr bool m_fast_exit{true}; -}; -class CompareNodesAttributes { -public: - using ReadAndStoreAttributes = detail::ReadAndStoreAttributes; - using ReadAndCompareAttributes = detail::ReadAndCompareAttributes; - - CompareNodesAttributes(Comparator::CmpValues m_compare_flags) - : m_compare_attr(m_store_attr, m_compare_flags) {} - - ReadAndStoreAttributes& get_ref_reader() { - return m_store_attr; - } - - ReadAndCompareAttributes& get_cmp_reader() { - return m_compare_attr; - } - - bool equal() const { - return m_compare_attr.all_attr_was_compared() && !m_compare_attr.cmp_result().has_error(); - } - - friend std::string to_string(const CompareNodesAttributes& c) { - const auto& result = c.m_compare_attr.cmp_result(); - if (result.has_error()) { - return result.message(); - } - if (!c.m_compare_attr.all_attr_was_compared()) { - return "not all of attr was compared: " + - to_str(c.m_compare_attr.compared_attr_number()) + " vs " + - to_str(c.m_store_attr.attributes_number()); - } - return "looks good [compared " + to_str(c.m_compare_attr.compared_attr_number()) + - " attributes]"; - } - -private: - ReadAndStoreAttributes m_store_attr; - ReadAndCompareAttributes m_compare_attr; -}; - -} // namespace detail - -Comparator::Result compare(ngraph::Node* node1, ngraph::Node* node2, Comparator::CmpValues comparition_flags); - -} // namespace attributes diff --git a/ngraph/core/include/ngraph/op/util/framework_node.hpp b/ngraph/core/include/ngraph/op/util/framework_node.hpp new file mode 100644 index 00000000000..44f993ecf8c --- /dev/null +++ b/ngraph/core/include/ngraph/op/util/framework_node.hpp @@ -0,0 +1,15 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include "ngraph/op/op.hpp" +#include "openvino/op/util/framework_node.hpp" + +namespace ngraph { +namespace op { +using ov::op::util::FrameworkNode; +using ov::op::util::FrameworkNodeAttrs; +} // namespace op +} // namespace ngraph diff --git a/ngraph/core/include/openvino/op/util/framework_node.hpp b/ngraph/core/include/openvino/op/util/framework_node.hpp new file mode 100644 index 00000000000..fd47d5c854e --- /dev/null +++ b/ngraph/core/include/openvino/op/util/framework_node.hpp @@ -0,0 +1,121 @@ +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include + +#include "openvino/core/partial_shape.hpp" +#include "openvino/core/strides.hpp" +#include "openvino/op/op.hpp" + +namespace ov { +namespace op { +namespace util { + +class OPENVINO_API FrameworkNodeAttrs { +public: + using attrs_t = std::unordered_map; + + void set_opset_name(const std::string& opset_name) { + m_opset_name = opset_name; + } + + void set_type_name(const std::string& type_name) { + m_type_name = type_name; + } + + const std::string& get_opset_name() const { + return m_opset_name; + } + + const std::string& get_type_name() const { + return m_type_name; + } + + attrs_t::iterator begin() { + return m_attrs.begin(); + } + + attrs_t::iterator end() { + return m_attrs.end(); + } + + attrs_t::const_iterator begin() const { + return m_attrs.begin(); + } + + attrs_t::const_iterator end() const { + return m_attrs.end(); + } + + std::string operator[](const std::string& key) { + return m_attrs[key]; + } + + std::string at(const std::string& key) const { + return m_attrs.at(key); + } + + bool operator==(const FrameworkNodeAttrs& other) const { + return m_type_name == other.m_type_name && m_opset_name == other.m_opset_name && m_attrs == m_attrs; + } + +private: + std::string m_type_name; + std::string m_opset_name; + + std::unordered_map m_attrs; +}; + +class OPENVINO_API FrameworkNode : public Op { +public: + OPENVINO_OP("FrameworkNode", "util"); + BWDCMP_RTTI_DECLARATION; + + FrameworkNode() = default; + + explicit FrameworkNode(const OutputVector& inputs, size_t output_size = 1); + + void validate_and_infer_types() override; + + bool visit_attributes(AttributeVisitor& visitor) override { + visitor.on_attribute("framework_node_attrs", m_attrs); + return true; + } + + const FrameworkNodeAttrs& get_attrs() const { + return m_attrs; + } + + void set_attrs(const FrameworkNodeAttrs& attrs) { + m_attrs = attrs; + } + + std::shared_ptr clone_with_new_inputs(const OutputVector& new_args) const override; + + void cache_output_descriptor(); + +private: + std::vector> m_inputs_desc; + std::vector> m_output_desc; + + FrameworkNodeAttrs m_attrs; +}; +} // namespace util +} // namespace op +} // namespace ov + +namespace ov { + +template <> +class OPENVINO_API AttributeAdapter + : public DirectValueAccessor { +public: + AttributeAdapter(ov::op::util::FrameworkNodeAttrs& value); + + OPENVINO_RTTI("AttributeAdapter"); +}; + +} // namespace ov diff --git a/inference-engine/src/transformations/src/ngraph_ops/framework_node.cpp b/ngraph/core/src/op/util/framework_node.cpp similarity index 63% rename from inference-engine/src/transformations/src/ngraph_ops/framework_node.cpp rename to ngraph/core/src/op/util/framework_node.cpp index 9ffbcf0c075..d9088c536ca 100644 --- a/inference-engine/src/transformations/src/ngraph_ops/framework_node.cpp +++ b/ngraph/core/src/op/util/framework_node.cpp @@ -2,38 +2,35 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "ngraph_ops/framework_node.hpp" +#include "openvino/op/util/framework_node.hpp" + #include "itt.hpp" -using namespace std; -using namespace ngraph; +BWDCMP_RTTI_DEFINITION(ov::op::util::FrameworkNode); -BWDCMP_RTTI_DEFINITION(op::FrameworkNode); - -op::FrameworkNode::FrameworkNode(const OutputVector& inputs, size_t output_size) - : Op(inputs) { +ov::op::util::FrameworkNode::FrameworkNode(const OutputVector& inputs, size_t output_size) : Op(inputs) { set_output_size(output_size); constructor_validate_and_infer_types(); } -shared_ptr op::FrameworkNode::clone_with_new_inputs(const OutputVector& new_args) const { - INTERNAL_OP_SCOPE(FrameworkNode_clone_with_new_inputs); +std::shared_ptr ov::op::util::FrameworkNode::clone_with_new_inputs(const OutputVector& new_args) const { + NGRAPH_OP_SCOPE(FrameworkNode_clone_with_new_inputs); check_new_args_count(this, new_args); - auto node = std::make_shared(new_args); + auto node = std::make_shared(new_args); for (size_t i = 0; i < get_output_size(); ++i) { node->set_output_type(i, get_output_element_type(i), get_output_partial_shape(i)); } return node; } -void op::FrameworkNode::cache_output_descriptor() { +void ov::op::util::FrameworkNode::cache_output_descriptor() { for (size_t i = 0; i < get_output_size(); ++i) { m_output_desc.emplace_back(get_output_partial_shape(i), get_output_element_type(i)); } } -void op::FrameworkNode::validate_and_infer_types() { - INTERNAL_OP_SCOPE(FrameworkNode_validate_and_infer_types); +void ov::op::util::FrameworkNode::validate_and_infer_types() { + NGRAPH_OP_SCOPE(FrameworkNode_validate_and_infer_types); // Save initial inputs descriptors bool initialize_input_desc = m_inputs_desc.empty(); bool reset_output_shape_to_dynamic = false; @@ -44,14 +41,11 @@ void op::FrameworkNode::validate_and_infer_types() { const auto& input_type = get_input_element_type(i); const auto& rank = input_pshape.rank(); - const auto & get_error_message = [&]() { + const auto& get_error_message = [&]() { std::stringstream out; - out << "Input descriptor for " << get_friendly_name() - << " node has been changed:" << std::endl; - out << "Before: " << std::get<0>(m_inputs_desc[i]) << ", " - << std::get<1>(m_inputs_desc[i]) << std::endl; - out << "After: " << input_pshape << ", " - << input_type << std::endl; + out << "Input descriptor for " << get_friendly_name() << " node has been changed:" << std::endl; + out << "Before: " << std::get<0>(m_inputs_desc[i]) << ", " << std::get<1>(m_inputs_desc[i]) << std::endl; + out << "After: " << input_pshape << ", " << input_type << std::endl; out << "Please specify InferenceEngine Extensions to support this case."; return out.str(); }; @@ -67,14 +61,17 @@ void op::FrameworkNode::validate_and_infer_types() { } else if (rank.is_static() && orig_input_pshape.rank().is_static() && rank.get_length() == orig_input_pshape.rank().get_length()) { for (int64_t dim = 0; dim < rank.get_length(); ++dim) { - NODE_VALIDATION_CHECK(this, input_pshape[dim].is_dynamic() || - (orig_input_pshape[dim].is_static() && - orig_input_pshape[dim].get_length() == input_pshape[dim].get_length()), + NODE_VALIDATION_CHECK(this, + input_pshape[dim].is_dynamic() || + (orig_input_pshape[dim].is_static() && + orig_input_pshape[dim].get_length() == input_pshape[dim].get_length()), get_error_message()); } reset_output_shape_to_dynamic = true; } else { - NODE_VALIDATION_CHECK(this, m_inputs_desc[i] == std::make_tuple(input_pshape, input_type), get_error_message()); + NODE_VALIDATION_CHECK(this, + m_inputs_desc[i] == std::make_tuple(input_pshape, input_type), + get_error_message()); } } } @@ -95,6 +92,5 @@ void op::FrameworkNode::validate_and_infer_types() { } } -ov::AttributeAdapter::AttributeAdapter( - ngraph::op::FrameworkNodeAttrs& value) - : DirectValueAccessor(value) {} +ov::AttributeAdapter::AttributeAdapter(ov::op::util::FrameworkNodeAttrs& value) + : DirectValueAccessor(value) {} diff --git a/ngraph/frontend/ir/src/ir_deserializer.cpp b/ngraph/frontend/ir/src/ir_deserializer.cpp index 6cbc7689602..1c540d6875e 100644 --- a/ngraph/frontend/ir/src/ir_deserializer.cpp +++ b/ngraph/frontend/ir/src/ir_deserializer.cpp @@ -6,8 +6,8 @@ #include #include +#include #include -#include #include #include #include diff --git a/ngraph/frontend/ir/src/model.cpp b/ngraph/frontend/ir/src/model.cpp index a3106a97667..d10568b816b 100644 --- a/ngraph/frontend/ir/src/model.cpp +++ b/ngraph/frontend/ir/src/model.cpp @@ -8,7 +8,7 @@ #include #include -#include +#include #include using namespace ngraph; diff --git a/ngraph/frontend/onnx/frontend/src/onnx_framework_node.hpp b/ngraph/frontend/onnx/frontend/src/onnx_framework_node.hpp index 9bdda7657fb..852a3f07b09 100644 --- a/ngraph/frontend/onnx/frontend/src/onnx_framework_node.hpp +++ b/ngraph/frontend/onnx/frontend/src/onnx_framework_node.hpp @@ -20,8 +20,8 @@ #include #include #include -#include #include +#include namespace ONNX_NAMESPACE { // forward declaration @@ -34,19 +34,19 @@ class Model; } namespace frontend { -class ONNXFrameworkNode : public op::FrameworkNode { +class ONNXFrameworkNode : public ov::op::util::FrameworkNode { public: NGRAPH_RTTI_DECLARATION; ONNXFrameworkNode(std::shared_ptr graph, const onnx_import::Node& node) - : FrameworkNode(node.get_ng_inputs(), node.get_outputs_size()), + : ov::op::util::FrameworkNode(node.get_ng_inputs(), node.get_outputs_size()), m_node(node), m_graph(graph) {} ONNXFrameworkNode(std::shared_ptr graph, const onnx_import::Node& node, const OutputVector& inputs) - : FrameworkNode(inputs, node.get_outputs_size()), + : ov::op::util::FrameworkNode(inputs, node.get_outputs_size()), m_node(node), m_graph(graph) {} diff --git a/ngraph/frontend/paddlepaddle/src/pdpd_fw_node.hpp b/ngraph/frontend/paddlepaddle/src/pdpd_fw_node.hpp index dbbbcb6e020..cb429b520cd 100644 --- a/ngraph/frontend/paddlepaddle/src/pdpd_fw_node.hpp +++ b/ngraph/frontend/paddlepaddle/src/pdpd_fw_node.hpp @@ -4,13 +4,13 @@ #pragma once -#include +#include #include "decoder.hpp" namespace ngraph { namespace frontend { -class PDPDFrameworkNode : public op::FrameworkNode { +class PDPDFrameworkNode : public ov::op::util::FrameworkNode { public: NGRAPH_RTTI_DECLARATION; @@ -20,7 +20,7 @@ public: : FrameworkNode(inputs, decoder.get_output_size()), m_decoder{decoder}, m_inputs_names{inputs_names} { - op::FrameworkNodeAttrs attrs; + ov::op::util::FrameworkNodeAttrs attrs; attrs.set_type_name(m_decoder.get_op_type()); set_attrs(attrs); @@ -50,4 +50,4 @@ private: std::vector m_inputs_names; }; } // namespace frontend -} // namespace ngraph \ No newline at end of file +} // namespace ngraph diff --git a/ngraph/test/CMakeLists.txt b/ngraph/test/CMakeLists.txt index 3853ac1f4d9..4b0a08076e3 100644 --- a/ngraph/test/CMakeLists.txt +++ b/ngraph/test/CMakeLists.txt @@ -147,6 +147,7 @@ set(SRC type_prop/fake_quantize.cpp type_prop/floor.cpp type_prop/floor_mod.cpp + type_prop/framework_node.cpp type_prop/gather.cpp type_prop/gather_elements.cpp type_prop/gather_nd.cpp @@ -412,6 +413,11 @@ endif() add_definitions("-DTEST_FILES=\"${TEST_MODEL_ZOO}/ngraph/files\"") add_subdirectory(util) +add_subdirectory(engines_util) +if (NGRAPH_ONNX_FRONTEND_ENABLE) + add_subdirectory(onnx_test_util) +endif() + # backend specific test files must meet the following requirements: # 1) The must be named .in.cpp @@ -608,6 +614,7 @@ if(UNIT_TESTS_DEPENDENCIES) endif() target_link_libraries(unit-test PRIVATE ngraph_test_util + engines_test_util ngraph::builder ${CMAKE_DL_LIBS} ie_backend @@ -637,7 +644,7 @@ endif() if (NGRAPH_ONNX_FRONTEND_ENABLE) get_target_property(ONNX_FRONTEND_SRC_DIR onnx_ngraph_frontend SOURCE_DIR) target_include_directories(unit-test PRIVATE ${ONNX_FRONTEND_SRC_DIR}/src) - target_link_libraries(unit-test PRIVATE onnx_ngraph_frontend) + target_link_libraries(unit-test PRIVATE onnx_ngraph_frontend onnx_test_util) if (LINUX) target_link_options(unit-test PRIVATE -Wl,--exclude-libs,ALL) elseif(APPLE) diff --git a/ngraph/test/backend/abc.in.cpp b/ngraph/test/backend/abc.in.cpp index 459047654a2..876f3156ac1 100644 --- a/ngraph/test/backend/abc.in.cpp +++ b/ngraph/test/backend/abc.in.cpp @@ -4,8 +4,8 @@ #include "gtest/gtest.h" #include "ngraph/ngraph.hpp" -#include "util/engine/test_engines.hpp" -#include "util/test_case.hpp" +#include "test_case.hpp" +#include "test_engines.hpp" #include "util/test_control.hpp" using namespace std; diff --git a/ngraph/test/backend/abs.in.cpp b/ngraph/test/backend/abs.in.cpp index 7834b735ee1..cc7d3911c69 100644 --- a/ngraph/test/backend/abs.in.cpp +++ b/ngraph/test/backend/abs.in.cpp @@ -21,8 +21,8 @@ #include "gtest/gtest.h" #include "ngraph/ngraph.hpp" -#include "util/engine/test_engines.hpp" -#include "util/test_case.hpp" +#include "engines_util/test_engines.hpp" +#include "engines_util/test_case.hpp" #include "util/test_control.hpp" using namespace std; diff --git a/ngraph/test/backend/adaptive_avg_pool.in.cpp b/ngraph/test/backend/adaptive_avg_pool.in.cpp index 1185b00fc0d..ae6377e76b6 100644 --- a/ngraph/test/backend/adaptive_avg_pool.in.cpp +++ b/ngraph/test/backend/adaptive_avg_pool.in.cpp @@ -2,10 +2,10 @@ // SPDX-License-Identifier: Apache-2.0 // +#include "engines_util/test_case.hpp" +#include "engines_util/test_engines.hpp" #include "gtest/gtest.h" #include "ngraph/ngraph.hpp" -#include "util/engine/test_engines.hpp" -#include "util/test_case.hpp" #include "util/test_control.hpp" using namespace std; diff --git a/ngraph/test/backend/adaptive_max_pool.in.cpp b/ngraph/test/backend/adaptive_max_pool.in.cpp index 323387f9907..3ce25626b1c 100644 --- a/ngraph/test/backend/adaptive_max_pool.in.cpp +++ b/ngraph/test/backend/adaptive_max_pool.in.cpp @@ -1,10 +1,10 @@ // Copyright (C) 2018-2021 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // +#include "engines_util/test_case.hpp" +#include "engines_util/test_engines.hpp" #include "gtest/gtest.h" #include "ngraph/ngraph.hpp" -#include "util/engine/test_engines.hpp" -#include "util/test_case.hpp" #include "util/test_control.hpp" using namespace std; diff --git a/ngraph/test/backend/add.in.cpp b/ngraph/test/backend/add.in.cpp index 240fff15ace..0916d09583f 100644 --- a/ngraph/test/backend/add.in.cpp +++ b/ngraph/test/backend/add.in.cpp @@ -21,8 +21,8 @@ #include "gtest/gtest.h" #include "ngraph/ngraph.hpp" -#include "util/engine/test_engines.hpp" -#include "util/test_case.hpp" +#include "engines_util/test_engines.hpp" +#include "engines_util/test_case.hpp" #include "util/test_control.hpp" using namespace std; diff --git a/ngraph/test/backend/aliased_output.in.cpp b/ngraph/test/backend/aliased_output.in.cpp index 52efc89ad50..ef142e1cafd 100644 --- a/ngraph/test/backend/aliased_output.in.cpp +++ b/ngraph/test/backend/aliased_output.in.cpp @@ -2,10 +2,10 @@ // SPDX-License-Identifier: Apache-2.0 // +#include "engines_util/test_case.hpp" +#include "engines_util/test_engines.hpp" #include "gtest/gtest.h" #include "ngraph/ngraph.hpp" -#include "util/engine/test_engines.hpp" -#include "util/test_case.hpp" #include "util/test_control.hpp" using namespace std; diff --git a/ngraph/test/backend/api.in.cpp b/ngraph/test/backend/api.in.cpp index 3113cd30fd2..0240521c68d 100644 --- a/ngraph/test/backend/api.in.cpp +++ b/ngraph/test/backend/api.in.cpp @@ -2,15 +2,15 @@ // SPDX-License-Identifier: Apache-2.0 // +#include "engines_util/execute_tools.hpp" +#include "engines_util/random.hpp" #include "gtest/gtest.h" #include "ngraph/ngraph.hpp" #include "ngraph/runtime/tensor.hpp" #include "runtime/backend.hpp" #include "util/all_close_f.hpp" #include "util/ndarray.hpp" -#include "util/random.hpp" #include "util/test_control.hpp" -#include "util/test_tools.hpp" using namespace std; using namespace ngraph; diff --git a/ngraph/test/backend/auto_broadcast.in.cpp b/ngraph/test/backend/auto_broadcast.in.cpp index 0bed6670bf5..e4c3e24c149 100644 --- a/ngraph/test/backend/auto_broadcast.in.cpp +++ b/ngraph/test/backend/auto_broadcast.in.cpp @@ -38,7 +38,7 @@ #include "util/all_close_f.hpp" #include "util/ndarray.hpp" #include "util/test_control.hpp" -#include "util/test_tools.hpp" +#include "engines_util/execute_tools.hpp" NGRAPH_SUPPRESS_DEPRECATED_START diff --git a/ngraph/test/backend/avg_pool.in.cpp b/ngraph/test/backend/avg_pool.in.cpp index cf983ecf659..075da10cd20 100644 --- a/ngraph/test/backend/avg_pool.in.cpp +++ b/ngraph/test/backend/avg_pool.in.cpp @@ -14,8 +14,8 @@ #include "gtest/gtest.h" #include "ngraph/ngraph.hpp" -#include "util/engine/test_engines.hpp" -#include "util/test_case.hpp" +#include "engines_util/test_engines.hpp" +#include "engines_util/test_case.hpp" #include "util/test_control.hpp" using namespace std; diff --git a/ngraph/test/backend/batch_norm.in.cpp b/ngraph/test/backend/batch_norm.in.cpp index 11aebd70fe1..96b0d1e3e6f 100644 --- a/ngraph/test/backend/batch_norm.in.cpp +++ b/ngraph/test/backend/batch_norm.in.cpp @@ -2,10 +2,10 @@ // SPDX-License-Identifier: Apache-2.0 // +#include "engines_util/test_case.hpp" +#include "engines_util/test_engines.hpp" #include "gtest/gtest.h" #include "ngraph/ngraph.hpp" -#include "util/engine/test_engines.hpp" -#include "util/test_case.hpp" #include "util/test_control.hpp" using namespace std; diff --git a/ngraph/test/backend/batch_to_space.in.cpp b/ngraph/test/backend/batch_to_space.in.cpp index 66db0505d08..dfa748fc153 100644 --- a/ngraph/test/backend/batch_to_space.in.cpp +++ b/ngraph/test/backend/batch_to_space.in.cpp @@ -2,11 +2,11 @@ // SPDX-License-Identifier: Apache-2.0 // +#include "engines_util/test_case.hpp" +#include "engines_util/test_engines.hpp" #include "gtest/gtest.h" #include "ngraph/ngraph.hpp" -#include "util/engine/test_engines.hpp" #include "util/ndarray.hpp" -#include "util/test_case.hpp" #include "util/test_control.hpp" using namespace std; diff --git a/ngraph/test/backend/binary_convolution.in.cpp b/ngraph/test/backend/binary_convolution.in.cpp index 23f219852da..805c41ff29c 100644 --- a/ngraph/test/backend/binary_convolution.in.cpp +++ b/ngraph/test/backend/binary_convolution.in.cpp @@ -2,6 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 // +#include "engines_util/execute_tools.hpp" #include "gtest/gtest.h" #include "ngraph/ngraph.hpp" #include "ngraph/runtime/tensor.hpp" diff --git a/ngraph/test/backend/broadcast.in.cpp b/ngraph/test/backend/broadcast.in.cpp index 51518dc71c1..ce1b916c616 100644 --- a/ngraph/test/backend/broadcast.in.cpp +++ b/ngraph/test/backend/broadcast.in.cpp @@ -10,6 +10,7 @@ #include #include +#include "engines_util/execute_tools.hpp" #include "gtest/gtest.h" #include "ngraph/builder/autobroadcast.hpp" #include "ngraph/ngraph.hpp" @@ -19,7 +20,6 @@ #include "util/all_close_f.hpp" #include "util/ndarray.hpp" #include "util/test_control.hpp" -#include "util/test_tools.hpp" NGRAPH_SUPPRESS_DEPRECATED_START diff --git a/ngraph/test/backend/bucketize.in.cpp b/ngraph/test/backend/bucketize.in.cpp index 11efc95f469..f26ffe8a9db 100644 --- a/ngraph/test/backend/bucketize.in.cpp +++ b/ngraph/test/backend/bucketize.in.cpp @@ -2,10 +2,10 @@ // SPDX-License-Identifier: Apache-2.0 // +#include "engines_util/test_case.hpp" +#include "engines_util/test_engines.hpp" #include "gtest/gtest.h" #include "ngraph/ngraph.hpp" -#include "util/engine/test_engines.hpp" -#include "util/test_case.hpp" #include "util/test_control.hpp" NGRAPH_SUPPRESS_DEPRECATED_START diff --git a/ngraph/test/backend/builder_reduce_ops_opset1.in.cpp b/ngraph/test/backend/builder_reduce_ops_opset1.in.cpp index 7e0b368bd75..4eab8c6f1fd 100644 --- a/ngraph/test/backend/builder_reduce_ops_opset1.in.cpp +++ b/ngraph/test/backend/builder_reduce_ops_opset1.in.cpp @@ -4,13 +4,13 @@ #include +#include "engines_util/execute_tools.hpp" +#include "engines_util/test_case.hpp" +#include "engines_util/test_engines.hpp" #include "ngraph/builder/reduce_ops.hpp" #include "ngraph/builder/reshape.hpp" #include "ngraph/ngraph.hpp" -#include "util/engine/test_engines.hpp" -#include "util/test_case.hpp" #include "util/test_control.hpp" -#include "util/test_tools.hpp" using namespace ngraph; using namespace std; diff --git a/ngraph/test/backend/ceiling.in.cpp b/ngraph/test/backend/ceiling.in.cpp index f0e470465e2..451f77f4906 100644 --- a/ngraph/test/backend/ceiling.in.cpp +++ b/ngraph/test/backend/ceiling.in.cpp @@ -14,8 +14,8 @@ #include "gtest/gtest.h" #include "ngraph/ngraph.hpp" -#include "util/engine/test_engines.hpp" -#include "util/test_case.hpp" +#include "engines_util/test_engines.hpp" +#include "engines_util/test_case.hpp" #include "util/test_control.hpp" using namespace std; diff --git a/ngraph/test/backend/clamp.in.cpp b/ngraph/test/backend/clamp.in.cpp index db70b634359..a4c86f026cc 100644 --- a/ngraph/test/backend/clamp.in.cpp +++ b/ngraph/test/backend/clamp.in.cpp @@ -14,10 +14,10 @@ // limitations under the License. //***************************************************************************** +#include "engines_util/test_case.hpp" +#include "engines_util/test_engines.hpp" #include "gtest/gtest.h" #include "ngraph/ngraph.hpp" -#include "util/engine/test_engines.hpp" -#include "util/test_case.hpp" #include "util/test_control.hpp" using namespace std; diff --git a/ngraph/test/backend/concat.in.cpp b/ngraph/test/backend/concat.in.cpp index 2479b6ff400..b319880f776 100644 --- a/ngraph/test/backend/concat.in.cpp +++ b/ngraph/test/backend/concat.in.cpp @@ -2,6 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 // +#include "engines_util/execute_tools.hpp" #include "gtest/gtest.h" #include "ngraph/ngraph.hpp" #include "ngraph/runtime/tensor.hpp" @@ -10,7 +11,6 @@ #include "util/all_close_f.hpp" #include "util/ndarray.hpp" #include "util/test_control.hpp" -#include "util/test_tools.hpp" NGRAPH_SUPPRESS_DEPRECATED_START diff --git a/ngraph/test/backend/constant.in.cpp b/ngraph/test/backend/constant.in.cpp index a1c9181db8e..546d284f8fb 100644 --- a/ngraph/test/backend/constant.in.cpp +++ b/ngraph/test/backend/constant.in.cpp @@ -2,6 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 // +#include "engines_util/execute_tools.hpp" #include "gtest/gtest.h" #include "ngraph/ngraph.hpp" #include "ngraph/runtime/tensor.hpp" @@ -10,7 +11,6 @@ #include "util/all_close_f.hpp" #include "util/ndarray.hpp" #include "util/test_control.hpp" -#include "util/test_tools.hpp" NGRAPH_SUPPRESS_DEPRECATED_START diff --git a/ngraph/test/backend/convolution.in.cpp b/ngraph/test/backend/convolution.in.cpp index 174f42ef79d..99755ebb9ab 100644 --- a/ngraph/test/backend/convolution.in.cpp +++ b/ngraph/test/backend/convolution.in.cpp @@ -2,17 +2,17 @@ // SPDX-License-Identifier: Apache-2.0 // +#include "engines_util/execute_tools.hpp" +#include "engines_util/test_case.hpp" +#include "engines_util/test_engines.hpp" #include "gtest/gtest.h" #include "ngraph/ngraph.hpp" #include "ngraph/runtime/tensor.hpp" #include "runtime/backend.hpp" #include "util/all_close.hpp" #include "util/all_close_f.hpp" -#include "util/engine/test_engines.hpp" #include "util/ndarray.hpp" -#include "util/test_case.hpp" #include "util/test_control.hpp" -#include "util/test_tools.hpp" using namespace std; using namespace ngraph; diff --git a/ngraph/test/backend/convolution_backprop.in.cpp b/ngraph/test/backend/convolution_backprop.in.cpp index 4421727eb13..cd483a7cbfa 100644 --- a/ngraph/test/backend/convolution_backprop.in.cpp +++ b/ngraph/test/backend/convolution_backprop.in.cpp @@ -14,17 +14,17 @@ // limitations under the License. //***************************************************************************** +#include "engines_util/execute_tools.hpp" +#include "engines_util/test_case.hpp" +#include "engines_util/test_engines.hpp" #include "gtest/gtest.h" #include "ngraph/ngraph.hpp" #include "ngraph/runtime/tensor.hpp" #include "runtime/backend.hpp" #include "util/all_close.hpp" #include "util/all_close_f.hpp" -#include "util/engine/test_engines.hpp" #include "util/ndarray.hpp" -#include "util/test_case.hpp" #include "util/test_control.hpp" -#include "util/test_tools.hpp" using namespace std; using namespace ngraph; diff --git a/ngraph/test/backend/ctc_greedy_decoder.in.cpp b/ngraph/test/backend/ctc_greedy_decoder.in.cpp index 65af7994b7b..ba39f03c423 100644 --- a/ngraph/test/backend/ctc_greedy_decoder.in.cpp +++ b/ngraph/test/backend/ctc_greedy_decoder.in.cpp @@ -21,8 +21,8 @@ #include "gtest/gtest.h" #include "ngraph/ngraph.hpp" -#include "util/engine/test_engines.hpp" -#include "util/test_case.hpp" +#include "engines_util/test_engines.hpp" +#include "engines_util/test_case.hpp" #include "util/test_control.hpp" NGRAPH_SUPPRESS_DEPRECATED_START diff --git a/ngraph/test/backend/ctc_greedy_decoder_seq_len.in.cpp b/ngraph/test/backend/ctc_greedy_decoder_seq_len.in.cpp index 0f1f6b4adb4..459c945ccbf 100644 --- a/ngraph/test/backend/ctc_greedy_decoder_seq_len.in.cpp +++ b/ngraph/test/backend/ctc_greedy_decoder_seq_len.in.cpp @@ -21,8 +21,8 @@ #include "gtest/gtest.h" #include "ngraph/ngraph.hpp" -#include "util/engine/test_engines.hpp" -#include "util/test_case.hpp" +#include "engines_util/test_engines.hpp" +#include "engines_util/test_case.hpp" #include "util/test_control.hpp" NGRAPH_SUPPRESS_DEPRECATED_START @@ -169,4 +169,4 @@ NGRAPH_TEST(${BACKEND_NAME}, evaluate_ctc_greedy_decoder_seq_len_no_optional_inp test_case.add_expected_output(Shape{N}, vector{2}); test_case.run(); -} \ No newline at end of file +} diff --git a/ngraph/test/backend/deformable_convolution.in.cpp b/ngraph/test/backend/deformable_convolution.in.cpp index 4fed63fc69e..df046f1d121 100644 --- a/ngraph/test/backend/deformable_convolution.in.cpp +++ b/ngraph/test/backend/deformable_convolution.in.cpp @@ -2,17 +2,17 @@ // SPDX-License-Identifier: Apache-2.0 // +#include "engines_util/execute_tools.hpp" +#include "engines_util/test_case.hpp" +#include "engines_util/test_engines.hpp" #include "gtest/gtest.h" #include "ngraph/ngraph.hpp" #include "ngraph/runtime/tensor.hpp" #include "runtime/backend.hpp" #include "util/all_close.hpp" #include "util/all_close_f.hpp" -#include "util/engine/test_engines.hpp" #include "util/ndarray.hpp" -#include "util/test_case.hpp" #include "util/test_control.hpp" -#include "util/test_tools.hpp" using namespace std; using namespace ngraph; diff --git a/ngraph/test/backend/deformable_convolution_opset8.in.cpp b/ngraph/test/backend/deformable_convolution_opset8.in.cpp index 0cad1177a90..723fe319500 100644 --- a/ngraph/test/backend/deformable_convolution_opset8.in.cpp +++ b/ngraph/test/backend/deformable_convolution_opset8.in.cpp @@ -2,17 +2,17 @@ // SPDX-License-Identifier: Apache-2.0 // +#include "engines_util/execute_tools.hpp" +#include "engines_util/test_case.hpp" +#include "engines_util/test_engines.hpp" #include "gtest/gtest.h" #include "ngraph/ngraph.hpp" #include "ngraph/runtime/tensor.hpp" #include "runtime/backend.hpp" #include "util/all_close.hpp" #include "util/all_close_f.hpp" -#include "util/engine/test_engines.hpp" #include "util/ndarray.hpp" -#include "util/test_case.hpp" #include "util/test_control.hpp" -#include "util/test_tools.hpp" using namespace std; using namespace ngraph; diff --git a/ngraph/test/backend/deformable_psroi_pooling.in.cpp b/ngraph/test/backend/deformable_psroi_pooling.in.cpp index 6731f7bb920..fa7abe5210c 100644 --- a/ngraph/test/backend/deformable_psroi_pooling.in.cpp +++ b/ngraph/test/backend/deformable_psroi_pooling.in.cpp @@ -2,10 +2,10 @@ // SPDX-License-Identifier: Apache-2.0 // +#include "engines_util/test_case.hpp" +#include "engines_util/test_engines.hpp" #include "gtest/gtest.h" #include "ngraph/op/deformable_psroi_pooling.hpp" -#include "util/engine/test_engines.hpp" -#include "util/test_case.hpp" #include "util/test_control.hpp" using namespace ngraph; diff --git a/ngraph/test/backend/depth_to_space.in.cpp b/ngraph/test/backend/depth_to_space.in.cpp index f301e361aea..85053d3b6e9 100644 --- a/ngraph/test/backend/depth_to_space.in.cpp +++ b/ngraph/test/backend/depth_to_space.in.cpp @@ -2,10 +2,10 @@ // SPDX-License-Identifier: Apache-2.0 // +#include "engines_util/test_case.hpp" +#include "engines_util/test_engines.hpp" #include "gtest/gtest.h" #include "ngraph/op/depth_to_space.hpp" -#include "util/engine/test_engines.hpp" -#include "util/test_case.hpp" #include "util/test_control.hpp" using namespace ngraph; diff --git a/ngraph/test/backend/detection_output.in.cpp b/ngraph/test/backend/detection_output.in.cpp index 6609f241d78..0ade8514a89 100644 --- a/ngraph/test/backend/detection_output.in.cpp +++ b/ngraph/test/backend/detection_output.in.cpp @@ -14,8 +14,8 @@ #include "gtest/gtest.h" #include "ngraph/ngraph.hpp" -#include "util/engine/test_engines.hpp" -#include "util/test_case.hpp" +#include "engines_util/test_engines.hpp" +#include "engines_util/test_case.hpp" #include "util/test_control.hpp" using namespace std; diff --git a/ngraph/test/backend/dft.in.cpp b/ngraph/test/backend/dft.in.cpp index d7e5e584143..839c6ed4b43 100644 --- a/ngraph/test/backend/dft.in.cpp +++ b/ngraph/test/backend/dft.in.cpp @@ -2,6 +2,9 @@ // SPDX-License-Identifier: Apache-2.0 // +#include "engines_util/execute_tools.hpp" +#include "engines_util/test_case.hpp" +#include "engines_util/test_engines.hpp" #include "gtest/gtest.h" #include "ngraph/ngraph.hpp" #include "ngraph/runtime/tensor.hpp" @@ -10,11 +13,8 @@ #include "runtime/backend.hpp" #include "util/all_close.hpp" #include "util/all_close_f.hpp" -#include "util/engine/test_engines.hpp" #include "util/ndarray.hpp" -#include "util/test_case.hpp" #include "util/test_control.hpp" -#include "util/test_tools.hpp" using namespace std; using namespace ngraph; diff --git a/ngraph/test/backend/divide.in.cpp b/ngraph/test/backend/divide.in.cpp index 4e3c617f3a8..3bf533e8203 100644 --- a/ngraph/test/backend/divide.in.cpp +++ b/ngraph/test/backend/divide.in.cpp @@ -28,7 +28,7 @@ #include "util/all_close_f.hpp" #include "util/ndarray.hpp" #include "util/test_control.hpp" -#include "util/test_tools.hpp" +#include "engines_util/execute_tools.hpp" using namespace std; using namespace ngraph; diff --git a/ngraph/test/backend/dyn_reshape.in.cpp b/ngraph/test/backend/dyn_reshape.in.cpp index 284b171be07..a6038eafe12 100644 --- a/ngraph/test/backend/dyn_reshape.in.cpp +++ b/ngraph/test/backend/dyn_reshape.in.cpp @@ -2,13 +2,13 @@ // SPDX-License-Identifier: Apache-2.0 // +#include "engines_util/execute_tools.hpp" #include "gtest/gtest.h" #include "ngraph/ngraph.hpp" #include "ngraph/runtime/tensor.hpp" #include "runtime/backend.hpp" #include "util/all_close_f.hpp" #include "util/test_control.hpp" -#include "util/test_tools.hpp" using namespace std; using namespace ngraph; diff --git a/ngraph/test/backend/dynamic.in.cpp b/ngraph/test/backend/dynamic.in.cpp index eff29f065db..674cbf12425 100644 --- a/ngraph/test/backend/dynamic.in.cpp +++ b/ngraph/test/backend/dynamic.in.cpp @@ -2,13 +2,13 @@ // SPDX-License-Identifier: Apache-2.0 // +#include "engines_util/execute_tools.hpp" #include "gtest/gtest.h" #include "ngraph/ngraph.hpp" #include "ngraph/runtime/tensor.hpp" #include "runtime/backend.hpp" #include "util/all_close_f.hpp" #include "util/test_control.hpp" -#include "util/test_tools.hpp" using namespace std; using namespace ngraph; diff --git a/ngraph/test/backend/elu.in.cpp b/ngraph/test/backend/elu.in.cpp index 17962fef1ac..3d4c4eb1fd1 100644 --- a/ngraph/test/backend/elu.in.cpp +++ b/ngraph/test/backend/elu.in.cpp @@ -21,8 +21,8 @@ #include "gtest/gtest.h" #include "ngraph/ngraph.hpp" -#include "util/engine/test_engines.hpp" -#include "util/test_case.hpp" +#include "engines_util/test_engines.hpp" +#include "engines_util/test_case.hpp" #include "util/test_control.hpp" using namespace std; @@ -51,4 +51,4 @@ NGRAPH_TEST(${BACKEND_NAME}, elu_negative_alpha) { test_case.add_input(vector{-2.f, 3.f, -2.f, 1.f, -1.f, 0.f}); test_case.add_expected_output(vector{0.864664717f, 3.f, 0.864664717f, 1.f, 0.632120559f, 0.f}); test_case.run(); -} \ No newline at end of file +} diff --git a/ngraph/test/backend/exp.in.cpp b/ngraph/test/backend/exp.in.cpp index 781eaa8d970..1f516a7b0a3 100644 --- a/ngraph/test/backend/exp.in.cpp +++ b/ngraph/test/backend/exp.in.cpp @@ -21,8 +21,8 @@ #include "gtest/gtest.h" #include "ngraph/ngraph.hpp" -#include "util/engine/test_engines.hpp" -#include "util/test_case.hpp" +#include "engines_util/test_engines.hpp" +#include "engines_util/test_case.hpp" #include "util/test_control.hpp" using namespace std; @@ -82,4 +82,4 @@ NGRAPH_TEST(${BACKEND_NAME}, exp_in_place) { test_case.add_input({a}); test_case.add_expected_output(shape, {expf(expf(1)), expf(expf(3))}); test_case.run(DEFAULT_FLOAT_TOLERANCE_BITS + 2); -} \ No newline at end of file +} diff --git a/ngraph/test/backend/experimental_detectron_detection_output.in.cpp b/ngraph/test/backend/experimental_detectron_detection_output.in.cpp index c23cef81821..698a564dfcf 100644 --- a/ngraph/test/backend/experimental_detectron_detection_output.in.cpp +++ b/ngraph/test/backend/experimental_detectron_detection_output.in.cpp @@ -31,9 +31,9 @@ #include "util/all_close.hpp" #include "util/all_close_f.hpp" #include "util/ndarray.hpp" -#include "util/random.hpp" +#include "engines_util/random.hpp" #include "util/test_control.hpp" -#include "util/test_tools.hpp" +#include "engines_util/execute_tools.hpp" using namespace std; using namespace ngraph; diff --git a/ngraph/test/backend/experimental_detectron_generate_proposals.in.cpp b/ngraph/test/backend/experimental_detectron_generate_proposals.in.cpp index 75d14b6ca77..cab6d3e8e92 100644 --- a/ngraph/test/backend/experimental_detectron_generate_proposals.in.cpp +++ b/ngraph/test/backend/experimental_detectron_generate_proposals.in.cpp @@ -19,9 +19,9 @@ #include "util/all_close.hpp" #include "util/all_close_f.hpp" #include "util/ndarray.hpp" -#include "util/random.hpp" +#include "engines_util/random.hpp" #include "util/test_control.hpp" -#include "util/test_tools.hpp" +#include "engines_util/execute_tools.hpp" using namespace std; using namespace ngraph; diff --git a/ngraph/test/backend/experimental_detectron_prior_grid.in.cpp b/ngraph/test/backend/experimental_detectron_prior_grid.in.cpp index 16638e66540..6d2cc2d7273 100644 --- a/ngraph/test/backend/experimental_detectron_prior_grid.in.cpp +++ b/ngraph/test/backend/experimental_detectron_prior_grid.in.cpp @@ -33,9 +33,9 @@ #include "util/all_close.hpp" #include "util/all_close_f.hpp" #include "util/ndarray.hpp" -#include "util/random.hpp" +#include "engines_util/random.hpp" #include "util/test_control.hpp" -#include "util/test_tools.hpp" +#include "engines_util/execute_tools.hpp" using namespace std; using namespace ngraph; diff --git a/ngraph/test/backend/experimental_detectron_topk_rois.in.cpp b/ngraph/test/backend/experimental_detectron_topk_rois.in.cpp index 6f4f73b07e7..57b6aef012d 100644 --- a/ngraph/test/backend/experimental_detectron_topk_rois.in.cpp +++ b/ngraph/test/backend/experimental_detectron_topk_rois.in.cpp @@ -2,17 +2,17 @@ // SPDX-License-Identifier: Apache-2.0 // +#include "engines_util/execute_tools.hpp" +#include "engines_util/test_case.hpp" +#include "engines_util/test_engines.hpp" #include "gtest/gtest.h" #include "ngraph/ngraph.hpp" #include "ngraph/runtime/tensor.hpp" #include "runtime/backend.hpp" #include "util/all_close.hpp" #include "util/all_close_f.hpp" -#include "util/engine/test_engines.hpp" #include "util/ndarray.hpp" -#include "util/test_case.hpp" #include "util/test_control.hpp" -#include "util/test_tools.hpp" using namespace std; using namespace ngraph; diff --git a/ngraph/test/backend/fake_quantize.in.cpp b/ngraph/test/backend/fake_quantize.in.cpp index d8c7c11a393..9c3d6eca3ae 100644 --- a/ngraph/test/backend/fake_quantize.in.cpp +++ b/ngraph/test/backend/fake_quantize.in.cpp @@ -22,8 +22,8 @@ #include "gtest/gtest.h" #include "ngraph/ngraph.hpp" -#include "util/engine/test_engines.hpp" -#include "util/test_case.hpp" +#include "engines_util/test_engines.hpp" +#include "engines_util/test_case.hpp" #include "util/test_control.hpp" using namespace ngraph; diff --git a/ngraph/test/backend/floor.in.cpp b/ngraph/test/backend/floor.in.cpp index 508b26d9b90..274a0a93946 100644 --- a/ngraph/test/backend/floor.in.cpp +++ b/ngraph/test/backend/floor.in.cpp @@ -21,8 +21,8 @@ #include "gtest/gtest.h" #include "ngraph/ngraph.hpp" -#include "util/engine/test_engines.hpp" -#include "util/test_case.hpp" +#include "engines_util/test_engines.hpp" +#include "engines_util/test_case.hpp" #include "util/test_control.hpp" using namespace std; diff --git a/ngraph/test/backend/floor_mod.in.cpp b/ngraph/test/backend/floor_mod.in.cpp index 5d35ab40892..4d61cc8fb38 100644 --- a/ngraph/test/backend/floor_mod.in.cpp +++ b/ngraph/test/backend/floor_mod.in.cpp @@ -21,8 +21,8 @@ #include "gtest/gtest.h" #include "ngraph/ngraph.hpp" -#include "util/engine/test_engines.hpp" -#include "util/test_case.hpp" +#include "engines_util/test_engines.hpp" +#include "engines_util/test_case.hpp" #include "util/test_control.hpp" using namespace std; diff --git a/ngraph/test/backend/function_name.in.cpp b/ngraph/test/backend/function_name.in.cpp index d0ae326ec1b..66eafa6f724 100644 --- a/ngraph/test/backend/function_name.in.cpp +++ b/ngraph/test/backend/function_name.in.cpp @@ -2,6 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 // +#include "engines_util/execute_tools.hpp" #include "gtest/gtest.h" #include "ngraph/ngraph.hpp" #include "ngraph/runtime/tensor.hpp" @@ -9,7 +10,6 @@ #include "util/all_close_f.hpp" #include "util/ndarray.hpp" #include "util/test_control.hpp" -#include "util/test_tools.hpp" using namespace std; using namespace ngraph; diff --git a/ngraph/test/backend/gather.in.cpp b/ngraph/test/backend/gather.in.cpp index 20a2bde3ac9..51f11d18221 100644 --- a/ngraph/test/backend/gather.in.cpp +++ b/ngraph/test/backend/gather.in.cpp @@ -9,10 +9,10 @@ #include #include +#include "engines_util/test_case.hpp" +#include "engines_util/test_engines.hpp" #include "gtest/gtest.h" #include "ngraph/ngraph.hpp" -#include "util/engine/test_engines.hpp" -#include "util/test_case.hpp" #include "util/test_control.hpp" NGRAPH_SUPPRESS_DEPRECATED_START diff --git a/ngraph/test/backend/gather_elements.in.cpp b/ngraph/test/backend/gather_elements.in.cpp index 727776d8919..8af59e4257b 100644 --- a/ngraph/test/backend/gather_elements.in.cpp +++ b/ngraph/test/backend/gather_elements.in.cpp @@ -2,10 +2,10 @@ // SPDX-License-Identifier: Apache-2.0 // +#include "engines_util/test_case.hpp" +#include "engines_util/test_engines.hpp" #include "gtest/gtest.h" #include "ngraph/ngraph.hpp" -#include "util/engine/test_engines.hpp" -#include "util/test_case.hpp" #include "util/test_control.hpp" NGRAPH_SUPPRESS_DEPRECATED_START diff --git a/ngraph/test/backend/gather_nd.in.cpp b/ngraph/test/backend/gather_nd.in.cpp index 5481a773dbd..d61d9516bf6 100644 --- a/ngraph/test/backend/gather_nd.in.cpp +++ b/ngraph/test/backend/gather_nd.in.cpp @@ -9,6 +9,9 @@ #include #include +#include "engines_util/execute_tools.hpp" +#include "engines_util/random.hpp" +#include "engines_util/test_case.hpp" #include "gtest/gtest.h" #include "ngraph/ngraph.hpp" #include "ngraph/runtime/tensor.hpp" @@ -16,10 +19,7 @@ #include "util/all_close.hpp" #include "util/all_close_f.hpp" #include "util/ndarray.hpp" -#include "util/random.hpp" -#include "util/test_case.hpp" #include "util/test_control.hpp" -#include "util/test_tools.hpp" NGRAPH_SUPPRESS_DEPRECATED_START diff --git a/ngraph/test/backend/gelu.in.cpp b/ngraph/test/backend/gelu.in.cpp index 22bc66730e6..a2981dbd94e 100644 --- a/ngraph/test/backend/gelu.in.cpp +++ b/ngraph/test/backend/gelu.in.cpp @@ -2,10 +2,10 @@ // SPDX-License-Identifier: Apache-2.0 // +#include "engines_util/test_case.hpp" +#include "engines_util/test_engines.hpp" #include "gtest/gtest.h" #include "ngraph/ngraph.hpp" -#include "util/engine/test_engines.hpp" -#include "util/test_case.hpp" #include "util/test_control.hpp" using namespace std; diff --git a/ngraph/test/backend/group_convolution.in.cpp b/ngraph/test/backend/group_convolution.in.cpp index 04745bc2f05..d053f534b44 100644 --- a/ngraph/test/backend/group_convolution.in.cpp +++ b/ngraph/test/backend/group_convolution.in.cpp @@ -2,17 +2,17 @@ // SPDX-License-Identifier: Apache-2.0 // +#include "engines_util/execute_tools.hpp" +#include "engines_util/test_case.hpp" +#include "engines_util/test_engines.hpp" #include "gtest/gtest.h" #include "ngraph/ngraph.hpp" #include "ngraph/runtime/tensor.hpp" #include "runtime/backend.hpp" #include "util/all_close.hpp" #include "util/all_close_f.hpp" -#include "util/engine/test_engines.hpp" #include "util/ndarray.hpp" -#include "util/test_case.hpp" #include "util/test_control.hpp" -#include "util/test_tools.hpp" using namespace std; using namespace ngraph; diff --git a/ngraph/test/backend/group_convolution_backprop_data.in.cpp b/ngraph/test/backend/group_convolution_backprop_data.in.cpp index dba5a4da0ec..73be838c6e6 100644 --- a/ngraph/test/backend/group_convolution_backprop_data.in.cpp +++ b/ngraph/test/backend/group_convolution_backprop_data.in.cpp @@ -2,10 +2,10 @@ // SPDX-License-Identifier: Apache-2.0 // +#include "engines_util/test_case.hpp" +#include "engines_util/test_engines.hpp" #include "gtest/gtest.h" #include "ngraph/ngraph.hpp" -#include "util/engine/test_engines.hpp" -#include "util/test_case.hpp" #include "util/test_control.hpp" using namespace std; @@ -248,4 +248,4 @@ NGRAPH_TEST(${BACKEND_NAME}, group_convolution_backprop_data_2D_output_shape) { Shape{1, 1, 1, 14}, vector{0.0f, 1.0f, 4.0f, 10.0f, 18.0f, 27.0f, 36.0f, 45.0f, 54.0f, 63.0f, 62.0f, 50.0f, 26.0f, 9.0f}); test_case.run(); -} \ No newline at end of file +} diff --git a/ngraph/test/backend/hard_sigmoid.in.cpp b/ngraph/test/backend/hard_sigmoid.in.cpp index f30855a3aac..495e16006c5 100644 --- a/ngraph/test/backend/hard_sigmoid.in.cpp +++ b/ngraph/test/backend/hard_sigmoid.in.cpp @@ -4,10 +4,10 @@ #include +#include "engines_util/test_case.hpp" +#include "engines_util/test_engines.hpp" #include "gtest/gtest.h" #include "ngraph/ngraph.hpp" -#include "util/engine/test_engines.hpp" -#include "util/test_case.hpp" #include "util/test_control.hpp" NGRAPH_SUPPRESS_DEPRECATED_START diff --git a/ngraph/test/backend/idft.in.cpp b/ngraph/test/backend/idft.in.cpp index a2f3c2a7df8..c39aa92db86 100644 --- a/ngraph/test/backend/idft.in.cpp +++ b/ngraph/test/backend/idft.in.cpp @@ -2,6 +2,9 @@ // SPDX-License-Identifier: Apache-2.0 // +#include "engines_util/execute_tools.hpp" +#include "engines_util/test_case.hpp" +#include "engines_util/test_engines.hpp" #include "gtest/gtest.h" #include "ngraph/ngraph.hpp" #include "ngraph/runtime/tensor.hpp" @@ -10,11 +13,8 @@ #include "runtime/backend.hpp" #include "util/all_close.hpp" #include "util/all_close_f.hpp" -#include "util/engine/test_engines.hpp" #include "util/ndarray.hpp" -#include "util/test_case.hpp" #include "util/test_control.hpp" -#include "util/test_tools.hpp" using namespace std; using namespace ngraph; diff --git a/ngraph/test/backend/interpolate.in.cpp b/ngraph/test/backend/interpolate.in.cpp index cd21415bd10..27e641a0876 100644 --- a/ngraph/test/backend/interpolate.in.cpp +++ b/ngraph/test/backend/interpolate.in.cpp @@ -2,17 +2,17 @@ // SPDX-License-Identifier: Apache-2.0 // +#include "engines_util/execute_tools.hpp" +#include "engines_util/test_case.hpp" +#include "engines_util/test_engines.hpp" #include "gtest/gtest.h" #include "ngraph/ngraph.hpp" #include "ngraph/runtime/tensor.hpp" #include "runtime/backend.hpp" #include "util/all_close.hpp" #include "util/all_close_f.hpp" -#include "util/engine/test_engines.hpp" #include "util/ndarray.hpp" -#include "util/test_case.hpp" #include "util/test_control.hpp" -#include "util/test_tools.hpp" using namespace std; using namespace ngraph; diff --git a/ngraph/test/backend/layer_norm.in.cpp b/ngraph/test/backend/layer_norm.in.cpp index 5f183a22d96..1d116835f60 100644 --- a/ngraph/test/backend/layer_norm.in.cpp +++ b/ngraph/test/backend/layer_norm.in.cpp @@ -27,15 +27,14 @@ #include "util/all_close_f.hpp" #include "util/ndarray.hpp" #include "util/test_control.hpp" -#include "util/test_tools.hpp" +#include "engines_util/execute_tools.hpp" using namespace std; using namespace ngraph; static string s_manifest = "${MANIFEST}"; -NGRAPH_TEST(${BACKEND_NAME}, layer_norm_affine_stats) -{ +NGRAPH_TEST(${BACKEND_NAME}, layer_norm_affine_stats) { auto p_data = make_shared(element::f32, Shape{2, 4}); auto p_scale = make_shared(element::f32, Shape{4}); auto p_bias = make_shared(element::f32, Shape{4}); diff --git a/ngraph/test/backend/log.in.cpp b/ngraph/test/backend/log.in.cpp index f9a6331d436..c6250f73c09 100644 --- a/ngraph/test/backend/log.in.cpp +++ b/ngraph/test/backend/log.in.cpp @@ -21,8 +21,8 @@ #include "gtest/gtest.h" #include "ngraph/ngraph.hpp" -#include "util/engine/test_engines.hpp" -#include "util/test_case.hpp" +#include "engines_util/test_engines.hpp" +#include "engines_util/test_case.hpp" #include "util/test_control.hpp" using namespace std; diff --git a/ngraph/test/backend/log_softmax.in.cpp b/ngraph/test/backend/log_softmax.in.cpp index 1f2e462e346..fec292a24bd 100644 --- a/ngraph/test/backend/log_softmax.in.cpp +++ b/ngraph/test/backend/log_softmax.in.cpp @@ -20,7 +20,7 @@ #include "util/all_close_f.hpp" #include "util/ndarray.hpp" #include "util/test_control.hpp" -#include "util/test_tools.hpp" +#include "engines_util/execute_tools.hpp" NGRAPH_SUPPRESS_DEPRECATED_START diff --git a/ngraph/test/backend/lrn.in.cpp b/ngraph/test/backend/lrn.in.cpp index e75196ecf34..f069065ce39 100644 --- a/ngraph/test/backend/lrn.in.cpp +++ b/ngraph/test/backend/lrn.in.cpp @@ -16,8 +16,8 @@ #include "gtest/gtest.h" #include "ngraph/ngraph.hpp" -#include "util/engine/test_engines.hpp" -#include "util/test_case.hpp" +#include "engines_util/test_engines.hpp" +#include "engines_util/test_case.hpp" #include "util/test_control.hpp" using namespace std; diff --git a/ngraph/test/backend/matmul.in.cpp b/ngraph/test/backend/matmul.in.cpp index 0a9ef9b2f1c..cd0bc81a10d 100644 --- a/ngraph/test/backend/matmul.in.cpp +++ b/ngraph/test/backend/matmul.in.cpp @@ -10,17 +10,17 @@ #include #include +#include "engines_util/execute_tools.hpp" +#include "engines_util/test_case.hpp" +#include "engines_util/test_engines.hpp" #include "gtest/gtest.h" #include "ngraph/ngraph.hpp" #include "ngraph/runtime/tensor.hpp" #include "runtime/backend.hpp" #include "util/all_close.hpp" #include "util/all_close_f.hpp" -#include "util/engine/test_engines.hpp" #include "util/ndarray.hpp" -#include "util/test_case.hpp" #include "util/test_control.hpp" -#include "util/test_tools.hpp" using namespace std; using namespace ngraph; diff --git a/ngraph/test/backend/matrix_nms.in.cpp b/ngraph/test/backend/matrix_nms.in.cpp index ac72b1ad05c..09c1d59f46a 100644 --- a/ngraph/test/backend/matrix_nms.in.cpp +++ b/ngraph/test/backend/matrix_nms.in.cpp @@ -14,8 +14,8 @@ #include "gtest/gtest.h" #include "ngraph/ngraph.hpp" -#include "util/engine/test_engines.hpp" -#include "util/test_case.hpp" +#include "engines_util/test_engines.hpp" +#include "engines_util/test_case.hpp" #include "util/test_control.hpp" using namespace std; diff --git a/ngraph/test/backend/max_pool.in.cpp b/ngraph/test/backend/max_pool.in.cpp index 1ee201a922f..76639917d6c 100644 --- a/ngraph/test/backend/max_pool.in.cpp +++ b/ngraph/test/backend/max_pool.in.cpp @@ -14,8 +14,8 @@ #include "gtest/gtest.h" #include "ngraph/ngraph.hpp" -#include "util/engine/test_engines.hpp" -#include "util/test_case.hpp" +#include "engines_util/test_engines.hpp" +#include "engines_util/test_case.hpp" #include "util/test_control.hpp" using namespace std; diff --git a/ngraph/test/backend/maximum.in.cpp b/ngraph/test/backend/maximum.in.cpp index ee34628ff04..b7e6e664552 100644 --- a/ngraph/test/backend/maximum.in.cpp +++ b/ngraph/test/backend/maximum.in.cpp @@ -21,8 +21,8 @@ #include "gtest/gtest.h" #include "ngraph/ngraph.hpp" -#include "util/engine/test_engines.hpp" -#include "util/test_case.hpp" +#include "engines_util/test_engines.hpp" +#include "engines_util/test_case.hpp" #include "util/test_control.hpp" using namespace std; diff --git a/ngraph/test/backend/mish.in.cpp b/ngraph/test/backend/mish.in.cpp index 8c289e368c4..d4e989d59bc 100644 --- a/ngraph/test/backend/mish.in.cpp +++ b/ngraph/test/backend/mish.in.cpp @@ -9,6 +9,7 @@ #include #include +#include "engines_util/execute_tools.hpp" #include "gtest/gtest.h" #include "ngraph/ngraph.hpp" #include "ngraph/runtime/tensor.hpp" @@ -17,7 +18,6 @@ #include "util/all_close_f.hpp" #include "util/ndarray.hpp" #include "util/test_control.hpp" -#include "util/test_tools.hpp" using namespace std; using namespace ngraph; @@ -86,4 +86,4 @@ NGRAPH_TEST(${BACKEND_NAME}, mish_f16) { NGRAPH_TEST(${BACKEND_NAME}, mish_dynamic) { mish_test(PartialShape::dynamic(), {2, 3, 4, 5}); mish_test({2, Dimension::dynamic(), 4, 5}, {2, 3, 4, 5}); -} \ No newline at end of file +} diff --git a/ngraph/test/backend/mod.in.cpp b/ngraph/test/backend/mod.in.cpp index 9fc84020d57..860ffd817b2 100644 --- a/ngraph/test/backend/mod.in.cpp +++ b/ngraph/test/backend/mod.in.cpp @@ -21,8 +21,8 @@ #include "gtest/gtest.h" #include "ngraph/ngraph.hpp" -#include "util/engine/test_engines.hpp" -#include "util/test_case.hpp" +#include "engines_util/test_engines.hpp" +#include "engines_util/test_case.hpp" #include "util/test_control.hpp" using namespace std; @@ -139,4 +139,4 @@ NGRAPH_TEST(${BACKEND_NAME}, mod_in_place) { test_case.add_multiple_inputs({a, b}); test_case.add_expected_output(shape, {0, 0, 0, 0}); test_case.run(); -} \ No newline at end of file +} diff --git a/ngraph/test/backend/multiclass_nms.in.cpp b/ngraph/test/backend/multiclass_nms.in.cpp index 4f713badca2..6143f9d1c54 100644 --- a/ngraph/test/backend/multiclass_nms.in.cpp +++ b/ngraph/test/backend/multiclass_nms.in.cpp @@ -14,8 +14,8 @@ #include "gtest/gtest.h" #include "ngraph/ngraph.hpp" -#include "util/engine/test_engines.hpp" -#include "util/test_case.hpp" +#include "engines_util/test_engines.hpp" +#include "engines_util/test_case.hpp" #include "util/test_control.hpp" using namespace std; diff --git a/ngraph/test/backend/multiple_backends.in.cpp b/ngraph/test/backend/multiple_backends.in.cpp index 68a919ca0c6..5c8c26407ac 100644 --- a/ngraph/test/backend/multiple_backends.in.cpp +++ b/ngraph/test/backend/multiple_backends.in.cpp @@ -2,6 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 // +#include "engines_util/execute_tools.hpp" #include "gtest/gtest.h" #include "ngraph/ngraph.hpp" #include "ngraph/runtime/tensor.hpp" @@ -10,7 +11,6 @@ #include "util/all_close_f.hpp" #include "util/ndarray.hpp" #include "util/test_control.hpp" -#include "util/test_tools.hpp" using namespace std; using namespace ngraph; diff --git a/ngraph/test/backend/multiple_result.in.cpp b/ngraph/test/backend/multiple_result.in.cpp index c0debf53e99..3f8c1aa9afc 100644 --- a/ngraph/test/backend/multiple_result.in.cpp +++ b/ngraph/test/backend/multiple_result.in.cpp @@ -2,6 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 // +#include "engines_util/execute_tools.hpp" #include "gtest/gtest.h" #include "ngraph/ngraph.hpp" #include "ngraph/runtime/tensor.hpp" @@ -9,7 +10,6 @@ #include "util/all_close_f.hpp" #include "util/ndarray.hpp" #include "util/test_control.hpp" -#include "util/test_tools.hpp" NGRAPH_SUPPRESS_DEPRECATED_START diff --git a/ngraph/test/backend/multiply.in.cpp b/ngraph/test/backend/multiply.in.cpp index 90d9843e3f9..f8ce5adc788 100644 --- a/ngraph/test/backend/multiply.in.cpp +++ b/ngraph/test/backend/multiply.in.cpp @@ -21,8 +21,8 @@ #include "gtest/gtest.h" #include "ngraph/ngraph.hpp" -#include "util/engine/test_engines.hpp" -#include "util/test_case.hpp" +#include "engines_util/test_engines.hpp" +#include "engines_util/test_case.hpp" #include "util/test_control.hpp" NGRAPH_SUPPRESS_DEPRECATED_START diff --git a/ngraph/test/backend/negative.in.cpp b/ngraph/test/backend/negative.in.cpp index d60c4215211..020146d00f7 100644 --- a/ngraph/test/backend/negative.in.cpp +++ b/ngraph/test/backend/negative.in.cpp @@ -14,8 +14,8 @@ #include "gtest/gtest.h" #include "ngraph/ngraph.hpp" -#include "util/engine/test_engines.hpp" -#include "util/test_case.hpp" +#include "engines_util/test_engines.hpp" +#include "engines_util/test_case.hpp" #include "util/test_control.hpp" using namespace std; diff --git a/ngraph/test/backend/node_name.in.cpp b/ngraph/test/backend/node_name.in.cpp index 45ef8b97e4d..6a7859eb973 100644 --- a/ngraph/test/backend/node_name.in.cpp +++ b/ngraph/test/backend/node_name.in.cpp @@ -2,6 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 // +#include "engines_util/execute_tools.hpp" #include "gtest/gtest.h" #include "ngraph/ngraph.hpp" #include "ngraph/runtime/tensor.hpp" @@ -9,7 +10,6 @@ #include "util/all_close_f.hpp" #include "util/ndarray.hpp" #include "util/test_control.hpp" -#include "util/test_tools.hpp" using namespace std; using namespace ngraph; diff --git a/ngraph/test/backend/non_max_suppression.in.cpp b/ngraph/test/backend/non_max_suppression.in.cpp index d0950eeb4ec..652e2bfafa2 100644 --- a/ngraph/test/backend/non_max_suppression.in.cpp +++ b/ngraph/test/backend/non_max_suppression.in.cpp @@ -20,7 +20,7 @@ #include "util/all_close_f.hpp" #include "util/ndarray.hpp" #include "util/test_control.hpp" -#include "util/test_tools.hpp" +#include "engines_util/execute_tools.hpp" NGRAPH_SUPPRESS_DEPRECATED_START diff --git a/ngraph/test/backend/non_zero.in.cpp b/ngraph/test/backend/non_zero.in.cpp index eadcaaa0c94..5b65d6017af 100644 --- a/ngraph/test/backend/non_zero.in.cpp +++ b/ngraph/test/backend/non_zero.in.cpp @@ -2,12 +2,12 @@ // SPDX-License-Identifier: Apache-2.0 // +#include "engines_util/execute_tools.hpp" #include "gtest/gtest.h" #include "ngraph/ngraph.hpp" #include "util/all_close_f.hpp" #include "util/ndarray.hpp" #include "util/test_control.hpp" -#include "util/test_tools.hpp" using namespace std; using namespace ngraph; diff --git a/ngraph/test/backend/normalize_l2.in.cpp b/ngraph/test/backend/normalize_l2.in.cpp index d532163d240..db90c6ab49f 100644 --- a/ngraph/test/backend/normalize_l2.in.cpp +++ b/ngraph/test/backend/normalize_l2.in.cpp @@ -10,16 +10,16 @@ #include #include +#include "engines_util/execute_tools.hpp" +#include "engines_util/random.hpp" +#include "engines_util/test_case.hpp" +#include "engines_util/test_engines.hpp" #include "gtest/gtest.h" #include "ngraph/ngraph.hpp" #include "util/all_close.hpp" #include "util/all_close_f.hpp" -#include "util/engine/test_engines.hpp" #include "util/ndarray.hpp" -#include "util/random.hpp" -#include "util/test_case.hpp" #include "util/test_control.hpp" -#include "util/test_tools.hpp" using namespace std; using namespace ngraph; diff --git a/ngraph/test/backend/one_hot.in.cpp b/ngraph/test/backend/one_hot.in.cpp index f9b884f3a50..fd37ea852e3 100644 --- a/ngraph/test/backend/one_hot.in.cpp +++ b/ngraph/test/backend/one_hot.in.cpp @@ -9,10 +9,10 @@ #include #include +#include "engines_util/test_case.hpp" +#include "engines_util/test_engines.hpp" #include "gtest/gtest.h" #include "ngraph/ngraph.hpp" -#include "util/engine/test_engines.hpp" -#include "util/test_case.hpp" #include "util/test_control.hpp" using namespace std; diff --git a/ngraph/test/backend/pad.in.cpp b/ngraph/test/backend/pad.in.cpp index 86fcb038b64..c506e843ab8 100644 --- a/ngraph/test/backend/pad.in.cpp +++ b/ngraph/test/backend/pad.in.cpp @@ -2,6 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 // +#include "engines_util/execute_tools.hpp" #include "gtest/gtest.h" #include "ngraph/ngraph.hpp" #include "ngraph/runtime/tensor.hpp" @@ -10,7 +11,6 @@ #include "util/all_close_f.hpp" #include "util/ndarray.hpp" #include "util/test_control.hpp" -#include "util/test_tools.hpp" using namespace std; using namespace ngraph; diff --git a/ngraph/test/backend/parameter_as_output.in.cpp b/ngraph/test/backend/parameter_as_output.in.cpp index 9043f828e99..365515b8e8e 100644 --- a/ngraph/test/backend/parameter_as_output.in.cpp +++ b/ngraph/test/backend/parameter_as_output.in.cpp @@ -2,6 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 // +#include "engines_util/execute_tools.hpp" #include "gtest/gtest.h" #include "ngraph/ngraph.hpp" #include "ngraph/runtime/tensor.hpp" @@ -9,7 +10,6 @@ #include "util/all_close_f.hpp" #include "util/ndarray.hpp" #include "util/test_control.hpp" -#include "util/test_tools.hpp" using namespace std; using namespace ngraph; diff --git a/ngraph/test/backend/partial_slice.in.cpp b/ngraph/test/backend/partial_slice.in.cpp index f3a759d190a..6ad9443565b 100644 --- a/ngraph/test/backend/partial_slice.in.cpp +++ b/ngraph/test/backend/partial_slice.in.cpp @@ -27,24 +27,22 @@ #include "util/all_close_f.hpp" #include "util/ndarray.hpp" #include "util/test_control.hpp" -#include "util/test_tools.hpp" +#include "engines_util/execute_tools.hpp" using namespace std; using namespace ngraph; static string s_manifest = "${MANIFEST}"; -NGRAPH_TEST(${BACKEND_NAME}, partial_slice_static) -{ +NGRAPH_TEST(${BACKEND_NAME}, partial_slice_static) { Shape shape_x{2, 3, 2}; auto x = make_shared(element::f32, shape_x); AxisVector axes{0, 1}; vector lower_bounds{1, 0}; vector upper_bounds{2, 2}; AxisVector decrease_axes{}; - auto f = make_shared( - make_shared(x, axes, lower_bounds, upper_bounds, decrease_axes), - ParameterVector{x}); + auto f = make_shared(make_shared(x, axes, lower_bounds, upper_bounds, decrease_axes), + ParameterVector{x}); auto backend = runtime::Backend::create("${BACKEND_NAME}"); @@ -61,17 +59,15 @@ NGRAPH_TEST(${BACKEND_NAME}, partial_slice_static) EXPECT_TRUE(test::all_close_f(v_r, read_vector(t_r))); } -NGRAPH_TEST(${BACKEND_NAME}, partial_slice_partial_shape) -{ +NGRAPH_TEST(${BACKEND_NAME}, partial_slice_partial_shape) { auto pshape_x = PartialShape{Dimension::dynamic(), 3, Dimension::dynamic()}; auto x = make_shared(element::f32, pshape_x); AxisVector axes{0, 1}; vector lower_bounds{1, 0}; vector upper_bounds{2, 2}; AxisVector decrease_axes{}; - auto f = make_shared( - make_shared(x, axes, lower_bounds, upper_bounds, decrease_axes), - ParameterVector{x}); + auto f = make_shared(make_shared(x, axes, lower_bounds, upper_bounds, decrease_axes), + ParameterVector{x}); auto backend = runtime::Backend::create("${BACKEND_NAME}", true); @@ -89,17 +85,15 @@ NGRAPH_TEST(${BACKEND_NAME}, partial_slice_partial_shape) EXPECT_TRUE(test::all_close_f(v_r, read_vector(t_r))); } -NGRAPH_TEST(${BACKEND_NAME}, partial_slice_unkown_rank) -{ +NGRAPH_TEST(${BACKEND_NAME}, partial_slice_unkown_rank) { auto pshape_x = PartialShape::dynamic(); auto x = make_shared(element::f32, pshape_x); AxisVector axes{0, 1}; vector lower_bounds{1, 0}; vector upper_bounds{2, 2}; AxisVector decrease_axes{}; - auto f = make_shared( - make_shared(x, axes, lower_bounds, upper_bounds, decrease_axes), - ParameterVector{x}); + auto f = make_shared(make_shared(x, axes, lower_bounds, upper_bounds, decrease_axes), + ParameterVector{x}); auto backend = runtime::Backend::create("${BACKEND_NAME}", true); diff --git a/ngraph/test/backend/power.in.cpp b/ngraph/test/backend/power.in.cpp index beb7ab84e5e..23fc582a301 100644 --- a/ngraph/test/backend/power.in.cpp +++ b/ngraph/test/backend/power.in.cpp @@ -21,8 +21,8 @@ #include "gtest/gtest.h" #include "ngraph/ngraph.hpp" -#include "util/engine/test_engines.hpp" -#include "util/test_case.hpp" +#include "engines_util/test_engines.hpp" +#include "engines_util/test_case.hpp" #include "util/test_control.hpp" NGRAPH_SUPPRESS_DEPRECATED_START @@ -96,4 +96,4 @@ NGRAPH_TEST(${BACKEND_NAME}, power_vector_and_scalar) { test_case.add_multiple_inputs({a, b}); test_case.add_expected_output(shape_a, {4, 9, 16, 25}); test_case.run(); -} \ No newline at end of file +} diff --git a/ngraph/test/backend/prelu.in.cpp b/ngraph/test/backend/prelu.in.cpp index 650e6326abd..0e0e937dbe1 100644 --- a/ngraph/test/backend/prelu.in.cpp +++ b/ngraph/test/backend/prelu.in.cpp @@ -1,10 +1,10 @@ // Co pyright (C) 2018-2021 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // +#include "engines_util/test_case.hpp" +#include "engines_util/test_engines.hpp" #include "gtest/gtest.h" #include "ngraph/ngraph.hpp" -#include "util/engine/test_engines.hpp" -#include "util/test_case.hpp" #include "util/test_control.hpp" using namespace std; diff --git a/ngraph/test/backend/prior_box.in.cpp b/ngraph/test/backend/prior_box.in.cpp index 65c2576b0b3..c95eec8c829 100644 --- a/ngraph/test/backend/prior_box.in.cpp +++ b/ngraph/test/backend/prior_box.in.cpp @@ -1,11 +1,11 @@ // Copyright (C) 2018-2021 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // +#include "engines_util/test_case.hpp" +#include "engines_util/test_engines.hpp" #include "gtest/gtest.h" #include "ngraph/ngraph.hpp" #include "ngraph/op/prior_box.hpp" -#include "util/engine/test_engines.hpp" -#include "util/test_case.hpp" #include "util/test_control.hpp" using namespace std; diff --git a/ngraph/test/backend/prior_box_clustered.in.cpp b/ngraph/test/backend/prior_box_clustered.in.cpp index 18e71b06d7c..478723aa9f2 100644 --- a/ngraph/test/backend/prior_box_clustered.in.cpp +++ b/ngraph/test/backend/prior_box_clustered.in.cpp @@ -2,11 +2,11 @@ // SPDX-License-Identifier: Apache-2.0 // +#include "engines_util/test_case.hpp" +#include "engines_util/test_engines.hpp" #include "gtest/gtest.h" #include "ngraph/ngraph.hpp" #include "ngraph/op/prior_box_clustered.hpp" -#include "util/engine/test_engines.hpp" -#include "util/test_case.hpp" #include "util/test_control.hpp" using namespace std; diff --git a/ngraph/test/backend/proposal.in.cpp b/ngraph/test/backend/proposal.in.cpp index 2307531e21f..9647c95cef5 100644 --- a/ngraph/test/backend/proposal.in.cpp +++ b/ngraph/test/backend/proposal.in.cpp @@ -9,11 +9,11 @@ #include #include +#include "engines_util/test_case.hpp" +#include "engines_util/test_engines.hpp" #include "gtest/gtest.h" #include "ngraph/ngraph.hpp" #include "ngraph/op/proposal.hpp" -#include "util/engine/test_engines.hpp" -#include "util/test_case.hpp" #include "util/test_control.hpp" NGRAPH_SUPPRESS_DEPRECATED_START @@ -239,4 +239,4 @@ NGRAPH_TEST(${BACKEND_NAME}, proposal_v4_basic) { test_case.add_expected_output(output_shape, o); test_case.add_expected_output(probs_shape, p); test_case.run(); -} \ No newline at end of file +} diff --git a/ngraph/test/backend/psroi_pooling.in.cpp b/ngraph/test/backend/psroi_pooling.in.cpp index 72188063f74..a24c8d34932 100644 --- a/ngraph/test/backend/psroi_pooling.in.cpp +++ b/ngraph/test/backend/psroi_pooling.in.cpp @@ -2,10 +2,10 @@ // SPDX-License-Identifier: Apache-2.0 // +#include "engines_util/test_case.hpp" +#include "engines_util/test_engines.hpp" #include "gtest/gtest.h" #include "ngraph/op/psroi_pooling.hpp" -#include "util/engine/test_engines.hpp" -#include "util/test_case.hpp" #include "util/test_control.hpp" using namespace ngraph; diff --git a/ngraph/test/backend/quantize_dequantize.in.cpp b/ngraph/test/backend/quantize_dequantize.in.cpp index 750f2ef91d2..9dd717e7a34 100644 --- a/ngraph/test/backend/quantize_dequantize.in.cpp +++ b/ngraph/test/backend/quantize_dequantize.in.cpp @@ -2,10 +2,10 @@ // SPDX-License-Identifier: Apache-2.0 // +#include "engines_util/test_case.hpp" +#include "engines_util/test_engines.hpp" #include "gtest/gtest.h" #include "ngraph/ngraph.hpp" -#include "util/engine/test_engines.hpp" -#include "util/test_case.hpp" #include "util/test_control.hpp" NGRAPH_SUPPRESS_DEPRECATED_START @@ -16,8 +16,7 @@ using namespace ngraph; static string s_manifest = "${MANIFEST}"; using TestEngine = test::ENGINE_CLASS_NAME(${BACKEND_NAME}); -NGRAPH_TEST(${BACKEND_NAME}, quantize) -{ +NGRAPH_TEST(${BACKEND_NAME}, quantize) { Shape input_shape{4, 3}; Shape scale_offset_shape; AxisSet quantization_axes; @@ -33,8 +32,7 @@ NGRAPH_TEST(${BACKEND_NAME}, quantize) auto X = make_shared(input_type, input_shape); auto scale = op::Constant::create(input_type, scale_offset_shape, {2}); auto offset = op::Constant::create(output_type, scale_offset_shape, {1}); - auto quantize = - make_shared(X, scale, offset, output_type, quantization_axes, round_mode); + auto quantize = make_shared(X, scale, offset, output_type, quantization_axes, round_mode); auto f = make_shared(quantize, ParameterVector{X}); std::vector x{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}; @@ -49,8 +47,7 @@ NGRAPH_TEST(${BACKEND_NAME}, quantize) test_case.run(); } -NGRAPH_TEST(${BACKEND_NAME}, quantize_zero_offset) -{ +NGRAPH_TEST(${BACKEND_NAME}, quantize_zero_offset) { Shape input_shape{4, 3}; Shape scale_offset_shape; AxisSet quantization_axes; @@ -66,8 +63,7 @@ NGRAPH_TEST(${BACKEND_NAME}, quantize_zero_offset) auto X = make_shared(input_type, input_shape); auto scale = op::Constant::create(input_type, scale_offset_shape, {2}); auto offset = op::Constant::create(output_type, scale_offset_shape, {0}); - auto quantize = - make_shared(X, scale, offset, output_type, quantization_axes, round_mode); + auto quantize = make_shared(X, scale, offset, output_type, quantization_axes, round_mode); auto f = make_shared(quantize, ParameterVector{X}); std::vector x{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}; @@ -82,8 +78,7 @@ NGRAPH_TEST(${BACKEND_NAME}, quantize_zero_offset) test_case.run(); } -NGRAPH_TEST(${BACKEND_NAME}, quantize_axes) -{ +NGRAPH_TEST(${BACKEND_NAME}, quantize_axes) { Shape input_shape{4, 3}; Shape scale_offset_shape{4}; AxisSet quantization_axes{0}; @@ -99,8 +94,7 @@ NGRAPH_TEST(${BACKEND_NAME}, quantize_axes) auto X = make_shared(input_type, input_shape); auto scale = op::Constant::create(input_type, scale_offset_shape, {2, 3, 4, 5}); auto offset = op::Constant::create(output_type, scale_offset_shape, {10, 20, 30, 40}); - auto quantize = - make_shared(X, scale, offset, output_type, quantization_axes, round_mode); + auto quantize = make_shared(X, scale, offset, output_type, quantization_axes, round_mode); auto f = make_shared(quantize, ParameterVector{X}); std::vector x{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}; @@ -111,13 +105,11 @@ NGRAPH_TEST(${BACKEND_NAME}, quantize_axes) auto test_case = test::TestCase(f); test_case.add_input({x}); - test_case.add_expected_output(input_shape, - {10, 11, 11, 21, 21, 22, 32, 32, 32, 42, 42, 42}); + test_case.add_expected_output(input_shape, {10, 11, 11, 21, 21, 22, 32, 32, 32, 42, 42, 42}); test_case.run(); } -NGRAPH_TEST(${BACKEND_NAME}, quantize_int8) -{ +NGRAPH_TEST(${BACKEND_NAME}, quantize_int8) { Shape input_shape{4, 3}; Shape scale_offset_shape; AxisSet quantization_axes; @@ -133,8 +125,7 @@ NGRAPH_TEST(${BACKEND_NAME}, quantize_int8) auto X = make_shared(input_type, input_shape); auto scale = op::Constant::create(input_type, scale_offset_shape, {2}); auto offset = op::Constant::create(output_type, scale_offset_shape, {1}); - auto quantize = - make_shared(X, scale, offset, output_type, quantization_axes, round_mode); + auto quantize = make_shared(X, scale, offset, output_type, quantization_axes, round_mode); auto f = make_shared(quantize, ParameterVector{X}); std::vector x{0, -1, 2, -3, 4, -5, 6, -7, 8, -9, 10, -11}; @@ -145,13 +136,11 @@ NGRAPH_TEST(${BACKEND_NAME}, quantize_int8) auto test_case = test::TestCase(f); test_case.add_input({x}); - test_case.add_expected_output(input_shape, - {1, 1, 2, -1, 3, -1, 4, -3, 5, -3, 6, -5}); + test_case.add_expected_output(input_shape, {1, 1, 2, -1, 3, -1, 4, -3, 5, -3, 6, -5}); test_case.run(); } -NGRAPH_TEST(${BACKEND_NAME}, quantize_int8_zero_offset) -{ +NGRAPH_TEST(${BACKEND_NAME}, quantize_int8_zero_offset) { Shape input_shape{4, 3}; Shape scale_offset_shape; AxisSet quantization_axes; @@ -167,8 +156,7 @@ NGRAPH_TEST(${BACKEND_NAME}, quantize_int8_zero_offset) auto X = make_shared(input_type, input_shape); auto scale = op::Constant::create(input_type, scale_offset_shape, {2}); auto offset = op::Constant::create(output_type, scale_offset_shape, {0}); - auto quantize = - make_shared(X, scale, offset, output_type, quantization_axes, round_mode); + auto quantize = make_shared(X, scale, offset, output_type, quantization_axes, round_mode); auto f = make_shared(quantize, ParameterVector{X}); std::vector x{0, -1, 2, -3, 4, -5, 6, -7, 8, -9, 10, -11}; @@ -179,13 +167,11 @@ NGRAPH_TEST(${BACKEND_NAME}, quantize_int8_zero_offset) auto test_case = test::TestCase(f); test_case.add_input({x}); - test_case.add_expected_output(input_shape, - {0, 0, 1, -2, 2, -2, 3, -4, 4, -4, 5, -6}); + test_case.add_expected_output(input_shape, {0, 0, 1, -2, 2, -2, 3, -4, 4, -4, 5, -6}); test_case.run(); } -NGRAPH_TEST(${BACKEND_NAME}, quantize_int32) -{ +NGRAPH_TEST(${BACKEND_NAME}, quantize_int32) { Shape input_shape{4, 3}; Shape scale_offset_shape; AxisSet quantization_axes; @@ -201,8 +187,7 @@ NGRAPH_TEST(${BACKEND_NAME}, quantize_int32) auto X = make_shared(input_type, input_shape); auto scale = op::Constant::create(input_type, scale_offset_shape, {2}); auto offset = op::Constant::create(output_type, scale_offset_shape, {1}); - auto quantize = - make_shared(X, scale, offset, output_type, quantization_axes, round_mode); + auto quantize = make_shared(X, scale, offset, output_type, quantization_axes, round_mode); auto f = make_shared(quantize, ParameterVector{X}); std::vector x{0, -1, 2, -3, 4, -5, 6, -7, 8, -9, 10, -11}; @@ -213,13 +198,11 @@ NGRAPH_TEST(${BACKEND_NAME}, quantize_int32) auto test_case = test::TestCase(f); test_case.add_input({x}); - test_case.add_expected_output(input_shape, - {1, 1, 2, -1, 3, -1, 4, -3, 5, -3, 6, -5}); + test_case.add_expected_output(input_shape, {1, 1, 2, -1, 3, -1, 4, -3, 5, -3, 6, -5}); test_case.run(); } -NGRAPH_TEST(${BACKEND_NAME}, quantize_int32_zero_offset) -{ +NGRAPH_TEST(${BACKEND_NAME}, quantize_int32_zero_offset) { Shape input_shape{4, 3}; Shape scale_offset_shape; AxisSet quantization_axes; @@ -235,8 +218,7 @@ NGRAPH_TEST(${BACKEND_NAME}, quantize_int32_zero_offset) auto X = make_shared(input_type, input_shape); auto scale = op::Constant::create(input_type, scale_offset_shape, {2}); auto offset = op::Constant::create(output_type, scale_offset_shape, {0}); - auto quantize = - make_shared(X, scale, offset, output_type, quantization_axes, round_mode); + auto quantize = make_shared(X, scale, offset, output_type, quantization_axes, round_mode); auto f = make_shared(quantize, ParameterVector{X}); std::vector x{0, -1, 2, -3, 4, -5, 6, -7, 8, -9, 10, -11}; @@ -247,13 +229,11 @@ NGRAPH_TEST(${BACKEND_NAME}, quantize_int32_zero_offset) auto test_case = test::TestCase(f); test_case.add_input({x}); - test_case.add_expected_output(input_shape, - {0, 0, 1, -2, 2, -2, 3, -4, 4, -4, 5, -6}); + test_case.add_expected_output(input_shape, {0, 0, 1, -2, 2, -2, 3, -4, 4, -4, 5, -6}); test_case.run(); } -NGRAPH_TEST(${BACKEND_NAME}, quantize_clamp_uint8) -{ +NGRAPH_TEST(${BACKEND_NAME}, quantize_clamp_uint8) { Shape input_shape{4, 3}; Shape scale_offset_shape; AxisSet quantization_axes; @@ -271,21 +251,19 @@ NGRAPH_TEST(${BACKEND_NAME}, quantize_clamp_uint8) auto X = make_shared(input_type, input_shape); auto scale = op::Constant::create(input_type, scale_offset_shape, {1.0 / (max + 1.0)}); auto offset = op::Constant::create(output_type, scale_offset_shape, {0}); - auto quantize = - make_shared(X, scale, offset, output_type, quantization_axes, round_mode); + auto quantize = make_shared(X, scale, offset, output_type, quantization_axes, round_mode); auto f = make_shared(quantize, ParameterVector{X}); std::vector x{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}; auto test_case = test::TestCase(f); test_case.add_input({x}); - test_case.add_expected_output( - input_shape, {0, max, max, max, max, max, max, max, max, max, max, max}); + test_case.add_expected_output(input_shape, + {0, max, max, max, max, max, max, max, max, max, max, max}); test_case.run(); } -NGRAPH_TEST(${BACKEND_NAME}, quantize_clamp_int8) -{ +NGRAPH_TEST(${BACKEND_NAME}, quantize_clamp_int8) { Shape input_shape{4, 3}; Shape scale_offset_shape; AxisSet quantization_axes; @@ -304,21 +282,19 @@ NGRAPH_TEST(${BACKEND_NAME}, quantize_clamp_int8) auto X = make_shared(input_type, input_shape); auto scale = op::Constant::create(input_type, scale_offset_shape, {1.0 / (max + 1.0)}); auto offset = op::Constant::create(output_type, scale_offset_shape, {0}); - auto quantize = - make_shared(X, scale, offset, output_type, quantization_axes, round_mode); + auto quantize = make_shared(X, scale, offset, output_type, quantization_axes, round_mode); auto f = make_shared(quantize, ParameterVector{X}); std::vector x{0, -1, 2, -3, 4, -5, 6, -7, 8, -9, 10, -11}; auto test_case = test::TestCase(f); test_case.add_input({x}); - test_case.add_expected_output( - input_shape, {0, min, max, min, max, min, max, min, max, min, max, min}); + test_case.add_expected_output(input_shape, + {0, min, max, min, max, min, max, min, max, min, max, min}); test_case.run(); } -NGRAPH_TEST(${BACKEND_NAME}, quantize_clamp_int32) -{ +NGRAPH_TEST(${BACKEND_NAME}, quantize_clamp_int32) { Shape input_shape{4, 3}; Shape scale_offset_shape; AxisSet quantization_axes; @@ -338,21 +314,19 @@ NGRAPH_TEST(${BACKEND_NAME}, quantize_clamp_int32) auto X = make_shared(input_type, input_shape); auto scale = op::Constant::create(input_type, scale_offset_shape, {1.0 / (max + 1.0)}); auto offset = op::Constant::create(output_type, scale_offset_shape, {0}); - auto quantize = - make_shared(X, scale, offset, output_type, quantization_axes, round_mode); + auto quantize = make_shared(X, scale, offset, output_type, quantization_axes, round_mode); auto f = make_shared(quantize, ParameterVector{X}); std::vector x{0, -1, 2, -3, 4, -5, 6, -7, 8, -9, 10, -11}; auto test_case = test::TestCase(f); test_case.add_input({x}); - test_case.add_expected_output( - input_shape, {0, min, max, min, max, min, max, min, max, min, max, min}); + test_case.add_expected_output(input_shape, + {0, min, max, min, max, min, max, min, max, min, max, min}); test_case.run(); } -NGRAPH_TEST(${BACKEND_NAME}, quantize_ROUND_NEAREST_TOWARD_ZERO) -{ +NGRAPH_TEST(${BACKEND_NAME}, quantize_ROUND_NEAREST_TOWARD_ZERO) { Shape input_shape{4, 3}; Shape scale_offset_shape; AxisSet quantization_axes; @@ -368,8 +342,7 @@ NGRAPH_TEST(${BACKEND_NAME}, quantize_ROUND_NEAREST_TOWARD_ZERO) auto X = make_shared(input_type, input_shape); auto scale = op::Constant::create(input_type, scale_offset_shape, {4}); auto offset = op::Constant::create(output_type, scale_offset_shape, {0}); - auto quantize = - make_shared(X, scale, offset, output_type, quantization_axes, round_mode); + auto quantize = make_shared(X, scale, offset, output_type, quantization_axes, round_mode); auto f = make_shared(quantize, ParameterVector{X}); std::vector x{9, 10, 11, -9, -10, -11, 13, 14, 15, -13, -14, -15}; @@ -378,13 +351,11 @@ NGRAPH_TEST(${BACKEND_NAME}, quantize_ROUND_NEAREST_TOWARD_ZERO) auto test_case = test::TestCase(f); test_case.add_input({x}); - test_case.add_expected_output(input_shape, - {2, 2, 3, -2, -2, -3, 3, 3, 4, -3, -3, -4}); + test_case.add_expected_output(input_shape, {2, 2, 3, -2, -2, -3, 3, 3, 4, -3, -3, -4}); test_case.run(); } -NGRAPH_TEST(${BACKEND_NAME}, quantize_ROUND_NEAREST_TOWARD_INFINITY) -{ +NGRAPH_TEST(${BACKEND_NAME}, quantize_ROUND_NEAREST_TOWARD_INFINITY) { Shape input_shape{4, 3}; Shape scale_offset_shape; AxisSet quantization_axes; @@ -400,8 +371,7 @@ NGRAPH_TEST(${BACKEND_NAME}, quantize_ROUND_NEAREST_TOWARD_INFINITY) auto X = make_shared(input_type, input_shape); auto scale = op::Constant::create(input_type, scale_offset_shape, {4}); auto offset = op::Constant::create(output_type, scale_offset_shape, {0}); - auto quantize = - make_shared(X, scale, offset, output_type, quantization_axes, round_mode); + auto quantize = make_shared(X, scale, offset, output_type, quantization_axes, round_mode); auto f = make_shared(quantize, ParameterVector{X}); std::vector x{9, 10, 11, -9, -10, -11, 13, 14, 15, -13, -14, -15}; @@ -410,13 +380,11 @@ NGRAPH_TEST(${BACKEND_NAME}, quantize_ROUND_NEAREST_TOWARD_INFINITY) auto test_case = test::TestCase(f); test_case.add_input({x}); - test_case.add_expected_output(input_shape, - {2, 3, 3, -2, -3, -3, 3, 4, 4, -3, -4, -4}); + test_case.add_expected_output(input_shape, {2, 3, 3, -2, -3, -3, 3, 4, 4, -3, -4, -4}); test_case.run(); } -NGRAPH_TEST(${BACKEND_NAME}, quantize_ROUND_NEAREST_UPWARD) -{ +NGRAPH_TEST(${BACKEND_NAME}, quantize_ROUND_NEAREST_UPWARD) { Shape input_shape{4, 3}; Shape scale_offset_shape; AxisSet quantization_axes; @@ -432,8 +400,7 @@ NGRAPH_TEST(${BACKEND_NAME}, quantize_ROUND_NEAREST_UPWARD) auto X = make_shared(input_type, input_shape); auto scale = op::Constant::create(input_type, scale_offset_shape, {4}); auto offset = op::Constant::create(output_type, scale_offset_shape, {0}); - auto quantize = - make_shared(X, scale, offset, output_type, quantization_axes, round_mode); + auto quantize = make_shared(X, scale, offset, output_type, quantization_axes, round_mode); auto f = make_shared(quantize, ParameterVector{X}); std::vector x{9, 10, 11, -9, -10, -11, 13, 14, 15, -13, -14, -15}; @@ -442,13 +409,11 @@ NGRAPH_TEST(${BACKEND_NAME}, quantize_ROUND_NEAREST_UPWARD) auto test_case = test::TestCase(f); test_case.add_input({x}); - test_case.add_expected_output(input_shape, - {2, 3, 3, -2, -2, -3, 3, 4, 4, -3, -3, -4}); + test_case.add_expected_output(input_shape, {2, 3, 3, -2, -2, -3, 3, 4, 4, -3, -3, -4}); test_case.run(); } -NGRAPH_TEST(${BACKEND_NAME}, quantize_ROUND_NEAREST_DOWNWARD) -{ +NGRAPH_TEST(${BACKEND_NAME}, quantize_ROUND_NEAREST_DOWNWARD) { Shape input_shape{4, 3}; Shape scale_offset_shape; AxisSet quantization_axes; @@ -464,8 +429,7 @@ NGRAPH_TEST(${BACKEND_NAME}, quantize_ROUND_NEAREST_DOWNWARD) auto X = make_shared(input_type, input_shape); auto scale = op::Constant::create(input_type, scale_offset_shape, {4}); auto offset = op::Constant::create(output_type, scale_offset_shape, {0}); - auto quantize = - make_shared(X, scale, offset, output_type, quantization_axes, round_mode); + auto quantize = make_shared(X, scale, offset, output_type, quantization_axes, round_mode); auto f = make_shared(quantize, ParameterVector{X}); std::vector x{9, 10, 11, -9, -10, -11, 13, 14, 15, -13, -14, -15}; @@ -474,13 +438,11 @@ NGRAPH_TEST(${BACKEND_NAME}, quantize_ROUND_NEAREST_DOWNWARD) auto test_case = test::TestCase(f); test_case.add_input({x}); - test_case.add_expected_output(input_shape, - {2, 2, 3, -2, -3, -3, 3, 3, 4, -3, -4, -4}); + test_case.add_expected_output(input_shape, {2, 2, 3, -2, -3, -3, 3, 3, 4, -3, -4, -4}); test_case.run(); } -NGRAPH_TEST(${BACKEND_NAME}, quantize_ROUND_NEAREST_TOWARD_EVEN) -{ +NGRAPH_TEST(${BACKEND_NAME}, quantize_ROUND_NEAREST_TOWARD_EVEN) { Shape input_shape{4, 3}; Shape scale_offset_shape; AxisSet quantization_axes; @@ -496,8 +458,7 @@ NGRAPH_TEST(${BACKEND_NAME}, quantize_ROUND_NEAREST_TOWARD_EVEN) auto X = make_shared(input_type, input_shape); auto scale = op::Constant::create(input_type, scale_offset_shape, {4}); auto offset = op::Constant::create(output_type, scale_offset_shape, {0}); - auto quantize = - make_shared(X, scale, offset, output_type, quantization_axes, round_mode); + auto quantize = make_shared(X, scale, offset, output_type, quantization_axes, round_mode); auto f = make_shared(quantize, ParameterVector{X}); std::vector x{9, 10, 11, -9, -10, -11, 13, 14, 15, -13, -14, -15}; @@ -506,13 +467,11 @@ NGRAPH_TEST(${BACKEND_NAME}, quantize_ROUND_NEAREST_TOWARD_EVEN) auto test_case = test::TestCase(f); test_case.add_input({x}); - test_case.add_expected_output(input_shape, - {2, 2, 3, -2, -2, -3, 3, 4, 4, -3, -4, -4}); + test_case.add_expected_output(input_shape, {2, 2, 3, -2, -2, -3, 3, 4, 4, -3, -4, -4}); test_case.run(); } -NGRAPH_TEST(${BACKEND_NAME}, quantize_ROUND_TOWARD_INFINITY) -{ +NGRAPH_TEST(${BACKEND_NAME}, quantize_ROUND_TOWARD_INFINITY) { Shape input_shape{4, 3}; Shape scale_offset_shape; AxisSet quantization_axes; @@ -528,13 +487,12 @@ NGRAPH_TEST(${BACKEND_NAME}, quantize_ROUND_TOWARD_INFINITY) auto X = make_shared(input_type, input_shape); auto scale = op::Constant::create(input_type, scale_offset_shape, {4}); auto offset = op::Constant::create(output_type, scale_offset_shape, {0}); - auto quantize = make_shared( - X, - scale, - offset, - output_type, - quantization_axes, - static_cast(static_cast(round_mode))); + auto quantize = make_shared(X, + scale, + offset, + output_type, + quantization_axes, + static_cast(static_cast(round_mode))); auto f = make_shared(quantize, ParameterVector{X}); std::vector x{9, 10, 11, -9, -10, -11, 13, 14, 15, -13, -14, -15}; @@ -543,13 +501,11 @@ NGRAPH_TEST(${BACKEND_NAME}, quantize_ROUND_TOWARD_INFINITY) auto test_case = test::TestCase(f); test_case.add_input({x}); - test_case.add_expected_output(input_shape, - {3, 3, 3, -3, -3, -3, 4, 4, 4, -4, -4, -4}); + test_case.add_expected_output(input_shape, {3, 3, 3, -3, -3, -3, 4, 4, 4, -4, -4, -4}); test_case.run(); } -NGRAPH_TEST(${BACKEND_NAME}, quantize_ROUND_TOWARD_ZERO) -{ +NGRAPH_TEST(${BACKEND_NAME}, quantize_ROUND_TOWARD_ZERO) { Shape input_shape{4, 3}; Shape scale_offset_shape; AxisSet quantization_axes; @@ -565,13 +521,12 @@ NGRAPH_TEST(${BACKEND_NAME}, quantize_ROUND_TOWARD_ZERO) auto X = make_shared(input_type, input_shape); auto scale = op::Constant::create(input_type, scale_offset_shape, {4}); auto offset = op::Constant::create(output_type, scale_offset_shape, {0}); - auto quantize = make_shared( - X, - scale, - offset, - output_type, - quantization_axes, - static_cast(static_cast(round_mode))); + auto quantize = make_shared(X, + scale, + offset, + output_type, + quantization_axes, + static_cast(static_cast(round_mode))); auto f = make_shared(quantize, ParameterVector{X}); std::vector x{9, 10, 11, -9, -10, -11, 13, 14, 15, -13, -14, -15}; @@ -580,13 +535,11 @@ NGRAPH_TEST(${BACKEND_NAME}, quantize_ROUND_TOWARD_ZERO) auto test_case = test::TestCase(f); test_case.add_input({x}); - test_case.add_expected_output(input_shape, - {2, 2, 2, -2, -2, -2, 3, 3, 3, -3, -3, -3}); + test_case.add_expected_output(input_shape, {2, 2, 2, -2, -2, -2, 3, 3, 3, -3, -3, -3}); test_case.run(); } -NGRAPH_TEST(${BACKEND_NAME}, quantize_ROUND_UP) -{ +NGRAPH_TEST(${BACKEND_NAME}, quantize_ROUND_UP) { Shape input_shape{4, 3}; Shape scale_offset_shape; AxisSet quantization_axes; @@ -602,8 +555,7 @@ NGRAPH_TEST(${BACKEND_NAME}, quantize_ROUND_UP) auto X = make_shared(input_type, input_shape); auto scale = op::Constant::create(input_type, scale_offset_shape, {4}); auto offset = op::Constant::create(output_type, scale_offset_shape, {0}); - auto quantize = - make_shared(X, scale, offset, output_type, quantization_axes, round_mode); + auto quantize = make_shared(X, scale, offset, output_type, quantization_axes, round_mode); auto f = make_shared(quantize, ParameterVector{X}); std::vector x{9, 10, 11, -9, -10, -11, 13, 14, 15, -13, -14, -15}; @@ -612,13 +564,11 @@ NGRAPH_TEST(${BACKEND_NAME}, quantize_ROUND_UP) auto test_case = test::TestCase(f); test_case.add_input({x}); - test_case.add_expected_output(input_shape, - {3, 3, 3, -2, -2, -2, 4, 4, 4, -3, -3, -3}); + test_case.add_expected_output(input_shape, {3, 3, 3, -2, -2, -2, 4, 4, 4, -3, -3, -3}); test_case.run(); } -NGRAPH_TEST(${BACKEND_NAME}, quantize_ROUND_DOWN) -{ +NGRAPH_TEST(${BACKEND_NAME}, quantize_ROUND_DOWN) { Shape input_shape{4, 3}; Shape scale_offset_shape; AxisSet quantization_axes; @@ -634,8 +584,7 @@ NGRAPH_TEST(${BACKEND_NAME}, quantize_ROUND_DOWN) auto X = make_shared(input_type, input_shape); auto scale = op::Constant::create(input_type, scale_offset_shape, {4}); auto offset = op::Constant::create(output_type, scale_offset_shape, {0}); - auto quantize = - make_shared(X, scale, offset, output_type, quantization_axes, round_mode); + auto quantize = make_shared(X, scale, offset, output_type, quantization_axes, round_mode); auto f = make_shared(quantize, ParameterVector{X}); std::vector x{9, 10, 11, -9, -10, -11, 13, 14, 15, -13, -14, -15}; @@ -644,13 +593,11 @@ NGRAPH_TEST(${BACKEND_NAME}, quantize_ROUND_DOWN) auto test_case = test::TestCase(f); test_case.add_input({x}); - test_case.add_expected_output(input_shape, - {2, 2, 2, -3, -3, -3, 3, 3, 3, -4, -4, -4}); + test_case.add_expected_output(input_shape, {2, 2, 2, -3, -3, -3, 3, 3, 3, -4, -4, -4}); test_case.run(); } -NGRAPH_TEST(${BACKEND_NAME}, quantize_dynamic_offset) -{ +NGRAPH_TEST(${BACKEND_NAME}, quantize_dynamic_offset) { Shape input_shape{4, 3}; Shape scale_offset_shape = {}; AxisSet quantization_axes; @@ -666,8 +613,7 @@ NGRAPH_TEST(${BACKEND_NAME}, quantize_dynamic_offset) auto X = make_shared(input_type, input_shape); auto scale = make_shared(input_type, scale_offset_shape); auto offset = make_shared(output_type, scale_offset_shape); - auto quantize = - make_shared(X, scale, offset, output_type, quantization_axes, round_mode); + auto quantize = make_shared(X, scale, offset, output_type, quantization_axes, round_mode); auto f = make_shared(quantize, ParameterVector{X, scale, offset}); std::vector x{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}; diff --git a/ngraph/test/backend/range.in.cpp b/ngraph/test/backend/range.in.cpp index 0907241f593..af93b2afee4 100644 --- a/ngraph/test/backend/range.in.cpp +++ b/ngraph/test/backend/range.in.cpp @@ -2,12 +2,12 @@ // SPDX-License-Identifier: Apache-2.0 // +#include "engines_util/execute_tools.hpp" +#include "engines_util/test_case.hpp" +#include "engines_util/test_engines.hpp" #include "gtest/gtest.h" #include "ngraph/ngraph.hpp" -#include "util/engine/test_engines.hpp" -#include "util/test_case.hpp" #include "util/test_control.hpp" -#include "util/test_tools.hpp" using namespace std; using namespace ngraph; diff --git a/ngraph/test/backend/recurrent_cells.in.cpp b/ngraph/test/backend/recurrent_cells.in.cpp index 9813e5f9c25..728d79e38be 100644 --- a/ngraph/test/backend/recurrent_cells.in.cpp +++ b/ngraph/test/backend/recurrent_cells.in.cpp @@ -13,10 +13,10 @@ #include "ngraph/ngraph.hpp" #include "ngraph/opsets/opset4.hpp" -#include "util/engine/test_engines.hpp" -#include "util/test_case.hpp" +#include "engines_util/test_engines.hpp" +#include "engines_util/test_case.hpp" #include "util/test_control.hpp" -#include "util/test_tools.hpp" +#include "engines_util/execute_tools.hpp" using namespace std; using namespace ngraph; diff --git a/ngraph/test/backend/region_yolo.in.cpp b/ngraph/test/backend/region_yolo.in.cpp index 648a5046537..4207d65eff6 100644 --- a/ngraph/test/backend/region_yolo.in.cpp +++ b/ngraph/test/backend/region_yolo.in.cpp @@ -4,10 +4,10 @@ #include +#include "engines_util/test_case.hpp" +#include "engines_util/test_engines.hpp" #include "gtest/gtest.h" #include "ngraph/ngraph.hpp" -#include "util/engine/test_engines.hpp" -#include "util/test_case.hpp" #include "util/test_control.hpp" NGRAPH_SUPPRESS_DEPRECATED_START diff --git a/ngraph/test/backend/relu.in.cpp b/ngraph/test/backend/relu.in.cpp index 06ef5b73d5c..2e93828f46c 100644 --- a/ngraph/test/backend/relu.in.cpp +++ b/ngraph/test/backend/relu.in.cpp @@ -2,6 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 // +#include "engines_util/execute_tools.hpp" #include "gtest/gtest.h" #include "ngraph/ngraph.hpp" #include "ngraph/runtime/tensor.hpp" @@ -10,7 +11,6 @@ #include "util/all_close_f.hpp" #include "util/ndarray.hpp" #include "util/test_control.hpp" -#include "util/test_tools.hpp" using namespace std; using namespace ngraph; diff --git a/ngraph/test/backend/reorg_yolo.in.cpp b/ngraph/test/backend/reorg_yolo.in.cpp index f02687c75a7..7131833fa74 100644 --- a/ngraph/test/backend/reorg_yolo.in.cpp +++ b/ngraph/test/backend/reorg_yolo.in.cpp @@ -21,8 +21,8 @@ #include "gtest/gtest.h" #include "ngraph/ngraph.hpp" -#include "util/engine/test_engines.hpp" -#include "util/test_case.hpp" +#include "engines_util/test_engines.hpp" +#include "engines_util/test_case.hpp" #include "util/test_control.hpp" #include "util/type_prop.hpp" diff --git a/ngraph/test/backend/reshape.in.cpp b/ngraph/test/backend/reshape.in.cpp index ae7a2c381d4..d0e806ab71f 100644 --- a/ngraph/test/backend/reshape.in.cpp +++ b/ngraph/test/backend/reshape.in.cpp @@ -10,6 +10,9 @@ #include #include +#include "engines_util/execute_tools.hpp" +#include "engines_util/test_case.hpp" +#include "engines_util/test_engines.hpp" #include "gtest/gtest.h" #include "ngraph/builder/reshape.hpp" #include "ngraph/ngraph.hpp" @@ -17,11 +20,8 @@ #include "runtime/backend.hpp" #include "util/all_close.hpp" #include "util/all_close_f.hpp" -#include "util/engine/test_engines.hpp" #include "util/ndarray.hpp" -#include "util/test_case.hpp" #include "util/test_control.hpp" -#include "util/test_tools.hpp" NGRAPH_SUPPRESS_DEPRECATED_START diff --git a/ngraph/test/backend/result.in.cpp b/ngraph/test/backend/result.in.cpp index d42a6d80510..b7c3c6235af 100644 --- a/ngraph/test/backend/result.in.cpp +++ b/ngraph/test/backend/result.in.cpp @@ -2,10 +2,10 @@ // SPDX-License-Identifier: Apache-2.0 // +#include "engines_util/test_case.hpp" +#include "engines_util/test_engines.hpp" #include "gtest/gtest.h" #include "ngraph/op/result.hpp" -#include "util/engine/test_engines.hpp" -#include "util/test_case.hpp" #include "util/test_control.hpp" using namespace ngraph; diff --git a/ngraph/test/backend/reverse.in.cpp b/ngraph/test/backend/reverse.in.cpp index dbba1eefc02..7aa6a1147c5 100644 --- a/ngraph/test/backend/reverse.in.cpp +++ b/ngraph/test/backend/reverse.in.cpp @@ -2,6 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 // +#include "engines_util/execute_tools.hpp" #include "gtest/gtest.h" #include "ngraph/ngraph.hpp" #include "ngraph/runtime/tensor.hpp" @@ -10,7 +11,6 @@ #include "util/all_close_f.hpp" #include "util/ndarray.hpp" #include "util/test_control.hpp" -#include "util/test_tools.hpp" using namespace std; using namespace ngraph; diff --git a/ngraph/test/backend/roll.in.cpp b/ngraph/test/backend/roll.in.cpp index 4f6e4cf8282..1024e591c13 100644 --- a/ngraph/test/backend/roll.in.cpp +++ b/ngraph/test/backend/roll.in.cpp @@ -14,6 +14,7 @@ // limitations under the License. //***************************************************************************** +#include "engines_util/execute_tools.hpp" #include "gtest/gtest.h" #include "ngraph/ngraph.hpp" #include "ngraph/opsets/opset7.hpp" diff --git a/ngraph/test/backend/round.in.cpp b/ngraph/test/backend/round.in.cpp index 21c81bc8d1b..8b4b0b34bae 100644 --- a/ngraph/test/backend/round.in.cpp +++ b/ngraph/test/backend/round.in.cpp @@ -2,6 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 // +#include "engines_util/execute_tools.hpp" #include "gtest/gtest.h" #include "ngraph/ngraph.hpp" #include "ngraph/runtime/tensor.hpp" @@ -10,7 +11,6 @@ #include "util/all_close_f.hpp" #include "util/ndarray.hpp" #include "util/test_control.hpp" -#include "util/test_tools.hpp" NGRAPH_SUPPRESS_DEPRECATED_START diff --git a/ngraph/test/backend/scatter_nd_update.in.cpp b/ngraph/test/backend/scatter_nd_update.in.cpp index 8f3369246ab..a7e875a48d4 100644 --- a/ngraph/test/backend/scatter_nd_update.in.cpp +++ b/ngraph/test/backend/scatter_nd_update.in.cpp @@ -17,6 +17,7 @@ #include #include +#include "engines_util/execute_tools.hpp" #include "gtest/gtest.h" #include "ngraph/opsets/opset7.hpp" #include "ngraph/type/element_type.hpp" @@ -24,7 +25,6 @@ #include "util/all_close_f.hpp" #include "util/ndarray.hpp" #include "util/test_control.hpp" -#include "util/test_tools.hpp" static std::string s_manifest = "${MANIFEST}"; diff --git a/ngraph/test/backend/selu.in.cpp b/ngraph/test/backend/selu.in.cpp index b1d37423ee9..9dc7d0357ae 100644 --- a/ngraph/test/backend/selu.in.cpp +++ b/ngraph/test/backend/selu.in.cpp @@ -2,10 +2,10 @@ // SPDX-License-Identifier: Apache-2.0 // +#include "engines_util/test_case.hpp" +#include "engines_util/test_engines.hpp" #include "gtest/gtest.h" #include "ngraph/ngraph.hpp" -#include "util/engine/test_engines.hpp" -#include "util/test_case.hpp" #include "util/test_control.hpp" using namespace std; diff --git a/ngraph/test/backend/shape_of.in.cpp b/ngraph/test/backend/shape_of.in.cpp index 670f9342b09..5ff296b92fb 100644 --- a/ngraph/test/backend/shape_of.in.cpp +++ b/ngraph/test/backend/shape_of.in.cpp @@ -2,6 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 // +#include "engines_util/execute_tools.hpp" #include "gtest/gtest.h" #include "ngraph/ngraph.hpp" #include "ngraph/runtime/tensor.hpp" @@ -10,7 +11,6 @@ #include "util/all_close_f.hpp" #include "util/ndarray.hpp" #include "util/test_control.hpp" -#include "util/test_tools.hpp" using namespace std; using namespace ngraph; diff --git a/ngraph/test/backend/shuffle_channels.in.cpp b/ngraph/test/backend/shuffle_channels.in.cpp index 27b09160289..7b1296b3cef 100644 --- a/ngraph/test/backend/shuffle_channels.in.cpp +++ b/ngraph/test/backend/shuffle_channels.in.cpp @@ -2,15 +2,15 @@ // SPDX-License-Identifier: Apache-2.0 // +#include "engines_util/execute_tools.hpp" +#include "engines_util/test_case.hpp" +#include "engines_util/test_engines.hpp" #include "gtest/gtest.h" #include "ngraph/ngraph.hpp" #include "runtime/backend.hpp" #include "util/all_close.hpp" #include "util/all_close_f.hpp" -#include "util/engine/test_engines.hpp" -#include "util/test_case.hpp" #include "util/test_control.hpp" -#include "util/test_tools.hpp" using namespace std; using namespace ngraph; diff --git a/ngraph/test/backend/sigmoid.in.cpp b/ngraph/test/backend/sigmoid.in.cpp index 18791018514..dc59cfbf725 100644 --- a/ngraph/test/backend/sigmoid.in.cpp +++ b/ngraph/test/backend/sigmoid.in.cpp @@ -20,7 +20,7 @@ #include "util/all_close_f.hpp" #include "util/ndarray.hpp" #include "util/test_control.hpp" -#include "util/test_tools.hpp" +#include "engines_util/execute_tools.hpp" using namespace std; using namespace ngraph; diff --git a/ngraph/test/backend/slice.in.cpp b/ngraph/test/backend/slice.in.cpp index ccf4fcf8ef2..4c66c6aa36c 100644 --- a/ngraph/test/backend/slice.in.cpp +++ b/ngraph/test/backend/slice.in.cpp @@ -2,6 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 // +#include "engines_util/execute_tools.hpp" #include "gtest/gtest.h" #include "ngraph/builder/reshape.hpp" #include "ngraph/ngraph.hpp" @@ -11,7 +12,6 @@ #include "util/all_close_f.hpp" #include "util/ndarray.hpp" #include "util/test_control.hpp" -#include "util/test_tools.hpp" NGRAPH_SUPPRESS_DEPRECATED_START @@ -20,8 +20,7 @@ using namespace ngraph; static string s_manifest = "${MANIFEST}"; -NGRAPH_TEST(${BACKEND_NAME}, slice_scalar) -{ +NGRAPH_TEST(${BACKEND_NAME}, slice_scalar) { Shape shape_a{}; auto A = make_shared(element::f32, shape_a); Shape shape_r{}; @@ -37,12 +36,10 @@ NGRAPH_TEST(${BACKEND_NAME}, slice_scalar) auto handle = backend->compile(f); handle->call_with_validate({result}, {a}); - EXPECT_TRUE(test::all_close_f( - (vector{312}), read_vector(result), MIN_FLOAT_TOLERANCE_BITS)); + EXPECT_TRUE(test::all_close_f((vector{312}), read_vector(result), MIN_FLOAT_TOLERANCE_BITS)); } -NGRAPH_TEST(${BACKEND_NAME}, slice_matrix) -{ +NGRAPH_TEST(${BACKEND_NAME}, slice_matrix) { Shape shape_a{4, 4}; auto A = make_shared(element::f32, shape_a); Shape shape_r{3, 2}; @@ -58,12 +55,11 @@ NGRAPH_TEST(${BACKEND_NAME}, slice_matrix) auto handle = backend->compile(f); handle->call_with_validate({result}, {a}); - EXPECT_TRUE(test::all_close_f( - (vector{2, 3, 6, 7, 10, 11}), read_vector(result), MIN_FLOAT_TOLERANCE_BITS)); + EXPECT_TRUE( + test::all_close_f((vector{2, 3, 6, 7, 10, 11}), read_vector(result), MIN_FLOAT_TOLERANCE_BITS)); } -NGRAPH_TEST(${BACKEND_NAME}, slice_vector) -{ +NGRAPH_TEST(${BACKEND_NAME}, slice_vector) { Shape shape_a{16}; auto A = make_shared(element::f32, shape_a); Shape shape_r{12}; @@ -84,8 +80,7 @@ NGRAPH_TEST(${BACKEND_NAME}, slice_vector) MIN_FLOAT_TOLERANCE_BITS)); } -NGRAPH_TEST(${BACKEND_NAME}, slice_matrix_axis_0_overlap) -{ +NGRAPH_TEST(${BACKEND_NAME}, slice_matrix_axis_0_overlap) { Shape shape_a{4, 4}; auto A = make_shared(element::f32, shape_a); auto B = make_shared(element::f32, shape_a); @@ -112,8 +107,7 @@ NGRAPH_TEST(${BACKEND_NAME}, slice_matrix_axis_0_overlap) MIN_FLOAT_TOLERANCE_BITS)); } -NGRAPH_TEST(${BACKEND_NAME}, slice_matrix_axis_0_in_place) -{ +NGRAPH_TEST(${BACKEND_NAME}, slice_matrix_axis_0_in_place) { Shape shape_a{4, 4}; auto A = make_shared(element::f32, shape_a); Shape shape_r{2, 4}; @@ -136,8 +130,7 @@ NGRAPH_TEST(${BACKEND_NAME}, slice_matrix_axis_0_in_place) MIN_FLOAT_TOLERANCE_BITS)); } -NGRAPH_TEST(${BACKEND_NAME}, slice_matrix_axis_0_in_place_twice) -{ +NGRAPH_TEST(${BACKEND_NAME}, slice_matrix_axis_0_in_place_twice) { Shape shape_a{4, 4}; auto A = make_shared(element::f32, shape_a); Shape shape_r{1, 4}; @@ -156,12 +149,11 @@ NGRAPH_TEST(${BACKEND_NAME}, slice_matrix_axis_0_in_place_twice) auto handle = backend->compile(f); handle->call_with_validate({result}, {a}); - EXPECT_TRUE(test::all_close_f( - (vector{14, 16, 18, 20}), read_vector(result), MIN_FLOAT_TOLERANCE_BITS)); + EXPECT_TRUE( + test::all_close_f((vector{14, 16, 18, 20}), read_vector(result), MIN_FLOAT_TOLERANCE_BITS)); } -NGRAPH_TEST(${BACKEND_NAME}, slice_matrix_axis_0_in_place_twice_overlap) -{ +NGRAPH_TEST(${BACKEND_NAME}, slice_matrix_axis_0_in_place_twice_overlap) { Shape shape_a{5, 4}; auto A = make_shared(element::f32, shape_a); Shape shape_r{2, 4}; @@ -175,8 +167,7 @@ NGRAPH_TEST(${BACKEND_NAME}, slice_matrix_axis_0_in_place_twice_overlap) // Create some tensors for input/output auto a = backend->create_tensor(element::f32, shape_a); - copy_data(a, - vector{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20}); + copy_data(a, vector{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20}); auto result = backend->create_tensor(element::f32, shape_r); auto handle = backend->compile(f); @@ -186,8 +177,7 @@ NGRAPH_TEST(${BACKEND_NAME}, slice_matrix_axis_0_in_place_twice_overlap) MIN_FLOAT_TOLERANCE_BITS)); } -NGRAPH_TEST(${BACKEND_NAME}, slice_matrix_axis_0_in_place_with_transpose) -{ +NGRAPH_TEST(${BACKEND_NAME}, slice_matrix_axis_0_in_place_with_transpose) { Shape shape_a{4, 5}; auto A = make_shared(element::f32, shape_a); Shape shape_r{2, 4}; @@ -202,8 +192,7 @@ NGRAPH_TEST(${BACKEND_NAME}, slice_matrix_axis_0_in_place_with_transpose) // Create some tensors for input/output auto a = backend->create_tensor(element::f32, shape_a); - copy_data(a, - vector{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20}); + copy_data(a, vector{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20}); auto result = backend->create_tensor(element::f32, shape_r); auto handle = backend->compile(f); @@ -213,8 +202,7 @@ NGRAPH_TEST(${BACKEND_NAME}, slice_matrix_axis_0_in_place_with_transpose) MIN_FLOAT_TOLERANCE_BITS)); } -NGRAPH_TEST(${BACKEND_NAME}, slice_matrix_strided) -{ +NGRAPH_TEST(${BACKEND_NAME}, slice_matrix_strided) { Shape shape_a{4, 4}; auto A = make_shared(element::f32, shape_a); Shape shape_r{2, 2}; @@ -230,12 +218,10 @@ NGRAPH_TEST(${BACKEND_NAME}, slice_matrix_strided) auto handle = backend->compile(f); handle->call_with_validate({result}, {a}); - EXPECT_TRUE(test::all_close_f( - (vector{4, 7, 12, 15}), read_vector(result), MIN_FLOAT_TOLERANCE_BITS)); + EXPECT_TRUE(test::all_close_f((vector{4, 7, 12, 15}), read_vector(result), MIN_FLOAT_TOLERANCE_BITS)); } -NGRAPH_TEST(${BACKEND_NAME}, slice_3d) -{ +NGRAPH_TEST(${BACKEND_NAME}, slice_3d) { Shape shape_a{4, 4, 4}; auto A = make_shared(element::f32, shape_a); Shape shape_r{2, 2, 2}; @@ -262,8 +248,7 @@ NGRAPH_TEST(${BACKEND_NAME}, slice_3d) MIN_FLOAT_TOLERANCE_BITS)); } -NGRAPH_TEST(${BACKEND_NAME}, slice_3d_strided) -{ +NGRAPH_TEST(${BACKEND_NAME}, slice_3d_strided) { Shape shape_a{4, 4, 4}; auto A = make_shared(element::f32, shape_a); Shape shape_r{2, 2, 2}; @@ -290,8 +275,7 @@ NGRAPH_TEST(${BACKEND_NAME}, slice_3d_strided) MIN_FLOAT_TOLERANCE_BITS)); } -NGRAPH_TEST(${BACKEND_NAME}, slice_3d_strided_different_strides) -{ +NGRAPH_TEST(${BACKEND_NAME}, slice_3d_strided_different_strides) { Shape shape_a{4, 4, 4}; auto A = make_shared(element::f32, shape_a); Shape shape_r{2, 2, 2}; @@ -318,8 +302,7 @@ NGRAPH_TEST(${BACKEND_NAME}, slice_3d_strided_different_strides) MIN_FLOAT_TOLERANCE_BITS)); } -NGRAPH_TEST(${BACKEND_NAME}, slice_3d_strided_different_strides_int64) -{ +NGRAPH_TEST(${BACKEND_NAME}, slice_3d_strided_different_strides_int64) { Shape shape_a{4, 4, 4}; auto A = make_shared(element::i64, shape_a); Shape shape_r{2, 2, 2}; @@ -344,13 +327,11 @@ NGRAPH_TEST(${BACKEND_NAME}, slice_3d_strided_different_strides_int64) EXPECT_EQ((vector{0, 3, 8, 11, 32, 35, 40, 43}), read_vector(result)); } -NGRAPH_TEST(${BACKEND_NAME}, slice_3d_start_just_oob) -{ +NGRAPH_TEST(${BACKEND_NAME}, slice_3d_start_just_oob) { Shape shape_a{20, 10, 5}; auto A = make_shared(element::f32, shape_a); Shape shape_r{20, 0, 5}; - auto r = - make_shared(A, Coordinate{0, 10, 0}, Coordinate{20, 10, 5}, Strides{1, 1, 1}); + auto r = make_shared(A, Coordinate{0, 10, 0}, Coordinate{20, 10, 5}, Strides{1, 1, 1}); auto f = make_shared(r, ParameterVector{A}); auto backend = runtime::Backend::create("${BACKEND_NAME}"); diff --git a/ngraph/test/backend/softmax.in.cpp b/ngraph/test/backend/softmax.in.cpp index cecb9af0a5b..07ce69c0add 100644 --- a/ngraph/test/backend/softmax.in.cpp +++ b/ngraph/test/backend/softmax.in.cpp @@ -20,7 +20,7 @@ #include "util/all_close_f.hpp" #include "util/ndarray.hpp" #include "util/test_control.hpp" -#include "util/test_tools.hpp" +#include "engines_util/execute_tools.hpp" using namespace std; using namespace ngraph; diff --git a/ngraph/test/backend/softplus.in.cpp b/ngraph/test/backend/softplus.in.cpp index 252ec32826f..0aa37db6af0 100644 --- a/ngraph/test/backend/softplus.in.cpp +++ b/ngraph/test/backend/softplus.in.cpp @@ -21,8 +21,8 @@ #include "gtest/gtest.h" #include "ngraph/ngraph.hpp" -#include "util/engine/test_engines.hpp" -#include "util/test_case.hpp" +#include "engines_util/test_engines.hpp" +#include "engines_util/test_case.hpp" #include "util/test_control.hpp" using namespace std; diff --git a/ngraph/test/backend/space_to_batch.in.cpp b/ngraph/test/backend/space_to_batch.in.cpp index e47c5e0e6e1..d168be4bfca 100644 --- a/ngraph/test/backend/space_to_batch.in.cpp +++ b/ngraph/test/backend/space_to_batch.in.cpp @@ -2,10 +2,10 @@ // SPDX-License-Identifier: Apache-2.0 // +#include "engines_util/test_case.hpp" +#include "engines_util/test_engines.hpp" #include "gtest/gtest.h" #include "ngraph/ngraph.hpp" -#include "util/engine/test_engines.hpp" -#include "util/test_case.hpp" #include "util/test_control.hpp" using namespace std; diff --git a/ngraph/test/backend/space_to_depth.in.cpp b/ngraph/test/backend/space_to_depth.in.cpp index c0c1f6997d8..d3467a5d9a3 100644 --- a/ngraph/test/backend/space_to_depth.in.cpp +++ b/ngraph/test/backend/space_to_depth.in.cpp @@ -2,10 +2,10 @@ // SPDX-License-Identifier: Apache-2.0 // +#include "engines_util/test_case.hpp" +#include "engines_util/test_engines.hpp" #include "gtest/gtest.h" #include "ngraph/op/space_to_depth.hpp" -#include "util/engine/test_engines.hpp" -#include "util/test_case.hpp" #include "util/test_control.hpp" using namespace ngraph; diff --git a/ngraph/test/backend/split.in.cpp b/ngraph/test/backend/split.in.cpp index 8d47af6b416..b1cb692a1ae 100644 --- a/ngraph/test/backend/split.in.cpp +++ b/ngraph/test/backend/split.in.cpp @@ -2,10 +2,10 @@ // SPDX-License-Identifier: Apache-2.0 // +#include "engines_util/test_case.hpp" +#include "engines_util/test_engines.hpp" #include "gtest/gtest.h" #include "ngraph/ngraph.hpp" -#include "util/engine/test_engines.hpp" -#include "util/test_case.hpp" #include "util/test_control.hpp" using namespace std; diff --git a/ngraph/test/backend/sqrt.in.cpp b/ngraph/test/backend/sqrt.in.cpp index 360fa80ca2b..47fd70a1efd 100644 --- a/ngraph/test/backend/sqrt.in.cpp +++ b/ngraph/test/backend/sqrt.in.cpp @@ -21,10 +21,10 @@ #include "gtest/gtest.h" #include "ngraph/ngraph.hpp" -#include "util/test_case.hpp" +#include "engines_util/test_case.hpp" #include "util/test_control.hpp" -#include "util/test_tools.hpp" -#include "util/engine/test_engines.hpp" +#include "engines_util/execute_tools.hpp" +#include "engines_util/test_engines.hpp" using namespace std; using namespace ngraph; diff --git a/ngraph/test/backend/squared_difference.in.cpp b/ngraph/test/backend/squared_difference.in.cpp index 5e9733c8ff5..7c5e89faa14 100644 --- a/ngraph/test/backend/squared_difference.in.cpp +++ b/ngraph/test/backend/squared_difference.in.cpp @@ -21,8 +21,8 @@ #include "gtest/gtest.h" #include "ngraph/ngraph.hpp" -#include "util/engine/test_engines.hpp" -#include "util/test_case.hpp" +#include "engines_util/test_engines.hpp" +#include "engines_util/test_case.hpp" #include "util/test_control.hpp" using namespace std; diff --git a/ngraph/test/backend/squeeze.in.cpp b/ngraph/test/backend/squeeze.in.cpp index 427fedd411e..7512b861cef 100644 --- a/ngraph/test/backend/squeeze.in.cpp +++ b/ngraph/test/backend/squeeze.in.cpp @@ -2,10 +2,10 @@ // SPDX-License-Identifier: Apache-2.0 // +#include "engines_util/test_case.hpp" +#include "engines_util/test_engines.hpp" #include "gtest/gtest.h" #include "ngraph/ngraph.hpp" -#include "util/engine/test_engines.hpp" -#include "util/test_case.hpp" #include "util/test_control.hpp" using namespace std; diff --git a/ngraph/test/backend/strided_slice.in.cpp b/ngraph/test/backend/strided_slice.in.cpp index 90f9f5c6978..7d0bbfe116a 100644 --- a/ngraph/test/backend/strided_slice.in.cpp +++ b/ngraph/test/backend/strided_slice.in.cpp @@ -4,13 +4,13 @@ #include +#include "engines_util/execute_tools.hpp" #include "gtest/gtest.h" #include "ngraph/ngraph.hpp" #include "ngraph/runtime/tensor.hpp" #include "runtime/backend.hpp" #include "util/all_close_f.hpp" #include "util/test_control.hpp" -#include "util/test_tools.hpp" using namespace std; using namespace ngraph; diff --git a/ngraph/test/backend/subtract.in.cpp b/ngraph/test/backend/subtract.in.cpp index a3c40e9ebbf..473d6468859 100644 --- a/ngraph/test/backend/subtract.in.cpp +++ b/ngraph/test/backend/subtract.in.cpp @@ -27,7 +27,7 @@ #include "util/all_close_f.hpp" #include "util/ndarray.hpp" #include "util/test_control.hpp" -#include "util/test_tools.hpp" +#include "engines_util/execute_tools.hpp" using namespace std; using namespace ngraph; diff --git a/ngraph/test/backend/swish.in.cpp b/ngraph/test/backend/swish.in.cpp index c5a8c045ba9..1b56cf277f0 100644 --- a/ngraph/test/backend/swish.in.cpp +++ b/ngraph/test/backend/swish.in.cpp @@ -1,10 +1,10 @@ // Copyright (C) 2018-2021 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // +#include "engines_util/test_case.hpp" +#include "engines_util/test_engines.hpp" #include "gtest/gtest.h" #include "ngraph/ngraph.hpp" -#include "util/engine/test_engines.hpp" -#include "util/test_case.hpp" #include "util/test_control.hpp" using namespace std; diff --git a/ngraph/test/backend/tile.in.cpp b/ngraph/test/backend/tile.in.cpp index e5887aecec6..94927c91dd0 100644 --- a/ngraph/test/backend/tile.in.cpp +++ b/ngraph/test/backend/tile.in.cpp @@ -9,6 +9,7 @@ #include #include +#include "engines_util/execute_tools.hpp" #include "gtest/gtest.h" #include "ngraph/ngraph.hpp" #include "ngraph/runtime/tensor.hpp" @@ -17,7 +18,6 @@ #include "util/all_close_f.hpp" #include "util/ndarray.hpp" #include "util/test_control.hpp" -#include "util/test_tools.hpp" using namespace std; using namespace ngraph; diff --git a/ngraph/test/backend/topk.in.cpp b/ngraph/test/backend/topk.in.cpp index d145fac3d5a..9d60d5a252a 100644 --- a/ngraph/test/backend/topk.in.cpp +++ b/ngraph/test/backend/topk.in.cpp @@ -10,6 +10,9 @@ #include #include +#include "engines_util/execute_tools.hpp" +#include "engines_util/test_case.hpp" +#include "engines_util/test_engines.hpp" #include "gtest/gtest.h" #include "ngraph/op/constant.hpp" #include "ngraph/op/parameter.hpp" @@ -18,10 +21,7 @@ #include "ngraph/runtime/tensor.hpp" #include "runtime/backend.hpp" #include "util/all_close_f.hpp" -#include "util/engine/test_engines.hpp" -#include "util/test_case.hpp" #include "util/test_control.hpp" -#include "util/test_tools.hpp" using namespace std; using namespace ngraph; diff --git a/ngraph/test/backend/transpose.in.cpp b/ngraph/test/backend/transpose.in.cpp index ae5d536ef43..cf065298579 100644 --- a/ngraph/test/backend/transpose.in.cpp +++ b/ngraph/test/backend/transpose.in.cpp @@ -2,15 +2,15 @@ // SPDX-License-Identifier: Apache-2.0 // +#include "engines_util/execute_tools.hpp" +#include "engines_util/test_case.hpp" +#include "engines_util/test_engines.hpp" #include "gtest/gtest.h" #include "ngraph/ngraph.hpp" #include "ngraph/runtime/tensor.hpp" #include "runtime/backend.hpp" #include "util/all_close_f.hpp" -#include "util/engine/test_engines.hpp" -#include "util/test_case.hpp" #include "util/test_control.hpp" -#include "util/test_tools.hpp" using namespace std; using namespace ngraph; diff --git a/ngraph/test/backend/unsqueeze.in.cpp b/ngraph/test/backend/unsqueeze.in.cpp index 847c833bdfa..0d6476d834c 100644 --- a/ngraph/test/backend/unsqueeze.in.cpp +++ b/ngraph/test/backend/unsqueeze.in.cpp @@ -2,10 +2,10 @@ // SPDX-License-Identifier: Apache-2.0 // +#include "engines_util/test_case.hpp" +#include "engines_util/test_engines.hpp" #include "gtest/gtest.h" #include "ngraph/ngraph.hpp" -#include "util/engine/test_engines.hpp" -#include "util/test_case.hpp" #include "util/test_control.hpp" using namespace std; diff --git a/ngraph/test/backend/validate_call.in.cpp b/ngraph/test/backend/validate_call.in.cpp index f48721909b2..2f5b63f819b 100644 --- a/ngraph/test/backend/validate_call.in.cpp +++ b/ngraph/test/backend/validate_call.in.cpp @@ -2,6 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 // +#include "engines_util/execute_tools.hpp" #include "gtest/gtest.h" #include "ngraph/ngraph.hpp" #include "ngraph/runtime/tensor.hpp" @@ -10,7 +11,6 @@ #include "util/all_close_f.hpp" #include "util/ndarray.hpp" #include "util/test_control.hpp" -#include "util/test_tools.hpp" NGRAPH_SUPPRESS_DEPRECATED_START diff --git a/ngraph/test/backend/variadic_split.in.cpp b/ngraph/test/backend/variadic_split.in.cpp index 3b8158cddb5..7cd1dcf64e4 100644 --- a/ngraph/test/backend/variadic_split.in.cpp +++ b/ngraph/test/backend/variadic_split.in.cpp @@ -2,10 +2,10 @@ // SPDX-License-Identifier: Apache-2.0 // +#include "engines_util/test_case.hpp" +#include "engines_util/test_engines.hpp" #include "gtest/gtest.h" #include "ngraph/ngraph.hpp" -#include "util/engine/test_engines.hpp" -#include "util/test_case.hpp" #include "util/test_control.hpp" using namespace std; @@ -331,4 +331,4 @@ NGRAPH_TEST(${BACKEND_NAME}, variadic_split_4d_axis_3_dynamic) { test_case.add_expected_output(Shape{2, 1, 2, 3}, {3, 4, 5, 9, 10, 11, 15, 16, 17, 21, 22, 23}); test_case.run(); -} \ No newline at end of file +} diff --git a/ngraph/test/backend/zero_sized.in.cpp b/ngraph/test/backend/zero_sized.in.cpp index 64864471d82..76cf60671ed 100644 --- a/ngraph/test/backend/zero_sized.in.cpp +++ b/ngraph/test/backend/zero_sized.in.cpp @@ -2,6 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 // +#include "engines_util/execute_tools.hpp" #include "gtest/gtest.h" #include "ngraph/ngraph.hpp" #include "ngraph/runtime/tensor.hpp" @@ -10,7 +11,6 @@ #include "util/all_close_f.hpp" #include "util/ndarray.hpp" #include "util/test_control.hpp" -#include "util/test_tools.hpp" using namespace std; using namespace ngraph; diff --git a/ngraph/test/builder.cpp b/ngraph/test/builder.cpp index 20653f2f821..8fa73432a15 100644 --- a/ngraph/test/builder.cpp +++ b/ngraph/test/builder.cpp @@ -2,10 +2,10 @@ // SPDX-License-Identifier: Apache-2.0 // +#include "engines_util/execute_tools.hpp" #include "gtest/gtest.h" #include "ngraph/ngraph.hpp" #include "util/all_close.hpp" -#include "util/test_tools.hpp" using namespace ngraph; using namespace std; diff --git a/ngraph/test/control_dependencies.cpp b/ngraph/test/control_dependencies.cpp index fe15187c506..2c03dfc4b20 100644 --- a/ngraph/test/control_dependencies.cpp +++ b/ngraph/test/control_dependencies.cpp @@ -8,6 +8,7 @@ #include #include +#include "engines_util/random.hpp" #include "gtest/gtest.h" #include "ngraph/file_util.hpp" #include "ngraph/graph_util.hpp" @@ -21,7 +22,6 @@ #include "ngraph/util.hpp" #include "util/all_close.hpp" #include "util/ndarray.hpp" -#include "util/random.hpp" #include "util/test_tools.hpp" using namespace ngraph; diff --git a/ngraph/test/engines_util/CMakeLists.txt b/ngraph/test/engines_util/CMakeLists.txt new file mode 100644 index 00000000000..49639ae1662 --- /dev/null +++ b/ngraph/test/engines_util/CMakeLists.txt @@ -0,0 +1,17 @@ +# Copyright (C) 2018-2021 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 +# + +file(GLOB_RECURSE ENGINES_UTIL_SRC "${CMAKE_CURRENT_SOURCE_DIR}/*.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/*.hpp") + +add_library(engines_test_util STATIC ${ENGINES_UTIL_SRC}) + +if(COMMAND ie_faster_build) + ie_faster_build(engines_test_util UNITY) +endif() + +target_include_directories(engines_test_util PRIVATE $) +target_link_libraries(engines_test_util PUBLIC ngraph ngraph_backend gtest gmock ngraph_test_util) +target_include_directories(engines_test_util PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) + +add_clang_format_target(engines_test_util_clang FOR_SOURCES ${ENGINES_UTIL_SRC}) diff --git a/ngraph/test/util/engine/engine_factory.hpp b/ngraph/test/engines_util/engine_factory.hpp similarity index 97% rename from ngraph/test/util/engine/engine_factory.hpp rename to ngraph/test/engines_util/engine_factory.hpp index 7f2e905d3e4..f502d2dace2 100644 --- a/ngraph/test/util/engine/engine_factory.hpp +++ b/ngraph/test/engines_util/engine_factory.hpp @@ -4,8 +4,8 @@ #pragma once +#include "engine_traits.hpp" #include "ngraph/function.hpp" -#include "util/engine/engine_traits.hpp" namespace ngraph { namespace test { diff --git a/ngraph/test/util/engine/engine_traits.hpp b/ngraph/test/engines_util/engine_traits.hpp similarity index 100% rename from ngraph/test/util/engine/engine_traits.hpp rename to ngraph/test/engines_util/engine_traits.hpp diff --git a/ngraph/test/util/test_tools.cpp b/ngraph/test/engines_util/execute_tools.cpp similarity index 99% rename from ngraph/test/util/test_tools.cpp rename to ngraph/test/engines_util/execute_tools.cpp index 88306135690..a515c3c2628 100644 --- a/ngraph/test/util/test_tools.cpp +++ b/ngraph/test/engines_util/execute_tools.cpp @@ -2,7 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "test_tools.hpp" +#include "execute_tools.hpp" #include diff --git a/ngraph/test/engines_util/execute_tools.hpp b/ngraph/test/engines_util/execute_tools.hpp new file mode 100644 index 00000000000..a152cd9847b --- /dev/null +++ b/ngraph/test/engines_util/execute_tools.hpp @@ -0,0 +1,217 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "backend.hpp" +#include "graph_comparator.hpp" +#include "gtest/gtest.h" +#include "ngraph/file_util.hpp" +#include "ngraph/log.hpp" +#include "ngraph/node.hpp" +#include "ngraph/op/op.hpp" +#include "ngraph/runtime/host_tensor.hpp" +#include "ngraph/runtime/tensor.hpp" +#include "ngraph/type/element_type_traits.hpp" +#include "test_tools.hpp" + +namespace ngraph { +class TestOpMultiOut : public op::Op { +public: + static constexpr NodeTypeInfo type_info{"TestOpMultiOut", 0}; + const NodeTypeInfo& get_type_info() const override { + return type_info; + } + TestOpMultiOut() = default; + + TestOpMultiOut(const Output& output_1, const Output& output_2) : Op({output_1, output_2}) { + validate_and_infer_types(); + } + void validate_and_infer_types() override { + set_output_size(2); + set_output_type(0, get_input_element_type(0), get_input_partial_shape(0)); + set_output_type(1, get_input_element_type(1), get_input_partial_shape(1)); + } + + std::shared_ptr clone_with_new_inputs(const OutputVector& new_args) const override { + return std::make_shared(new_args.at(0), new_args.at(1)); + } + bool evaluate(const HostTensorVector& outputs, const HostTensorVector& inputs) const override; +}; +} // namespace ngraph + +bool validate_list(const std::vector>& nodes); +std::shared_ptr make_test_graph(); + +template +void copy_data(std::shared_ptr tv, const std::vector& data) { + size_t data_size = data.size() * sizeof(T); + if (data_size > 0) { + tv->write(data.data(), data_size); + } +} + +template +ngraph::HostTensorPtr make_host_tensor(const ngraph::Shape& shape, + const std::vector::value_type>& data) { + NGRAPH_CHECK(shape_size(shape) == data.size(), "Incorrect number of initialization elements"); + auto host_tensor = std::make_shared(ET, shape); + copy_data(host_tensor, data); + return host_tensor; +} + +template <> +void copy_data(std::shared_ptr tv, const std::vector& data); + +template +void write_vector(std::shared_ptr tv, const std::vector& values) { + tv->write(values.data(), values.size() * sizeof(T)); +} + +template +std::vector> get_ops_of_type(std::shared_ptr f) { + std::vector> ops; + for (auto op : f->get_ops()) { + if (auto cop = ngraph::as_type_ptr(op)) { + ops.push_back(cop); + } + } + + return ops; +} + +template +void init_int_tv(ngraph::runtime::Tensor* tv, std::default_random_engine& engine, T min, T max) { + size_t size = tv->get_element_count(); + std::uniform_int_distribution dist(min, max); + std::vector vec(size); + for (T& element : vec) { + element = dist(engine); + } + tv->write(vec.data(), vec.size() * sizeof(T)); +} + +template +void init_real_tv(ngraph::runtime::Tensor* tv, std::default_random_engine& engine, T min, T max) { + size_t size = tv->get_element_count(); + std::uniform_real_distribution dist(min, max); + std::vector vec(size); + for (T& element : vec) { + element = dist(engine); + } + tv->write(vec.data(), vec.size() * sizeof(T)); +} + +void random_init(ngraph::runtime::Tensor* tv, std::default_random_engine& engine); + +template +std::vector> prepare_and_run(const std::shared_ptr& function, + std::vector> t1args, + std::vector> t2args, + const std::string& backend_id) { + auto backend = ngraph::runtime::Backend::create(backend_id); + + auto parms = function->get_parameters(); + + if (parms.size() != t1args.size() + t2args.size()) { + throw ngraph::ngraph_error("number of parameters and arguments don't match"); + } + + std::vector> arg_tensors(t1args.size() + t2args.size()); + + size_t total_arg_count = 0; + for (size_t i = 0; i < t1args.size(); i++) { + auto t = backend->create_tensor(parms.at(total_arg_count)->get_element_type(), + parms.at(total_arg_count)->get_shape()); + auto x = t1args.at(i); + copy_data(t, x); + arg_tensors.at(total_arg_count) = t; + total_arg_count++; + } + + for (size_t i = 0; i < t2args.size(); i++) { + auto t = backend->create_tensor(parms.at(total_arg_count)->get_element_type(), + parms.at(total_arg_count)->get_shape()); + copy_data(t, t2args.at(i)); + arg_tensors.at(total_arg_count) = t; + total_arg_count++; + } + + auto results = function->get_results(); + std::vector> result_tensors(results.size()); + + for (size_t i = 0; i < results.size(); i++) { + result_tensors.at(i) = backend->create_tensor(results.at(i)->get_element_type(), results.at(i)->get_shape()); + } + + auto handle = backend->compile(function); + handle->call_with_validate(result_tensors, arg_tensors); + + return result_tensors; +} + +template +std::vector> execute(const std::shared_ptr& function, + std::vector> t1args, + std::vector> t2args, + const std::string& backend_id) { + std::vector> result_tensors = + prepare_and_run(function, t1args, t2args, backend_id); + + std::vector> result_vectors; + for (auto rt : result_tensors) { + result_vectors.push_back(read_vector(rt)); + } + return result_vectors; +} + +template +std::vector> execute(const std::shared_ptr& function, + std::vector> args, + const std::string& backend_id) { + std::vector> emptyargs; + return execute(function, args, emptyargs, backend_id); +} + +template +std::string get_results_str(const std::vector& ref_data, + const std::vector& actual_data, + size_t max_results = 16) { + std::stringstream ss; + size_t num_results = std::min(static_cast(max_results), ref_data.size()); + ss << "First " << num_results << " results"; + for (size_t i = 0; i < num_results; ++i) { + ss << std::endl + // use unary + operator to force integral values to be displayed as numbers + << std::setw(4) << i << " ref: " << std::setw(16) << std::left << +ref_data[i] + << " actual: " << std::setw(16) << std::left << +actual_data[i]; + } + ss << std::endl; + + return ss.str(); +} + +template <> +std::string get_results_str(const std::vector& ref_data, + const std::vector& actual_data, + size_t max_results); + +testing::AssertionResult test_ordered_ops(std::shared_ptr f, const ngraph::NodeVector& required_ops); + +template +ngraph::HostTensorPtr make_host_tensor(const ngraph::Shape& shape) { + auto host_tensor = std::make_shared(ET, shape); + static std::default_random_engine engine(2112); + random_init(host_tensor.get(), engine); + return host_tensor; +} diff --git a/ngraph/test/util/engine/ie_engines.cpp b/ngraph/test/engines_util/ie_engines.cpp similarity index 100% rename from ngraph/test/util/engine/ie_engines.cpp rename to ngraph/test/engines_util/ie_engines.cpp diff --git a/ngraph/test/util/engine/ie_engines.hpp b/ngraph/test/engines_util/ie_engines.hpp similarity index 97% rename from ngraph/test/util/engine/ie_engines.hpp rename to ngraph/test/engines_util/ie_engines.hpp index 4191124f38a..8cc864e65df 100644 --- a/ngraph/test/util/engine/ie_engines.hpp +++ b/ngraph/test/engines_util/ie_engines.hpp @@ -6,11 +6,11 @@ #include +#include "all_close.hpp" +#include "all_close_f.hpp" +#include "engine_traits.hpp" #include "ngraph/function.hpp" -#include "util/all_close.hpp" -#include "util/all_close_f.hpp" -#include "util/engine/engine_traits.hpp" -#include "util/engine/test_case_engine.hpp" +#include "test_case_engine.hpp" namespace ngraph { namespace test { diff --git a/ngraph/test/util/engine/interpreter_engine.cpp b/ngraph/test/engines_util/interpreter_engine.cpp similarity index 100% rename from ngraph/test/util/engine/interpreter_engine.cpp rename to ngraph/test/engines_util/interpreter_engine.cpp diff --git a/ngraph/test/util/engine/interpreter_engine.hpp b/ngraph/test/engines_util/interpreter_engine.hpp similarity index 93% rename from ngraph/test/util/engine/interpreter_engine.hpp rename to ngraph/test/engines_util/interpreter_engine.hpp index 08de7db1f05..87a36db5f16 100644 --- a/ngraph/test/util/engine/interpreter_engine.hpp +++ b/ngraph/test/engines_util/interpreter_engine.hpp @@ -4,12 +4,14 @@ #pragma once +#include "all_close.hpp" +#include "all_close_f.hpp" +#include "backend.hpp" +#include "engine_traits.hpp" +#include "execute_tools.hpp" #include "ngraph/function.hpp" #include "ngraph/op/constant.hpp" -#include "util/all_close.hpp" -#include "util/all_close_f.hpp" -#include "util/engine/engine_traits.hpp" -#include "util/engine/test_case_engine.hpp" +#include "test_case_engine.hpp" namespace ngraph { namespace test { diff --git a/ngraph/test/util/random.hpp b/ngraph/test/engines_util/random.hpp similarity index 95% rename from ngraph/test/util/random.hpp rename to ngraph/test/engines_util/random.hpp index f613cb07c38..9270c15165d 100644 --- a/ngraph/test/util/random.hpp +++ b/ngraph/test/engines_util/random.hpp @@ -7,8 +7,9 @@ #include #include +#include "execute_tools.hpp" +#include "ngraph/runtime/tensor.hpp" #include "ngraph/type/element_type.hpp" -#include "test_tools.hpp" namespace ngraph { namespace test { diff --git a/ngraph/test/util/engine/shared_utils.cpp b/ngraph/test/engines_util/shared_utils.cpp similarity index 100% rename from ngraph/test/util/engine/shared_utils.cpp rename to ngraph/test/engines_util/shared_utils.cpp diff --git a/ngraph/test/util/engine/shared_utils.hpp b/ngraph/test/engines_util/shared_utils.hpp similarity index 100% rename from ngraph/test/util/engine/shared_utils.hpp rename to ngraph/test/engines_util/shared_utils.hpp diff --git a/ngraph/test/util/test_case.cpp b/ngraph/test/engines_util/test_case.cpp similarity index 100% rename from ngraph/test/util/test_case.cpp rename to ngraph/test/engines_util/test_case.cpp diff --git a/ngraph/test/util/test_case.hpp b/ngraph/test/engines_util/test_case.hpp similarity index 98% rename from ngraph/test/util/test_case.hpp rename to ngraph/test/engines_util/test_case.hpp index 8aa4b45a716..9b3c5f30582 100644 --- a/ngraph/test/util/test_case.hpp +++ b/ngraph/test/engines_util/test_case.hpp @@ -8,10 +8,11 @@ #include "all_close.hpp" #include "all_close_f.hpp" +#include "engine_factory.hpp" +#include "ngraph/file_util.hpp" #include "ngraph/function.hpp" #include "ngraph/ngraph.hpp" #include "test_tools.hpp" -#include "util/engine/engine_factory.hpp" namespace ngraph { namespace test { diff --git a/ngraph/test/util/engine/test_case_engine.hpp b/ngraph/test/engines_util/test_case_engine.hpp similarity index 100% rename from ngraph/test/util/engine/test_case_engine.hpp rename to ngraph/test/engines_util/test_case_engine.hpp diff --git a/ngraph/test/util/engine/test_engines.hpp b/ngraph/test/engines_util/test_engines.hpp similarity index 100% rename from ngraph/test/util/engine/test_engines.hpp rename to ngraph/test/engines_util/test_engines.hpp diff --git a/ngraph/test/eval.cpp b/ngraph/test/eval.cpp index bdf9aed5941..feaa3aa6c72 100644 --- a/ngraph/test/eval.cpp +++ b/ngraph/test/eval.cpp @@ -7,6 +7,7 @@ #include #include +#include "engines_util/execute_tools.hpp" #include "gmock/gmock.h" #include "gtest/gtest.h" #include "ngraph/node.hpp" diff --git a/ngraph/test/frontend/paddlepaddle/op_fuzzy.cpp b/ngraph/test/frontend/paddlepaddle/op_fuzzy.cpp index bfb1ce023a4..9e7f91096d9 100644 --- a/ngraph/test/frontend/paddlepaddle/op_fuzzy.cpp +++ b/ngraph/test/frontend/paddlepaddle/op_fuzzy.cpp @@ -8,9 +8,9 @@ #include +#include "engines_util/test_engines.hpp" #include "ngraph/ngraph.hpp" #include "paddle_utils.hpp" -#include "util/engine/test_engines.hpp" #include "util/test_control.hpp" using namespace ngraph; diff --git a/ngraph/test/frontend/shared/CMakeLists.txt b/ngraph/test/frontend/shared/CMakeLists.txt index 0c1f6f133e2..c048c3bfb7c 100644 --- a/ngraph/test/frontend/shared/CMakeLists.txt +++ b/ngraph/test/frontend/shared/CMakeLists.txt @@ -12,6 +12,6 @@ add_library(${TARGET_NAME} STATIC ${LIBRARY_SRC} ${LIBRARY_HEADERS}) target_include_directories(${TARGET_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include) target_include_directories(${TARGET_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../..) target_link_libraries(${TARGET_NAME} PUBLIC frontend_manager - ngraph::ngraph cnpy ie_backend ngraph_test_util commonTestUtils openvino::util) + ngraph::ngraph cnpy ie_backend ngraph_test_util engines_test_util commonTestUtils openvino::util) add_clang_format_target(${TARGET_NAME}_clang FOR_TARGETS ${TARGET_NAME}) diff --git a/ngraph/test/frontend/shared/src/op_fuzzy.cpp b/ngraph/test/frontend/shared/src/op_fuzzy.cpp index 32b404e8113..6db34a4d358 100644 --- a/ngraph/test/frontend/shared/src/op_fuzzy.cpp +++ b/ngraph/test/frontend/shared/src/op_fuzzy.cpp @@ -6,8 +6,8 @@ #include -#include "util/engine/test_engines.hpp" -#include "util/test_case.hpp" +#include "engines_util/test_case.hpp" +#include "engines_util/test_engines.hpp" #include "util/test_control.hpp" #include "utils.hpp" diff --git a/ngraph/test/onnx/onnx_editor.cpp b/ngraph/test/onnx/onnx_editor.cpp index 21c7be215b6..12ac45826c4 100644 --- a/ngraph/test/onnx/onnx_editor.cpp +++ b/ngraph/test/onnx/onnx_editor.cpp @@ -7,14 +7,14 @@ #include "default_opset.hpp" #include "editor.hpp" +#include "engines_util/interpreter_engine.hpp" +#include "engines_util/test_case.hpp" #include "gtest/gtest.h" #include "ngraph/file_util.hpp" #include "ngraph/op/util/op_types.hpp" #include "ngraph/opsets/opset1.hpp" #include "onnx_import/onnx.hpp" -#include "util/engine/interpreter_engine.hpp" -#include "util/onnx_test_util.hpp" -#include "util/test_case.hpp" +#include "onnx_test_util.hpp" #include "util/test_control.hpp" NGRAPH_SUPPRESS_DEPRECATED_START diff --git a/ngraph/test/onnx/onnx_import.in.cpp b/ngraph/test/onnx/onnx_import.in.cpp index 25f0899f0f5..e3be4a31d70 100644 --- a/ngraph/test/onnx/onnx_import.in.cpp +++ b/ngraph/test/onnx/onnx_import.in.cpp @@ -33,9 +33,9 @@ #include "util/all_close.hpp" #include "util/all_close_f.hpp" #include "util/ndarray.hpp" -#include "util/test_case.hpp" +#include "engines_util/test_case.hpp" #include "util/test_control.hpp" -#include "util/engine/test_engines.hpp" +#include "engines_util/test_engines.hpp" #include "util/test_tools.hpp" #include "util/type_prop.hpp" #include diff --git a/ngraph/test/onnx/onnx_import_controlflow.in.cpp b/ngraph/test/onnx/onnx_import_controlflow.in.cpp index 6a29e1d8587..025e4a0ba6b 100644 --- a/ngraph/test/onnx/onnx_import_controlflow.in.cpp +++ b/ngraph/test/onnx/onnx_import_controlflow.in.cpp @@ -3,13 +3,13 @@ // #include "default_opset.hpp" +#include "engines_util/test_case.hpp" +#include "engines_util/test_engines.hpp" #include "gtest/gtest.h" #include "ngraph/file_util.hpp" #include "ngraph/type.hpp" #include "ngraph/type/element_type.hpp" #include "onnx_import/onnx.hpp" -#include "util/engine/test_engines.hpp" -#include "util/test_case.hpp" #include "util/test_control.hpp" #include "util/test_tools.hpp" #include "util/type_prop.hpp" diff --git a/ngraph/test/onnx/onnx_import_convpool.in.cpp b/ngraph/test/onnx/onnx_import_convpool.in.cpp index 2a6d3fa76b0..ad0db7ccd58 100644 --- a/ngraph/test/onnx/onnx_import_convpool.in.cpp +++ b/ngraph/test/onnx/onnx_import_convpool.in.cpp @@ -13,14 +13,14 @@ #include #include +#include "engines_util/test_case.hpp" +#include "engines_util/test_engines.hpp" #include "gtest/gtest.h" #include "ngraph/ngraph.hpp" #include "onnx_import/onnx.hpp" #include "util/all_close.hpp" #include "util/all_close_f.hpp" -#include "util/engine/test_engines.hpp" #include "util/ndarray.hpp" -#include "util/test_case.hpp" #include "util/test_control.hpp" #include "util/test_tools.hpp" diff --git a/ngraph/test/onnx/onnx_import_deprecated.in.cpp b/ngraph/test/onnx/onnx_import_deprecated.in.cpp index cff0441e095..cb756bfedca 100644 --- a/ngraph/test/onnx/onnx_import_deprecated.in.cpp +++ b/ngraph/test/onnx/onnx_import_deprecated.in.cpp @@ -13,14 +13,14 @@ #include #include +#include "engines_util/test_case.hpp" +#include "engines_util/test_engines.hpp" #include "gtest/gtest.h" #include "ngraph/ngraph.hpp" #include "onnx_import/onnx.hpp" #include "util/all_close.hpp" #include "util/all_close_f.hpp" -#include "util/engine/test_engines.hpp" #include "util/ndarray.hpp" -#include "util/test_case.hpp" #include "util/test_control.hpp" #include "util/test_tools.hpp" diff --git a/ngraph/test/onnx/onnx_import_dyn_shapes.in.cpp b/ngraph/test/onnx/onnx_import_dyn_shapes.in.cpp index caf1d251a2d..6b7535e6319 100644 --- a/ngraph/test/onnx/onnx_import_dyn_shapes.in.cpp +++ b/ngraph/test/onnx/onnx_import_dyn_shapes.in.cpp @@ -19,8 +19,8 @@ #include "ngraph/file_util.hpp" #include "default_opset.hpp" #include "onnx_import/onnx.hpp" -#include "util/engine/test_engines.hpp" -#include "util/test_case.hpp" +#include "engines_util/test_engines.hpp" +#include "engines_util/test_case.hpp" #include "util/test_control.hpp" #include "util/test_tools.hpp" #include "util/type_prop.hpp" diff --git a/ngraph/test/onnx/onnx_import_external_data.in.cpp b/ngraph/test/onnx/onnx_import_external_data.in.cpp index 32f8d4e62b5..80874d5d79f 100644 --- a/ngraph/test/onnx/onnx_import_external_data.in.cpp +++ b/ngraph/test/onnx/onnx_import_external_data.in.cpp @@ -3,12 +3,12 @@ // #include "default_opset.hpp" +#include "engines_util/test_case.hpp" +#include "engines_util/test_engines.hpp" #include "gtest/gtest.h" #include "ngraph/file_util.hpp" #include "ngraph/type/element_type.hpp" #include "onnx_import/onnx.hpp" -#include "util/engine/test_engines.hpp" -#include "util/test_case.hpp" #include "util/test_control.hpp" #include "util/test_tools.hpp" #include "util/type_prop.hpp" diff --git a/ngraph/test/onnx/onnx_import_org_openvino.in.cpp b/ngraph/test/onnx/onnx_import_org_openvino.in.cpp index 71d47ae099d..e3e46eb5b85 100644 --- a/ngraph/test/onnx/onnx_import_org_openvino.in.cpp +++ b/ngraph/test/onnx/onnx_import_org_openvino.in.cpp @@ -33,9 +33,9 @@ #include "util/all_close.hpp" #include "util/all_close_f.hpp" #include "util/ndarray.hpp" -#include "util/test_case.hpp" +#include "engines_util/test_case.hpp" #include "util/test_control.hpp" -#include "util/engine/test_engines.hpp" +#include "engines_util/test_engines.hpp" #include "util/test_tools.hpp" #include "util/type_prop.hpp" diff --git a/ngraph/test/onnx/onnx_import_quant.in.cpp b/ngraph/test/onnx/onnx_import_quant.in.cpp index cfb3a918785..551952ee090 100644 --- a/ngraph/test/onnx/onnx_import_quant.in.cpp +++ b/ngraph/test/onnx/onnx_import_quant.in.cpp @@ -13,14 +13,14 @@ #include #include +#include "engines_util/test_case.hpp" +#include "engines_util/test_engines.hpp" #include "gtest/gtest.h" #include "ngraph/ngraph.hpp" #include "onnx_import/onnx.hpp" #include "util/all_close.hpp" #include "util/all_close_f.hpp" -#include "util/engine/test_engines.hpp" #include "util/ndarray.hpp" -#include "util/test_case.hpp" #include "util/test_control.hpp" #include "util/test_tools.hpp" diff --git a/ngraph/test/onnx/onnx_import_reshape.in.cpp b/ngraph/test/onnx/onnx_import_reshape.in.cpp index 78bc5cdac1b..9430f7acb13 100644 --- a/ngraph/test/onnx/onnx_import_reshape.in.cpp +++ b/ngraph/test/onnx/onnx_import_reshape.in.cpp @@ -12,14 +12,15 @@ #include #include +#include "engines_util/execute_tools.hpp" +#include "engines_util/test_case.hpp" +#include "engines_util/test_engines.hpp" #include "gtest/gtest.h" #include "ngraph/ngraph.hpp" #include "onnx_import/onnx.hpp" #include "util/all_close.hpp" #include "util/all_close_f.hpp" -#include "util/engine/test_engines.hpp" #include "util/ndarray.hpp" -#include "util/test_case.hpp" #include "util/test_control.hpp" #include "util/test_tools.hpp" diff --git a/ngraph/test/onnx/onnx_import_rnn.in.cpp b/ngraph/test/onnx/onnx_import_rnn.in.cpp index 39f7b313e8b..bb6d894e8ac 100644 --- a/ngraph/test/onnx/onnx_import_rnn.in.cpp +++ b/ngraph/test/onnx/onnx_import_rnn.in.cpp @@ -13,14 +13,14 @@ #include #include +#include "engines_util/test_case.hpp" +#include "engines_util/test_engines.hpp" #include "gtest/gtest.h" #include "ngraph/ngraph.hpp" #include "onnx_import/onnx.hpp" #include "util/all_close.hpp" #include "util/all_close_f.hpp" -#include "util/engine/test_engines.hpp" #include "util/ndarray.hpp" -#include "util/test_case.hpp" #include "util/test_control.hpp" #include "util/test_tools.hpp" diff --git a/ngraph/test/onnx/onnx_import_with_editor.in.cpp b/ngraph/test/onnx/onnx_import_with_editor.in.cpp index 283d7b2ded2..88aef0c548a 100644 --- a/ngraph/test/onnx/onnx_import_with_editor.in.cpp +++ b/ngraph/test/onnx/onnx_import_with_editor.in.cpp @@ -14,9 +14,9 @@ #include "gtest/gtest.h" #include "editor.hpp" #include "ngraph/ngraph.hpp" -#include "util/test_case.hpp" +#include "engines_util/test_case.hpp" #include "util/test_control.hpp" -#include "util/engine/test_engines.hpp" +#include "engines_util/test_engines.hpp" using namespace ngraph; diff --git a/ngraph/test/onnx/onnx_tensor_names.cpp b/ngraph/test/onnx/onnx_tensor_names.cpp index aaccafd37ff..198f8f4d2a1 100644 --- a/ngraph/test/onnx/onnx_tensor_names.cpp +++ b/ngraph/test/onnx/onnx_tensor_names.cpp @@ -2,11 +2,11 @@ // SPDX-License-Identifier: Apache-2.0 // +#include "engines_util/test_case.hpp" #include "gtest/gtest.h" #include "ngraph/ngraph.hpp" #include "onnx_import/onnx.hpp" #include "onnx_import/onnx_utils.hpp" -#include "util/test_case.hpp" #include "util/test_control.hpp" NGRAPH_SUPPRESS_DEPRECATED_START diff --git a/ngraph/test/onnx/onnx_test_utils.in.cpp b/ngraph/test/onnx/onnx_test_utils.in.cpp index 8b6bba6a680..40ce14c5956 100644 --- a/ngraph/test/onnx/onnx_test_utils.in.cpp +++ b/ngraph/test/onnx/onnx_test_utils.in.cpp @@ -7,14 +7,14 @@ #include "default_opset.hpp" #include "editor.hpp" +#include "engines_util/test_case.hpp" +#include "engines_util/test_engines.hpp" #include "gtest/gtest.h" #include "ngraph/file_util.hpp" #include "ngraph/op/util/op_types.hpp" #include "onnx_import/onnx.hpp" #include "util/all_close.hpp" #include "util/all_close_f.hpp" -#include "util/engine/test_engines.hpp" -#include "util/test_case.hpp" #include "util/test_control.hpp" #include "util/test_tools.hpp" diff --git a/ngraph/test/onnx_test_util/CMakeLists.txt b/ngraph/test/onnx_test_util/CMakeLists.txt new file mode 100644 index 00000000000..4c8195f8b1e --- /dev/null +++ b/ngraph/test/onnx_test_util/CMakeLists.txt @@ -0,0 +1,16 @@ +# Copyright (C) 2018-2021 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 +# + +file(GLOB_RECURSE ONNX_UTIL_SRC "${CMAKE_CURRENT_SOURCE_DIR}/*.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/*.hpp") + +add_library(onnx_test_util STATIC ${ONNX_UTIL_SRC}) + +if(COMMAND ie_faster_build) + ie_faster_build(onnx_test_util UNITY) +endif() + +target_link_libraries(onnx_test_util PRIVATE onnx_common) +target_include_directories(onnx_test_util PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) + +add_clang_format_target(onnx_test_util_clang FOR_SOURCES ${ONNX_UTIL_SRC}) diff --git a/ngraph/test/util/onnx_test_util.cpp b/ngraph/test/onnx_test_util/onnx_test_util.cpp similarity index 100% rename from ngraph/test/util/onnx_test_util.cpp rename to ngraph/test/onnx_test_util/onnx_test_util.cpp diff --git a/ngraph/test/util/onnx_test_util.hpp b/ngraph/test/onnx_test_util/onnx_test_util.hpp similarity index 100% rename from ngraph/test/util/onnx_test_util.hpp rename to ngraph/test/onnx_test_util/onnx_test_util.hpp diff --git a/ngraph/test/op_eval/binary_convolution.cpp b/ngraph/test/op_eval/binary_convolution.cpp index eb8ed95c690..17ff77c8f88 100644 --- a/ngraph/test/op_eval/binary_convolution.cpp +++ b/ngraph/test/op_eval/binary_convolution.cpp @@ -2,6 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 // +#include "engines_util/execute_tools.hpp" #include "gtest/gtest.h" #include "ngraph/ngraph.hpp" #include "ngraph/runtime/tensor.hpp" diff --git a/ngraph/test/op_eval/bucketize.cpp b/ngraph/test/op_eval/bucketize.cpp index e49844601f4..ad8c1cc2631 100644 --- a/ngraph/test/op_eval/bucketize.cpp +++ b/ngraph/test/op_eval/bucketize.cpp @@ -2,11 +2,11 @@ // SPDX-License-Identifier: Apache-2.0 // +#include "engines_util/interpreter_engine.hpp" +#include "engines_util/test_case.hpp" +#include "engines_util/test_engines.hpp" #include "gtest/gtest.h" #include "ngraph/ngraph.hpp" -#include "util/engine/interpreter_engine.hpp" -#include "util/engine/test_engines.hpp" -#include "util/test_case.hpp" #include "util/test_control.hpp" using namespace std; diff --git a/ngraph/test/op_eval/clamp.cpp b/ngraph/test/op_eval/clamp.cpp index 3fc457db5d6..c554896bad4 100644 --- a/ngraph/test/op_eval/clamp.cpp +++ b/ngraph/test/op_eval/clamp.cpp @@ -14,11 +14,11 @@ // limitations under the License. //***************************************************************************** +#include "engines_util/interpreter_engine.hpp" +#include "engines_util/test_case.hpp" +#include "engines_util/test_engines.hpp" #include "gtest/gtest.h" #include "ngraph/ngraph.hpp" -#include "util/engine/interpreter_engine.hpp" -#include "util/engine/test_engines.hpp" -#include "util/test_case.hpp" #include "util/test_control.hpp" using namespace std; diff --git a/ngraph/test/op_eval/einsum.cpp b/ngraph/test/op_eval/einsum.cpp index 79187bdd7b2..205b2d7206d 100644 --- a/ngraph/test/op_eval/einsum.cpp +++ b/ngraph/test/op_eval/einsum.cpp @@ -7,13 +7,13 @@ #include #include +#include "engines_util/interpreter_engine.hpp" +#include "engines_util/test_case.hpp" +#include "engines_util/test_engines.hpp" #include "gtest/gtest.h" #include "ngraph/runtime/host_tensor.hpp" #include "ngraph/validation_util.hpp" #include "runtime/backend.hpp" -#include "util/engine/interpreter_engine.hpp" -#include "util/engine/test_engines.hpp" -#include "util/test_case.hpp" #include "util/test_tools.hpp" using namespace std; diff --git a/ngraph/test/op_eval/floor_mod.cpp b/ngraph/test/op_eval/floor_mod.cpp index 429c3ce40b6..1d07ebd4181 100644 --- a/ngraph/test/op_eval/floor_mod.cpp +++ b/ngraph/test/op_eval/floor_mod.cpp @@ -7,11 +7,11 @@ #include #include +#include "engines_util/interpreter_engine.hpp" +#include "engines_util/test_case.hpp" +#include "engines_util/test_engines.hpp" #include "gtest/gtest.h" #include "ngraph/ngraph.hpp" -#include "util/engine/interpreter_engine.hpp" -#include "util/engine/test_engines.hpp" -#include "util/test_case.hpp" #include "util/test_control.hpp" using namespace std; diff --git a/ngraph/test/op_eval/gelu.cpp b/ngraph/test/op_eval/gelu.cpp index 05e3a743af3..28f472a4b49 100644 --- a/ngraph/test/op_eval/gelu.cpp +++ b/ngraph/test/op_eval/gelu.cpp @@ -7,6 +7,7 @@ #include #include +#include "engines_util/execute_tools.hpp" #include "gtest/gtest.h" #include "ngraph/runtime/host_tensor.hpp" #include "ngraph/validation_util.hpp" diff --git a/ngraph/test/op_eval/hsigmoid.cpp b/ngraph/test/op_eval/hsigmoid.cpp index 67ba89e201b..03dec2745df 100644 --- a/ngraph/test/op_eval/hsigmoid.cpp +++ b/ngraph/test/op_eval/hsigmoid.cpp @@ -7,6 +7,7 @@ #include #include +#include "engines_util/execute_tools.hpp" #include "gtest/gtest.h" #include "ngraph/runtime/host_tensor.hpp" #include "ngraph/validation_util.hpp" diff --git a/ngraph/test/op_eval/hswish.cpp b/ngraph/test/op_eval/hswish.cpp index 06a3f55f37c..e6066b00687 100644 --- a/ngraph/test/op_eval/hswish.cpp +++ b/ngraph/test/op_eval/hswish.cpp @@ -7,6 +7,7 @@ #include #include +#include "engines_util/execute_tools.hpp" #include "gtest/gtest.h" #include "ngraph/runtime/host_tensor.hpp" #include "ngraph/validation_util.hpp" diff --git a/ngraph/test/op_eval/interpolate.cpp b/ngraph/test/op_eval/interpolate.cpp index 7ddb2c3b64e..f484edc75bf 100644 --- a/ngraph/test/op_eval/interpolate.cpp +++ b/ngraph/test/op_eval/interpolate.cpp @@ -7,6 +7,7 @@ #include #include +#include "engines_util/execute_tools.hpp" #include "gtest/gtest.h" #include "ngraph/op/constant.hpp" #include "ngraph/runtime/host_tensor.hpp" diff --git a/ngraph/test/op_eval/matmul.cpp b/ngraph/test/op_eval/matmul.cpp index b98c5b2d5e2..eacbd7d278e 100644 --- a/ngraph/test/op_eval/matmul.cpp +++ b/ngraph/test/op_eval/matmul.cpp @@ -7,6 +7,7 @@ #include #include +#include "engines_util/execute_tools.hpp" #include "gtest/gtest.h" #include "ngraph/runtime/host_tensor.hpp" #include "util/all_close_f.hpp" diff --git a/ngraph/test/op_eval/memory.cpp b/ngraph/test/op_eval/memory.cpp index bdb5ee98907..9475240bac6 100644 --- a/ngraph/test/op_eval/memory.cpp +++ b/ngraph/test/op_eval/memory.cpp @@ -5,6 +5,7 @@ #include #include +#include "engines_util/execute_tools.hpp" #include "gtest/gtest.h" #include "ngraph/op/util/variable.hpp" #include "ngraph/op/util/variable_context.hpp" diff --git a/ngraph/test/op_eval/mish.cpp b/ngraph/test/op_eval/mish.cpp index cc657c865e2..c4ba4a6d741 100644 --- a/ngraph/test/op_eval/mish.cpp +++ b/ngraph/test/op_eval/mish.cpp @@ -7,6 +7,7 @@ #include #include +#include "engines_util/execute_tools.hpp" #include "gtest/gtest.h" #include "ngraph/runtime/host_tensor.hpp" #include "ngraph/validation_util.hpp" diff --git a/ngraph/test/op_eval/non_zero.cpp b/ngraph/test/op_eval/non_zero.cpp index 077c40f4c97..bb5cb7ad45b 100644 --- a/ngraph/test/op_eval/non_zero.cpp +++ b/ngraph/test/op_eval/non_zero.cpp @@ -7,6 +7,7 @@ #include #include +#include "engines_util/execute_tools.hpp" #include "gtest/gtest.h" #include "ngraph/runtime/host_tensor.hpp" #include "ngraph/validation_util.hpp" diff --git a/ngraph/test/op_eval/roi_align.cpp b/ngraph/test/op_eval/roi_align.cpp index bc484b677a2..89c6807f380 100644 --- a/ngraph/test/op_eval/roi_align.cpp +++ b/ngraph/test/op_eval/roi_align.cpp @@ -7,6 +7,7 @@ #include #include +#include "engines_util/execute_tools.hpp" #include "gtest/gtest.h" #include "ngraph/runtime/host_tensor.hpp" #include "ngraph/validation_util.hpp" diff --git a/ngraph/test/op_eval/roi_pooling.cpp b/ngraph/test/op_eval/roi_pooling.cpp index 0570c1f1b87..374ae8d15e3 100644 --- a/ngraph/test/op_eval/roi_pooling.cpp +++ b/ngraph/test/op_eval/roi_pooling.cpp @@ -2,11 +2,11 @@ // SPDX-License-Identifier: Apache-2.0 // +#include "engines_util/interpreter_engine.hpp" +#include "engines_util/test_case.hpp" +#include "engines_util/test_engines.hpp" #include "gtest/gtest.h" #include "ngraph/ngraph.hpp" -#include "util/engine/interpreter_engine.hpp" -#include "util/engine/test_engines.hpp" -#include "util/test_case.hpp" #include "util/test_control.hpp" using namespace std; diff --git a/ngraph/test/op_eval/round.cpp b/ngraph/test/op_eval/round.cpp index ca97d826b02..4deb47df5a5 100644 --- a/ngraph/test/op_eval/round.cpp +++ b/ngraph/test/op_eval/round.cpp @@ -7,6 +7,7 @@ #include #include +#include "engines_util/execute_tools.hpp" #include "gtest/gtest.h" #include "ngraph/runtime/host_tensor.hpp" #include "ngraph/validation_util.hpp" diff --git a/ngraph/test/op_eval/softplus.cpp b/ngraph/test/op_eval/softplus.cpp index 8ca5dc26ce3..757998c34aa 100644 --- a/ngraph/test/op_eval/softplus.cpp +++ b/ngraph/test/op_eval/softplus.cpp @@ -7,6 +7,7 @@ #include #include +#include "engines_util/execute_tools.hpp" #include "gtest/gtest.h" #include "ngraph/runtime/host_tensor.hpp" #include "ngraph/validation_util.hpp" diff --git a/ngraph/test/op_eval/split.cpp b/ngraph/test/op_eval/split.cpp index f62360a1ef3..3742c71330e 100644 --- a/ngraph/test/op_eval/split.cpp +++ b/ngraph/test/op_eval/split.cpp @@ -7,6 +7,7 @@ #include #include +#include "engines_util/execute_tools.hpp" #include "gtest/gtest.h" #include "ngraph/runtime/host_tensor.hpp" #include "ngraph/validation_util.hpp" diff --git a/ngraph/test/op_eval/strided_slice.cpp b/ngraph/test/op_eval/strided_slice.cpp index b8030b5a7c5..4801e1a3f53 100644 --- a/ngraph/test/op_eval/strided_slice.cpp +++ b/ngraph/test/op_eval/strided_slice.cpp @@ -7,6 +7,7 @@ #include #include +#include "engines_util/execute_tools.hpp" #include "gtest/gtest.h" #include "ngraph/runtime/host_tensor.hpp" #include "ngraph/validation_util.hpp" diff --git a/ngraph/test/op_eval/swish.cpp b/ngraph/test/op_eval/swish.cpp index 5213a658411..40190d7770c 100644 --- a/ngraph/test/op_eval/swish.cpp +++ b/ngraph/test/op_eval/swish.cpp @@ -7,6 +7,7 @@ #include #include +#include "engines_util/execute_tools.hpp" #include "gtest/gtest.h" #include "ngraph/runtime/host_tensor.hpp" #include "ngraph/validation_util.hpp" diff --git a/ngraph/test/op_eval/transpose.cpp b/ngraph/test/op_eval/transpose.cpp index 64e2f77bf5f..b3af1e4c4aa 100644 --- a/ngraph/test/op_eval/transpose.cpp +++ b/ngraph/test/op_eval/transpose.cpp @@ -7,6 +7,7 @@ #include #include +#include "engines_util/execute_tools.hpp" #include "gtest/gtest.h" #include "ngraph/runtime/host_tensor.hpp" #include "ngraph/runtime/reference/transpose.hpp" diff --git a/ngraph/test/op_eval/variadic_split.cpp b/ngraph/test/op_eval/variadic_split.cpp index ba80ad1ea9c..dce2127d377 100644 --- a/ngraph/test/op_eval/variadic_split.cpp +++ b/ngraph/test/op_eval/variadic_split.cpp @@ -1,12 +1,12 @@ // Copyright (C) 2018-2021 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // - #include "ngraph/op/variadic_split.hpp" #include #include +#include "engines_util/execute_tools.hpp" #include "gtest/gtest.h" #include "ngraph/runtime/host_tensor.hpp" #include "ngraph/validation_util.hpp" diff --git a/ngraph/test/pass_manager.cpp b/ngraph/test/pass_manager.cpp index 2251fc994e3..2aad079bec3 100644 --- a/ngraph/test/pass_manager.cpp +++ b/ngraph/test/pass_manager.cpp @@ -7,6 +7,7 @@ #include #include +#include "engines_util/execute_tools.hpp" #include "gtest/gtest.h" #include "ngraph/graph_util.hpp" #include "ngraph/ngraph.hpp" diff --git a/ngraph/test/type_prop/framework_node.cpp b/ngraph/test/type_prop/framework_node.cpp new file mode 100644 index 00000000000..8a2ebe8ee75 --- /dev/null +++ b/ngraph/test/type_prop/framework_node.cpp @@ -0,0 +1,52 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "openvino/op/util/framework_node.hpp" + +#include + +#include "openvino/opsets/opset8.hpp" +#include "util/type_prop.hpp" + +using namespace std; + +TEST(type_prop, framework_node) { + auto param = std::make_shared(ov::element::i64, ov::Shape{1, 64}); + auto f_node = std::make_shared(ov::OutputVector{param}); + f_node->set_output_type(0, ov::element::i64, ov::Shape{1, 64}); + + // Set partially dynamic shape + param->set_partial_shape(ov::PartialShape{ov::Dimension::dynamic(), 64}); + param->validate_and_infer_types(); + + ASSERT_NO_THROW(f_node->validate_and_infer_types()); + ASSERT_EQ(f_node->get_output_partial_shape(0), ov::PartialShape::dynamic()); + + // Set dynamic shape + param->set_partial_shape(ov::PartialShape::dynamic(2)); + param->validate_and_infer_types(); + + ASSERT_NO_THROW(f_node->validate_and_infer_types()); + ASSERT_EQ(f_node->get_output_partial_shape(0), ov::PartialShape::dynamic()); + + // Set fully dynamic shape + param->set_partial_shape(ov::PartialShape::dynamic()); + param->validate_and_infer_types(); + + ASSERT_NO_THROW(f_node->validate_and_infer_types()); + ASSERT_EQ(f_node->get_output_partial_shape(0), ov::PartialShape::dynamic()); + + // Set original static shape + param->set_partial_shape(ov::Shape{1, 64}); + param->validate_and_infer_types(); + + ASSERT_NO_THROW(f_node->validate_and_infer_types()); + ASSERT_EQ(f_node->get_output_partial_shape(0), ov::PartialShape({1, 64})); + + // Set different static shape + param->set_partial_shape(ov::Shape{2, 64}); + param->validate_and_infer_types(); + + ASSERT_THROW(f_node->validate_and_infer_types(), ov::Exception); +} diff --git a/ngraph/test/util.cpp b/ngraph/test/util.cpp index 0d57bd8d8be..b8f2117eeff 100644 --- a/ngraph/test/util.cpp +++ b/ngraph/test/util.cpp @@ -7,6 +7,7 @@ #include #include +#include "execute_tools.hpp" #include "gtest/gtest.h" #include "ngraph/file_util.hpp" #include "ngraph/function.hpp" diff --git a/ngraph/test/util/CMakeLists.txt b/ngraph/test/util/CMakeLists.txt index b00e502b03b..2ff5b1ed76e 100644 --- a/ngraph/test/util/CMakeLists.txt +++ b/ngraph/test/util/CMakeLists.txt @@ -2,36 +2,19 @@ # SPDX-License-Identifier: Apache-2.0 # -set (SRC - all_close_f.cpp - engine/ie_engines.cpp - engine/interpreter_engine.cpp - engine/shared_utils.cpp - float_util.cpp - test_tools.cpp - test_case.cpp - test_control.cpp - visitor.hpp - provenance_enabler.hpp -) -if (NGRAPH_ONNX_FRONTEND_ENABLE) - list(APPEND SRC onnx_test_util.cpp) -endif() +file(GLOB_RECURSE UTIL_SRC "${CMAKE_CURRENT_SOURCE_DIR}/*.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/*.hpp") -add_library(ngraph_test_util STATIC ${SRC}) +add_library(ngraph_test_util STATIC ${UTIL_SRC}) if(COMMAND ie_faster_build) - ie_faster_build(ngraph_test_util - UNITY - ) + ie_faster_build(ngraph_test_util UNITY) endif() -target_include_directories(ngraph_test_util PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/.. - $) -target_link_libraries(ngraph_test_util PUBLIC ngraph ngraph_backend gtest gmock) -if (NGRAPH_ONNX_FRONTEND_ENABLE) - target_link_libraries(ngraph_test_util PRIVATE onnx_common) -endif() +target_link_libraries(ngraph_test_util PUBLIC ngraph gtest gmock) +target_include_directories(ngraph_test_util PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) -file(GLOB_RECURSE util_src "${CMAKE_CURRENT_SOURCE_DIR}/*.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/*.hpp") -add_clang_format_target(ngraph_test_util_clang FOR_SOURCES ${util_src}) +file(GLOB_RECURSE all_util_src "${CMAKE_CURRENT_SOURCE_DIR}/*.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/*.hpp") +add_clang_format_target(ngraph_test_util_clang FOR_SOURCES ${all_util_src}) + +# developer package +openvino_developer_export_targets(COMPONENT ngraph TARGETS ngraph_test_util) diff --git a/ngraph/test/util/all_close.hpp b/ngraph/test/util/all_close.hpp index 662f148d9e7..5d8bc01ba97 100644 --- a/ngraph/test/util/all_close.hpp +++ b/ngraph/test/util/all_close.hpp @@ -11,8 +11,6 @@ #include "gtest/gtest.h" #include "ngraph/pass/manager.hpp" #include "ngraph/type/element_type.hpp" -#include "random.hpp" -#include "test_tools.hpp" namespace ngraph { namespace test { diff --git a/ngraph/test/util/all_close_f.cpp b/ngraph/test/util/all_close_f.cpp index 036ae5b301c..ce33e33692e 100644 --- a/ngraph/test/util/all_close_f.cpp +++ b/ngraph/test/util/all_close_f.cpp @@ -2,7 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "util/all_close_f.hpp" +#include "all_close_f.hpp" #include #include diff --git a/ngraph/test/util/all_close_f.hpp b/ngraph/test/util/all_close_f.hpp index fe5740b2006..522d7074905 100644 --- a/ngraph/test/util/all_close_f.hpp +++ b/ngraph/test/util/all_close_f.hpp @@ -8,7 +8,7 @@ #include #include "gtest/gtest.h" -#include "test_tools.hpp" +#include "ngraph/runtime/tensor.hpp" static constexpr int BFLOAT_MANTISSA_BITS = 8; static constexpr int FLOAT_MANTISSA_BITS = 24; diff --git a/ngraph/test/util/float_util.cpp b/ngraph/test/util/float_util.cpp index 61e70351706..d4d0f7f23d2 100644 --- a/ngraph/test/util/float_util.cpp +++ b/ngraph/test/util/float_util.cpp @@ -2,7 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "util/float_util.hpp" +#include "float_util.hpp" std::string ngraph::test::bfloat16_to_bits(bfloat16 f) { std::stringstream ss; diff --git a/inference-engine/tests/ie_test_utils/common_test_utils/ngraph_test_utils.cpp b/ngraph/test/util/graph_comparator.cpp similarity index 56% rename from inference-engine/tests/ie_test_utils/common_test_utils/ngraph_test_utils.cpp rename to ngraph/test/util/graph_comparator.cpp index 281013b887b..2feb1ccea64 100644 --- a/inference-engine/tests/ie_test_utils/common_test_utils/ngraph_test_utils.cpp +++ b/ngraph/test/util/graph_comparator.cpp @@ -2,7 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "ngraph_test_utils.hpp" +#include "graph_comparator.hpp" #include #include @@ -10,6 +10,9 @@ #include #include #include +#include +#include +#include #include #include #include @@ -17,46 +20,37 @@ #include #include -#include -#include -#include -#include -#include -#include - namespace { inline namespace tools { -bool isTypeRelaxed(const std::string &type) { +bool is_type_relaxed(const std::string& type) { return type.find_first_of("TypeRelaxed") == 0; } -bool compareTypeInfo(const ngraph::DiscreteTypeInfo &info1, const ngraph::DiscreteTypeInfo &info2) { - if (!isTypeRelaxed(info1.name) && !isTypeRelaxed(info2.name) && - (info1.version != info2.version)) { +bool compare_type_info(const ngraph::DiscreteTypeInfo& info1, const ngraph::DiscreteTypeInfo& info2) { + if (!is_type_relaxed(info1.name) && !is_type_relaxed(info2.name) && (info1.version != info2.version)) { return false; } const std::string info1Name = - isTypeRelaxed(info1.name) && (info1.parent != nullptr) ? info1.parent->name : info1.name; + is_type_relaxed(info1.name) && (info1.parent != nullptr) ? info1.parent->name : info1.name; const std::string info2Name = - isTypeRelaxed(info2.name) && (info2.parent != nullptr) ? info2.parent->name : info2.name; + is_type_relaxed(info2.name) && (info2.parent != nullptr) ? info2.parent->name : info2.name; return info1Name == info2Name; } -template -bool compare_rt_keys(const Node &node1, const Node &node2) { +template +bool compare_rt_keys(const Node& node1, const Node& node2) { // The "opset" parameter in RT info is optional // and mandatory only for TypeRelaxed operations. // Therefore, we ignore this key when comparing RT keys. - const auto &first_node_rt_info = node1->get_rt_info(); - const auto &second_node_rt_info = node2->get_rt_info(); + const auto& first_node_rt_info = node1->get_rt_info(); + const auto& second_node_rt_info = node2->get_rt_info(); auto first_node_rt_info_it = first_node_rt_info.begin(); auto second_node_rt_info_it = second_node_rt_info.begin(); - while (first_node_rt_info_it != first_node_rt_info.end() - && second_node_rt_info_it != second_node_rt_info.end()) { + while (first_node_rt_info_it != first_node_rt_info.end() && second_node_rt_info_it != second_node_rt_info.end()) { bool is_continue = false; if (first_node_rt_info_it->first == "opset") { ++first_node_rt_info_it; @@ -75,39 +69,32 @@ bool compare_rt_keys(const Node &node1, const Node &node2) { ++second_node_rt_info_it; } - if (first_node_rt_info_it != first_node_rt_info.end() - && first_node_rt_info_it->first == "opset") { + if (first_node_rt_info_it != first_node_rt_info.end() && first_node_rt_info_it->first == "opset") { ++first_node_rt_info_it; } - if (second_node_rt_info_it != second_node_rt_info.end() - && second_node_rt_info_it->first == "opset") { + if (second_node_rt_info_it != second_node_rt_info.end() && second_node_rt_info_it->first == "opset") { ++second_node_rt_info_it; } - return first_node_rt_info_it == first_node_rt_info.end() - && second_node_rt_info_it == second_node_rt_info.end(); + return first_node_rt_info_it == first_node_rt_info.end() && second_node_rt_info_it == second_node_rt_info.end(); } -bool less_by_name( - const std::shared_ptr &l, - const std::shared_ptr &r) { +bool less_by_name(const std::shared_ptr& l, const std::shared_ptr& r) { return l->get_friendly_name() < r->get_friendly_name(); } -bool less_by_parent_name( - const std::shared_ptr &l, - const std::shared_ptr &r) { +bool less_by_parent_name(const std::shared_ptr& l, + const std::shared_ptr& r) { return l->get_input_node_shared_ptr(0)->get_friendly_name() < r->get_input_node_shared_ptr(0)->get_friendly_name(); } -std::string typeInfoToStr(const ngraph::Node::type_info_t &typeInfo) { +std::string typeInfoToStr(const ngraph::Node::type_info_t& typeInfo) { return std::string(typeInfo.name) + "/" + to_str(typeInfo.version); } - -std::string tensor_names(const ngraph::descriptor::Tensor &t) { +std::string tensor_names(const ngraph::descriptor::Tensor& t) { std::string n; - const char *glue = ""; - for (const auto &name : t.get_names()) { + const char* glue = ""; + for (const auto& name : t.get_names()) { n.append(glue).append(name); glue = ", "; } @@ -119,70 +106,72 @@ namespace subgraph { namespace detail { -template -Ptr not_null(Ptr &&p) { +template +Ptr not_null(Ptr&& p) { if (!p) { - IE_THROW() << "empty pointer"; + throw ov::Exception("empty pointer"); } return std::forward(p); } -template -bool equal_type_and_partial_shape(const InOut1 &lhs, const InOut2 &rhs) { - return lhs.get_element_type() == rhs.get_element_type() && - lhs.get_partial_shape() == rhs.get_partial_shape(); +template +bool equal_type_and_partial_shape(const InOut1& lhs, const InOut2& rhs) { + return lhs.get_element_type() == rhs.get_element_type() && lhs.get_partial_shape() == rhs.get_partial_shape(); } class NodeAndInputDescription { public: - using SubGraphOp = ngraph::op::util::SubGraphOp; + using SubGraphOp = ov::op::util::SubGraphOp; using InputDescripton = SubGraphOp::InputDescription; using InputNode = ngraph::Input; - using Parameter = ngraph::opset6::Parameter; + using Parameter = ov::opset8::Parameter; - explicit NodeAndInputDescription( - const InputNode &input, const Parameter *parameter, const InputDescripton *description) - : m_input(input), m_parameter(not_null(parameter)), m_description(not_null(description)) {} + explicit NodeAndInputDescription(const InputNode& input, + const Parameter* parameter, + const InputDescripton* description) + : m_input(input), + m_parameter(not_null(parameter)), + m_description(not_null(description)) {} - static bool equal_descriptions(const InputDescripton *lhs, const InputDescripton *rhs) { + static bool equal_descriptions(const InputDescripton* lhs, const InputDescripton* rhs) { if (!lhs || !rhs || lhs->get_type_info() != rhs->get_type_info()) { return false; } if (lhs->get_type_info() == SubGraphOp::SliceInputDescription::get_type_info_static()) { using InDesc = SubGraphOp::SliceInputDescription; - const InDesc *l_input = static_cast(lhs); - const InDesc *r_input = static_cast(rhs); + const auto* l_input = static_cast(lhs); + const auto* r_input = static_cast(rhs); return l_input->m_start == r_input->m_start && l_input->m_stride == r_input->m_stride && - l_input->m_part_size == r_input->m_part_size && - l_input->m_end == r_input->m_end && l_input->m_axis == r_input->m_axis; + l_input->m_part_size == r_input->m_part_size && l_input->m_end == r_input->m_end && + l_input->m_axis == r_input->m_axis; } else if (lhs->get_type_info() == SubGraphOp::MergedInputDescription::get_type_info_static()) { return true; // noting extra to check } else if (lhs->get_type_info() == SubGraphOp::InvariantInputDescription::get_type_info_static()) { return true; // noting extra to check } - IE_THROW() << "Type is not supported: [" << lhs->get_type_info().name << "]"; - - return false; + std::stringstream ss; + ss << "Type is not supported: [" << lhs->get_type_info().name << "]"; + throw ov::Exception(ss.str()); } bool parameter_and_input_match(size_t num_iterations) const { - if (const SubGraphOp::SliceInputDescription *slice_description = + if (const SubGraphOp::SliceInputDescription* slice_description = ngraph::as_type(m_description)) { if (m_parameter->get_element_type() != m_input.get_element_type()) { return false; } - const auto ¶m_partial_shape = m_parameter->get_partial_shape(); - const auto &input_partial_shape = m_input.get_partial_shape(); + const auto& param_partial_shape = m_parameter->get_partial_shape(); + const auto& input_partial_shape = m_input.get_partial_shape(); if (param_partial_shape.is_dynamic() && input_partial_shape.is_dynamic()) { return true; } if (!param_partial_shape.is_static() || !input_partial_shape.is_static()) { return false; } - const auto ¶m_shape = param_partial_shape.to_shape(); - const auto &input_shape = input_partial_shape.to_shape(); + const auto& param_shape = param_partial_shape.to_shape(); + const auto& input_shape = input_partial_shape.to_shape(); if (param_shape.size() != input_shape.size()) { return false; } @@ -191,30 +180,27 @@ public: } for (size_t i = 0; i != param_shape.size(); ++i) { const auto expected_axis_size = - i == slice_description->m_axis ? slice_description->m_part_size * num_iterations - : param_shape[i]; + i == slice_description->m_axis ? slice_description->m_part_size * num_iterations : param_shape[i]; if (input_shape[i] != expected_axis_size) { return false; } } return true; - } else if ( - m_description->get_type_info() == SubGraphOp::MergedInputDescription::get_type_info_static() || - m_description->get_type_info() == SubGraphOp::InvariantInputDescription::get_type_info_static()) { + } else if (m_description->get_type_info() == SubGraphOp::MergedInputDescription::get_type_info_static() || + m_description->get_type_info() == SubGraphOp::InvariantInputDescription::get_type_info_static()) { return equal_type_and_partial_shape(*m_parameter, m_input); } - IE_THROW() << "Type is not supported: [" << m_description->get_type_info().name - << "]"; - - return false; + std::stringstream ss; + ss << "Type is not supported: [" << m_description->get_type_info().name << "]"; + throw ov::Exception(ss.str()); } - static bool equal_parameters(const Parameter *lhs, const Parameter *rhs) { + static bool equal_parameters(const Parameter* lhs, const Parameter* rhs) { return lhs && rhs && equal_type_and_partial_shape(*lhs, *rhs); } - friend bool operator==(const NodeAndInputDescription &lhs, const NodeAndInputDescription &rhs) { + friend bool operator==(const NodeAndInputDescription& lhs, const NodeAndInputDescription& rhs) { if (!equal_descriptions(lhs.m_description, rhs.m_description)) { return false; } @@ -223,63 +209,64 @@ public: private: const InputNode m_input; - const Parameter *m_parameter; - const InputDescripton *m_description; + const Parameter* m_parameter; + const InputDescripton* m_description; }; class NodeAndOutputDescription { public: - using SubGraphOp = ngraph::op::util::SubGraphOp; + using SubGraphOp = ov::op::util::SubGraphOp; using OutputDescription = SubGraphOp::OutputDescription; using OutputNode = ngraph::Output; - using Result = ngraph::opset6::Result; + using Result = ov::opset8::Result; - explicit NodeAndOutputDescription( - const OutputNode &output, const Result *result, const OutputDescription *description) - : m_output(output), m_result(not_null(result)), m_description(not_null(description)) {} + explicit NodeAndOutputDescription(const OutputNode& output, + const Result* result, + const OutputDescription* description) + : m_output(output), + m_result(not_null(result)), + m_description(not_null(description)) {} - static bool equal_descriptions(const OutputDescription *lhs, const OutputDescription *rhs) { + static bool equal_descriptions(const OutputDescription* lhs, const OutputDescription* rhs) { if (!lhs || !rhs || lhs->get_type_info() != rhs->get_type_info()) { return false; } if (lhs->get_type_info() == SubGraphOp::ConcatOutputDescription::get_type_info_static()) { using OutDesc = SubGraphOp::ConcatOutputDescription; - const OutDesc *l_output = static_cast(lhs); - const OutDesc *r_output = static_cast(rhs); - return l_output->m_start == r_output->m_start && - l_output->m_stride == r_output->m_stride && - l_output->m_part_size == r_output->m_part_size && - l_output->m_end == r_output->m_end && l_output->m_axis == r_output->m_axis; + const auto* l_output = static_cast(lhs); + const auto* r_output = static_cast(rhs); + return l_output->m_start == r_output->m_start && l_output->m_stride == r_output->m_stride && + l_output->m_part_size == r_output->m_part_size && l_output->m_end == r_output->m_end && + l_output->m_axis == r_output->m_axis; } else if (lhs->get_type_info() == SubGraphOp::BodyOutputDescription::get_type_info_static()) { using OutDesc = SubGraphOp::BodyOutputDescription; - const OutDesc *l_output = static_cast(lhs); - const OutDesc *r_output = static_cast(rhs); + const auto* l_output = static_cast(lhs); + const auto* r_output = static_cast(rhs); return l_output->m_iteration == r_output->m_iteration; } - IE_THROW() << "Type is not supported: [" << lhs->get_type_info().name << "]"; - - return false; + std::stringstream ss; + ss << "Type is not supported: [" << lhs->get_type_info().name << "]"; + throw ov::Exception(ss.str()); } bool result_and_output_match(size_t num_iterations) const { - if (const auto concat_desciption = - ngraph::as_type(m_description)) { + if (const auto concat_desciption = ngraph::as_type(m_description)) { if (m_result->output(0).get_element_type() != m_output.get_element_type()) { return false; } - const auto &output_partial_shape = m_output.get_partial_shape(); - const auto &result_partial_shape = m_result->output(0).get_partial_shape(); + const auto& output_partial_shape = m_output.get_partial_shape(); + const auto& result_partial_shape = m_result->output(0).get_partial_shape(); if (result_partial_shape.is_dynamic() && output_partial_shape.is_dynamic()) { return true; } if (!result_partial_shape.is_static() || !output_partial_shape.is_static()) { return false; } - const auto &output_shape = output_partial_shape.to_shape(); - const auto &result_shape = result_partial_shape.to_shape(); + const auto& output_shape = output_partial_shape.to_shape(); + const auto& result_shape = result_partial_shape.to_shape(); if (result_shape.size() != output_shape.size()) { return false; } @@ -294,18 +281,16 @@ public: return equal_type_and_partial_shape(m_result->output(0), m_output); } - IE_THROW() << "Type is not supported: [" << m_description->get_type_info().name - << "]"; - - return false; + std::stringstream ss; + ss << "Type is not supported: [" << m_description->get_type_info().name << "]"; + throw ov::Exception(ss.str()); } - static bool equal_results(const Result *lhs, const Result *rhs) { + static bool equal_results(const Result* lhs, const Result* rhs) { return lhs && rhs && equal_type_and_partial_shape(lhs->output(0), rhs->output(0)); } - friend bool operator==( - const NodeAndOutputDescription &lhs, const NodeAndOutputDescription &rhs) { + friend bool operator==(const NodeAndOutputDescription& lhs, const NodeAndOutputDescription& rhs) { if (!equal_descriptions(lhs.m_description, rhs.m_description)) { return false; } @@ -314,73 +299,73 @@ public: private: const OutputNode m_output; - const Result *m_result; - const OutputDescription *m_description; + const Result* m_result; + const OutputDescription* m_description; }; class BackEdge { public: - using Parameter = ngraph::opset6::Parameter; - using Result = ngraph::opset6::Result; + using Parameter = ov::opset8::Parameter; + using Result = ov::opset8::Result; using Id = uint64_t; - explicit BackEdge(const Parameter *parameter, const Result *result) - : m_parameter(not_null(parameter)), m_result(not_null(result)) {} + explicit BackEdge(const Parameter* parameter, const Result* result) + : m_parameter(not_null(parameter)), + m_result(not_null(result)) {} bool result_and_parameter_match() const { return equal_type_and_partial_shape(m_result->output(0), *m_parameter); } - friend bool operator==(const BackEdge &lhs, const BackEdge &rhs) { + friend bool operator==(const BackEdge& lhs, const BackEdge& rhs) { return equal_type_and_partial_shape(*lhs.m_parameter, *rhs.m_parameter) && equal_type_and_partial_shape(lhs.m_result->output(0), rhs.m_result->output(0)); } private: - const Parameter *m_parameter; - const Result *m_result; + const Parameter* m_parameter; + const Result* m_result; }; -std::vector extract_inputs(ngraph::op::util::SubGraphOp *sub) { +std::vector extract_inputs(ov::op::util::SubGraphOp* sub) { std::vector nodes; - const auto &fn_body = sub->get_function(); - const auto &fn_parameters = fn_body->get_parameters(); + const auto& fn_body = sub->get_function(); + const auto& fn_parameters = fn_body->get_parameters(); - for (const auto &in_desc : sub->get_input_descriptions()) { + for (const auto& in_desc : sub->get_input_descriptions()) { const auto parameter = fn_parameters.at(in_desc->m_body_parameter_index).get(); const auto input = sub->input(in_desc->m_input_index); - nodes.push_back(NodeAndInputDescription{input, parameter, in_desc.get()}); + nodes.emplace_back(input, parameter, in_desc.get()); } return nodes; } -std::vector extract_outputs(ngraph::op::util::SubGraphOp *sub) { +std::vector extract_outputs(ov::op::util::SubGraphOp* sub) { std::vector nodes; - const auto &fn_body = sub->get_function(); - const auto &fs_results = fn_body->get_results(); + const auto& fn_body = sub->get_function(); + const auto& fs_results = fn_body->get_results(); - for (const auto &out_desc : sub->get_output_descriptions()) { + for (const auto& out_desc : sub->get_output_descriptions()) { const auto result = fs_results.at(out_desc->m_body_value_index).get(); const auto output = sub->output(out_desc->m_output_index); - nodes.push_back(NodeAndOutputDescription{output, result, out_desc.get()}); + nodes.emplace_back(output, result, out_desc.get()); } return nodes; } -std::vector extract_backedges(ngraph::op::util::SubGraphOp *sub) { - using MergedInputDescription = ngraph::op::util::SubGraphOp::MergedInputDescription; +std::vector extract_backedges(ov::op::util::SubGraphOp* sub) { + using MergedInputDescription = ov::op::util::SubGraphOp::MergedInputDescription; std::vector edges; - const auto &fn_body = sub->get_function(); + const auto& fn_body = sub->get_function(); - const auto &fs_parameters = fn_body->get_parameters(); - const auto &fs_results = fn_body->get_results(); + const auto& fs_parameters = fn_body->get_parameters(); + const auto& fs_results = fn_body->get_results(); - for (const auto &in_desc : sub->get_input_descriptions()) { - if (const auto &merged_in_desc = - ngraph::as_type_ptr(in_desc)) { + for (const auto& in_desc : sub->get_input_descriptions()) { + if (const auto& merged_in_desc = ngraph::as_type_ptr(in_desc)) { const auto parameter = fs_parameters.at(merged_in_desc->m_body_parameter_index); const auto result = fs_results.at(merged_in_desc->m_body_value_index); - edges.push_back(BackEdge{parameter.get(), result.get()}); + edges.emplace_back(parameter.get(), result.get()); } } return edges; @@ -389,30 +374,30 @@ std::vector extract_backedges(ngraph::op::util::SubGraphOp *sub) { struct NotValidInputOrOutput { NotValidInputOrOutput(int64_t num_iterations) : m_num_iterations(num_iterations) {} - bool operator()(const NodeAndOutputDescription &d) const { + bool operator()(const NodeAndOutputDescription& d) const { return !d.result_and_output_match(m_num_iterations); } - bool operator()(const NodeAndInputDescription &d) const { + bool operator()(const NodeAndInputDescription& d) const { return !d.parameter_and_input_match(m_num_iterations); } int64_t m_num_iterations; }; -bool not_valid_back_edge(const BackEdge &be) { +bool not_valid_back_edge(const BackEdge& be) { return !be.result_and_parameter_match(); } -bool equal_body_ports(ngraph::opset6::Loop *lhs, ngraph::opset6::Loop *rhs) { +bool equal_body_ports(ov::opset8::Loop* lhs, ov::opset8::Loop* rhs) { if (!lhs || !rhs) { return false; } - const auto &lhs_fn_body = lhs->get_function(); - const auto &rhs_fn_body = rhs->get_function(); + const auto& lhs_fn_body = lhs->get_function(); + const auto& rhs_fn_body = rhs->get_function(); - const auto &lhs_sbp = lhs->get_special_body_ports(); - const auto &rhs_sbp = rhs->get_special_body_ports(); + const auto& lhs_sbp = lhs->get_special_body_ports(); + const auto& rhs_sbp = rhs->get_special_body_ports(); constexpr int64_t port_not_provided = -1; @@ -420,17 +405,15 @@ bool equal_body_ports(ngraph::opset6::Loop *lhs, ngraph::opset6::Loop *rhs) { rhs_sbp.current_iteration_input_idx != port_not_provided; if (input_provided) { - const auto &lhs_parameter = - lhs_fn_body->get_parameters().at(lhs_sbp.current_iteration_input_idx); - const auto &rhs_parameter = - rhs_fn_body->get_parameters().at(rhs_sbp.current_iteration_input_idx); + const auto& lhs_parameter = lhs_fn_body->get_parameters().at(lhs_sbp.current_iteration_input_idx); + const auto& rhs_parameter = rhs_fn_body->get_parameters().at(rhs_sbp.current_iteration_input_idx); if (!NodeAndInputDescription::equal_parameters(lhs_parameter.get(), rhs_parameter.get())) { return false; } } - const auto &lhs_result = lhs_fn_body->get_results().at(lhs_sbp.body_condition_output_idx); - const auto &rhs_result = rhs_fn_body->get_results().at(rhs_sbp.body_condition_output_idx); + const auto& lhs_result = lhs_fn_body->get_results().at(lhs_sbp.body_condition_output_idx); + const auto& rhs_result = rhs_fn_body->get_results().at(rhs_sbp.body_condition_output_idx); return NodeAndOutputDescription::equal_results(lhs_result.get(), rhs_result.get()); } @@ -438,9 +421,9 @@ bool equal_body_ports(ngraph::opset6::Loop *lhs, ngraph::opset6::Loop *rhs) { class CompareSubGraphs { public: using Result = Comparator::Result; - using SubGraphOp = ngraph::op::util::SubGraphOp; + using SubGraphOp = ov::op::util::SubGraphOp; - Result compare(SubGraphOp *sub_lhs, SubGraphOp *sub_rhs) { + Result compare(SubGraphOp* sub_lhs, SubGraphOp* sub_rhs) { const auto lhs_it_no = get_num_iterations(sub_lhs); const auto rhs_it_no = get_num_iterations(sub_rhs); if (lhs_it_no != rhs_it_no) { @@ -463,9 +446,9 @@ public: } private: - Result compare_inputs(SubGraphOp *sub_lhs, SubGraphOp *sub_rhs) const { - const auto &lhs_sub_inputs = extract_inputs(sub_lhs); - const auto &rhs_sub_inputs = extract_inputs(sub_rhs); + Result compare_inputs(SubGraphOp* sub_lhs, SubGraphOp* sub_rhs) const { + const auto& lhs_sub_inputs = extract_inputs(sub_lhs); + const auto& rhs_sub_inputs = extract_inputs(sub_rhs); if (lhs_sub_inputs.empty() || rhs_sub_inputs.empty()) { return Result::error("no input in subgraph"); @@ -479,16 +462,15 @@ private: } if (lhs_sub_inputs.size() != rhs_sub_inputs.size() || - !std::is_permutation( - begin(lhs_sub_inputs), end(lhs_sub_inputs), begin(rhs_sub_inputs))) { + !std::is_permutation(begin(lhs_sub_inputs), end(lhs_sub_inputs), begin(rhs_sub_inputs))) { return Result::error("different SubGraph InputDescription"); } return Result::ok(); } - Result compare_outputs(SubGraphOp *sub_lhs, SubGraphOp *sub_rhs) const { - const auto &lhs_sub_outputs = extract_outputs(sub_lhs); - const auto &rhs_sub_outputs = extract_outputs(sub_rhs); + Result compare_outputs(SubGraphOp* sub_lhs, SubGraphOp* sub_rhs) const { + const auto& lhs_sub_outputs = extract_outputs(sub_lhs); + const auto& rhs_sub_outputs = extract_outputs(sub_rhs); if (lhs_sub_outputs.empty() || rhs_sub_outputs.empty()) { return Result::error("no output in subgraph"); @@ -502,14 +484,13 @@ private: } if (lhs_sub_outputs.size() != rhs_sub_outputs.size() || - !std::is_permutation( - begin(lhs_sub_outputs), end(lhs_sub_outputs), begin(rhs_sub_outputs))) { + !std::is_permutation(begin(lhs_sub_outputs), end(lhs_sub_outputs), begin(rhs_sub_outputs))) { return Result::error("different SubGraph OutputDescription"); } return Result::ok(); } - Result compare_backedges(SubGraphOp *sub_lhs, SubGraphOp *sub_rhs) const { + Result compare_backedges(SubGraphOp* sub_lhs, SubGraphOp* sub_rhs) const { const auto lhs_back_edges = extract_backedges(sub_lhs); const auto rhs_back_edges = extract_backedges(sub_rhs); @@ -521,12 +502,11 @@ private: } if (lhs_back_edges.size() != rhs_back_edges.size() || - !std::is_permutation( - begin(lhs_back_edges), end(lhs_back_edges), begin(rhs_back_edges))) { + !std::is_permutation(begin(lhs_back_edges), end(lhs_back_edges), begin(rhs_back_edges))) { return Result::error("different SubGraph BackEdges"); } - if (auto loop_lhs = ngraph::as_type(sub_lhs)) { - auto loop_rhs = ngraph::as_type(sub_rhs); + if (auto loop_lhs = ngraph::as_type(sub_lhs)) { + auto loop_rhs = ngraph::as_type(sub_rhs); if (!equal_body_ports(loop_lhs, loop_rhs)) { return Result::error("different Special Body Ports"); } @@ -534,12 +514,12 @@ private: return Result::ok(); } - static int64_t get_num_iterations(ngraph::op::util::SubGraphOp *sub) { - using namespace ngraph::opset6; - if (const auto ti = dynamic_cast(sub)) { + static int64_t get_num_iterations(ov::op::util::SubGraphOp* sub) { + using namespace ov::opset8; + if (const auto ti = dynamic_cast(sub)) { return ti->get_num_iterations(); } - if (const auto l = dynamic_cast(sub)) { + if (const auto l = dynamic_cast(sub)) { return l->get_num_iterations(); } @@ -551,14 +531,13 @@ private: } // namespace detail -Comparator::Result compare_io( - ngraph::op::util::SubGraphOp *sub_lhs, ngraph::op::util::SubGraphOp *sub_rhs) { +Comparator::Result compare_io(ov::op::util::SubGraphOp* sub_lhs, ov::op::util::SubGraphOp* sub_rhs) { return detail::CompareSubGraphs{}.compare(sub_lhs, sub_rhs); } } // namespace subgraph } // namespace -Comparator::Result Comparator::compare( - const std::shared_ptr& f1, const std::shared_ptr& f2) { +Comparator::Result Comparator::compare(const std::shared_ptr& f1, + const std::shared_ptr& f2) { /* * This function compares two nGraph functions and requires them to have exactly one output * + Check nodes types @@ -572,15 +551,18 @@ Comparator::Result Comparator::compare( auto f2_results = f2->get_results(); auto cmp = less_by_name; - // In case if Result source output has more than one name so the Result may have any of this names as a friendly name - // And in case of multiple names we sort Result operation using their parent node names - if (std::any_of(f1_results.begin(), f1_results.end(), [](const std::shared_ptr & node) { - const auto & t = node->input_value(0).get_tensor_ptr(); - return t->get_names().size() > 1; - }) || std::any_of(f2_results.begin(), f2_results.end(), [](const std::shared_ptr & node) { - const auto & t = node->input_value(0).get_tensor_ptr(); - return t->get_names().size() > 1; - })) { + // In case if Result source output has more than one name so the Result may have any of this names as a friendly + // name And in case of multiple names we sort Result operation using their parent node names + if (std::any_of(f1_results.begin(), + f1_results.end(), + [](const std::shared_ptr& node) { + const auto& t = node->input_value(0).get_tensor_ptr(); + return t->get_names().size() > 1; + }) || + std::any_of(f2_results.begin(), f2_results.end(), [](const std::shared_ptr& node) { + const auto& t = node->input_value(0).get_tensor_ptr(); + return t->get_names().size() > 1; + })) { cmp = less_by_parent_name; } @@ -588,26 +570,23 @@ Comparator::Result Comparator::compare( std::sort(f2_results.begin(), f2_results.end(), cmp); if (f1_results.size() != f2_results.size()) { - return Result::error( - "Number of results is different: " + to_str(f1_results.size()) + " and " + - to_str(f2_results.size())); + return Result::error("Number of results is different: " + to_str(f1_results.size()) + " and " + + to_str(f2_results.size())); } const auto& f1_sinks = f1->get_sinks(); const auto& f2_sinks = f2->get_sinks(); if (f1_sinks.size() != f2_sinks.size()) { - return Result::error( - "Number of sinks is different: " + to_str(f1_sinks.size()) + " and " + - to_str(f2_sinks.size())); + return Result::error("Number of sinks is different: " + to_str(f1_sinks.size()) + " and " + + to_str(f2_sinks.size())); } for (size_t i = 0; i < f1_results.size(); ++i) { if (should_compare(CmpValues::NAMES)) { if (name(f1_results[i]->get_input_node_shared_ptr(0)) != name(f2_results[i]->get_input_node_shared_ptr(0))) { - return Result::error( - "Different output names: " + name(f1_results[i]->get_input_node_shared_ptr(0)) + - " and " + name(f2_results[i]->get_input_node_shared_ptr(0))); + return Result::error("Different output names: " + name(f1_results[i]->get_input_node_shared_ptr(0)) + + " and " + name(f2_results[i]->get_input_node_shared_ptr(0))); } } q.push({f1_results[i].get(), f2_results[i].get()}); @@ -632,17 +611,16 @@ Comparator::Result Comparator::compare( return msg.empty() ? Result::ok() : Result::error(msg); } -Comparator::Result Comparator::compare( - ngraph::Node* node1, ngraph::Node* node2, std::ostream& err_log) { +Comparator::Result Comparator::compare(ngraph::Node* node1, ngraph::Node* node2, std::ostream& err_log) { auto type_info1 = node1->get_type_info(); auto type_info2 = node2->get_type_info(); - if (!compareTypeInfo(type_info1, type_info2)) { + if (!compare_type_info(type_info1, type_info2)) { return Result::error(typeInfoToStr(type_info1) + " != " + typeInfoToStr(type_info2)); } - auto subgraph1 = dynamic_cast(node1); - auto subgraph2 = dynamic_cast(node2); + auto subgraph1 = dynamic_cast(node1); + auto subgraph2 = dynamic_cast(node2); const bool subgraph_nodes = subgraph1 && subgraph2; @@ -657,21 +635,18 @@ Comparator::Result Comparator::compare( const auto& dependencies_2 = node2->get_control_dependencies(); if (dependencies_1.size() != dependencies_2.size()) { - return Result::error( - "Number of dependencies is different: " + to_str(dependencies_1.size()) + " for " + - name(node1) + " and " + to_str(dependencies_2.size()) + " for " + name(node2)); + return Result::error("Number of dependencies is different: " + to_str(dependencies_1.size()) + " for " + + name(node1) + " and " + to_str(dependencies_2.size()) + " for " + name(node2)); } if (node1->inputs().size() != node2->inputs().size()) { - return Result::error( - "Number of inputs is different: " + to_str(node1->inputs().size()) + " for " + - name(node1) + " and " + to_str(node2->inputs().size()) + " for " + name(node2)); + return Result::error("Number of inputs is different: " + to_str(node1->inputs().size()) + " for " + + name(node1) + " and " + to_str(node2->inputs().size()) + " for " + name(node2)); } if (node1->outputs().size() != node2->outputs().size()) { - return Result::error( - "Number of outputs is different: " + to_str(node1->inputs().size()) + " for " + - name(node1) + " and " + to_str(node2->inputs().size()) + " for " + name(node2)); + return Result::error("Number of outputs is different: " + to_str(node1->inputs().size()) + " for " + + name(node1) + " and " + to_str(node2->inputs().size()) + " for " + name(node2)); } if (!subgraph_nodes) { @@ -689,53 +664,46 @@ Comparator::Result Comparator::compare( return Result::ok("Check if any minor error was log in to err_log"); } - void Comparator::compare_inputs(ngraph::Node* node1, ngraph::Node* node2, std::ostream& err_log) { for (size_t i = 0; i < node1->inputs().size(); ++i) { if (should_compare(CmpValues::CONST_VALUES)) { - using Constant = ngraph::opset1::Constant; - const auto equal_value = - ::attributes::detail::equal::Equal>::equal_value; + using Constant = ov::opset8::Constant; + const auto equal_value = ::attributes::detail::equal::Equal>::equal_value; auto const1 = ngraph::as_type_ptr(node1->get_input_node_shared_ptr(i)); auto const2 = ngraph::as_type_ptr(node2->get_input_node_shared_ptr(i)); if (const1 && const2 && !equal_value(const1, const2)) { err_log << "Different Constant values detected\n" - << node1->description() << " Input(" << i << ") and " - << node2->description() << " Input(" << i << ")" << std::endl; + << node1->description() << " Input(" << i << ") and " << node2->description() << " Input(" << i + << ")" << std::endl; } } if (should_compare(CmpValues::PRECISIONS)) { if (node1->input(i).get_element_type() != node2->input(i).get_element_type()) { err_log << "Different element type detected\n" - << name(node1) << " Input(" << i << ") " - << node1->input(i).get_element_type() << " and " << name(node2) << " Input(" - << i << ") " << node2->input(i).get_element_type() << std::endl; + << name(node1) << " Input(" << i << ") " << node1->input(i).get_element_type() << " and " + << name(node2) << " Input(" << i << ") " << node2->input(i).get_element_type() << std::endl; } } if (!node1->input(i).get_partial_shape().same_scheme(node2->input(i).get_partial_shape())) { err_log << "Different shape detected\n" - << name(node1) << " Input(" << i << ") " << node1->input(i).get_partial_shape() - << " and " << name(node2) << " Input(" << i << ") " - << node2->input(i).get_partial_shape() << std::endl; + << name(node1) << " Input(" << i << ") " << node1->input(i).get_partial_shape() << " and " + << name(node2) << " Input(" << i << ") " << node2->input(i).get_partial_shape() << std::endl; } - if (node1->get_input_source_output(i).get_index() != - node2->get_input_source_output(i).get_index()) { + if (node1->get_input_source_output(i).get_index() != node2->get_input_source_output(i).get_index()) { auto idx1 = node1->get_input_source_output(i).get_index(); auto idx2 = node2->get_input_source_output(i).get_index(); err_log << "Different ports detected\n" - << name(node1) << " Input(" << i << ") connected to parent port " << idx1 - << " and " << name(node2) << " Input(" << i << ") connected to parent port " - << idx2 << std::endl; + << name(node1) << " Input(" << i << ") connected to parent port " << idx1 << " and " << name(node2) + << " Input(" << i << ") connected to parent port " << idx2 << std::endl; } if (should_compare(CmpValues::RUNTIME_KEYS) && !compare_rt_keys(node1, node2)) { err_log << "Different runtime info detected\n" - << name(node1) << " and " << name(node2) << " not equal runtime info." - << std::endl; + << name(node1) << " and " << name(node2) << " not equal runtime info." << std::endl; } } } @@ -753,19 +721,17 @@ void Comparator::compare_outputs(ngraph::Node* node1, ngraph::Node* node2, std:: const auto& tensor1 = node1->output(i).get_tensor(); const auto& tensor2 = node2->output(i).get_tensor(); - if (tensor1.get_names() != tensor2.get_names() && (!autogenerated_names(tensor1.get_names()) || !autogenerated_names(tensor2.get_names()))) { - err_log << "Output tensors names " << tensor_names(tensor1) << " and " - << tensor_names(tensor2) + if (tensor1.get_names() != tensor2.get_names() && + (!autogenerated_names(tensor1.get_names()) || !autogenerated_names(tensor2.get_names()))) { + err_log << "Output tensors names " << tensor_names(tensor1) << " and " << tensor_names(tensor2) << " are different for nodes: " << node1->get_friendly_name() << " and " << node2->get_friendly_name() << std::endl; } - if (!node1->output(i).get_partial_shape().same_scheme( - node2->output(i).get_partial_shape())) { + if (!node1->output(i).get_partial_shape().same_scheme(node2->output(i).get_partial_shape())) { err_log << "Different shape detected\n" - << name(node1) << " Output(" << i << ") " - << node1->output(i).get_partial_shape() << " and " << name(node2) << " Output(" - << i << ") " << node2->output(i).get_partial_shape() << std::endl; + << name(node1) << " Output(" << i << ") " << node1->output(i).get_partial_shape() << " and " + << name(node2) << " Output(" << i << ") " << node2->output(i).get_partial_shape() << std::endl; } } } @@ -779,9 +745,8 @@ void Comparator::add_nodes_inputs_to_queue(ngraph::Node* node1, ngraph::Node* no } } -FunctionsComparator::Result FunctionsComparator::compare( - const std::shared_ptr& f1, - const std::shared_ptr& f2) const { +FunctionsComparator::Result FunctionsComparator::compare(const std::shared_ptr& f1, + const std::shared_ptr& f2) const { return Comparator(m_comparition_flags).compare(f1, f2); } @@ -790,13 +755,13 @@ void check_rt_info(const std::shared_ptr& f) { std::ostringstream err_log; for (auto& op : f->get_ops()) { - if (ngraph::op::is_constant(op)) continue; + if (ov::op::util::is_constant(op)) + continue; const auto& rt_info = op->get_rt_info(); for (const auto& attr_name : attrs_to_check) { if (!rt_info.count(attr_name)) { - err_log << "Node: " << op->get_friendly_name() << " has no attribute: " << attr_name - << std::endl; + err_log << "Node: " << op->get_friendly_name() << " has no attribute: " << attr_name << std::endl; } } } @@ -807,48 +772,42 @@ void check_rt_info(const std::shared_ptr& f) { } } -void set_tensor_name(ngraph::Output output, const std::string & name) { +void set_tensor_name(ngraph::Output output, const std::string& name) { output.get_tensor_ptr()->set_names({name}); } -void set_tensor_names(ngraph::Output output, const std::unordered_set & names) { +void set_tensor_names(ngraph::Output output, const std::unordered_set& names) { output.get_tensor_ptr()->set_names(names); } -NGRAPH_RTTI_DEFINITION(TestOpMultiOut, "TestOp", 0); - namespace attributes { namespace detail { void ReadAndStoreAttributes::on_adapter(const std::string& name, ngraph::ValueAccessor& adapter) { - if (auto inputs = - ngraph::as_type>(&adapter)) { + if (auto inputs = ngraph::as_type>(&adapter)) { insert(name, inputs->get()); - } else if ( - auto outputs = - ngraph::as_type>(&adapter)) { + } else if (auto outputs = ngraph::as_type>(&adapter)) { insert(name, outputs->get()); } else if (ngraph::is_type>(&adapter)) { // drop comparison, no more info than port indexes which will be check in // subgraph::compare_io - } else if ( - auto a = ngraph::as_type< - ngraph::AttributeAdapter>>( - &adapter)) { - const auto beg = static_cast(a->get()->get_ptr()); + } else if (auto a = ngraph::as_type>>( + &adapter)) { + const auto beg = static_cast(a->get()->get_ptr()); const auto end = beg + a->get()->size(); insert(name, storage::MemoryChunk{storage::MemoryChunk::Data(beg, end)}); - } else if (auto framework_node_attr = ngraph::as_type>(&adapter)) { + } else if (auto framework_node_attr = + ngraph::as_type>(&adapter)) { insert(name, framework_node_attr->get()); - } else if (auto variable_ptr = ngraph::as_type>>(&adapter)) { + } else if (auto variable_ptr = + ngraph::as_type>>(&adapter)) { insert(name, variable_ptr->get()); } else { - m_read_result += "store attr [ ERR ]: " + name + - " [drop `void` comparison which is '" + adapter.get_type_info().name + - "']"; + m_read_result += "store attr [ ERR ]: " + name + " [drop `void` comparison which is '" + + adapter.get_type_info().name + "']"; } } template -void ReadAndCompareAttributes::verify(const std::string &name, const AttrValue &attr_value) { +void ReadAndCompareAttributes::verify(const std::string& name, const AttrValue& attr_value) { if (should_return()) { return; } @@ -860,14 +819,13 @@ void ReadAndCompareAttributes::verify(const std::string &name, const AttrValue & } if (!equal::Equal::equal_value(*ref_value, attr_value)) { - m_cmp_result += "mismatch in value: '" + name + - "' : " + str::Get::value(*ref_value) + " vs " + + m_cmp_result += "mismatch in value: '" + name + "' : " + str::Get::value(*ref_value) + " vs " + str::Get::value(attr_value); } } -void ReadAndCompareAttributes::verify_mem_buf(const std::string &name, - const std::shared_ptr &buffer) { +void ReadAndCompareAttributes::verify_mem_buf(const std::string& name, + const std::shared_ptr& buffer) { if (should_return()) { return; } @@ -885,7 +843,7 @@ void ReadAndCompareAttributes::verify_mem_buf(const std::string &name, } } -void ReadAndCompareAttributes::verify_function(const std::string &name, FunctionAccessor &adapter) { +void ReadAndCompareAttributes::verify_function(const std::string& name, FunctionAccessor& adapter) { if (should_return()) { return; } @@ -902,44 +860,37 @@ void ReadAndCompareAttributes::verify_function(const std::string &name, Function } } -void ReadAndCompareAttributes::verify_others(const std::string &name, ngraph::ValueAccessor &adapter) { - if (auto inputs = - ngraph::as_type>(&adapter)) { +void ReadAndCompareAttributes::verify_others(const std::string& name, ngraph::ValueAccessor& adapter) { + if (auto inputs = ngraph::as_type>(&adapter)) { verify(name, inputs->get()); - } else if ( - auto outputs = - ngraph::as_type>(&adapter)) { + } else if (auto outputs = ngraph::as_type>(&adapter)) { verify(name, outputs->get()); } else if (ngraph::is_type>(&adapter)) { // drop comparison, no more info than port indexes which will be check in // subgraph::compare_io - } else if ( - auto a = ngraph::as_type< - ngraph::AttributeAdapter>>( - &adapter)) { + } else if (auto a = ngraph::as_type>>( + &adapter)) { verify_mem_buf(name, a->get()); - } else if (auto attrs = ngraph::as_type>(&adapter)) { + } else if (auto attrs = ngraph::as_type>(&adapter)) { verify(name, attrs->get()); - } else if (auto variable_ptr = ngraph::as_type>>(&adapter)) { + } else if (auto variable_ptr = + ngraph::as_type>>(&adapter)) { verify(name, variable_ptr->get()); } else { - m_cmp_result += "compare attr [ ERR ]: " + name + - " [drop `void` comparison which is '" + adapter.get_type_info().name + - "']"; + m_cmp_result += "compare attr [ ERR ]: " + name + " [drop `void` comparison which is '" + + adapter.get_type_info().name + "']"; } } } // namespace detail -Comparator::Result compare( - ngraph::Node* node1, ngraph::Node* node2, Comparator::CmpValues comparition_flags) { +Comparator::Result compare(ngraph::Node* node1, ngraph::Node* node2, Comparator::CmpValues comparition_flags) { detail::CompareNodesAttributes compare_nodes_attr(comparition_flags); node1->visit_attributes(compare_nodes_attr.get_ref_reader()); node2->visit_attributes(compare_nodes_attr.get_cmp_reader()); if (!compare_nodes_attr.equal()) { - return Comparator::Result::error( - "Comparison of attributes failed for nodes " + name(node1) + ", " + name(node2) + - " [cmp status: " + to_str(compare_nodes_attr) + "]"); + return Comparator::Result::error("Comparison of attributes failed for nodes " + name(node1) + ", " + + name(node2) + " [cmp status: " + to_str(compare_nodes_attr) + "]"); } return Comparator::Result::ok(to_str(compare_nodes_attr)); } diff --git a/ngraph/test/util/graph_comparator.hpp b/ngraph/test/util/graph_comparator.hpp new file mode 100644 index 00000000000..9f03a3caf2a --- /dev/null +++ b/ngraph/test/util/graph_comparator.hpp @@ -0,0 +1,796 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include +#include +#include + +#include "openvino/core/dimension.hpp" +#include "openvino/core/except.hpp" +#include "openvino/core/function.hpp" +#include "openvino/op/util/framework_node.hpp" +#include "openvino/opsets/opset8.hpp" +#include "openvino/pass/pass.hpp" + +class FunctionsComparator { +public: + enum CmpValues { + NONE = 0, + CONST_VALUES = 1 << 0, + NAMES = 1 << 1, + RUNTIME_KEYS = 1 << 2, + PRECISIONS = 1 << 3, + ATTRIBUTES = 1 << 4, + }; + + struct Result { + bool valid; + std::string message; + + static Result ok(std::string msg = {}) { + return {true, std::move(msg)}; + } + static Result error(std::string msg) { + return {false, std::move(msg)}; + } + }; + + static constexpr FunctionsComparator no_default() noexcept { + return FunctionsComparator{NONE}; + } + static constexpr FunctionsComparator with_default() noexcept { + return FunctionsComparator{PRECISIONS}; + } + FunctionsComparator& enable(CmpValues f) noexcept { + m_comparition_flags = static_cast(m_comparition_flags | f); + return *this; + } + constexpr bool should_compare(CmpValues f) const noexcept { + return m_comparition_flags & f; + } + Result compare(const std::shared_ptr& f1, const std::shared_ptr& f2) const; + + Result operator()(const std::shared_ptr& f1, const std::shared_ptr& f2) const { + return compare(f1, f2); + } + +private: + constexpr explicit FunctionsComparator(CmpValues f) noexcept : m_comparition_flags(f) {} + CmpValues m_comparition_flags; +}; + +/// +/// \deprecated +/// \brief compare_functions is obsolete function use FunctionsComparator instead. +/// +inline std::pair compare_functions(const std::shared_ptr& f1, + const std::shared_ptr& f2, + const bool compareConstValues = false, + const bool compareNames = false, + const bool compareRuntimeKeys = false, + const bool comparePrecisions = true, + const bool compareAttributes = false) { + auto fc = FunctionsComparator::no_default(); + + using Cmp = FunctionsComparator::CmpValues; + if (compareConstValues) + fc.enable(Cmp::CONST_VALUES); + if (compareNames) + fc.enable(Cmp::NAMES); + if (compareRuntimeKeys) + fc.enable(Cmp::RUNTIME_KEYS); + if (comparePrecisions) + fc.enable(Cmp::PRECISIONS); + if (compareAttributes) + fc.enable(Cmp::ATTRIBUTES); + + const auto r = fc(f1, f2); + return {r.valid, r.message}; +} + +void check_rt_info(const std::shared_ptr& f); + +void set_tensor_name(ngraph::Output output, const std::string& name); + +void set_tensor_names(ngraph::Output output, const std::unordered_set& names); + +namespace ngraph { +namespace pass { +class InjectionPass : public ov::pass::FunctionPass { +public: + using injection_callback = std::function)>; + + explicit InjectionPass(injection_callback callback) : FunctionPass(), m_callback(std::move(callback)) {} + + bool run_on_function(std::shared_ptr f) override { + m_callback(f); + return false; + } + +private: + injection_callback m_callback; +}; + +} // namespace pass +} // namespace ngraph + +class Comparator { +public: + using CmpValues = FunctionsComparator::CmpValues; + using Result = FunctionsComparator::Result; + using ComparedNodes = std::pair; + + explicit Comparator(CmpValues f) : m_comparition_flags(f) {} + + Result compare(const std::shared_ptr& f1, const std::shared_ptr& f2); + + Result compare(ngraph::Node* node1, ngraph::Node* node2) { + std::stringstream errors; + const auto result = compare(node1, node2, errors); + if (!result.valid) { + return result; + } + const auto msg = errors.str(); + return msg.empty() ? Result::ok() : Result::error(msg); + } + + Comparator recreate() const { + return Comparator(m_comparition_flags); + } + + void compare_inputs(ngraph::Node* node1, ngraph::Node* node2, std::ostream& err_log); + + void compare_outputs(ngraph::Node* node1, ngraph::Node* node2, std::ostream& err_log); + +private: + bool should_compare(CmpValues f) const noexcept { + return m_comparition_flags & f; + } + + /// + /// \param err_log - will be fill by minor errors if happen + /// \return only fatality error if some minor one appears it will be add to err_log + /// + Result compare(ngraph::Node* node1, ngraph::Node* node2, std::ostream& err_log); + + void add_nodes_inputs_to_queue(ngraph::Node* node1, ngraph::Node* node2); + + //-- DATA -- + CmpValues m_comparition_flags; + + std::queue q; + std::unordered_set used; +}; + +inline namespace tools { +template +std::string to_str(const T& v) { + using std::to_string; + return to_string(v); +} +template +std::string name(const Node& n) { + return n->get_friendly_name(); +} +} // namespace tools +namespace attributes { + +namespace detail { + +using AttrName = std::string; + +class Result { +public: + explicit Result(std::string m = {}) : m_message(std::move(m)) {} + + const std::string& message() const { + return m_message; + } + + bool has_error() const { + return !m_message.empty(); + } + + Result& operator+=(const std::string& msg) { + m_message.append(m_break_line_no, '\n').append(msg); + m_break_line_no = 1; + return *this; + } + +private: + std::string m_message; + int m_break_line_no{0}; +}; + +using SubGraphOpInputDescription = std::vector>; + +using SubGraphOpOutputDescription = std::vector>; + +using SpecialBodyPorts = ov::opset8::Loop::SpecialBodyPorts; + +namespace storage { + +class MemoryChunk { +public: + using Data = std::vector; + MemoryChunk(Data data) : m_data{std::move(data)} {} + + Data::const_pointer data() const { + return m_data.data(); + } + + size_t size() const { + return m_data.size(); + } + +private: + Data m_data; +}; + +template +class AttributeStorage { +public: + bool insert_value(AttrName name, AttrValue value) { + return m_attributes.insert({std::move(name), std::move(value)}).second; + } + + const AttrValue* get_value(const AttrName& name) const { + const auto found = m_attributes.find(name); + if (found != end(m_attributes)) { + return std::addressof(found->second); + } + return {}; + } + + std::size_t get_attributes_number() const { + return m_attributes.size(); + } + +private: + std::map m_attributes; +}; + +class Storage : private AttributeStorage, + private AttributeStorage, + private AttributeStorage, + private AttributeStorage, + private AttributeStorage, + private AttributeStorage, + private AttributeStorage, + private AttributeStorage, + private AttributeStorage, + private AttributeStorage, + private AttributeStorage, + private AttributeStorage, + private AttributeStorage, + private AttributeStorage>, + private AttributeStorage>, + private AttributeStorage>, + private AttributeStorage>, + private AttributeStorage>, + private AttributeStorage>, + private AttributeStorage>, + private AttributeStorage>, + private AttributeStorage>, + private AttributeStorage>, + private AttributeStorage>, + private AttributeStorage>, + private AttributeStorage, + private AttributeStorage, + private AttributeStorage, + private AttributeStorage> { +public: + template + const AttributeStorage& storage() const { + return *static_cast*>(this); + } + template + AttributeStorage& storage() { + return *static_cast*>(this); + } + + size_t stored_attributes_number() const { + return storage().get_attributes_number() + storage().get_attributes_number() + + storage().get_attributes_number() + storage().get_attributes_number() + + storage().get_attributes_number() + storage().get_attributes_number() + + storage().get_attributes_number() + storage().get_attributes_number() + + storage().get_attributes_number() + storage().get_attributes_number() + + storage().get_attributes_number() + storage().get_attributes_number() + + storage().get_attributes_number() + storage>().get_attributes_number() + + storage>().get_attributes_number() + + storage>().get_attributes_number() + + storage>().get_attributes_number() + + storage>().get_attributes_number() + + storage>().get_attributes_number() + + storage>().get_attributes_number() + + storage>().get_attributes_number() + + storage>().get_attributes_number() + + storage>().get_attributes_number() + + storage>().get_attributes_number() + + storage>().get_attributes_number() + + storage().get_attributes_number() + + storage().get_attributes_number() + + storage().get_attributes_number() + + storage>().get_attributes_number(); + } +}; + +} // namespace storage + +class ReadAndStoreAttributes : public ngraph::AttributeVisitor, protected storage::Storage { +public: + void on_adapter(const std::string& name, ngraph::ValueAccessor& adapter) override; + +#define ON_ADAPTER(TYPE) \ + void on_adapter(const std::string& name, ngraph::ValueAccessor& adapter) override { \ + insert(name, adapter.get()); \ + } + + ON_ADAPTER(bool) + ON_ADAPTER(std::string) + ON_ADAPTER(int8_t) + ON_ADAPTER(int16_t) + ON_ADAPTER(int32_t) + ON_ADAPTER(int64_t) + ON_ADAPTER(uint8_t) + ON_ADAPTER(uint16_t) + ON_ADAPTER(uint32_t) + ON_ADAPTER(uint64_t) + ON_ADAPTER(float) + ON_ADAPTER(double) + ON_ADAPTER(std::vector) + ON_ADAPTER(std::vector) + ON_ADAPTER(std::vector) + ON_ADAPTER(std::vector) + ON_ADAPTER(std::vector) + ON_ADAPTER(std::vector) + ON_ADAPTER(std::vector) + ON_ADAPTER(std::vector) + ON_ADAPTER(std::vector) + ON_ADAPTER(std::vector) + ON_ADAPTER(std::vector) + ON_ADAPTER(std::shared_ptr) + +#undef ON_ADAPTER + + template + const AttrValue* get(const AttrName& name) const { + return storage().get_value(name); + } + + template + bool insert(AttrName name, AttrValue value) { + return storage().insert_value(std::move(name), std::move(value)); + } + + size_t attributes_number() const { + return stored_attributes_number(); + } + + const Result read_result() const { + return m_read_result; + } + +private: + Result m_read_result; +}; + +namespace equal { + +template +struct Equal { + static bool equal_value(const Value& lhs, const Value& rhs) { + return lhs == rhs; + } +}; + +template <> +struct Equal { + static bool equal_value(ngraph::bfloat16 lhs, ngraph::bfloat16 rhs) { + if (lhs.to_bits() == rhs.to_bits()) { + return true; + } + return std::abs(lhs - rhs) < 1e-3; + } +}; + +template <> +struct Equal { + static bool equal_value(ngraph::float16 lhs, ngraph::float16 rhs) { + if (lhs.to_bits() == rhs.to_bits()) { + return true; + } + return std::abs(lhs - rhs) < 1e-3; + } +}; + +template <> +struct Equal { + static bool equal_value(float lhs, float rhs) { + if (std::isfinite(lhs) && std::isfinite(rhs)) { + return std::abs(lhs - rhs) < 1e-4; + } + return (std::isinf(lhs) && std::isinf(rhs)) || (std::isnan(lhs) && std::isnan(rhs)); + } +}; + +template <> +struct Equal { + static bool equal_value(double lhs, double rhs) { + if (std::isfinite(lhs) && std::isfinite(rhs)) { + return std::abs(lhs - rhs) < 1e-5; + } + return (std::isinf(lhs) && std::isinf(rhs)) || (std::isnan(lhs) && std::isnan(rhs)); + } +}; + +template +struct Equal> { + static bool equal_value(const std::vector& lhs, const std::vector& rhs) { + return lhs.size() == rhs.size() && std::equal(begin(lhs), end(lhs), begin(rhs), Equal::equal_value); + } +}; + +template <> +struct Equal { + static bool equal_value(SubGraphOpInputDescription::const_reference lhs, + SubGraphOpInputDescription::const_reference rhs) { + const auto& lhs_type_info = lhs->get_type_info(); + const auto& rhs_type_info = rhs->get_type_info(); + if (lhs_type_info != rhs_type_info) { + return false; + } + using SubGraphOp = ov::op::util::SubGraphOp; + if (lhs_type_info == SubGraphOp::SliceInputDescription::get_type_info_static()) { + const auto& l_input = static_cast(*lhs); + const auto& r_input = static_cast(*rhs); + return l_input.m_start == r_input.m_start && l_input.m_stride == r_input.m_stride && + l_input.m_part_size == r_input.m_part_size && l_input.m_end == r_input.m_end && + l_input.m_axis == r_input.m_axis; + } else if (lhs_type_info == SubGraphOp::MergedInputDescription::get_type_info_static()) { + return true; + } else if (lhs_type_info == SubGraphOp::InvariantInputDescription::get_type_info_static()) { + return true; + } + return false; + } +}; + +template <> +struct Equal { + static bool equal_value(const SubGraphOpInputDescription& lhs, const SubGraphOpInputDescription& rhs) { + if (lhs.size() != rhs.size()) { + return false; + } + return std::is_permutation(begin(lhs), + end(lhs), + begin(rhs), + Equal::equal_value); + } +}; + +template <> +struct Equal { + static bool equal_value(SubGraphOpOutputDescription::const_reference lhs, + SubGraphOpOutputDescription::const_reference rhs) { + const auto& lhs_type_info = lhs->get_type_info(); + const auto& rhs_type_info = rhs->get_type_info(); + if (lhs_type_info != rhs_type_info) { + return false; + } + using SubGraphOp = ov::op::util::SubGraphOp; + if (lhs_type_info == SubGraphOp::ConcatOutputDescription::get_type_info_static()) { + const auto& l_output = static_cast(*lhs); + const auto& r_output = static_cast(*rhs); + return l_output.m_start == r_output.m_start && l_output.m_stride == r_output.m_stride && + l_output.m_part_size == r_output.m_part_size && l_output.m_end == r_output.m_end && + l_output.m_axis == r_output.m_axis; + } else if (lhs_type_info == SubGraphOp::BodyOutputDescription::get_type_info_static()) { + const auto& l_output = static_cast(*lhs); + const auto& r_output = static_cast(*rhs); + return l_output.m_iteration == r_output.m_iteration; + } + return false; + } +}; + +template <> +struct Equal { + static bool equal_value(const SubGraphOpOutputDescription& lhs, const SubGraphOpOutputDescription& rhs) { + if (lhs.size() != rhs.size()) { + return false; + } + return std::is_permutation(begin(lhs), + end(lhs), + begin(rhs), + Equal::equal_value); + } +}; + +template <> +struct Equal> { + static bool equal_value(const std::shared_ptr& lhs, + const std::shared_ptr& rhs) { + return lhs->get_info() == rhs->get_info(); + } +}; + +template <> +struct Equal { + static constexpr uint8_t BITS_IN_BYTE_COUNT = 8; + + static inline uint8_t extract_bit(uint8_t val, uint8_t bit) { + return (val >> bit) & 0x01; + } + + static bool equal_value(const uint8_t* lhs, const uint8_t* rhs, size_t lhs_bit_size, size_t rhs_bit_size) { + if (lhs_bit_size != rhs_bit_size) + return false; + + for (size_t bit_idx = 0; bit_idx < lhs_bit_size; bit_idx++) { + const auto byte_idx_result(bit_idx / BITS_IN_BYTE_COUNT); + if (byte_idx_result > std::numeric_limits::max()) + throw ov::Exception("(bit_idx / BITS_IN_BYTE_COUNT) bigger than uint8_t::max_value"); + + const auto byte_idx(static_cast(byte_idx_result)); + const uint8_t bit_in_byte_idx = 7 - (bit_idx % BITS_IN_BYTE_COUNT); + + if (extract_bit(lhs[byte_idx], bit_in_byte_idx) != extract_bit(rhs[byte_idx], bit_in_byte_idx)) { + return false; + } + } + + return true; + } +}; + +using Constant = ov::opset8::Constant; +template <> +struct Equal> { + static bool equal_value(const std::shared_ptr& lhs, const std::shared_ptr& rhs) { + const auto lhs_t = lhs->get_element_type(); + const auto rhs_t = rhs->get_element_type(); + if (lhs_t != rhs_t) { + return false; + } + + switch (lhs_t) { + case ngraph::element::Type_t::u1: { + const auto lhs_v = static_cast(lhs->get_data_ptr()); + const auto rhs_v = static_cast(rhs->get_data_ptr()); + const auto lhs_bit_size = shape_size(lhs->get_shape()); + const auto rhs_bit_size = shape_size(rhs->get_shape()); + return Equal::equal_value(lhs_v, rhs_v, lhs_bit_size, rhs_bit_size); + } + case ngraph::element::Type_t::bf16: { + auto lhs_v = lhs->cast_vector(); + auto rhs_v = rhs->cast_vector(); + return Equal>::equal_value(lhs_v, rhs_v); + break; + } + case ngraph::element::Type_t::f16: { + const auto& lhs_v = lhs->cast_vector(); + const auto& rhs_v = rhs->cast_vector(); + return Equal>::equal_value(lhs_v, rhs_v); + break; + } + case ngraph::element::Type_t::f32: { + const auto& lhs_v = lhs->cast_vector(); + const auto& rhs_v = rhs->cast_vector(); + return Equal>::equal_value(lhs_v, rhs_v); + break; + } + default: { + const auto& lhs_v = lhs->cast_vector(); + const auto& rhs_v = rhs->cast_vector(); + return Equal>::equal_value(lhs_v, rhs_v); + break; + } + } + return false; + } +}; +} // namespace equal + +namespace str { +template +struct Void_t { + using type = void; +}; + +template +struct Get { + static std::string value(const T&) { + return std::string("[Ups can't convert this to value: ") + typeid(T).name() + "]"; + } +}; + +template +struct Get()))>::type> { + static std::string value(const T& v) { + return "[" + std::to_string(v) + "]"; + } +}; + +template <> +struct Get { + static std::string value(const std::string& v) { + return "[" + v + "]"; + } +}; + +template +struct Get())), decltype(end(std::declval()))>::type> { + template + static std::string join(const Container& c, const char* glue = ", ") { + std::stringstream oss; + const char* s = ""; + for (const auto& v : c) { + oss << s << v; + s = glue; + } + return oss.str(); + } + + static std::string value(const T& v) { + return "[" + join(v) + "]"; + } +}; + +template <> +struct Get { + static std::string value(const ov::op::util::FrameworkNodeAttrs& attrs) { + std::stringstream oss; + const auto& a = attrs; + oss << "version=" << attrs.get_opset_name() << ", "; + oss << "type=" << attrs.get_type_name() << ", "; + oss << "attrs["; + for (const auto& item : a) { + oss << item.first << "=" << item.second << " "; + } + oss << "]"; + return "[" + oss.str() + "]"; + } +}; + +template <> +struct Get, void> { + static std::string value(const std::shared_ptr& variable) { + std::stringstream oss; + const auto variable_info = variable->get_info(); + oss << "["; + oss << "data_shape=" << variable_info.data_shape << ", "; + oss << "data_type=" << variable_info.data_type << ", "; + oss << "variable_id=" << variable_info.variable_id; + oss << "]"; + return oss.str(); + } +}; + +} // namespace str + +class ReadAndCompareAttributes : public ngraph::AttributeVisitor { +public: + ReadAndCompareAttributes(const ReadAndStoreAttributes& ref, Comparator::CmpValues check_flags) + : m_attr_ref(ref), + m_cmp_result{ref.read_result()}, + m_check_flags(check_flags) {} + + void on_adapter(const std::string& name, ngraph::ValueAccessor& adapter) override { + verify_others(name, adapter); + } + +#define ON_ADAPTER(TYPE) \ + void on_adapter(const std::string& name, ngraph::ValueAccessor& adapter) override { \ + verify(name, adapter.get()); \ + } + + ON_ADAPTER(bool) + ON_ADAPTER(std::string) + ON_ADAPTER(int8_t) + ON_ADAPTER(int16_t) + ON_ADAPTER(int32_t) + ON_ADAPTER(int64_t) + ON_ADAPTER(uint8_t) + ON_ADAPTER(uint16_t) + ON_ADAPTER(uint32_t) + ON_ADAPTER(uint64_t) + ON_ADAPTER(float) + ON_ADAPTER(double) + ON_ADAPTER(std::vector) + ON_ADAPTER(std::vector) + ON_ADAPTER(std::vector) + ON_ADAPTER(std::vector) + ON_ADAPTER(std::vector) + ON_ADAPTER(std::vector) + ON_ADAPTER(std::vector) + ON_ADAPTER(std::vector) + ON_ADAPTER(std::vector) + ON_ADAPTER(std::vector) + ON_ADAPTER(std::vector) + +#undef ON_ADAPTER + + void on_adapter(const std::string& name, + ngraph::ValueAccessor>& adapter) override { + verify_function(name, adapter); + } + + bool all_attr_was_compared() const { + return m_visited_attributes.size() == m_attr_ref.attributes_number(); + } + + size_t compared_attr_number() const { + return m_visited_attributes.size(); + } + + const Result& cmp_result() const { + return m_cmp_result; + } + +private: + bool should_return() const { + return m_fast_exit && m_cmp_result.has_error(); + } + + template + void verify(const std::string& name, const AttrValue& attr_value); + + void verify_mem_buf(const std::string& name, const std::shared_ptr& buffer); + + using FunctionAccessor = ngraph::ValueAccessor>; + + void verify_function(const std::string& name, FunctionAccessor& adapter); + + void verify_others(const std::string& name, ngraph::ValueAccessor& adapter); + //-- DATA -- + const ReadAndStoreAttributes& m_attr_ref; + Result m_cmp_result; + Comparator::CmpValues m_check_flags; + std::set m_visited_attributes; + static constexpr bool m_fast_exit{true}; +}; +class CompareNodesAttributes { +public: + using ReadAndStoreAttributes = detail::ReadAndStoreAttributes; + using ReadAndCompareAttributes = detail::ReadAndCompareAttributes; + + CompareNodesAttributes(Comparator::CmpValues m_compare_flags) : m_compare_attr(m_store_attr, m_compare_flags) {} + + ReadAndStoreAttributes& get_ref_reader() { + return m_store_attr; + } + + ReadAndCompareAttributes& get_cmp_reader() { + return m_compare_attr; + } + + bool equal() const { + return m_compare_attr.all_attr_was_compared() && !m_compare_attr.cmp_result().has_error(); + } + + friend std::string to_string(const CompareNodesAttributes& c) { + const auto& result = c.m_compare_attr.cmp_result(); + if (result.has_error()) { + return result.message(); + } + if (!c.m_compare_attr.all_attr_was_compared()) { + return "not all of attr was compared: " + to_str(c.m_compare_attr.compared_attr_number()) + " vs " + + to_str(c.m_store_attr.attributes_number()); + } + return "looks good [compared " + to_str(c.m_compare_attr.compared_attr_number()) + " attributes]"; + } + +private: + ReadAndStoreAttributes m_store_attr; + ReadAndCompareAttributes m_compare_attr; +}; + +} // namespace detail + +Comparator::Result compare(ngraph::Node* node1, ngraph::Node* node2, Comparator::CmpValues comparition_flags); + +} // namespace attributes diff --git a/ngraph/test/util/matcher.hpp b/ngraph/test/util/matcher.hpp index 7e76cf1d618..f05a632df82 100644 --- a/ngraph/test/util/matcher.hpp +++ b/ngraph/test/util/matcher.hpp @@ -2,14 +2,17 @@ // SPDX-License-Identifier: Apache-2.0 // +#include "ngraph/log.hpp" +#include "ngraph/pattern/matcher.hpp" + // this is for more nuanced testing class TestMatcher : public ngraph::pattern::Matcher { using ngraph::pattern::Matcher::Matcher; public: - TestMatcher() {} - bool virtual match_value(const ngraph::Output& pattern_value, - const ngraph::Output& graph_value) override { + TestMatcher() = default; + bool match_value(const ngraph::Output& pattern_value, + const ngraph::Output& graph_value) override { if (ngraph::is_type<::ngraph::op::Parameter>(pattern_value.get_node_shared_ptr())) { bool result = pattern_value == graph_value; if (result) { diff --git a/ngraph/test/util/test_control.cpp b/ngraph/test/util/test_control.cpp index ea301c36616..a5b7ee783a3 100644 --- a/ngraph/test/util/test_control.cpp +++ b/ngraph/test/util/test_control.cpp @@ -2,7 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "util/test_control.hpp" +#include "test_control.hpp" #include #include diff --git a/ngraph/test/util/test_tools.hpp b/ngraph/test/util/test_tools.hpp index 610dc48408c..1a3dc91ad0d 100644 --- a/ngraph/test/util/test_tools.hpp +++ b/ngraph/test/util/test_tools.hpp @@ -14,82 +14,10 @@ #include #include "gtest/gtest.h" -#include "ngraph/file_util.hpp" -#include "ngraph/log.hpp" -#include "ngraph/node.hpp" -#include "ngraph/op/op.hpp" -#include "ngraph/runtime/host_tensor.hpp" -#include "ngraph/runtime/tensor.hpp" -#include "ngraph/type/element_type_traits.hpp" -#include "runtime/backend.hpp" - -namespace ngraph { -class TestOpMultiOut : public op::Op { -public: - static constexpr NodeTypeInfo type_info{"TestOpMultiOut", 0}; - const NodeTypeInfo& get_type_info() const override { - return type_info; - } - TestOpMultiOut() = default; - - TestOpMultiOut(const Output& output_1, const Output& output_2) : Op({output_1, output_2}) { - validate_and_infer_types(); - } - void validate_and_infer_types() override { - set_output_size(2); - set_output_type(0, get_input_element_type(0), get_input_partial_shape(0)); - set_output_type(1, get_input_element_type(1), get_input_partial_shape(1)); - } - - virtual std::shared_ptr clone_with_new_inputs(const OutputVector& new_args) const override { - return std::make_shared(new_args.at(0), new_args.at(1)); - } - bool evaluate(const HostTensorVector& outputs, const HostTensorVector& inputs) const override; -}; -} // namespace ngraph - -bool validate_list(const std::vector>& nodes); -std::shared_ptr make_test_graph(); +#include "ngraph/function.hpp" template -void copy_data(std::shared_ptr tv, const std::vector& data) { - size_t data_size = data.size() * sizeof(T); - if (data_size > 0) { - tv->write(data.data(), data_size); - } -} - -template -ngraph::HostTensorPtr make_host_tensor(const ngraph::Shape& shape, - const std::vector::value_type>& data) { - NGRAPH_CHECK(shape_size(shape) == data.size(), "Incorrect number of initialization elements"); - auto host_tensor = std::make_shared(ET, shape); - copy_data(host_tensor, data); - return host_tensor; -} - -template <> -void copy_data(std::shared_ptr tv, const std::vector& data); - -template -void write_vector(std::shared_ptr tv, const std::vector& values) { - tv->write(values.data(), values.size() * sizeof(T)); -} - -template -std::vector> get_ops_of_type(std::shared_ptr f) { - std::vector> ops; - for (auto op : f->get_ops()) { - if (auto cop = ngraph::as_type_ptr(op)) { - ops.push_back(cop); - } - } - - return ops; -} - -template -size_t count_ops_of_type(std::shared_ptr f) { +size_t count_ops_of_type(const std::shared_ptr& f) { size_t count = 0; for (auto op : f->get_ops()) { if (ngraph::is_type(op)) { @@ -100,130 +28,6 @@ size_t count_ops_of_type(std::shared_ptr f) { return count; } -template -void init_int_tv(ngraph::runtime::Tensor* tv, std::default_random_engine& engine, T min, T max) { - size_t size = tv->get_element_count(); - std::uniform_int_distribution dist(min, max); - std::vector vec(size); - for (T& element : vec) { - element = dist(engine); - } - tv->write(vec.data(), vec.size() * sizeof(T)); -} - -template -void init_real_tv(ngraph::runtime::Tensor* tv, std::default_random_engine& engine, T min, T max) { - size_t size = tv->get_element_count(); - std::uniform_real_distribution dist(min, max); - std::vector vec(size); - for (T& element : vec) { - element = dist(engine); - } - tv->write(vec.data(), vec.size() * sizeof(T)); -} - -void random_init(ngraph::runtime::Tensor* tv, std::default_random_engine& engine); - -template -std::vector> prepare_and_run(const std::shared_ptr& function, - std::vector> t1args, - std::vector> t2args, - const std::string& backend_id) { - auto backend = ngraph::runtime::Backend::create(backend_id); - - auto parms = function->get_parameters(); - - if (parms.size() != t1args.size() + t2args.size()) { - throw ngraph::ngraph_error("number of parameters and arguments don't match"); - } - - std::vector> arg_tensors(t1args.size() + t2args.size()); - - size_t total_arg_count = 0; - for (size_t i = 0; i < t1args.size(); i++) { - auto t = backend->create_tensor(parms.at(total_arg_count)->get_element_type(), - parms.at(total_arg_count)->get_shape()); - auto x = t1args.at(i); - copy_data(t, x); - arg_tensors.at(total_arg_count) = t; - total_arg_count++; - } - - for (size_t i = 0; i < t2args.size(); i++) { - auto t = backend->create_tensor(parms.at(total_arg_count)->get_element_type(), - parms.at(total_arg_count)->get_shape()); - copy_data(t, t2args.at(i)); - arg_tensors.at(total_arg_count) = t; - total_arg_count++; - } - - auto results = function->get_results(); - std::vector> result_tensors(results.size()); - - for (size_t i = 0; i < results.size(); i++) { - result_tensors.at(i) = backend->create_tensor(results.at(i)->get_element_type(), results.at(i)->get_shape()); - } - - auto handle = backend->compile(function); - handle->call_with_validate(result_tensors, arg_tensors); - - return result_tensors; -} - -template -std::vector> prepare_and_run(const std::shared_ptr& function, - std::vector> args, - const std::string& backend_id) { - std::vector> emptyargs; - return prepare_and_run(function, args, emptyargs, backend_id); -} - -template -std::vector> execute(const std::shared_ptr& function, - std::vector> t1args, - std::vector> t2args, - const std::string& backend_id) { - std::vector> result_tensors = - prepare_and_run(function, t1args, t2args, backend_id); - - std::vector> result_vectors; - for (auto rt : result_tensors) { - result_vectors.push_back(read_vector(rt)); - } - return result_vectors; -} - -template -std::vector> execute(const std::shared_ptr& function, - std::vector> args, - const std::string& backend_id) { - std::vector> emptyargs; - return execute(function, args, emptyargs, backend_id); -} - -template -std::string get_results_str(const std::vector& ref_data, - const std::vector& actual_data, - size_t max_results = 16) { - std::stringstream ss; - size_t num_results = std::min(static_cast(max_results), ref_data.size()); - ss << "First " << num_results << " results"; - for (size_t i = 0; i < num_results; ++i) { - ss << std::endl - // use unary + operator to force integral values to be displayed as numbers - << std::setw(4) << i << " ref: " << std::setw(16) << std::left << +ref_data[i] - << " actual: " << std::setw(16) << std::left << +actual_data[i]; - } - ss << std::endl; - - return ss.str(); -} - -template <> -std::string get_results_str(const std::vector& ref_data, - const std::vector& actual_data, - size_t max_results); - /// \brief Reads a binary file to a vector. /// /// \param[in] path The path where the file is located. @@ -251,13 +55,3 @@ std::vector read_binary_file(const std::string& path) { inputs_fs.read(reinterpret_cast(file_content.data()), size); return file_content; } - -testing::AssertionResult test_ordered_ops(std::shared_ptr f, const ngraph::NodeVector& required_ops); - -template -ngraph::HostTensorPtr make_host_tensor(const ngraph::Shape& shape) { - auto host_tensor = std::make_shared(ET, shape); - static std::default_random_engine engine(2112); - random_init(host_tensor.get(), engine); - return host_tensor; -}