@fugood/llama.node 1.2.1 → 1.2.2

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.
@@ -1,5 +1,41 @@
1
1
  cmake_minimum_required(VERSION 3.14) # for add_link_options and implicit target directories.
2
2
  project("ggml" C CXX ASM)
3
+
4
+ ### GGML Version
5
+ set(GGML_VERSION_MAJOR 0)
6
+ set(GGML_VERSION_MINOR 9)
7
+ set(GGML_VERSION_PATCH 0)
8
+ set(GGML_VERSION_DEV "-dev") # "-dev" for development, "" for releases
9
+ set(GGML_VERSION_BASE "${GGML_VERSION_MAJOR}.${GGML_VERSION_MINOR}.${GGML_VERSION_PATCH}")
10
+
11
+ find_program(GIT_EXE NAMES git git.exe NO_CMAKE_FIND_ROOT_PATH)
12
+ if(GIT_EXE)
13
+ # Get current git commit hash
14
+ execute_process(COMMAND ${GIT_EXE} rev-parse --short HEAD
15
+ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
16
+ OUTPUT_VARIABLE GGML_BUILD_COMMIT
17
+ OUTPUT_STRIP_TRAILING_WHITESPACE
18
+ ERROR_QUIET
19
+ )
20
+
21
+ # Check if the working directory is dirty (i.e., has uncommitted changes)
22
+ execute_process(COMMAND ${GIT_EXE} diff-index --quiet HEAD -- .
23
+ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
24
+ RESULT_VARIABLE GGML_GIT_DIRTY
25
+ ERROR_QUIET
26
+ )
27
+ endif()
28
+
29
+ # Build the version string with optional -dev suffix and dirty flag
30
+ set(GGML_VERSION "${GGML_VERSION_BASE}${GGML_VERSION_DEV}")
31
+ if(GGML_GIT_DIRTY AND NOT GGML_GIT_DIRTY EQUAL 0)
32
+ set(GGML_VERSION "${GGML_VERSION}-dirty")
33
+ endif()
34
+
35
+ if(NOT GGML_BUILD_COMMIT)
36
+ set(GGML_BUILD_COMMIT "unknown")
37
+ endif()
38
+
3
39
  include(CheckIncludeFileCXX)
4
40
 
5
41
  set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
@@ -300,26 +336,6 @@ endif()
300
336
  # Create CMake package
301
337
  #
302
338
 
303
- # Generate version info based on git commit.
304
-
305
- if(NOT DEFINED GGML_BUILD_NUMBER)
306
- find_program(GIT_EXE NAMES git git.exe REQUIRED NO_CMAKE_FIND_ROOT_PATH)
307
- execute_process(COMMAND ${GIT_EXE} rev-list --count HEAD
308
- WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
309
- OUTPUT_VARIABLE GGML_BUILD_NUMBER
310
- OUTPUT_STRIP_TRAILING_WHITESPACE
311
- )
312
-
313
- if(GGML_BUILD_NUMBER EQUAL 1)
314
- message(WARNING "GGML build version fixed at 1 likely due to a shallow clone.")
315
- endif()
316
-
317
- execute_process(COMMAND ${GIT_EXE} rev-parse --short HEAD
318
- WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
319
- OUTPUT_VARIABLE GGML_BUILD_COMMIT
320
- OUTPUT_STRIP_TRAILING_WHITESPACE
321
- )
322
- endif()
323
339
 
324
340
 
325
341
  # Capture variables prefixed with GGML_.
@@ -348,7 +364,7 @@ set(GGML_VARIABLES_EXPANDED ${variable_set_statements})
348
364
 
349
365
  # Create the CMake package and set install location.
350
366
 
351
- set(GGML_INSTALL_VERSION 0.0.${GGML_BUILD_NUMBER})
367
+ set(GGML_INSTALL_VERSION ${GGML_VERSION})
352
368
  set(GGML_INCLUDE_INSTALL_DIR ${CMAKE_INSTALL_INCLUDEDIR} CACHE PATH "Location of header files")
353
369
  set(GGML_LIB_INSTALL_DIR ${CMAKE_INSTALL_LIBDIR} CACHE PATH "Location of library files")
354
370
  set(GGML_BIN_INSTALL_DIR ${CMAKE_INSTALL_BINDIR} CACHE PATH "Location of binary files")
@@ -114,6 +114,9 @@ message(STATUS "GGML_SYSTEM_ARCH: ${GGML_SYSTEM_ARCH}")
114
114
 
115
115
  if (NOT MSVC)
116
116
  if (GGML_STATIC)
117
+ if (UNIX AND NOT APPLE)
118
+ set(CMAKE_FIND_LIBRARY_SUFFIXES ".a;.so")
119
+ endif()
117
120
  add_link_options(-static)
118
121
  if (MINGW)
119
122
  add_link_options(-static-libgcc -static-libstdc++)
@@ -7,7 +7,7 @@
7
7
  #include "ggml-cpu.h"
8
8
  #include "traits.h"
9
9
 
10
- #if defined(__gnu_linux__)
10
+ #if defined(__linux__)
11
11
  #include <sys/syscall.h>
12
12
  #include <unistd.h>
13
13
  #endif
@@ -186,7 +186,7 @@ static size_t ggml_backend_amx_buffer_type_get_alloc_size(ggml_backend_buffer_ty
186
186
  #define XFEATURE_XTILEDATA 18
187
187
 
188
188
  static bool ggml_amx_init() {
189
- #if defined(__gnu_linux__)
189
+ #if defined(__linux__)
190
190
  if (syscall(SYS_arch_prctl, ARCH_REQ_XCOMP_PERM, XFEATURE_XTILEDATA)) {
191
191
  fprintf(stderr, "AMX is not ready to be used!\n");
192
192
  return false;
@@ -194,6 +194,8 @@ static bool ggml_amx_init() {
194
194
  return true;
195
195
  #elif defined(_WIN32)
196
196
  return true;
197
+ #else
198
+ return false;
197
199
  #endif
198
200
  }
199
201
 
@@ -28,6 +28,14 @@ static inline float bf16_to_f32(ggml_bf16_t x) {
28
28
  return GGML_BF16_TO_FP32(x);
29
29
  }
30
30
 
31
+ static inline float i32_to_f32(int32_t x) {
32
+ return x;
33
+ }
34
+
35
+ static inline int32_t f32_to_i32(float x) {
36
+ return x;
37
+ }
38
+
31
39
  static inline float f32_to_f32(float x) {
32
40
  return x;
33
41
  }
@@ -54,6 +62,12 @@ struct type_conversion_table<ggml_bf16_t> {
54
62
  static constexpr ggml_bf16_t (*from_f32)(float) = f32_to_bf16;
55
63
  };
56
64
 
65
+ template <>
66
+ struct type_conversion_table<int32_t> {
67
+ static constexpr float (*to_f32)(int32_t) = i32_to_f32;
68
+ static constexpr int32_t (*from_f32)(float) = f32_to_i32;
69
+ };
70
+
57
71
  static std::pair<int64_t, int64_t> get_thread_range(const struct ggml_compute_params * params, const struct ggml_tensor * src0) {
58
72
  const int64_t ith = params->ith;
59
73
  const int64_t nth = params->nth;
@@ -190,7 +190,7 @@ static const struct ggml_backend_i ggml_backend_cpu_i = {
190
190
  /* .graph_compute = */ ggml_backend_cpu_graph_compute,
191
191
  /* .event_record = */ NULL,
192
192
  /* .event_wait = */ NULL,
193
- /* .optimize_graph = */ NULL,
193
+ /* .graph_optimize = */ NULL,
194
194
  };
195
195
 
196
196
  static ggml_guid_t ggml_backend_cpu_guid(void) {