summaryrefslogtreecommitdiff
path: root/ggml-kompute.cpp
diff options
context:
space:
mode:
authorUEXTM.com <84163508+uextm@users.noreply.github.com>2024-02-24 11:27:36 -0500
committerGeorgi Gerganov <ggerganov@gmail.com>2024-02-28 11:17:05 +0200
commit5f706718566e3a5147916dc381f3b99de0ffad47 (patch)
treea8375d9ea4eae5abac38cc0aba29fdedbf4fe9f5 /ggml-kompute.cpp
parenta693bea1e6762a17b78b6ddf4611e54136941ea2 (diff)
Introduce backend GUIDs (ggml/743)
* Introduce backend GUIDs Initial proposed implementation of backend GUIDs (Discussed in https://github.com/ggerganov/ggml/pull/741) Hardcoded CPU backend GUID (for now) Change ggml_backend_is_cpu logic to use GUID * Remove redundant functions Remove redundant functions `ggml_backend_i::get_name` and `ggml_backend_guid` which are not desired for future expansion * Add spaces to match style Co-authored-by: slaren <slarengh@gmail.com> * Fix brace style to match Co-authored-by: slaren <slarengh@gmail.com> * Add void to () in function signature Co-authored-by: slaren <slarengh@gmail.com> * Add back ggml_backend_guid and make CPU_GUID a local static in ggml_backend_cpu_guid * add guids to all backends ggml-ci --------- Co-authored-by: slaren <slarengh@gmail.com>
Diffstat (limited to 'ggml-kompute.cpp')
-rw-r--r--ggml-kompute.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/ggml-kompute.cpp b/ggml-kompute.cpp
index 51c5af8e..e740a76d 100644
--- a/ggml-kompute.cpp
+++ b/ggml-kompute.cpp
@@ -1953,11 +1953,17 @@ static struct ggml_backend_i kompute_backend_i = {
/* .supports_op = */ ggml_backend_kompute_supports_op,
};
+static ggml_guid_t ggml_backend_kompute_guid() {
+ static ggml_guid guid = { 0x7b, 0x57, 0xdc, 0xaf, 0xde, 0x12, 0x1d, 0x49, 0xfb, 0x35, 0xfa, 0x9b, 0x18, 0x31, 0x1d, 0xca };
+ return &guid;
+}
+
ggml_backend_t ggml_backend_kompute_init(int device) {
GGML_ASSERT(s_kompute_context == nullptr);
s_kompute_context = new ggml_kompute_context(device);
ggml_backend_t kompute_backend = new ggml_backend {
+ /* .guid = */ ggml_backend_kompute_guid(),
/* .interface = */ kompute_backend_i,
/* .context = */ s_kompute_context,
};
@@ -1966,7 +1972,7 @@ ggml_backend_t ggml_backend_kompute_init(int device) {
}
bool ggml_backend_is_kompute(ggml_backend_t backend) {
- return backend && backend->iface.get_name == ggml_backend_kompute_name;
+ return backend != NULL && ggml_guid_matches(backend->guid, ggml_backend_kompute_guid());
}
static ggml_backend_t ggml_backend_reg_kompute_init(const char * params, void * user_data) {