-
Notifications
You must be signed in to change notification settings - Fork 9.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add new GGUFValueType.OBJ virtual type
The content of the OBJ type is actually a list of all key names of the object. * Python * `gguf_writer.py`: * Added `def add_kv(self, key: str, val: Any) -> None`: Automatically determines the appropriate value type based on `val`. * Added `def add_dict(self, key: str, val: dict, excludes: Sequence[str] = []) -> None`: Adds object (dict) values, It will recursively add all subkeys. * Added `add_array_ex` to support the nested and mixed-type array. * `constants.py`: * Added `GGUFValueType.get_type_ex(val)`: Added support for numpy's integers and floating-point numbers, selecting the number of digits according to the size of the integer. * `gguf_reader.py`: * Added functionality to retrieve values from specific fields using `ReaderField.get()` method. * Unit test added * CPP * `ggml`: * Added `GGUF_TYPE_OBJ` to the `gguf_type` enum type. * Use `gguf_get_arr_n` and `gguf_get_arr_str` to get the subKey names of `GGUF_TYPE_OBJ`. * Added `gguf_set_obj_str` function to set object subkey names * Added `gguf_set_arr_obj` function to set object array count * Added `gguf_set_arr_arr` function to set nested array count * `llama`: * Modified `gguf_kv_to_str` * Added `LLAMA_API char * gguf_kv_to_c_str` function to get the c_str value as JSON format. * Maybe this API should be moved into `ggml` as `gguf_get_val_json`. (问题是 ggml.c 用的是C语言,而这里大量用了C++的功能) * Added basic support to `GGUF_TYPE_OBJ` and nested array * Unit test added feat: add basic support to GGUF_TYPE_OBJ on cpp feat(gguf.py): add OBJ and mixed-type array supports to GGUF ARRAY feat: add OBJ and mixed-type array supports to GGUF ARRAY(CPP) feat: add nested array supported feat: * Subkey name convention in OBJ types: * If the first letter of the subkey name is "/", it means referencing the full name of other keys. * If there is a ":" colon delimiter, it means that the string after the colon represents the subkey name in this object, otherwise the referencing subkey name is used. feat: add LLAMA_API gguf_kv_to_c_str to llama.h test: write test gguf file to tests folder directly(py) test: add test-gguf-meta.cpp feat: Key convention: "." indicates that the key is a subkey, not an independent key. feat: add excludes argument to add_dict(gguf_write.py) feat: add_array_ex to supports nested and mix-typed array, and keep the add_array to the same fix(constant.py): rollback the get_type function and add the new get_type_ex test: add test compatibility fix: use GGML_MALLOC instead of malloc
- Loading branch information
Showing
14 changed files
with
574 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.