Skip to content
Merged
Changes from all 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
15 changes: 13 additions & 2 deletions backends/vulkan/runtime/vk_api/Pipeline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -433,12 +433,12 @@ void ComputePipelineCache::purge() {
}

std::vector<char> ComputePipelineCache::load_cache() {
// Return if path is not specified; this means the optimization is disabled
// No optimization if path is unspecified
if (cache_data_path_.empty()) {
return {};
}

// Return if file doesn't exist; this is expected on the first model-load
// Return if file doesn't exist; this is expected on first model-load
std::ifstream file(cache_data_path_, std::ios::binary | std::ios::ate);
if (file.fail()) {
return {};
Expand All @@ -454,6 +454,17 @@ std::vector<char> ComputePipelineCache::load_cache() {
}

void ComputePipelineCache::save_cache() {
// No optimization if path is unspecified
if (cache_data_path_.empty()) {
return;
}

// Return if file exists; the cache is already saved
std::ifstream ifile(cache_data_path_);
if (ifile.good()) {
return;
}

size_t size{};
vkGetPipelineCacheData(device_, pipeline_cache_, &size, nullptr);

Expand Down
Loading