Skip to content

Commit

Permalink
Refactor shared beh tests to API 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
olpipi committed Jan 11, 2024
1 parent a561a2a commit 5e81b11
Show file tree
Hide file tree
Showing 10 changed files with 789 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,31 @@

#include <vector>

#include "behavior/plugin/hetero_synthetic.hpp"
#include "behavior/ov_plugin/hetero_synthetic.hpp"
#include "ov_models/builders.hpp"
#include "ov_models/subgraph_builders.hpp"

// defined in plugin_name.cpp
extern const char * cpu_plugin_file_name;

namespace {
using namespace HeteroTests;
using ov::test::behavior::OVHeteroSyntheticTest;
using ov::test::behavior::PluginParameter;

// this tests load plugin by library name: this is not available during static linkage
#ifndef OPENVINO_STATIC_LIBRARY

INSTANTIATE_TEST_SUITE_P(smoke_SingleMajorNode, HeteroSyntheticTest,
INSTANTIATE_TEST_SUITE_P(smoke_SingleMajorNode, OVHeteroSyntheticTest,
::testing::Combine(
::testing::Values(std::vector<PluginParameter>{{"CPU0", cpu_plugin_file_name}, {"CPU1", cpu_plugin_file_name}}),
::testing::ValuesIn(HeteroTests::HeteroSyntheticTest::_singleMajorNodeFunctions)),
HeteroSyntheticTest::getTestCaseName);
::testing::ValuesIn(OVHeteroSyntheticTest::_singleMajorNodeFunctions)),
OVHeteroSyntheticTest::getTestCaseName);

INSTANTIATE_TEST_SUITE_P(nightly_RandomMajorNodes, HeteroSyntheticTest,
INSTANTIATE_TEST_SUITE_P(nightly_RandomMajorNodes, OVHeteroSyntheticTest,
::testing::Combine(
::testing::Values(std::vector<PluginParameter>{{"CPU0", cpu_plugin_file_name}, {"CPU1", cpu_plugin_file_name}}),
::testing::ValuesIn(HeteroTests::HeteroSyntheticTest::_randomMajorNodeFunctions)),
HeteroSyntheticTest::getTestCaseName);
::testing::ValuesIn(OVHeteroSyntheticTest::_randomMajorNodeFunctions)),
OVHeteroSyntheticTest::getTestCaseName);

#endif // !OPENVINO_STATIC_LIBRARY

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,6 @@ std::vector<std::string> disabledTestPatterns() {
R"(.*KernelCachingSupportCase.*CanCreateCacheDirAndDumpBinariesUnicodePath.*)",
#endif
R"(.*CachingSupportCase.*GPU.*CompileModelCacheTestBase.*CompareWithRefImpl.*)",
// Looks like the test is targeting CPU plugin and doesn't respect that execution graph may vary from plugin to plugin
R"(.*ExecGraphSerializationTest.*)",
// unsupported metrics
R"(.*nightly_HeteroAutoBatchOVGetMetricPropsTest.*OVGetMetricPropsTest.*(FULL_DEVICE_NAME_with_DEVICE_ID|AVAILABLE_DEVICES|DEVICE_UUID|OPTIMIZATION_CAPABILITIES|MAX_BATCH_SIZE|DEVICE_GOPS|DEVICE_TYPE|RANGE_FOR_ASYNC_INFER_REQUESTS|RANGE_FOR_STREAMS).*)",
// Issue: 111437
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,19 @@ TEST_P(OVCompiledModelBaseTestOptional, CheckExecGraphInfoAfterExecution) {
}
}

TEST_P(OVCompiledModelBaseTest, CheckExecGraphInfoSerialization) {
auto filePrefix = ov::test::utils::generateTestFilePrefix();
std::string out_xml_path = filePrefix + ".xml";
std::string out_bin_path = filePrefix + ".bin";

std::shared_ptr<const ov::Model> runtime_model;

auto compiled_model = core->compile_model(function, target_device, configuration);
ASSERT_NO_THROW(runtime_model = compiled_model.get_runtime_model());
ASSERT_NO_THROW(ov::serialize(runtime_model, out_xml_path, out_bin_path));
ov::test::utils::removeIRFiles(out_xml_path, out_bin_path);
}

TEST_P(OVCompiledModelBaseTest, getInputFromFunctionWithSingleInput) {
ov::CompiledModel execNet;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "exec_graph_info.hpp"
#include "base/ov_behavior_test_utils.hpp"
#include "shared_test_classes/base/ov_subgraph.hpp"
#include "pugixml.hpp"

namespace ov {
namespace test {
Expand Down Expand Up @@ -45,6 +46,36 @@ class OVExecGraphUniqueNodeNames : public testing::WithParamInterface<ov::test::
std::shared_ptr<ov::Model> fnPtr;
};

class OVExecGraphSerializationTest : public testing::WithParamInterface<std::string>,
public OVCompiledNetworkTestBase {
public:
static std::string getTestCaseName(testing::TestParamInfo<std::string> obj);
void SetUp() override;
void TearDown() override;

private:
// walker traverse (DFS) xml document and store layer & data nodes in
// vector which is later used for comparison
struct exec_graph_walker : pugi::xml_tree_walker {
std::vector<pugi::xml_node> nodes;
bool for_each(pugi::xml_node &node) override;
};

// compare_docs() helper
std::pair<bool, std::string> compare_nodes(const pugi::xml_node &node1,
const pugi::xml_node &node2);

protected:
// checks if two exec graph xml's are equivalent:
// - the same count of <layer> and <data> nodes
// - the same count of attributes of each node
// - the same name of each attribute (value is not checked, since it can differ
// beetween different devices)
std::pair<bool, std::string> compare_docs(const pugi::xml_document &doc1,
const pugi::xml_document &doc2);

std::string m_out_xml_path, m_out_bin_path;
};
} // namespace behavior
} // namespace test
} // namespace ov
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,18 @@ TEST_P(OVClassBasicTestP, SetConfigAllNoThrow) {
OV_ASSERT_NO_THROW(ie.get_versions(target_device));
}

TEST_P(OVClassBasicTestP, SetGetConfigForTbbTerminateThrows) {
ov::Core ie = createCoreWithTemplate();
bool value = false;
ASSERT_NO_THROW(ie.set_property({ov::force_tbb_terminate(true)}));
ASSERT_NO_THROW(value = ie.get_property(target_device, ov::force_tbb_terminate));
ASSERT_TRUE(value);

ASSERT_NO_THROW(ie.set_property({{ov::force_tbb_terminate(false)}}));
ASSERT_NO_THROW(value = ie.get_property(target_device, ov::force_tbb_terminate));
ASSERT_FALSE(value);
}

TEST(OVClassBasicTest, smoke_SetConfigHeteroThrows) {
ov::Core ie = createCoreWithTemplate();
OV_ASSERT_NO_THROW(ie.set_property(ov::test::utils::DEVICE_HETERO, ov::enable_profiling(true)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,16 @@ TEST_P(CoreThreadingTest, smoke_GetVersions) {
});
}

// tested function: get_property, UnregisterPlugin
TEST_P(CoreThreadingTest, smoke_GetMetric) {
ov::Core core;

runParallel([&] () {
core.get_property(target_device, ov::internal::supported_properties);
safePluginUnload(core, target_device);
});
}

// tested function: set_property for already created plugins
TEST_P(CoreThreadingTest, smoke_SetProperty_PluginExists) {
ov::Core core;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
// Copyright (C) 2018-2023 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//

#pragma once

#include <tuple>
#include <string>
#include <vector>
#include <unordered_set>

#include "shared_test_classes/base/ov_subgraph.hpp"
#include "ov_models/utils/ov_helpers.hpp"

namespace ov {
namespace test {
namespace behavior {

struct PluginParameter {
std::string _name;
std::string _location;
};

struct FunctionParameter {
std::unordered_set<std::string> _majorPluginNodeIds;
std::shared_ptr<ov::Model> _function;
bool _dynamic_batch;
uint32_t _seed;
};

using OVHeteroSyntheticTestParameters = std::tuple<
std::vector<PluginParameter>,
FunctionParameter
>;

class OVHeteroSyntheticTest : public testing::WithParamInterface<OVHeteroSyntheticTestParameters>,
virtual public ov::test::SubgraphBaseStaticTest {
protected:
enum {Plugin, Function};

~OVHeteroSyntheticTest() override = default;
void SetUp() override;
void TearDown() override;

std::string SetUpAffinity();

std::vector<std::string> _registredPlugins;

public:
static std::string getTestCaseName(const ::testing::TestParamInfo<OVHeteroSyntheticTestParameters>& obj);

static std::vector<FunctionParameter> singleMajorNodeFunctions(
const std::vector<std::function<std::shared_ptr<ov::Model>()>>& builders, bool dynamic_batch = false);

static std::vector<FunctionParameter> randomMajorNodeFunctions(
const std::vector<std::function<std::shared_ptr<ov::Model>()>>& builders, bool dynamic_batch = false, uint32_t seed = 0);

static std::vector<FunctionParameter> _singleMajorNodeFunctions;
static std::vector<FunctionParameter> _randomMajorNodeFunctions;
};

} // namespace behavior
} // namespace test
} // namespace ov
Loading

0 comments on commit 5e81b11

Please sign in to comment.