From fb5b765cb1abefd5982254d8b4c13f3bf0845efa Mon Sep 17 00:00:00 2001 From: samwyi Date: Thu, 23 Apr 2020 08:05:42 -0700 Subject: [PATCH] fix [RUNTIME][VULKAN] vkBuffer released before memory copy command send to GPU (#5388) (#5418) --- src/runtime/vulkan/vulkan.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/runtime/vulkan/vulkan.cc b/src/runtime/vulkan/vulkan.cc index 80486406187b..4e2f8cbcc0bf 100644 --- a/src/runtime/vulkan/vulkan.cc +++ b/src/runtime/vulkan/vulkan.cc @@ -189,6 +189,10 @@ class VulkanDeviceAPI final : public DeviceAPI { } void FreeDataSpace(TVMContext ctx, void* ptr) final { + // Before releasing the vkBuffer, call sync to + // finish all the vulkan commands that reference the buffer. + StreamSync(ctx, nullptr); + const auto& vctx = context(ctx.device_id); auto* pbuf = static_cast(ptr); vkDestroyBuffer(vctx.device, pbuf->buffer, nullptr);