Skip to content

Commit

Permalink
fix buf
Browse files Browse the repository at this point in the history
  • Loading branch information
luoyu-intel committed Jul 18, 2024
1 parent 2162012 commit a8c75c0
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions ggml/src/ggml-sycl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4341,6 +4341,9 @@ static void ggml_backend_sycl_buffer_set_tensor(ggml_backend_buffer_t buffer,
if (tensor->type == GGML_TYPE_Q4_0)
{
auto tmp_buf = sycl::malloc_shared<char>(size, *stream);
SYCL_CHECK(
CHECK_TRY_ERROR((*stream).memcpy(tmp_buf, data, size)
.wait()));
GGML_ASSERT((size % sizeof(block_q4_0) == 0));
GGML_ASSERT((offset % sizeof(block_q4_0) == 0));
int blk_offset = offset / sizeof(block_q4_0);
Expand All @@ -4349,9 +4352,9 @@ static void ggml_backend_sycl_buffer_set_tensor(ggml_backend_buffer_t buffer,
size_t nrows = tensor->ne[1];
auto d_ptr = (sycl::half*)(qs_ptr + ncols * nrows / 2) + blk_offset;
stream->parallel_for(
size / QK4_0,
size / sizeof(block_q4_0),
[=](auto i) [[intel::reqd_sub_group_size(WARP_SIZE)]] {
const block_q4_0* x = (const block_q4_0*)data;
const block_q4_0* x = (const block_q4_0*)tmp_buf;
int ib = i;
typedef sycl::vec<uint8_t, QK4_0 / 2> CT;
CT tmp = *(CT*)x[ib].qs;
Expand All @@ -4371,7 +4374,7 @@ static void ggml_backend_sycl_buffer_set_tensor(ggml_backend_buffer_t buffer,
}
*(d_ptr + ib) = x[ib].d;

});
}).wait();
sycl::free(tmp_buf, *stream);
}
else
Expand Down

0 comments on commit a8c75c0

Please sign in to comment.