Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions src/llama-context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3090,7 +3090,8 @@ class llama_io_write_device : public llama_io_write_i {
for (const auto & winfo : winfos) {
auto * buft = ggml_backend_buffer_get_type(winfo.tensor->buffer);

const int64_t n = winfo.size/ggml_element_size(winfo.tensor);
GGML_ASSERT(winfo.size % ggml_type_size(winfo.tensor->type) == 0);
const int64_t n = winfo.size/ggml_type_size(winfo.tensor->type)*ggml_blck_size(winfo.tensor->type);

auto & mbuf = mbufs_new[buft];

Expand Down Expand Up @@ -3221,7 +3222,8 @@ class llama_io_read_device : public llama_io_read_i {
for (const auto & rinfo : rinfos) {
auto * buft = ggml_backend_buffer_get_type(rinfo.tensor->buffer);

const int64_t n = rinfo.size/ggml_element_size(rinfo.tensor);
GGML_ASSERT(rinfo.size % ggml_type_size(rinfo.tensor->type) == 0);
const int64_t n = rinfo.size/ggml_type_size(rinfo.tensor->type)*ggml_blck_size(rinfo.tensor->type);

auto & mbuf = mbufs_new[buft];

Expand Down Expand Up @@ -3288,8 +3290,8 @@ class llama_io_read_device : public llama_io_read_i {

const size_t n_copy = std::min(src_size - src_off, dst_size - dst_off);

const size_t el = ggml_element_size(src_t);
const int64_t n_el = (int64_t) (n_copy / el);
GGML_ASSERT(n_copy % ggml_type_size(src_t->type) == 0);
const int64_t n_el = n_copy / ggml_type_size(src_t->type) * ggml_blck_size(src_t->type);

auto * src_v = ggml_view_1d(ctx_scratch, src_t, n_el, src_off);
ggml_backend_view_init(src_v);
Expand Down