@@ -1954,6 +1954,11 @@ struct ggml_sycl_pool_leg : public ggml_sycl_pool {
19541954 SYCL_CHECK (
19551955 CHECK_TRY_ERROR (ptr = (void *)sycl::malloc_device (
19561956 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+
19571962 *actual_size = look_ahead_size;
19581963 pool_size += look_ahead_size;
19591964
@@ -4350,6 +4355,10 @@ ggml_backend_sycl_buffer_type_alloc_buffer(ggml_backend_buffer_type_t buft,
43504355 void * dev_ptr;
43514356 SYCL_CHECK (CHECK_TRY_ERROR (dev_ptr = (void *)sycl::malloc_device (
43524357 size, *stream)));
4358+ if (!dev_ptr) {
4359+ fprintf (stderr, " %s: can't malloc %lu Bytes memory on device" , __func__, size);
4360+ return nullptr ;
4361+ }
43534362 ggml_backend_sycl_buffer_context * ctx = new ggml_backend_sycl_buffer_context (buft_ctx->device , dev_ptr, buft_ctx->stream );
43544363 return ggml_backend_buffer_init (buft, ggml_backend_sycl_buffer_interface, ctx, size);
43554364}
@@ -4570,7 +4579,11 @@ ggml_backend_sycl_split_buffer_init_tensor(ggml_backend_buffer_t buffer,
45704579 */
45714580 SYCL_CHECK (CHECK_TRY_ERROR (buf = (char *)sycl::malloc_device (
45724581 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+ }
45744587 // set padding to 0 to avoid possible NaN values
45754588 if (size > original_size) {
45764589 /*
0 commit comments