Repository navigation
build: support ggml runtime-dispatched CPU backends #59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| // SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
| #pragma once | ||
|
|
||
| #include "ggml-backend.h" | ||
|
|
||
| namespace nemo_speech::common { | ||
|
|
||
| inline bool | ||
| is_cpu_backend(ggml_backend_t backend) { | ||
| auto* dev = backend ? ggml_backend_get_device(backend) : nullptr; | ||
| return dev && ggml_backend_dev_type(dev) == GGML_BACKEND_DEVICE_TYPE_CPU; | ||
| } | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
|
|
||
| inline void | ||
| set_cpu_backend_n_threads(ggml_backend_t backend, int n_threads) { | ||
| if (!is_cpu_backend(backend)) { | ||
| return; | ||
| } | ||
| // CPU plugin functions must be accessed through the backend registry. | ||
| auto* reg = ggml_backend_dev_backend_reg(ggml_backend_get_device(backend)); | ||
| auto* set_n_threads = (ggml_backend_set_n_threads_t)ggml_backend_reg_get_proc_address( | ||
| reg, "ggml_backend_set_n_threads"); | ||
| if (set_n_threads) { | ||
| set_n_threads(backend, n_threads); | ||
| } | ||
| } | ||
|
|
||
| } // namespace nemo_speech::common | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,7 +25,13 @@ target_include_directories(nemo_speech_runtime_ggml PRIVATE | |
| ${CMAKE_SOURCE_DIR}/src/common | ||
| ) | ||
|
|
||
| target_link_libraries(nemo_speech_runtime_ggml PUBLIC ${GGML_DEPENDENCIES}) | ||
| # ggml propagates linked backends and builds plugins when GGML_BACKEND_DL is enabled. | ||
| target_link_libraries(nemo_speech_runtime_ggml PUBLIC ggml) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. With Update the test to load the plugins and create its CPU backend through |
||
|
|
||
| # ggml exports this definition only for directly linked backends. | ||
| if(GGML_VULKAN) | ||
| target_compile_definitions(nemo_speech_runtime_ggml PRIVATE GGML_USE_VULKAN) | ||
| endif() | ||
|
|
||
| # Consumers use the patched operations only when patches/ was applied; runtime.h | ||
| # derives NEMO_SPEECH_CUDA_FAST_PATHS from this and GGML_USE_CUDA. | ||
|
|
@@ -38,6 +44,6 @@ endif() | |
| # here so tests/ and riva_server inherit it and ld can resolve libggml-cuda's | ||
| # NEEDED libcuda.so.1 at link time. CUDAToolkit was found in the top-level | ||
| # CMakeLists.txt under the same GGML_CUDA gate. | ||
| if(GGML_CUDA) | ||
| if(GGML_CUDA AND NOT GGML_BACKEND_DL) | ||
| target_link_libraries(nemo_speech_runtime_ggml PUBLIC CUDA::cuda_driver) | ||
| endif() | ||
Uh oh!
There was an error while loading. Please reload this page.