mirror of
https://github.com/ggerganov/llama.cpp.git
synced 2025-01-14 06:19:02 +01:00
ggml: fix ggml_graph_cpy undefined behavior (ggml/943)
This commit is contained in:
parent
ba1cf846ed
commit
dbbebcab33
@ -681,8 +681,8 @@ extern "C" {
|
|||||||
|
|
||||||
struct ggml_hash_set {
|
struct ggml_hash_set {
|
||||||
size_t size;
|
size_t size;
|
||||||
ggml_bitset_t * used;
|
ggml_bitset_t * used; // whether or not the keys are in use i.e. set
|
||||||
struct ggml_tensor ** keys;
|
struct ggml_tensor ** keys; // actual tensors in the set, keys[i] is only defined if ggml_bitset_get(used, i)
|
||||||
};
|
};
|
||||||
|
|
||||||
// computation graph
|
// computation graph
|
||||||
|
@ -19130,7 +19130,8 @@ void ggml_graph_cpy(struct ggml_cgraph * src, struct ggml_cgraph * dst) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (size_t i = 0; i < src->visited_hash_set.size; ++i) {
|
for (size_t i = 0; i < src->visited_hash_set.size; ++i) {
|
||||||
if (src->visited_hash_set.keys[i]) {
|
// copy all hashset keys (tensors) that are in use
|
||||||
|
if (ggml_bitset_get(src->visited_hash_set.used, i)) {
|
||||||
ggml_hash_insert(&dst->visited_hash_set, src->visited_hash_set.keys[i]);
|
ggml_hash_insert(&dst->visited_hash_set, src->visited_hash_set.keys[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user