fix ggml_compute_forward_dup_same_cont for when nelements < nthreads

when more threads are used than elements exist ie1 was less than ie0, resulting in invalid negative byte count argument in memcpy
This commit is contained in:
xaedes 2023-05-01 14:42:44 +02:00
parent c1a8893de3
commit 83fa6b3bcb
No known key found for this signature in database
GPG key ID: 30030EDD817EA2B1

10
ggml.c
View file

@ -6662,10 +6662,12 @@ static void ggml_compute_forward_dup_same_cont(
const int ie0 = dr * ith;
const int ie1 = MIN(ie0 + dr, ne);
memcpy(
((char *) dst->data + ie0*nb0),
((char *) src0->data + ie0*nb00),
(ie1 - ie0) * GGML_TYPE_SIZE[src0->type]);
if (ie0 < ie1) {
memcpy(
((char *) dst->data + ie0*nb0),
((char *) src0->data + ie0*nb00),
(ie1 - ie0) * GGML_TYPE_SIZE[src0->type]);
}
}
static void ggml_compute_forward_dup_f16(