mirror of
https://github.com/ggerganov/whisper.cpp.git
synced 2024-12-18 20:27:53 +00:00
vulkan : improve ggml_vk_create_buffer error handling (llama/9898)
This commit is contained in:
parent
0665168ef3
commit
ec3e16445e
@ -1047,7 +1047,6 @@ static vk_buffer ggml_vk_create_buffer(vk_device& device, size_t size, vk::Memor
|
|||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
buf->size = size;
|
|
||||||
vk::BufferCreateInfo buffer_create_info{
|
vk::BufferCreateInfo buffer_create_info{
|
||||||
vk::BufferCreateFlags(),
|
vk::BufferCreateFlags(),
|
||||||
size,
|
size,
|
||||||
@ -1075,7 +1074,6 @@ static vk_buffer ggml_vk_create_buffer(vk_device& device, size_t size, vk::Memor
|
|||||||
|
|
||||||
if (memory_type_index == UINT32_MAX) {
|
if (memory_type_index == UINT32_MAX) {
|
||||||
device->device.destroyBuffer(buf->buffer);
|
device->device.destroyBuffer(buf->buffer);
|
||||||
buf->size = 0;
|
|
||||||
throw vk::OutOfDeviceMemoryError("No suitable memory type found");
|
throw vk::OutOfDeviceMemoryError("No suitable memory type found");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1092,13 +1090,11 @@ static vk_buffer ggml_vk_create_buffer(vk_device& device, size_t size, vk::Memor
|
|||||||
}
|
}
|
||||||
catch (const vk::SystemError& e) {
|
catch (const vk::SystemError& e) {
|
||||||
device->device.destroyBuffer(buf->buffer);
|
device->device.destroyBuffer(buf->buffer);
|
||||||
buf->size = 0;
|
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Out of Host/Device memory, clean up buffer
|
// Out of Host/Device memory, clean up buffer
|
||||||
device->device.destroyBuffer(buf->buffer);
|
device->device.destroyBuffer(buf->buffer);
|
||||||
buf->size = 0;
|
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1111,6 +1107,7 @@ static vk_buffer ggml_vk_create_buffer(vk_device& device, size_t size, vk::Memor
|
|||||||
device->device.bindBufferMemory(buf->buffer, buf->device_memory, 0);
|
device->device.bindBufferMemory(buf->buffer, buf->device_memory, 0);
|
||||||
|
|
||||||
buf->device = device;
|
buf->device = device;
|
||||||
|
buf->size = size;
|
||||||
|
|
||||||
#ifdef GGML_VULKAN_MEMORY_DEBUG
|
#ifdef GGML_VULKAN_MEMORY_DEBUG
|
||||||
device->memory_logger->log_allocation(buf, size);
|
device->memory_logger->log_allocation(buf, size);
|
||||||
|
Loading…
Reference in New Issue
Block a user