@@ -1820,6 +1820,11 @@ struct ggml_sycl_pool_leg : public ggml_sycl_pool {
1820
1820
SYCL_CHECK (
1821
1821
CHECK_TRY_ERROR (ptr = (void *)sycl::malloc_device (
1822
1822
look_ahead_size, *qptr)));
1823
+ if (!ptr) {
1824
+ fprintf (stderr, " %s: can't malloc %lu Bytes memory on device" , __func__, look_ahead_size);
1825
+ return nullptr ;
1826
+ }
1827
+
1823
1828
*actual_size = look_ahead_size;
1824
1829
pool_size += look_ahead_size;
1825
1830
@@ -4226,6 +4231,10 @@ ggml_backend_sycl_buffer_type_alloc_buffer(ggml_backend_buffer_type_t buft,
4226
4231
void * dev_ptr;
4227
4232
SYCL_CHECK (CHECK_TRY_ERROR (dev_ptr = (void *)sycl::malloc_device (
4228
4233
size, *stream)));
4234
+ if (!dev_ptr) {
4235
+ fprintf (stderr, " %s: can't malloc %lu Bytes memory on device" , __func__, size);
4236
+ return nullptr ;
4237
+ }
4229
4238
ggml_backend_sycl_buffer_context * ctx = new ggml_backend_sycl_buffer_context (buft_ctx->device , dev_ptr, buft_ctx->stream );
4230
4239
return ggml_backend_buffer_init (buft, ggml_backend_sycl_buffer_interface, ctx, size);
4231
4240
}
@@ -4439,7 +4448,11 @@ ggml_backend_sycl_split_buffer_init_tensor(ggml_backend_buffer_t buffer,
4439
4448
*/
4440
4449
SYCL_CHECK (CHECK_TRY_ERROR (buf = (char *)sycl::malloc_device (
4441
4450
size, *stream)));
4442
-
4451
+ if (!buf) {
4452
+ char err_buf[1024 ];
4453
+ snprintf (err_buf, 1023 , " %s: can't malloc %lu Bytes memory on device" , __func__, size);
4454
+ throw std::runtime_error (err_buf);
4455
+ }
4443
4456
// set padding to 0 to avoid possible NaN values
4444
4457
if (size > original_size) {
4445
4458
/*
0 commit comments