Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions src/common/util/src/file_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -294,12 +294,9 @@ void ov::util::create_directory_recursive(const std::wstring& path) {
void ov::util::create_directory_recursive(const std::filesystem::path& path) {
namespace fs = std::filesystem;
auto dir_path = fs::weakly_canonical(path);
if (!dir_path.has_filename() || dir_path.has_extension()) {
dir_path = get_directory(dir_path);
}

if (!dir_path.empty() && !directory_exists(dir_path)) {
if (std::error_code ec; !fs::create_directories(dir_path, ec)) {
if (std::error_code ec; !fs::create_directories(dir_path, ec) && !std::filesystem::exists(dir_path)) {
std::stringstream ss;
ss << "Couldn't create directory [" << dir_path << "], err=" << ec.message() << ")";
throw std::runtime_error(ss.str());
Expand Down
2 changes: 1 addition & 1 deletion src/core/src/pass/serialize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ bool pass::Serialize::run_on_model(const std::shared_ptr<ov::Model>& model) {
if (m_xmlFile && m_binFile) {
serialize_func(*m_xmlFile, *m_binFile, model, m_version);
} else {
ov::util::create_directory_recursive(m_xmlPath);
ov::util::create_directory_recursive(m_xmlPath.parent_path());

std::ofstream bin_file(m_binPath, std::ios::binary);
OPENVINO_ASSERT(bin_file, "Can't open bin file: \"", m_binPath, "\"");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include "shared_test_classes/base/ov_subgraph.hpp"
#include "subgraphs_builders.hpp"
#include "openvino/op/relu.hpp"

namespace {

Expand Down Expand Up @@ -65,4 +66,60 @@ TEST_F(LSTMSequenceTest, smoke_serialize) {
TEST_F(GRUSequenceTest, smoke_serialize) {
run();
}

class GpuCacheDirWithDotsParamTest : public ::testing::TestWithParam<std::string> {
protected:
ov::Core core;
std::string cacheDir;

static bool has_gpu(ov::Core& c) {
for (auto&& d : c.get_available_devices())
if (d.find("GPU") != std::string::npos)
return true;
return false;
}

void SetUp() override {
if (!has_gpu(core)) {
GTEST_SKIP() << "GPU device not available";
}
std::stringstream ss;
ss << std::hex
<< std::hash<std::string>{}(
std::string(::testing::UnitTest::GetInstance()->current_test_info()->name()));

// Base (no trailing slash first)
cacheDir = ss.str() + GetParam();

// Clean previous
ov::test::utils::removeFilesWithExt(cacheDir, "blob");
ov::test::utils::removeFilesWithExt(cacheDir, "cl_cache");
ov::test::utils::removeDir(cacheDir);

core.set_property(ov::cache_dir(cacheDir));
}

void TearDown() override {
ov::test::utils::removeFilesWithExt(cacheDir, "blob");
ov::test::utils::removeFilesWithExt(cacheDir, "cl_cache");
ov::test::utils::removeDir(cacheDir);
}
};


TEST_P(GpuCacheDirWithDotsParamTest, PopulateAndReuseCache) {
auto param = std::make_shared<ov::op::v0::Parameter>(ov::element::f32, ov::Shape{1, 3, 8, 8});
auto relu = std::make_shared<ov::op::v0::Relu>(param);
auto res = std::make_shared<ov::op::v0::Result>(relu);
auto model = std::make_shared<ov::Model>(ov::ResultVector{res}, ov::ParameterVector{param}, "CacheDotsModel");
core.compile_model(model, "GPU");
}

INSTANTIATE_TEST_SUITE_P(CacheDirDotVariants,
GpuCacheDirWithDotsParamTest,
::testing::Values(
"/test_encoder/test_encoder.encrypted/",
"/test_encoder/test_encoder.encrypted"
));

} // namespace
Loading