@@ -1820,6 +1820,11 @@ struct ggml_sycl_pool_leg : public ggml_sycl_pool {
18201820 SYCL_CHECK (
18211821 CHECK_TRY_ERROR (ptr = (void *)sycl::malloc_device (
18221822 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+
18231828 *actual_size = look_ahead_size;
18241829 pool_size += look_ahead_size;
18251830
@@ -4226,6 +4231,10 @@ ggml_backend_sycl_buffer_type_alloc_buffer(ggml_backend_buffer_type_t buft,
42264231 void * dev_ptr;
42274232 SYCL_CHECK (CHECK_TRY_ERROR (dev_ptr = (void *)sycl::malloc_device (
42284233 size, *stream)));
4234+ if (!dev_ptr) {
4235+ fprintf (stderr, " %s: can't malloc %lu Bytes memory on device" , __func__, size);
4236+ return nullptr ;
4237+ }
42294238 ggml_backend_sycl_buffer_context * ctx = new ggml_backend_sycl_buffer_context (buft_ctx->device , dev_ptr, buft_ctx->stream );
42304239 return ggml_backend_buffer_init (buft, ggml_backend_sycl_buffer_interface, ctx, size);
42314240}
@@ -4439,7 +4448,11 @@ ggml_backend_sycl_split_buffer_init_tensor(ggml_backend_buffer_t buffer,
44394448 */
44404449 SYCL_CHECK (CHECK_TRY_ERROR (buf = (char *)sycl::malloc_device (
44414450 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+ }
44434456 // set padding to 0 to avoid possible NaN values
44444457 if (size > original_size) {
44454458 /*
0 commit comments