Xuejun/fix cvs 98110 (#14534)
* [CAPI][UNITE TEST] 1) create plugin test xml file in runtime; 2) fix arm plugin test error; Signed-off-by: xuejun <Xuejun.Zhai@intel.com> * [CAPI] fix format issue Signed-off-by: xuejun <Xuejun.Zhai@intel.com> * [CAPI] change the time of Copyright Signed-off-by: xuejun <Xuejun.Zhai@intel.com> --------- Signed-off-by: xuejun <Xuejun.Zhai@intel.com>
This commit is contained in:
parent
36df508baf
commit
5030660b9f
@ -24,18 +24,6 @@ const char* input_image_nv12 = input_image_nv12_std.c_str();
|
||||
std::mutex m;
|
||||
bool ready = false;
|
||||
std::condition_variable condVar;
|
||||
#ifdef _WIN32
|
||||
#ifdef __MINGW32__
|
||||
std::string plugins_xml_std = TestDataHelpers::generate_ieclass_xml_path("plugins_mingw.xml");
|
||||
#else
|
||||
std::string plugins_xml_std = TestDataHelpers::generate_ieclass_xml_path("plugins_win.xml");
|
||||
#endif
|
||||
#elif defined __APPLE__
|
||||
std::string plugins_xml_std = TestDataHelpers::generate_ieclass_xml_path("plugins_apple.xml");
|
||||
#else
|
||||
std::string plugins_xml_std = TestDataHelpers::generate_ieclass_xml_path("plugins.xml");
|
||||
#endif
|
||||
const char* plugins_xml = plugins_xml_std.c_str();
|
||||
|
||||
#define IE_EXPECT_OK(...) EXPECT_EQ(IEStatusCode::OK, __VA_ARGS__)
|
||||
#define IE_ASSERT_OK(...) ASSERT_EQ(IEStatusCode::OK, __VA_ARGS__)
|
||||
@ -93,11 +81,13 @@ static void completion_callback(void *args) {
|
||||
}
|
||||
|
||||
TEST(ie_core_create, coreCreatewithConfig) {
|
||||
std::string plugins_xml = TestDataHelpers::generate_test_xml_file();
|
||||
ie_core_t *core = nullptr;
|
||||
IE_ASSERT_OK(ie_core_create(plugins_xml, &core));
|
||||
IE_ASSERT_OK(ie_core_create(plugins_xml.c_str(), &core));
|
||||
ASSERT_NE(nullptr, core);
|
||||
|
||||
ie_core_free(&core);
|
||||
TestDataHelpers::delete_test_xml_file();
|
||||
}
|
||||
|
||||
TEST(ie_core_create, coreCreateNoConfig) {
|
||||
@ -135,13 +125,15 @@ TEST(ie_core_register_plugin, registerPlugin) {
|
||||
}
|
||||
|
||||
TEST(ie_core_register_plugins, registerPlugins) {
|
||||
std::string plugins_xml = TestDataHelpers::generate_test_xml_file();
|
||||
ie_core_t *core = nullptr;
|
||||
IE_ASSERT_OK(ie_core_create("", &core));
|
||||
ASSERT_NE(nullptr, core);
|
||||
|
||||
IE_EXPECT_OK(ie_core_register_plugins(core, plugins_xml));
|
||||
IE_EXPECT_OK(ie_core_register_plugins(core, plugins_xml.c_str()));
|
||||
|
||||
ie_core_free(&core);
|
||||
TestDataHelpers::delete_test_xml_file();
|
||||
}
|
||||
|
||||
TEST(ie_core_unload_plugin, unloadPlugin) {
|
||||
@ -1280,6 +1272,8 @@ TEST(ie_infer_request_infer_async, inferAsyncWaitTime) {
|
||||
ie_core_free(&core);
|
||||
}
|
||||
|
||||
// For ARM plugin, no "Batch" related operations support for now, so skip related APIs
|
||||
#ifndef __aarch64__
|
||||
TEST(ie_infer_request_set_batch, setBatch) {
|
||||
ie_core_t *core = nullptr;
|
||||
IE_ASSERT_OK(ie_core_create("", &core));
|
||||
@ -1366,6 +1360,7 @@ TEST(ie_infer_request_set_batch, setNegativeBatch) {
|
||||
ie_network_free(&network);
|
||||
ie_core_free(&core);
|
||||
}
|
||||
#endif
|
||||
|
||||
TEST(ie_blob_make_memory, makeMemory) {
|
||||
|
||||
|
@ -181,14 +181,14 @@ TEST_P(ov_compiled_model, create_compiled_model_with_property) {
|
||||
OV_EXPECT_OK(ov_core_read_model(core, xml, bin, &model));
|
||||
EXPECT_NE(nullptr, model);
|
||||
|
||||
const char* key = ov_property_key_hint_num_requests;
|
||||
const char* num = "9";
|
||||
const char* key = ov_property_key_hint_performance_mode;
|
||||
const char* num = "LATENCY";
|
||||
ov_compiled_model_t* compiled_model = nullptr;
|
||||
OV_EXPECT_OK(ov_core_compile_model(core, model, device_name.c_str(), 2, &compiled_model, key, num));
|
||||
EXPECT_NE(nullptr, compiled_model);
|
||||
char* result = nullptr;
|
||||
OV_EXPECT_OK(ov_compiled_model_get_property(compiled_model, key, &result));
|
||||
EXPECT_STREQ(result, "9");
|
||||
EXPECT_STREQ(result, "LATENCY");
|
||||
ov_free(result);
|
||||
|
||||
ov_compiled_model_free(compiled_model);
|
||||
|
@ -23,10 +23,12 @@ class ov_core : public ::testing::TestWithParam<std::string> {};
|
||||
INSTANTIATE_TEST_SUITE_P(device_name, ov_core, ::testing::Values("CPU"));
|
||||
|
||||
TEST(ov_core, ov_core_create_with_config) {
|
||||
std::string plugins_xml = TestDataHelpers::generate_test_xml_file();
|
||||
ov_core_t* core = nullptr;
|
||||
OV_EXPECT_OK(ov_core_create_with_config(plugins_xml, &core));
|
||||
OV_EXPECT_OK(ov_core_create_with_config(plugins_xml.c_str(), &core));
|
||||
EXPECT_NE(nullptr, core);
|
||||
ov_core_free(core);
|
||||
TestDataHelpers::delete_test_xml_file();
|
||||
}
|
||||
|
||||
TEST(ov_core, ov_core_create_with_no_config) {
|
||||
@ -233,22 +235,14 @@ TEST_P(ov_core, ov_core_set_and_get_property_enum) {
|
||||
OV_EXPECT_OK(ov_core_create(&core));
|
||||
EXPECT_NE(nullptr, core);
|
||||
|
||||
const char* key = ov_property_key_affinity;
|
||||
const char* affinity = "HYBRID_AWARE";
|
||||
const char* key = ov_property_key_hint_performance_mode;
|
||||
const char* affinity = "LATENCY";
|
||||
OV_EXPECT_OK(ov_core_set_property(core, device_name.c_str(), key, affinity));
|
||||
char* ret = nullptr;
|
||||
OV_EXPECT_OK(ov_core_get_property(core, device_name.c_str(), key, &ret));
|
||||
EXPECT_STREQ(affinity, ret);
|
||||
ov_free(ret);
|
||||
|
||||
key = ov_property_key_hint_inference_precision;
|
||||
const char* precision = "f32";
|
||||
OV_EXPECT_OK(ov_core_set_property(core, device_name.c_str(), key, precision));
|
||||
ret = nullptr;
|
||||
OV_EXPECT_OK(ov_core_get_property(core, device_name.c_str(), key, &ret));
|
||||
EXPECT_STREQ(precision, ret);
|
||||
ov_free(ret);
|
||||
|
||||
ov_core_free(core);
|
||||
}
|
||||
|
||||
@ -301,6 +295,9 @@ TEST_P(ov_core, ov_core_get_property) {
|
||||
}
|
||||
|
||||
TEST_P(ov_core, ov_core_set_get_property_str) {
|
||||
#ifdef __aarch64__
|
||||
GTEST_SKIP() << "Skip this test for ARM CPU for now, cause no string property supported";
|
||||
#endif
|
||||
auto device_name = GetParam();
|
||||
ov_core_t* core = nullptr;
|
||||
OV_EXPECT_OK(ov_core_create(&core));
|
||||
@ -354,6 +351,9 @@ TEST_P(ov_core, ov_core_set_property_int_invalid) {
|
||||
}
|
||||
|
||||
TEST_P(ov_core, ov_core_set_multiple_common_properties) {
|
||||
#ifdef __aarch64__
|
||||
GTEST_SKIP() << "Skip this test for ARM CPU for now, cause no string property supported";
|
||||
#endif
|
||||
auto device_name = GetParam();
|
||||
ov_core_t* core = nullptr;
|
||||
OV_EXPECT_OK(ov_core_create(&core));
|
||||
@ -419,6 +419,12 @@ TEST_P(ov_core, ov_compiled_model_export_model) {
|
||||
OV_EXPECT_OK(ov_core_create(&core));
|
||||
EXPECT_NE(nullptr, core);
|
||||
|
||||
char* optimization_capabilites = NULL;
|
||||
ov_core_get_property(core, device_name.c_str(), "OPTIMIZATION_CAPABILITIES", &optimization_capabilites);
|
||||
if (std::string(optimization_capabilites).find("EXPORT_IMPORT") == std::string::npos) {
|
||||
GTEST_SKIP() << "Skip this test, cause no EXPORT_IMPORT supported";
|
||||
}
|
||||
|
||||
ov_compiled_model_t* compiled_model = nullptr;
|
||||
OV_EXPECT_OK(ov_core_compile_model_from_file(core, xml, device_name.c_str(), 0, &compiled_model));
|
||||
EXPECT_NE(nullptr, compiled_model);
|
||||
@ -437,6 +443,12 @@ TEST_P(ov_core, ov_core_import_model) {
|
||||
OV_EXPECT_OK(ov_core_create(&core));
|
||||
EXPECT_NE(nullptr, core);
|
||||
|
||||
char* optimization_capabilites = NULL;
|
||||
ov_core_get_property(core, device_name.c_str(), "OPTIMIZATION_CAPABILITIES", &optimization_capabilites);
|
||||
if (std::string(optimization_capabilites).find("EXPORT_IMPORT") == std::string::npos) {
|
||||
GTEST_SKIP() << "Skip this test, cause no EXPORT_IMPORT supported";
|
||||
}
|
||||
|
||||
ov_compiled_model_t* compiled_model = nullptr;
|
||||
OV_EXPECT_OK(ov_core_compile_model_from_file(core, xml, device_name.c_str(), 0, &compiled_model));
|
||||
EXPECT_NE(nullptr, compiled_model);
|
||||
@ -481,6 +493,7 @@ const std::vector<std::wstring> test_unicode_postfix_vector = {L"unicode_Яㅎ
|
||||
L"АБВГДЕЁЖЗИЙ",
|
||||
L"СТУФХЦЧШЩЬЮЯ"};
|
||||
TEST(ov_core, ov_core_create_with_config_unicode) {
|
||||
std::string plugins_xml = TestDataHelpers::generate_test_xml_file();
|
||||
ov_core_t* core = nullptr;
|
||||
|
||||
for (std::size_t index = 0; index < test_unicode_postfix_vector.size(); index++) {
|
||||
@ -493,6 +506,7 @@ TEST(ov_core, ov_core_create_with_config_unicode) {
|
||||
remove_file_ws(plugins_xml_ws);
|
||||
ov_core_free(core);
|
||||
}
|
||||
TestDataHelpers::delete_test_xml_file();
|
||||
}
|
||||
|
||||
TEST(ov_core, ov_core_read_model_unicode) {
|
||||
|
@ -11,19 +11,6 @@ std::string bin_std = TestDataHelpers::generate_model_path("test_model", "test_m
|
||||
const char* xml = xml_std.c_str();
|
||||
const char* bin = bin_std.c_str();
|
||||
|
||||
#ifdef _WIN32
|
||||
# ifdef __MINGW32__
|
||||
std::string plugins_xml_std = TestDataHelpers::generate_ieclass_xml_path("plugins_mingw.xml");
|
||||
# else
|
||||
std::string plugins_xml_std = TestDataHelpers::generate_ieclass_xml_path("plugins_win.xml");
|
||||
# endif
|
||||
#elif defined __APPLE__
|
||||
std::string plugins_xml_std = TestDataHelpers::generate_ieclass_xml_path("plugins_apple.xml");
|
||||
#else
|
||||
std::string plugins_xml_std = TestDataHelpers::generate_ieclass_xml_path("plugins.xml");
|
||||
#endif
|
||||
const char* plugins_xml = plugins_xml_std.c_str();
|
||||
|
||||
std::map<ov_element_type_e, size_t> element_type_size_map = {{ov_element_type_e::BOOLEAN, 8},
|
||||
{ov_element_type_e::BF16, 16},
|
||||
{ov_element_type_e::F16, 16},
|
||||
|
@ -17,8 +17,6 @@ extern const char* bin;
|
||||
extern const char* input_image;
|
||||
extern const char* input_image_nv12;
|
||||
|
||||
extern const char* plugins_xml;
|
||||
|
||||
#define OV_EXPECT_OK(...) EXPECT_EQ(ov_status_e::OK, __VA_ARGS__)
|
||||
#define OV_ASSERT_OK(...) ASSERT_EQ(ov_status_e::OK, __VA_ARGS__)
|
||||
#define OV_EXPECT_NOT_OK(...) EXPECT_NE(ov_status_e::OK, __VA_ARGS__)
|
||||
|
@ -1,6 +1,7 @@
|
||||
// Copyright (C) 2018-2023 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
#include <fstream>
|
||||
|
||||
namespace TestDataHelpers {
|
||||
|
||||
@ -47,7 +48,46 @@ inline std::string generate_image_path(std::string dir, std::string filename) {
|
||||
return get_data_path() + kPathSeparator + "validation_set" + kPathSeparator + dir + kPathSeparator + filename;
|
||||
}
|
||||
|
||||
inline std::string generate_ieclass_xml_path(std::string filename) {
|
||||
return getModelPathNonFatal() + kPathSeparator + "ie_class" + kPathSeparator + filename;
|
||||
inline std::string generate_test_xml_file() {
|
||||
#ifdef _WIN32
|
||||
# ifdef __MINGW32__
|
||||
std::string libraryname = "libopenvino_intel_cpu_plugin.dll";
|
||||
# else
|
||||
std::string libraryname = "openvino_intel_cpu_plugin.dll";
|
||||
# endif
|
||||
#elif defined __APPLE__
|
||||
# ifdef __aarch64__
|
||||
std::string libraryname = "libopenvino_arm_cpu_plugin.so";
|
||||
# else
|
||||
std::string libraryname = "libopenvino_intel_cpu_plugin.so";
|
||||
# endif
|
||||
#else
|
||||
std::string libraryname = "libopenvino_intel_cpu_plugin.so";
|
||||
#endif
|
||||
// Create the file
|
||||
std::string plugin_xml = "plugin_test.xml";
|
||||
std::ofstream plugin_xml_file(plugin_xml);
|
||||
|
||||
// Write to the file
|
||||
plugin_xml_file << "<!--\n";
|
||||
plugin_xml_file << "Copyright (C) 2023 Intel Corporation\n";
|
||||
plugin_xml_file << "SPDX-License-Identifier: Apache-2.0\n";
|
||||
plugin_xml_file << "-->\n";
|
||||
plugin_xml_file << "\n";
|
||||
|
||||
plugin_xml_file << "<ie>\n";
|
||||
plugin_xml_file << " <plugins>\n";
|
||||
plugin_xml_file << " <plugin location=\"" << libraryname << "\" name=\"CUSTOM\">\n";
|
||||
plugin_xml_file << " </plugin>\n";
|
||||
plugin_xml_file << " </plugins>\n";
|
||||
plugin_xml_file << "</ie>\n";
|
||||
|
||||
// Close the file
|
||||
plugin_xml_file.close();
|
||||
return plugin_xml;
|
||||
}
|
||||
|
||||
inline void delete_test_xml_file() {
|
||||
std::remove("plugin_test.xml");
|
||||
}
|
||||
} // namespace TestDataHelpers
|
||||
|
Loading…
Reference in New Issue
Block a user