mirror of
https://github.com/antirez/gguf-tools.git
synced 2025-09-16 17:48:08 +08:00
Rename gguf_init/end to more obvious names.
This commit is contained in:
10
gguf-tools.c
10
gguf-tools.c
@@ -141,7 +141,7 @@ int strmatch(const char *pattern, int patternLen,
|
||||
/* ========================== 'show' subcommand ============================= */
|
||||
|
||||
void gguf_tools_show(const char *filename) {
|
||||
gguf_ctx *ctx = gguf_init(filename);
|
||||
gguf_ctx *ctx = gguf_open(filename);
|
||||
if (ctx == NULL) {
|
||||
perror("Opening GGUF file");
|
||||
exit(1);
|
||||
@@ -190,7 +190,7 @@ void gguf_tools_show(const char *filename) {
|
||||
* on the weights of the experts with IDs in the array of 'experts_id'.
|
||||
* The array must contain 32 integers, one for each layer. */
|
||||
void gguf_tools_split_mixtral(int *experts_id, const char *mixtral_filename, const char *output_filename) {
|
||||
gguf_ctx *mixtral = gguf_init(mixtral_filename);
|
||||
gguf_ctx *mixtral = gguf_open(mixtral_filename);
|
||||
if (mixtral == NULL) {
|
||||
perror("Opening Mixtral file");
|
||||
exit(1);
|
||||
@@ -331,7 +331,7 @@ void gguf_tools_split_mixtral(int *experts_id, const char *mixtral_filename, con
|
||||
/* ====================== 'inspect-weights' subcommand ====================== */
|
||||
|
||||
void gguf_tools_inspect_weights(const char *filename, const char *tname, uint64_t count) {
|
||||
gguf_ctx *ctx = gguf_init(filename);
|
||||
gguf_ctx *ctx = gguf_open(filename);
|
||||
if (ctx == NULL) {
|
||||
perror("Opening GGUF file");
|
||||
exit(1);
|
||||
@@ -453,8 +453,8 @@ int tensors_avg_diff(gguf_tensor *t1, gguf_tensor *t2, double *diff) {
|
||||
}
|
||||
|
||||
void gguf_tools_compare(const char *file1, const char *file2) {
|
||||
gguf_ctx *ctx1 = gguf_init(file1);
|
||||
gguf_ctx *ctx2 = gguf_init(file2);
|
||||
gguf_ctx *ctx1 = gguf_open(file1);
|
||||
gguf_ctx *ctx2 = gguf_open(file2);
|
||||
if (ctx1 == NULL || ctx2 == NULL) {
|
||||
perror("Opening GGUF files");
|
||||
exit(1);
|
||||
|
10
gguflib.c
10
gguflib.c
@@ -96,7 +96,7 @@ uint64_t gguf_value_len(uint32_t type, union gguf_value *val) {
|
||||
/* =============================== GGUF file API ============================ */
|
||||
|
||||
/* Open a GGUF file and return a parsing context. */
|
||||
gguf_ctx *gguf_init(const char *filename) {
|
||||
gguf_ctx *gguf_open(const char *filename) {
|
||||
int fd = open(filename,O_RDWR|O_APPEND);
|
||||
if (fd == -1) return NULL;
|
||||
|
||||
@@ -107,7 +107,7 @@ gguf_ctx *gguf_init(const char *filename) {
|
||||
ctx->alignment = 32; // Default alignment of GGUF files.
|
||||
ctx->data_off = 0; // Set later.
|
||||
if (gguf_remap(ctx) == 0) {
|
||||
gguf_end(ctx);
|
||||
gguf_close(ctx);
|
||||
return NULL;
|
||||
}
|
||||
gguf_rewind(ctx);
|
||||
@@ -156,9 +156,9 @@ int gguf_remap(gguf_ctx *ctx) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Cleanup needed after gguf_init(), to terminate the context
|
||||
/* Cleanup needed after gguf_open() and gguf_create(), to terminate the context
|
||||
* and cleanup resources. */
|
||||
void gguf_end(gguf_ctx *ctx) {
|
||||
void gguf_close(gguf_ctx *ctx) {
|
||||
if (ctx == NULL) return;
|
||||
if (ctx->data) munmap(ctx->data,ctx->size);
|
||||
close(ctx->fd);
|
||||
@@ -443,7 +443,7 @@ gguf_ctx *gguf_create(const char *filename, int flags) {
|
||||
}
|
||||
fclose(fp);
|
||||
|
||||
return gguf_init(filename);
|
||||
return gguf_open(filename);
|
||||
}
|
||||
|
||||
/* Low level API to append some key-value data to the GGUF file identified
|
||||
|
@@ -163,11 +163,11 @@ typedef struct {
|
||||
|
||||
/* =============================== Prototypes =============================== */
|
||||
|
||||
gguf_ctx *gguf_init(const char *filename);
|
||||
gguf_ctx *gguf_open(const char *filename);
|
||||
gguf_ctx *gguf_create(const char *filename, int flags);
|
||||
int gguf_remap(gguf_ctx *ctx);
|
||||
void gguf_rewind(gguf_ctx *ctx);
|
||||
void gguf_end(gguf_ctx *ctx);
|
||||
void gguf_close(gguf_ctx *ctx);
|
||||
int gguf_get_key(gguf_ctx *ctx, gguf_key *key);
|
||||
int gguf_get_tensor(gguf_ctx *ctx, gguf_tensor *tensor);
|
||||
const char *gguf_get_value_type_name(uint32_t type);
|
||||
|
Reference in New Issue
Block a user