Change comparation (#18515)

This commit is contained in:
Sofya Balandina 2023-07-19 10:01:09 +01:00 committed by GitHub
parent e600a8e45a
commit d08b424935
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 55 additions and 0 deletions

View File

@ -28,6 +28,7 @@ class ReadIRTest : public testing::WithParamInterface<ReadIRParams>,
public:
static std::string getTestCaseName(const testing::TestParamInfo<ReadIRParams> &obj);
void query_model() override;
void import_export();
std::vector<ov::Tensor> calculate_refs() override;
protected:

View File

@ -13,6 +13,7 @@
#include "common_test_utils/file_utils.hpp"
#include "common_test_utils/data_utils.hpp"
#include "common_test_utils/common_utils.hpp"
#include "common_test_utils/graph_comparator.hpp"
#include "functional_test_utils/crash_handler.hpp"
#include "functional_test_utils/summary/op_info.hpp"
#include "functional_test_utils/skip_tests_config.hpp"
@ -136,6 +137,55 @@ void ReadIRTest::query_model() {
}
}
void ReadIRTest::import_export() {
// in case of crash jump will be made and work will be continued
auto crashHandler = std::unique_ptr<CommonTestUtils::CrashHandler>(new CommonTestUtils::CrashHandler());
auto &summary = ov::test::utils::OpSummary::getInstance();
// place to jump in case of a crash
int jmpRes = 0;
#ifdef _WIN32
jmpRes = setjmp(CommonTestUtils::env);
#else
jmpRes = sigsetjmp(CommonTestUtils::env, 1);
#endif
if (jmpRes == CommonTestUtils::JMP_STATUS::ok) {
crashHandler->StartTimer();
summary.setDeviceName(targetDevice);
try {
ov::CompiledModel model = core->compile_model(function, targetDevice, configuration);
std::stringstream strm;
model.export_model(strm);
ov::CompiledModel importedModel = core->import_model(strm, targetDevice, configuration);
auto comparator = FunctionsComparator::with_default()
.enable(FunctionsComparator::ATTRIBUTES)
.enable(FunctionsComparator::NAMES)
.enable(FunctionsComparator::CONST_VALUES);
auto importedFunction = importedModel.get_runtime_model()->clone();
auto res = comparator.compare(importedFunction, function);
EXPECT_TRUE(res.valid) << res.message;
summary.updateOPsImplStatus(function, true);
} catch (const std::exception &e) {
summary.updateOPsImplStatus(function, false);
GTEST_FAIL() << "Exception in the Core::compile_model() method call: " << e.what();
} catch (...) {
summary.updateOPsImplStatus(function, false);
GTEST_FAIL() << "Error in the Core::query_model() method call!";
}
} else if (jmpRes == CommonTestUtils::JMP_STATUS::anyError) {
summary.updateOPsImplStatus(function, false);
GTEST_FAIL() << "Crash happens";
} else if (jmpRes == CommonTestUtils::JMP_STATUS::alarmErr) {
summary.updateOPsImplStatus(function, false);
GTEST_FAIL() << "Hang happens";
}
}
uint64_t clip(uint64_t n, uint64_t lower, uint64_t upper) {
return std::max(lower, std::min(n, upper));
}

View File

@ -25,6 +25,10 @@ TEST_P(ReadIRTest, QueryModel) {
query_model();
}
TEST_P(ReadIRTest, ImportExport) {
import_export();
}
#define _OPENVINO_OP_REG(NAME, NAMESPACE) \
INSTANTIATE_TEST_SUITE_P(conformance_##NAME, \
ReadIRTest, \