From 5713aa0ca845f6eaf971e9ac9dab0eae297ceaef Mon Sep 17 00:00:00 2001 From: Yi Wang Date: Wed, 22 Apr 2020 17:25:24 -0700 Subject: [PATCH] fix [RUNTIME][VULKAN] vkBuffer released before memory copy command send to GPU (#5388) --- 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);