@@ -1821,6 +1821,11 @@ struct ggml_sycl_pool_leg : public ggml_sycl_pool {
18211821 SYCL_CHECK (
18221822 CHECK_TRY_ERROR (ptr = (void *)sycl::malloc_device (
18231823 look_ahead_size, *qptr)));
1824+ if (!ptr) {
1825+ fprintf (stderr, " %s: can't malloc %lu Bytes memory on device" , __func__, look_ahead_size);
1826+ return nullptr ;
1827+ }
1828+
18241829 *actual_size = look_ahead_size;
18251830 pool_size += look_ahead_size;
18261831
@@ -4227,6 +4232,10 @@ ggml_backend_sycl_buffer_type_alloc_buffer(ggml_backend_buffer_type_t buft,
42274232 void * dev_ptr;
42284233 SYCL_CHECK (CHECK_TRY_ERROR (dev_ptr = (void *)sycl::malloc_device (
42294234 size, *stream)));
4235+ if (!dev_ptr) {
4236+ fprintf (stderr, " %s: can't malloc %lu Bytes memory on device" , __func__, size);
4237+ return nullptr ;
4238+ }
42304239 ggml_backend_sycl_buffer_context * ctx = new ggml_backend_sycl_buffer_context (buft_ctx->device , dev_ptr, buft_ctx->stream );
42314240 return ggml_backend_buffer_init (buft, ggml_backend_sycl_buffer_interface, ctx, size);
42324241}
@@ -4440,7 +4449,11 @@ ggml_backend_sycl_split_buffer_init_tensor(ggml_backend_buffer_t buffer,
44404449 */
44414450 SYCL_CHECK (CHECK_TRY_ERROR (buf = (char *)sycl::malloc_device (
44424451 size, *stream)));
4443-
4452+ if (!buf) {
4453+ char err_buf[1024 ];
4454+ snprintf (err_buf, 1023 , " %s: can't malloc %lu Bytes memory on device" , __func__, size);
4455+ throw std::runtime_error (err_buf);
4456+ }
44444457 // set padding to 0 to avoid possible NaN values
44454458 if (size > original_size) {
44464459 /*
0 commit comments