Skip to content

Commit ffeb66a

Browse files
danbevggerganov
authored andcommitted
ggml : add version function to get lib version (ggml/1286)
* 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 <ggerganov@gmail.com>
1 parent 4b6e553 commit ffeb66a

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

ggml/CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,13 @@ write_basic_package_version_file(
360360
VERSION ${GGML_INSTALL_VERSION}
361361
COMPATIBILITY SameMajorVersion)
362362

363+
target_compile_definitions(ggml-base PRIVATE
364+
GGML_VERSION="${GGML_INSTALL_VERSION}"
365+
GGML_COMMIT="${GGML_BUILD_COMMIT}"
366+
)
367+
message(STATUS "ggml version: ${GGML_INSTALL_VERSION}")
368+
message(STATUS "ggml commit: ${GGML_BUILD_COMMIT}")
369+
363370
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/ggml-config.cmake
364371
${CMAKE_CURRENT_BINARY_DIR}/ggml-version.cmake
365372
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/ggml)

ggml/include/ggml.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -646,6 +646,9 @@ extern "C" {
646646

647647
// misc
648648

649+
GGML_API const char * ggml_version(void);
650+
GGML_API const char * ggml_commit(void);
651+
649652
GGML_API void ggml_time_init(void); // call this once at the beginning of the program
650653
GGML_API int64_t ggml_time_ms(void);
651654
GGML_API int64_t ggml_time_us(void);

ggml/src/ggml.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -473,6 +473,14 @@ bool ggml_guid_matches(ggml_guid_t guid_a, ggml_guid_t guid_b) {
473473
return memcmp(guid_a, guid_b, sizeof(ggml_guid)) == 0;
474474
}
475475

476+
const char * ggml_version(void) {
477+
return GGML_VERSION;
478+
}
479+
480+
const char * ggml_commit(void) {
481+
return GGML_COMMIT;
482+
}
483+
476484
//
477485
// timing
478486
//

0 commit comments

Comments
 (0)