Skip to content

Commit

Permalink
[CANN] Adapt to dynamically loadable backends mechanism (ggerganov#9970)
Browse files Browse the repository at this point in the history
* [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
  • Loading branch information
leo-pony authored and arthw committed Nov 15, 2024
1 parent aec56df commit 6fd0666
Show file tree
Hide file tree
Showing 5 changed files with 268 additions and 150 deletions.
2 changes: 2 additions & 0 deletions ggml/include/ggml-cann.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ extern "C" {
*/
#define GGML_CANN_MAX_DEVICES 16

GGML_API ggml_backend_reg_t ggml_backend_cann_reg(void);

/**
* @brief Initializes the CANN backend for a specified device.
*
Expand Down
9 changes: 8 additions & 1 deletion ggml/src/ggml-backend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,10 @@ void * ggml_backend_reg_get_proc_address(ggml_backend_reg_t reg, const char * na
# include "ggml-amx.h"
#endif

#ifdef GGML_USE_CANN
#include "ggml-cann.h"
#endif

struct ggml_backend_registry {
std::vector<ggml_backend_reg_t> backends;
std::vector<ggml_backend_dev_t> devices;
Expand All @@ -587,8 +591,11 @@ struct ggml_backend_registry {
#ifdef GGML_USE_AMX
register_backend(ggml_backend_amx_reg());
#endif
#ifdef GGML_USE_CANN
register_backend(ggml_backend_cann_reg());
#endif

// TODO: kompute, cann
// TODO: kompute

register_backend(ggml_backend_cpu_reg());
}
Expand Down
Loading

0 comments on commit 6fd0666

Please sign in to comment.