@novastera-oss/llamarn 0.6.8 → 0.6.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/android/src/main/jniLibs/arm64-v8a/libggml-htp-v73.so +0 -0
- package/android/src/main/jniLibs/arm64-v8a/libggml-htp-v75.so +0 -0
- package/android/src/main/jniLibs/arm64-v8a/libggml-htp-v79.so +0 -0
- package/android/src/main/jniLibs/arm64-v8a/libggml-htp-v81.so +0 -0
- package/cpp/PureCppImpl.cpp +24 -0
- package/package.json +1 -1
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/cpp/PureCppImpl.cpp
CHANGED
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
#include <cstdio>
|
|
12
12
|
#include <cstring>
|
|
13
13
|
#include <cerrno>
|
|
14
|
+
#include <cstdlib> // for setenv
|
|
14
15
|
#include "SystemUtils.h"
|
|
15
16
|
// Include our custom headers - this was missing!
|
|
16
17
|
#include "rn-llama.h"
|
|
@@ -123,6 +124,29 @@ static void load_android_backends() {
|
|
|
123
124
|
|
|
124
125
|
// Load Hexagon backend first (Snapdragon DSP) - more performant than Vulkan on Snapdragon devices
|
|
125
126
|
if (!ggml_backend_reg_by_name("HTP")) {
|
|
127
|
+
// FastRPC (used by Hexagon) requires ADSP_LIBRARY_PATH to find HTP libraries
|
|
128
|
+
// Get the app's native library directory by using dladdr on a known symbol
|
|
129
|
+
// All libraries from jniLibs are extracted to the same directory by Android
|
|
130
|
+
void* test_handle = dlopen("libggml.so", RTLD_LAZY | RTLD_LOCAL);
|
|
131
|
+
if (test_handle) {
|
|
132
|
+
// Get a function pointer from the library to use with dladdr
|
|
133
|
+
void* symbol = dlsym(test_handle, "ggml_init");
|
|
134
|
+
if (symbol) {
|
|
135
|
+
Dl_info info;
|
|
136
|
+
if (dladdr(symbol, &info) && info.dli_fname) {
|
|
137
|
+
// Extract directory from library path (e.g., "/data/app/.../lib/arm64/libggml.so" -> "/data/app/.../lib/arm64")
|
|
138
|
+
std::string lib_path = info.dli_fname;
|
|
139
|
+
size_t last_slash = lib_path.find_last_of('/');
|
|
140
|
+
if (last_slash != std::string::npos) {
|
|
141
|
+
std::string lib_dir = lib_path.substr(0, last_slash);
|
|
142
|
+
// Set ADSP_LIBRARY_PATH so FastRPC can find HTP libraries in the same directory
|
|
143
|
+
setenv("ADSP_LIBRARY_PATH", lib_dir.c_str(), 0); // 0 = don't overwrite if already set
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
dlclose(test_handle);
|
|
148
|
+
}
|
|
149
|
+
|
|
126
150
|
void* hexagon_handle = dlopen("libggml-hexagon.so", RTLD_LAZY | RTLD_LOCAL);
|
|
127
151
|
if (hexagon_handle) {
|
|
128
152
|
backend_init_fn_t backend_init = (backend_init_fn_t)dlsym(hexagon_handle, "ggml_backend_init");
|