Save and load VkPipelineCache data if path is specified (#3546)
Summary: Pull Request resolved: https://github.com/pytorch/executorch/pull/3546 ## Context Pipeline creation involves the compilation of shader SPIR-V code into machine-specific code. This makes the application's first model-load via the `Program::load_method()` ET-API very slow, due to the creation of compute pipelines via the `vkCreateComputePipelines()` VK-API. To amortize that cost, Vulkan offers a [Compute Pipeline Cache API](https://docs.vulkan.org/guide/latest/pipeline_cache.html). Following [this Vulkan example](https://github.com/KhronosGroup/Vulkan-Samples/tree/main/samples/performance/pipeline_cache), we can (A) retrieve the compiled machine-specific code saving it to a file and (B) load it to a file next time. For an internal model executing on a resource-constrained device, this improves model-load time from ~1200ms to ~500ms. ## This change We implement both (A)+(B) ET-VK logic. Note that these changes are actually no-op unless you initialize the `pipeline_cache_file_path` manually. The expectation is for the client application to specify the file path of their pipeline cache data if they want to leverage this optimization. In a future ET-wide change, we will expose the file_path config parameter to the ET-API. ghstack-source-id: 225763792 bypass-github-export-checks bypass-github-pytorch-ci-checks bypass-github-executorch-ci-checks Reviewed By: SS-JIA Differential Revision: D57085276 fbshipit-source-id: 993dc55d5930c913884ad455f359b62afb75bf87
J
Jorge Pineda committed
ebdb152aba547f17ef2952d105658e16afb70a0b
Parent: f6f881a
Committed by Facebook GitHub Bot <facebook-github-bot@users.noreply.github.com>
on 5/9/2024, 7:22:59 PM