Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't silently ignore errors in VkCompute::submit_and_wait #4828

Merged
merged 1 commit into from
Jul 11, 2023
Merged
Show file tree
Hide file tree
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
10 changes: 6 additions & 4 deletions src/gpu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1878,9 +1878,7 @@ int VulkanDevicePrivate::create_dummy_buffer_image()
cmd.record_dummy_readonly(dummy_image_readonly);
#endif

cmd.submit_and_wait();

return 0;
return cmd.submit_and_wait();
}

void VulkanDevicePrivate::destroy_dummy_buffer_image()
Expand Down Expand Up @@ -2289,7 +2287,11 @@ VulkanDevice::VulkanDevice(int device_index)
}
}

d->create_dummy_buffer_image();
int cret = d->create_dummy_buffer_image();
if (cret != 0)
{
NCNN_LOGE("VulkanDevice create_dummy_buffer_image failed %d", cret);
}

d->pipeline_cache = new PipelineCache(this);

Expand Down
29 changes: 16 additions & 13 deletions src/net.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,7 @@ int NetPrivate::upload_model()
}
}

cmd.submit_and_wait();

return 0;
return cmd.submit_and_wait();
}
#endif // NCNN_VULKAN

Expand Down Expand Up @@ -288,9 +286,10 @@ int NetPrivate::forward_layer(int layer_index, std::vector<Mat>& blob_mats, std:
}
}

int ret;
if (cmd_submit_and_wait)
{
cmd.submit_and_wait();
ret = cmd.submit_and_wait();

#if NCNN_BENCHMARK
std::vector<uint64_t> results(layer_index * 2);
Expand All @@ -308,9 +307,10 @@ int NetPrivate::forward_layer(int layer_index, std::vector<Mat>& blob_mats, std:
#endif // NCNN_BENCHMARK

cmd.reset();
if (ret != 0)
return ret;
}

int ret;
if (layer->support_vulkan)
{
#if NCNN_BENCHMARK
Expand Down Expand Up @@ -505,9 +505,10 @@ int NetPrivate::forward_layer(int layer_index, std::vector<Mat>& blob_mats, std:
}
}

int ret;
if (cmd_submit_and_wait)
{
cmd.submit_and_wait();
ret = cmd.submit_and_wait();

#if NCNN_BENCHMARK
std::vector<uint64_t> results(layer_index * 2);
Expand All @@ -525,9 +526,11 @@ int NetPrivate::forward_layer(int layer_index, std::vector<Mat>& blob_mats, std:
#endif // NCNN_BENCHMARK

cmd.reset();

if (ret != 0)
return ret;
}

int ret;
if (layer->support_vulkan && !image_allocation_failed)
{
#if NCNN_BENCHMARK
Expand Down Expand Up @@ -1827,9 +1830,9 @@ int Net::load_model(const DataReader& dr)
}

#if NCNN_VULKAN
if (opt.use_vulkan_compute)
if (ret == 0 && opt.use_vulkan_compute)
{
d->upload_model();
ret = d->upload_model();
}
#endif // NCNN_VULKAN

Expand Down Expand Up @@ -2506,11 +2509,11 @@ int Extractor::extract(int blob_index, Mat& feat, int type)
VkImageMat feat_gpu;
ret = extract(blob_index, feat_gpu, cmd);

if (d->blob_mats[blob_index].dims == 0 && feat_gpu.dims != 0)
if (ret == 0 && d->blob_mats[blob_index].dims == 0 && feat_gpu.dims != 0)
{
cmd.record_download(feat_gpu, d->blob_mats[blob_index], d->opt);

cmd.submit_and_wait();
ret = cmd.submit_and_wait();

#if NCNN_BENCHMARK
std::vector<uint64_t> results(d->net->layers().size() * 2);
Expand All @@ -2533,11 +2536,11 @@ int Extractor::extract(int blob_index, Mat& feat, int type)
VkMat feat_gpu;
ret = extract(blob_index, feat_gpu, cmd);

if (d->blob_mats[blob_index].dims == 0 && feat_gpu.dims != 0)
if (ret == 0 && d->blob_mats[blob_index].dims == 0 && feat_gpu.dims != 0)
{
cmd.record_download(feat_gpu, d->blob_mats[blob_index], d->opt);

cmd.submit_and_wait();
ret = cmd.submit_and_wait();

#if NCNN_BENCHMARK
std::vector<uint64_t> results(d->net->layers().size() * 2);
Expand Down