Skip to content

Commit

Permalink
ggml : ggml_backend_graph_copy -> ggml_backend_graph_copy_state
Browse files Browse the repository at this point in the history
ggml-ci
  • Loading branch information
ggerganov committed Jan 12, 2025
1 parent afd40ea commit a97b362
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions ggml/include/ggml-backend.h
Original file line number Diff line number Diff line change
Expand Up @@ -323,16 +323,16 @@ extern "C" {
// Utils
//

struct ggml_backend_graph_copy {
struct ggml_backend_graph_copy_state {
ggml_backend_buffer_t buffer;
struct ggml_context * ctx_allocated;
struct ggml_context * ctx_unallocated;
struct ggml_cgraph * graph;
};

// Copy a graph to a different backend
GGML_API struct ggml_backend_graph_copy ggml_backend_graph_copy_init(ggml_backend_t backend, struct ggml_cgraph * graph);
GGML_API void ggml_backend_graph_copy_free(struct ggml_backend_graph_copy copy);
GGML_API struct ggml_backend_graph_copy_state ggml_backend_graph_copy(ggml_backend_t backend, struct ggml_cgraph * graph);
GGML_API void ggml_backend_graph_copy_free(struct ggml_backend_graph_copy_state copy);

typedef bool (*ggml_backend_eval_callback)(int node_index, struct ggml_tensor * t1, struct ggml_tensor * t2, void * user_data);

Expand Down
6 changes: 3 additions & 3 deletions ggml/src/ggml-backend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1724,7 +1724,7 @@ static void graph_copy_init_tensor(struct ggml_hash_set * hash_set, struct ggml_
}
}

struct ggml_backend_graph_copy ggml_backend_graph_copy_init(ggml_backend_t backend, struct ggml_cgraph * graph) {
struct ggml_backend_graph_copy_state ggml_backend_graph_copy(ggml_backend_t backend, struct ggml_cgraph * graph) {
struct ggml_hash_set hash_set = ggml_hash_set_new(graph->visited_hash_set.size);
struct ggml_tensor ** node_copies = (ggml_tensor **) calloc(hash_set.size, sizeof(node_copies[0])); // NOLINT
bool * node_init = (bool *) calloc(hash_set.size, sizeof(node_init[0]));
Expand Down Expand Up @@ -1805,14 +1805,14 @@ struct ggml_backend_graph_copy ggml_backend_graph_copy_init(ggml_backend_t backe
};
}

void ggml_backend_graph_copy_free(struct ggml_backend_graph_copy copy) {
void ggml_backend_graph_copy_free(struct ggml_backend_graph_copy_state copy) {
ggml_backend_buffer_free(copy.buffer);
ggml_free(copy.ctx_allocated);
ggml_free(copy.ctx_unallocated);
}

bool ggml_backend_compare_graph_backend(ggml_backend_t backend1, ggml_backend_t backend2, struct ggml_cgraph * graph, ggml_backend_eval_callback callback, void * user_data) {
struct ggml_backend_graph_copy copy = ggml_backend_graph_copy_init(backend2, graph);
struct ggml_backend_graph_copy_state copy = ggml_backend_graph_copy(backend2, graph);
if (copy.buffer == NULL) {
return false;
}
Expand Down

0 comments on commit a97b362

Please sign in to comment.