Skip to content

Commit 6fd0666

Browse files
leo-ponyarthw
authored andcommitted
[CANN] Adapt to dynamically loadable backends mechanism (ggml-org#9970)
* [CANN] Adapt to dynamically loadable backends mechanism * Fix the Bug: inference running result is garbled in debug running model for LM models who's type is Q4_0 class * Handle the review comments of this pull request build passed
1 parent aec56df commit 6fd0666

File tree

5 files changed

+268
-150
lines changed

5 files changed

+268
-150
lines changed

ggml/include/ggml-cann.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ extern "C" {
3434
*/
3535
#define GGML_CANN_MAX_DEVICES 16
3636

37+
GGML_API ggml_backend_reg_t ggml_backend_cann_reg(void);
38+
3739
/**
3840
* @brief Initializes the CANN backend for a specified device.
3941
*

ggml/src/ggml-backend.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -561,6 +561,10 @@ void * ggml_backend_reg_get_proc_address(ggml_backend_reg_t reg, const char * na
561561
# include "ggml-amx.h"
562562
#endif
563563

564+
#ifdef GGML_USE_CANN
565+
#include "ggml-cann.h"
566+
#endif
567+
564568
struct ggml_backend_registry {
565569
std::vector<ggml_backend_reg_t> backends;
566570
std::vector<ggml_backend_dev_t> devices;
@@ -587,8 +591,11 @@ struct ggml_backend_registry {
587591
#ifdef GGML_USE_AMX
588592
register_backend(ggml_backend_amx_reg());
589593
#endif
594+
#ifdef GGML_USE_CANN
595+
register_backend(ggml_backend_cann_reg());
596+
#endif
590597

591-
// TODO: kompute, cann
598+
// TODO: kompute
592599

593600
register_backend(ggml_backend_cpu_reg());
594601
}

0 commit comments

Comments
 (0)