init
This commit is contained in:
parent
3d6474a4a3
commit
0e59ebd2fe
@ -17,6 +17,7 @@ namespace test {
|
||||
namespace conformance {
|
||||
extern const char* targetDevice;
|
||||
extern const char *targetPluginName;
|
||||
extern const char* refCachePath;
|
||||
|
||||
extern std::vector<std::string> IRFolderPaths;
|
||||
extern std::vector<std::string> disabledTests;
|
||||
@ -103,8 +104,19 @@ static std::set<std::string> get_element_type_names() {
|
||||
static auto unique_ops = get_unique_ops();
|
||||
static auto element_type_names = get_element_type_names();
|
||||
|
||||
inline std::vector<std::string> getModelPaths(const std::vector<std::string>& conformance_ir_paths,
|
||||
const std::string& opName = "Other") {
|
||||
inline std::string get_ref_path(const std::string& model_path) {
|
||||
std::string path_to_cache = "";
|
||||
if (CommonTestUtils::directoryExists(refCachePath)) {
|
||||
std::string ref_name = model_path.substr(model_path.rfind(CommonTestUtils::FileSeparator) + 1);
|
||||
ref_name = CommonTestUtils::replaceExt(ref_name, ".bin");
|
||||
path_to_cache += refCachePath + std::string(CommonTestUtils::FileSeparator) + ref_name;
|
||||
}
|
||||
return path_to_cache;
|
||||
}
|
||||
|
||||
// vector<ir_path, ref_path>
|
||||
inline std::vector<std::pair<std::string, std::string>> getModelPaths(const std::vector<std::string>& conformance_ir_paths,
|
||||
const std::string& opName = "Other") {
|
||||
// This is required to prevent re-scan folders each call in case there is nothing found
|
||||
static bool listPrepared = false;
|
||||
if (!listPrepared) {
|
||||
@ -125,7 +137,7 @@ inline std::vector<std::string> getModelPaths(const std::vector<std::string>& co
|
||||
listPrepared = true;
|
||||
}
|
||||
|
||||
std::vector<std::string> result;
|
||||
std::vector<std::pair<std::string, std::string>> result;
|
||||
if (!opName.empty() && opName != "Other") {
|
||||
for (const auto& op_version : unique_ops[opName]) {
|
||||
std::string final_op_name = op_version == "" ? opName : opName + "-" + op_version;
|
||||
@ -133,7 +145,7 @@ inline std::vector<std::string> getModelPaths(const std::vector<std::string>& co
|
||||
auto it = dirList.begin();
|
||||
while (it != dirList.end()) {
|
||||
if (it->find(strToFind) != std::string::npos) {
|
||||
result.push_back(*it);
|
||||
result.push_back({*it, get_ref_path(*it)});
|
||||
it = dirList.erase(it);
|
||||
} else {
|
||||
++it;
|
||||
@ -142,7 +154,10 @@ inline std::vector<std::string> getModelPaths(const std::vector<std::string>& co
|
||||
}
|
||||
} else if (opName == "Other") {
|
||||
// For "Undefined" operation name - run all applicable files in "Undefined" handler
|
||||
result.insert(result.end(), dirList.begin(), dirList.end());
|
||||
// result.insert(result.end(), dirList.begin(), dirList.end());
|
||||
for (const auto& file : dirList) {
|
||||
result.push_back({file, get_ref_path(file)});
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@ -46,6 +46,7 @@ static const char extract_body_message[] = "Optional. Allows to count extracted
|
||||
static const char shape_mode_message[] = "Optional. Allows to run `static`, `dynamic` or both scenarios. Default value is empty string allows to run both"
|
||||
" scenarios. Possible values are `static`, `dynamic`, ``";
|
||||
static const char test_timeout_message[] = "Optional. Setup timeout for each test in seconds, default timeout 900seconds (15 minutes).";
|
||||
static const char reference_cache_dir_message[] = "Optional. Set the directory with reference cache";
|
||||
|
||||
|
||||
DEFINE_bool(h, false, help_message);
|
||||
@ -62,6 +63,7 @@ DEFINE_bool(report_unique_name, false, report_unique_name_message);
|
||||
DEFINE_bool(extract_body, false, extract_body_message);
|
||||
DEFINE_string(shape_mode, "", shape_mode_message);
|
||||
DEFINE_uint32(test_timeout, UINT_MAX, test_timeout_message);
|
||||
DEFINE_string(ref_dir, "", reference_cache_dir_message);
|
||||
|
||||
/**
|
||||
* @brief This function shows a help message
|
||||
@ -85,6 +87,7 @@ static void showUsage() {
|
||||
std::cout << " --plugin_lib_name " << output_folder_message << std::endl;
|
||||
std::cout << " --shape_mode \"<value>\" " << shape_mode_message << std::endl;
|
||||
std::cout << " --test_timeout \"<value>\" " << test_timeout_message << std::endl;
|
||||
std::cout << " --ref_dir \"<paths>\" " << reference_cache_dir_message << std::endl;
|
||||
}
|
||||
|
||||
} // namespace conformance
|
||||
|
@ -19,7 +19,7 @@ enum ShapeMode {
|
||||
extern ShapeMode shapeMode;
|
||||
|
||||
using ReadIRParams = std::tuple<
|
||||
std::string, // IR path
|
||||
std::pair<std::string, std::string>, // pair<ir_path, cache_path>
|
||||
std::string, // Target Device
|
||||
ov::AnyMap>; // Plugin Config
|
||||
|
||||
@ -28,14 +28,14 @@ class ReadIRTest : public testing::WithParamInterface<ReadIRParams>,
|
||||
public:
|
||||
static std::string getTestCaseName(const testing::TestParamInfo<ReadIRParams> &obj);
|
||||
void query_model() override;
|
||||
std::vector<ov::Tensor> calculate_refs() override;
|
||||
|
||||
protected:
|
||||
void SetUp() override;
|
||||
|
||||
private:
|
||||
std::string pathToModel;
|
||||
std::string sourceModel;
|
||||
std::vector<std::pair<std::string, size_t>> ocuranceInModels;
|
||||
std::string path_to_model, path_to_cache, source_model;
|
||||
std::vector<std::pair<std::string, size_t>> ocurance_in_models;
|
||||
};
|
||||
} // namespace subgraph
|
||||
} // namespace test
|
||||
|
@ -34,12 +34,14 @@ ShapeMode shapeMode = ShapeMode::BOTH;
|
||||
|
||||
std::string ReadIRTest::getTestCaseName(const testing::TestParamInfo<ReadIRParams> &obj) {
|
||||
using namespace CommonTestUtils;
|
||||
std::string pathToModel, deviceName;
|
||||
std::pair<std::string, std::string> model_pair;
|
||||
std::string path_to_model, path_to_cache, deviceName;
|
||||
ov::AnyMap config;
|
||||
std::tie(pathToModel, deviceName, config) = obj.param;
|
||||
std::tie(model_pair, deviceName, config) = obj.param;
|
||||
std::tie(path_to_model, path_to_cache) = model_pair;
|
||||
|
||||
std::ostringstream result;
|
||||
auto splittedFilename = CommonTestUtils::splitStringByDelimiter(pathToModel, CommonTestUtils::FileSeparator);
|
||||
auto splittedFilename = CommonTestUtils::splitStringByDelimiter(path_to_model, CommonTestUtils::FileSeparator);
|
||||
std::reverse(splittedFilename.begin(), splittedFilename.end());
|
||||
bool is_valid_path_format = true;
|
||||
|
||||
@ -74,7 +76,7 @@ std::string ReadIRTest::getTestCaseName(const testing::TestParamInfo<ReadIRParam
|
||||
is_valid_path_format = false;
|
||||
}
|
||||
}
|
||||
result << "IR=" << (is_valid_path_format ? CommonTestUtils::replaceExt(splittedFilename[0], "") : pathToModel) << "_";
|
||||
result << "IR=" << (is_valid_path_format ? CommonTestUtils::replaceExt(splittedFilename[0], "") : path_to_model) << "_";
|
||||
result << "Device=" << deviceName << "_";
|
||||
result << "Config=(";
|
||||
auto configItem = config.begin();
|
||||
@ -134,16 +136,18 @@ uint64_t clip(uint64_t n, uint64_t lower, uint64_t upper) {
|
||||
}
|
||||
|
||||
void ReadIRTest::SetUp() {
|
||||
std::tie(pathToModel, targetDevice, configuration) = this->GetParam();
|
||||
function = core->read_model(pathToModel);
|
||||
const auto metaFile = CommonTestUtils::replaceExt(pathToModel, "meta");
|
||||
std::pair<std::string, std::string> model_pair;
|
||||
std::tie(model_pair, targetDevice, configuration) = this->GetParam();
|
||||
std::tie(path_to_model, path_to_cache) = model_pair;
|
||||
function = core->read_model(path_to_model);
|
||||
const auto metaFile = CommonTestUtils::replaceExt(path_to_model, "meta");
|
||||
if (CommonTestUtils::fileExists(metaFile)) {
|
||||
pugi::xml_document doc;
|
||||
doc.load_file(metaFile.c_str());
|
||||
auto models = doc.child("meta_info").child("models");
|
||||
sourceModel = models.child("initial_model").attribute("name").as_string();
|
||||
source_model = models.child("initial_model").attribute("name").as_string();
|
||||
for (const auto &model : models.children("model")) {
|
||||
ocuranceInModels.push_back({model.attribute("name").as_string(), model.attribute("count").as_uint()});
|
||||
ocurance_in_models.push_back({model.attribute("name").as_string(), model.attribute("count").as_uint()});
|
||||
}
|
||||
auto portsInfo = doc.child("meta_info").child("ports_info");
|
||||
auto getPortInfo = [&](size_t id) {
|
||||
@ -264,6 +268,44 @@ void ReadIRTest::SetUp() {
|
||||
is_report_stages = true;
|
||||
}
|
||||
|
||||
std::vector<ov::Tensor> ReadIRTest::calculate_refs() {
|
||||
if (!CommonTestUtils::fileExists(path_to_cache)) {
|
||||
std::cout << "[ REFERENCE ] Calculate reference in runtime" << std::endl;
|
||||
auto output_tensors = SubgraphBaseTest::calculate_refs();
|
||||
if (path_to_cache != "") {
|
||||
std::ofstream ofp(path_to_cache, std::ios::out | std::ios::binary);
|
||||
for (const auto& out_tensor : output_tensors) {
|
||||
ofp.write(reinterpret_cast<const char*>(out_tensor.data<char>()), out_tensor.get_byte_size());
|
||||
}
|
||||
ofp.close();
|
||||
}
|
||||
return output_tensors;
|
||||
} else {
|
||||
std::cout << "[ REFERENCE ] Read refernce from file: " << path_to_cache << std::endl;
|
||||
|
||||
ov::TensorVector output_tensors;
|
||||
// Because of functionRefs is a static function
|
||||
std::ifstream ref_data_ifstream(path_to_cache, std::ios_base::binary);
|
||||
ref_data_ifstream.open(path_to_cache, std::ios::binary);
|
||||
if (!ref_data_ifstream.is_open())
|
||||
// IE_THROW() << "Weights file " << ref_tensors << " cannot be opened!";
|
||||
|
||||
ref_data_ifstream.seekg(0, std::ios::end);
|
||||
size_t file_size = ref_data_ifstream.tellg();
|
||||
ref_data_ifstream.seekg(0, std::ios::beg);
|
||||
|
||||
char* ref_data;
|
||||
ref_data_ifstream.read(ref_data, file_size);
|
||||
ref_data_ifstream.close();
|
||||
|
||||
size_t pos = 0;
|
||||
for (const auto& output : functionRefs->outputs()) {
|
||||
auto out_tensor = ov::runtime::Tensor(output.get_element_type(), output.get_shape(), &ref_data[pos]);
|
||||
pos += out_tensor.get_byte_size();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace subgraph
|
||||
} // namespace test
|
||||
} // namespace ov
|
||||
|
@ -15,6 +15,7 @@ namespace conformance {
|
||||
|
||||
const char *targetDevice = "";
|
||||
const char *targetPluginName = "";
|
||||
const char *refCachePath = "";
|
||||
|
||||
std::vector<std::string> IRFolderPaths = {};
|
||||
std::vector<std::string> disabledTests = {};
|
||||
|
Loading…
Reference in New Issue
Block a user