From acea65028a224e868b1fc15f003a5be4589f414a Mon Sep 17 00:00:00 2001 From: daquexian Date: Mon, 21 Aug 2023 22:46:22 +0800 Subject: [PATCH] load bin in a single pass Signed-off-by: daquexian --- src/net.cpp | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/src/net.cpp b/src/net.cpp index 8d4e234f75c..aed2f20a48e 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -1735,6 +1735,18 @@ int Net::load_model(const DataReader& dr) // load file int ret = 0; +#if NCNN_VULKAN + if (opt.use_vulkan_compute) + { + if (!opt.pipeline_cache) + { + if (!d->pipeline_cache) + d->pipeline_cache = new PipelineCache(d->vkdev); + opt.pipeline_cache = d->pipeline_cache; + } + } +#endif // NCNN_VULKAN + ModelBinFromDataReader mb(dr); for (int i = 0; i < layer_count; i++) { @@ -1765,23 +1777,6 @@ int Net::load_model(const DataReader& dr) // no int8 gpu support yet opt.use_vulkan_compute = false; } - } - -#if NCNN_VULKAN - if (opt.use_vulkan_compute) - { - if (!opt.pipeline_cache) - { - if (!d->pipeline_cache) - d->pipeline_cache = new PipelineCache(d->vkdev); - opt.pipeline_cache = d->pipeline_cache; - } - } -#endif // NCNN_VULKAN - - for (int i = 0; i < layer_count; i++) - { - Layer* layer = d->layers[i]; Option opt1 = get_masked_option(opt, layer->featmask); #if NCNN_VULKAN