forked from openvinotoolkit/openvino
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_model_repo.hpp
93 lines (79 loc) · 2.43 KB
/
test_model_repo.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
// Copyright (C) 2018-2023 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#include <fstream>
namespace TestDataHelpers {
static const char kPathSeparator =
#if defined _WIN32 || defined __CYGWIN__
'\\';
#else
'/';
#endif
inline std::string getModelPathNonFatal() noexcept {
if (const auto envVar = std::getenv("MODELS_PATH")) {
return envVar;
}
#ifdef MODELS_PATH
return MODELS_PATH;
#else
return "";
#endif
}
inline std::string get_models_path() {
return getModelPathNonFatal() + kPathSeparator + std::string("models");
};
inline std::string get_data_path() {
if (const auto envVar = std::getenv("DATA_PATH")) {
return envVar;
}
#ifdef DATA_PATH
return DATA_PATH;
#else
return "";
#endif
}
inline std::string generate_model_path(std::string dir, std::string filename) {
return get_models_path() + kPathSeparator + dir + kPathSeparator + filename;
}
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_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