]> git.djapps.eu Git - pkg/ggml/sources/llama.cpp/commitdiff
ggml : add version function to get lib version (ggml/1286)
authorDaniel Bevenius <redacted>
Wed, 2 Jul 2025 11:55:32 +0000 (13:55 +0200)
committerGeorgi Gerganov <redacted>
Wed, 2 Jul 2025 17:08:45 +0000 (20:08 +0300)
* ggml : add version function to get lib version

This commit adds a function `ggml_version()` to the ggml library that
returns the version of the library as a string.

The motivation for this is that it can be useful to be able to
programmatically check the version of the ggml library being used.

Usage:
```c
printf("GGML version: %s\n", ggml_version());
```
Output:
```console
GGML version: 0.0.2219
```

* ggml : add ggml_commit()

---------

Co-authored-by: Georgi Gerganov <redacted>
ggml/CMakeLists.txt
ggml/include/ggml.h
ggml/src/ggml.c

index 215eb23486814e91d87a8e3e9dbb7cb6a092d431..675f3bf7567ff66bd29c4e1675db37f0e64b0be2 100644 (file)
@@ -360,6 +360,13 @@ write_basic_package_version_file(
     VERSION ${GGML_INSTALL_VERSION}
     COMPATIBILITY SameMajorVersion)
 
+target_compile_definitions(ggml-base PRIVATE
+    GGML_VERSION="${GGML_INSTALL_VERSION}"
+    GGML_COMMIT="${GGML_BUILD_COMMIT}"
+)
+message(STATUS "ggml version: ${GGML_INSTALL_VERSION}")
+message(STATUS "ggml commit:  ${GGML_BUILD_COMMIT}")
+
 install(FILES ${CMAKE_CURRENT_BINARY_DIR}/ggml-config.cmake
               ${CMAKE_CURRENT_BINARY_DIR}/ggml-version.cmake
         DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/ggml)
index a92495dbb0070330ddec35300ceca0ea161a886f..4647c8f70c03bf6ace9d2c16224b8a17cc11bf49 100644 (file)
@@ -646,6 +646,9 @@ extern "C" {
 
     // misc
 
+    GGML_API const char * ggml_version(void);
+    GGML_API const char * ggml_commit(void);
+
     GGML_API void    ggml_time_init(void); // call this once at the beginning of the program
     GGML_API int64_t ggml_time_ms(void);
     GGML_API int64_t ggml_time_us(void);
index f1245c50c9299013d08d5213a470b398b470ef9f..474e9d83fc4953df74b3667dfa19aad6afd4fd6a 100644 (file)
@@ -473,6 +473,14 @@ bool ggml_guid_matches(ggml_guid_t guid_a, ggml_guid_t guid_b) {
     return memcmp(guid_a, guid_b, sizeof(ggml_guid)) == 0;
 }
 
+const char * ggml_version(void) {
+    return GGML_VERSION;
+}
+
+const char * ggml_commit(void) {
+    return GGML_COMMIT;
+}
+
 //
 // timing
 //