@@ -1954,6 +1954,11 @@ struct ggml_sycl_pool_leg : public ggml_sycl_pool {
1954
1954
SYCL_CHECK (
1955
1955
CHECK_TRY_ERROR (ptr = (void *)sycl::malloc_device (
1956
1956
look_ahead_size, *qptr)));
1957
+ if (!ptr) {
1958
+ fprintf (stderr, " %s: can't malloc %lu Bytes memory on device" , __func__, look_ahead_size);
1959
+ return nullptr ;
1960
+ }
1961
+
1957
1962
*actual_size = look_ahead_size;
1958
1963
pool_size += look_ahead_size;
1959
1964
@@ -4350,6 +4355,10 @@ ggml_backend_sycl_buffer_type_alloc_buffer(ggml_backend_buffer_type_t buft,
4350
4355
void * dev_ptr;
4351
4356
SYCL_CHECK (CHECK_TRY_ERROR (dev_ptr = (void *)sycl::malloc_device (
4352
4357
size, *stream)));
4358
+ if (!dev_ptr) {
4359
+ fprintf (stderr, " %s: can't malloc %lu Bytes memory on device" , __func__, size);
4360
+ return nullptr ;
4361
+ }
4353
4362
ggml_backend_sycl_buffer_context * ctx = new ggml_backend_sycl_buffer_context (buft_ctx->device , dev_ptr, buft_ctx->stream );
4354
4363
return ggml_backend_buffer_init (buft, ggml_backend_sycl_buffer_interface, ctx, size);
4355
4364
}
@@ -4570,7 +4579,11 @@ ggml_backend_sycl_split_buffer_init_tensor(ggml_backend_buffer_t buffer,
4570
4579
*/
4571
4580
SYCL_CHECK (CHECK_TRY_ERROR (buf = (char *)sycl::malloc_device (
4572
4581
size, *stream)));
4573
-
4582
+ if (!buf) {
4583
+ char err_buf[1024 ];
4584
+ snprintf (err_buf, 1023 , " %s: can't malloc %lu Bytes memory on device" , __func__, size);
4585
+ throw std::runtime_error (err_buf);
4586
+ }
4574
4587
// set padding to 0 to avoid possible NaN values
4575
4588
if (size > original_size) {
4576
4589
/*
0 commit comments