From 610a03a8c447d1b119ae038f2d89e2dd7c5dfca2 Mon Sep 17 00:00:00 2001 From: Georgi Gerganov Date: Fri, 10 Jan 2025 17:42:43 +0200 Subject: [PATCH 01/14] contrib : add naming guidelines --- CONTRIBUTING.md | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 5a85ec5d2efb4..22fca849db744 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -22,12 +22,39 @@ - Avoid fancy-looking modern STL constructs, use basic `for` loops, avoid templates, keep it simple - There are no strict rules for the code style, but try to follow the patterns in the code (indentation, spaces, etc.). Vertical alignment makes things more readable and easier to batch edit - Clean-up any trailing whitespaces, use 4 spaces for indentation, brackets on the same line, `void * ptr`, `int & a` -- Naming usually optimizes for common prefix (see https://github.com/ggerganov/ggml/pull/302#discussion_r1243240963) - Tensors store data in row-major order. We refer to dimension 0 as columns, 1 as rows, 2 as matrices - Matrix multiplication is unconventional: [`C = ggml_mul_mat(ctx, A, B)`](https://github.com/ggerganov/llama.cpp/blob/880e352277fc017df4d5794f0c21c44e1eae2b84/ggml.h#L1058-L1064) means $C^T = A B^T \Leftrightarrow C = B A^T.$ ![matmul](media/matmul.png) +# Naming convention + +- Naming usually optimizes for common prefix (see https://github.com/ggerganov/ggml/pull/302#discussion_r1243240963) + + ```cpp + // not OK + int small_number; + int big_number; + + // OK + int number_small; + int number_big; + ``` + +- The general pattern is `subject_verb_object`: + + ```cpp + llama_model_init(); // sub: "llama_model", vrb: "init", obj: "" + llama_sampler_chain_remove(); // sub: "llama_sampler_chain", vrb: "remove", obj: "" + llama_sampler_get_seed(); // sub: "llama_sampler", vrb: "get", obj: "seed" + llama_set_embeddings(); // sub: "llama_context", vrb: "set", obj: "embeddings" + llama_n_threads(); // sub: "llama_context", vrb: "", obj: "n_threads" + llama_adapter_lora_free(); // sub: "llama_adapter_lora", vrb: "free", obj: "" + ``` + +- The `get` verb is optional +- The `_context` suffix of the subject is optional + # Resources The Github issues, PRs and discussions contain a lot of information that can be useful to get familiar with the codebase. For convenience, some of the more important information is referenced from Github projects: From e7bc61bc53af790fe59d7265a560ba60e58b43bd Mon Sep 17 00:00:00 2001 From: Georgi Gerganov Date: Sat, 11 Jan 2025 15:50:59 +0200 Subject: [PATCH 02/14] contrib : expand naming guidelines [no ci] --- CONTRIBUTING.md | 79 ++++++++++++++++++++++++++++++++----------------- 1 file changed, 52 insertions(+), 27 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 22fca849db744..e5ac6f70a8502 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,10 +1,10 @@ # Pull requests (for contributors) - Test your changes: - - Execute [the full CI locally on your machine](ci/README.md) before publishing - - Verify that the perplexity and the performance are not affected negatively by your changes (use `llama-perplexity` and `llama-bench`) - - If you modified the `ggml` source, run the `test-backend-ops` tool to check whether different backend implementations of the `ggml` operators produce consistent results (this requires access to at least two different `ggml` backends) - - If you modified a `ggml` operator or added a new one, add the corresponding test cases to `test-backend-ops` + - Execute [the full CI locally on your machine](ci/README.md) before publishing + - Verify that the perplexity and the performance are not affected negatively by your changes (use `llama-perplexity` and `llama-bench`) + - If you modified the `ggml` source, run the `test-backend-ops` tool to check whether different backend implementations of the `ggml` operators produce consistent results (this requires access to at least two different `ggml` backends) + - If you modified a `ggml` operator or added a new one, add the corresponding test cases to `test-backend-ops` - Consider allowing write access to your branch for faster reviews, as reviewers can push commits directly - If your PR becomes stale, don't hesitate to ping the maintainers in the comments @@ -29,31 +29,56 @@ # Naming convention +- Use `snake_case` for function, variable and type names +- Use sized integer types in the public API - Naming usually optimizes for common prefix (see https://github.com/ggerganov/ggml/pull/302#discussion_r1243240963) - ```cpp - // not OK - int small_number; - int big_number; - - // OK - int number_small; - int number_big; - ``` - -- The general pattern is `subject_verb_object`: - - ```cpp - llama_model_init(); // sub: "llama_model", vrb: "init", obj: "" - llama_sampler_chain_remove(); // sub: "llama_sampler_chain", vrb: "remove", obj: "" - llama_sampler_get_seed(); // sub: "llama_sampler", vrb: "get", obj: "seed" - llama_set_embeddings(); // sub: "llama_context", vrb: "set", obj: "embeddings" - llama_n_threads(); // sub: "llama_context", vrb: "", obj: "n_threads" - llama_adapter_lora_free(); // sub: "llama_adapter_lora", vrb: "free", obj: "" - ``` - -- The `get` verb is optional -- The `_context` suffix of the subject is optional + ```cpp + // not OK + int small_number; + int big_number; + + // OK + int number_small; + int number_big; + ``` + +- Enum values are always in upper case and prefixed with the enum name + + ```cpp + enum llama_vocab_type { + LLAMA_VOCAB_TYPE_NONE = 0, + LLAMA_VOCAB_TYPE_SPM = 1, + LLAMA_VOCAB_TYPE_BPE = 2, + LLAMA_VOCAB_TYPE_WPM = 3, + LLAMA_VOCAB_TYPE_UGM = 4, + LLAMA_VOCAB_TYPE_RWKV = 5, + }; + ``` + +- The general naming pattern is `_`, with `` being `_` + + ```cpp + llama_model_init(); // class: "llama_model", method: "init" + llama_sampler_chain_remove(); // class: "llama_sampler_chain", method: "remove" + llama_sampler_get_seed(); // class: "llama_sampler", method: "get_seed" + llama_set_embeddings(); // class: "llama_context", method: "set_embeddings" + llama_n_threads(); // class: "llama_context", method: "n_threads" + llama_adapter_lora_free(); // class: "llama_adapter_lora", method: "free" + ``` + + - The `get` `` can be omitted + - The `` can be omitted if not necessary + - The `_context` suffix of the subject is optional + - Use `init`/`free` for constructor/destructor `` + +- Declare structs with `struct x {}` instead of `typedef struct x {} x` + - In C++ code omit the `struct` keyword whenever it is not necessary + - Use `_t` suffix when ... + +- Follow the existing code style, in case of doubt use `clang-format` to format the added code + +- (TODO: abbreviations usage) # Resources From 7fd17ba7cc15ef9e263e9acd9df6a4e767aad2ee Mon Sep 17 00:00:00 2001 From: Georgi Gerganov Date: Sat, 11 Jan 2025 16:01:51 +0200 Subject: [PATCH 03/14] contrib : cont [no ci] --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e5ac6f70a8502..2b6dd1224ea72 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -69,7 +69,7 @@ - The `get` `` can be omitted - The `` can be omitted if not necessary - - The `_context` suffix of the subject is optional + - The `_context` suffix of the `` is optional - Use `init`/`free` for constructor/destructor `` - Declare structs with `struct x {}` instead of `typedef struct x {} x` From da47eb0650e27946da02c0858b657348aff9665d Mon Sep 17 00:00:00 2001 From: Georgi Gerganov Date: Sat, 11 Jan 2025 16:17:18 +0200 Subject: [PATCH 04/14] contrib : add `_t` suffix guideline [no ci] --- CONTRIBUTING.md | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 2b6dd1224ea72..c336fd9699e00 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -74,7 +74,16 @@ - Declare structs with `struct x {}` instead of `typedef struct x {} x` - In C++ code omit the `struct` keyword whenever it is not necessary - - Use `_t` suffix when ... + - Use the `_t` suffix when the types are supposed to be opaque to the user - it's not relevant to them if it is a struct or anything else + + ```cpp + typedef struct llama_context * llama_context_t; + + enum llama_pooling_type llama_pooling_type(const llama_context_t ctx); + ``` + + > [!NOTE] + > This guideline is yet to be applied to the `llama.cpp` codebase. New code should follow this guideline. - Follow the existing code style, in case of doubt use `clang-format` to format the added code From f44939a6eba3ab49ae28beb140b24d7248fcc295 Mon Sep 17 00:00:00 2001 From: Georgi Gerganov Date: Sat, 11 Jan 2025 16:22:58 +0200 Subject: [PATCH 05/14] contrib : cont [no ci] --- CONTRIBUTING.md | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index c336fd9699e00..579cbdb7cc296 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -74,16 +74,19 @@ - Declare structs with `struct x {}` instead of `typedef struct x {} x` - In C++ code omit the `struct` keyword whenever it is not necessary - - Use the `_t` suffix when the types are supposed to be opaque to the user - it's not relevant to them if it is a struct or anything else + > [!NOTE] + > This guideline is yet to be applied to the `llama.cpp` codebase. New code should follow this guideline. - ```cpp - typedef struct llama_context * llama_context_t; +- Use the `_t` suffix when a type is supposed to be opaque to the user - it's not relevant to them if it is a struct or anything else - enum llama_pooling_type llama_pooling_type(const llama_context_t ctx); - ``` + ```cpp + typedef struct llama_context * llama_context_t; + + enum llama_pooling_type llama_pooling_type(const llama_context_t ctx); + ``` - > [!NOTE] - > This guideline is yet to be applied to the `llama.cpp` codebase. New code should follow this guideline. + > [!NOTE] + > This guideline is yet to be applied to the `llama.cpp` codebase. New code should follow this guideline. - Follow the existing code style, in case of doubt use `clang-format` to format the added code From 7637216d3f104ea3900350bb4aa6b674e7eded54 Mon Sep 17 00:00:00 2001 From: Georgi Gerganov Date: Sat, 11 Jan 2025 16:23:58 +0200 Subject: [PATCH 06/14] minor [no ci] --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 579cbdb7cc296..aaaf72e60dd59 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -27,7 +27,7 @@ ![matmul](media/matmul.png) -# Naming convention +# Naming guidelines - Use `snake_case` for function, variable and type names - Use sized integer types in the public API From 10ef6c1853f93cde09392f01adf133418a591809 Mon Sep 17 00:00:00 2001 From: Georgi Gerganov Date: Sat, 11 Jan 2025 16:28:27 +0200 Subject: [PATCH 07/14] contrib : move coding guidelines to correct section [no ci] --- CONTRIBUTING.md | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index aaaf72e60dd59..ec8f7c306b7e5 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -22,6 +22,12 @@ - Avoid fancy-looking modern STL constructs, use basic `for` loops, avoid templates, keep it simple - There are no strict rules for the code style, but try to follow the patterns in the code (indentation, spaces, etc.). Vertical alignment makes things more readable and easier to batch edit - Clean-up any trailing whitespaces, use 4 spaces for indentation, brackets on the same line, `void * ptr`, `int & a` +- Use sized integer types in the public API +- Follow the existing code style, in case of doubt use `clang-format` to format the added code +- Declare structs with `struct x {}` instead of `typedef struct x {} x` + - In C++ code omit the `struct` keyword whenever it is not necessary + > [!NOTE] + > This guideline is yet to be applied to the `llama.cpp` codebase. New code should follow this guideline. - Tensors store data in row-major order. We refer to dimension 0 as columns, 1 as rows, 2 as matrices - Matrix multiplication is unconventional: [`C = ggml_mul_mat(ctx, A, B)`](https://github.com/ggerganov/llama.cpp/blob/880e352277fc017df4d5794f0c21c44e1eae2b84/ggml.h#L1058-L1064) means $C^T = A B^T \Leftrightarrow C = B A^T.$ @@ -30,7 +36,6 @@ # Naming guidelines - Use `snake_case` for function, variable and type names -- Use sized integer types in the public API - Naming usually optimizes for common prefix (see https://github.com/ggerganov/ggml/pull/302#discussion_r1243240963) ```cpp @@ -72,11 +77,6 @@ - The `_context` suffix of the `` is optional - Use `init`/`free` for constructor/destructor `` -- Declare structs with `struct x {}` instead of `typedef struct x {} x` - - In C++ code omit the `struct` keyword whenever it is not necessary - > [!NOTE] - > This guideline is yet to be applied to the `llama.cpp` codebase. New code should follow this guideline. - - Use the `_t` suffix when a type is supposed to be opaque to the user - it's not relevant to them if it is a struct or anything else ```cpp @@ -88,8 +88,6 @@ > [!NOTE] > This guideline is yet to be applied to the `llama.cpp` codebase. New code should follow this guideline. -- Follow the existing code style, in case of doubt use `clang-format` to format the added code - - (TODO: abbreviations usage) # Resources From 31a44094ad818f6d1472777bc6bbc02a82eaf295 Mon Sep 17 00:00:00 2001 From: Georgi Gerganov Date: Sat, 11 Jan 2025 16:32:53 +0200 Subject: [PATCH 08/14] contrib : minor reword coding guidelines [no ci] --- CONTRIBUTING.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index ec8f7c306b7e5..e82851dd6bc4f 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -20,16 +20,16 @@ - Avoid adding third-party dependencies, extra files, extra headers, etc. - Always consider cross-compatibility with other operating systems and architectures - Avoid fancy-looking modern STL constructs, use basic `for` loops, avoid templates, keep it simple -- There are no strict rules for the code style, but try to follow the patterns in the code (indentation, spaces, etc.). Vertical alignment makes things more readable and easier to batch edit +- Vertical alignment makes things more readable and easier to batch edit - Clean-up any trailing whitespaces, use 4 spaces for indentation, brackets on the same line, `void * ptr`, `int & a` - Use sized integer types in the public API -- Follow the existing code style, in case of doubt use `clang-format` to format the added code - Declare structs with `struct x {}` instead of `typedef struct x {} x` - In C++ code omit the `struct` keyword whenever it is not necessary > [!NOTE] > This guideline is yet to be applied to the `llama.cpp` codebase. New code should follow this guideline. - Tensors store data in row-major order. We refer to dimension 0 as columns, 1 as rows, 2 as matrices - Matrix multiplication is unconventional: [`C = ggml_mul_mat(ctx, A, B)`](https://github.com/ggerganov/llama.cpp/blob/880e352277fc017df4d5794f0c21c44e1eae2b84/ggml.h#L1058-L1064) means $C^T = A B^T \Leftrightarrow C = B A^T.$ +- Try to follow the existing patterns in the code (indentation, spaces, etc.). In case of doubt use `clang-format` to format the added code ![matmul](media/matmul.png) From b6f9640157aa6046e2312f072cf616f7af55cc73 Mon Sep 17 00:00:00 2001 From: Georgi Gerganov Date: Sat, 11 Jan 2025 17:00:01 +0200 Subject: [PATCH 09/14] contrib : add TODO for preprocessor directives [no ci] --- CONTRIBUTING.md | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e82851dd6bc4f..d35a3ec9ea7b8 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -23,16 +23,24 @@ - Vertical alignment makes things more readable and easier to batch edit - Clean-up any trailing whitespaces, use 4 spaces for indentation, brackets on the same line, `void * ptr`, `int & a` - Use sized integer types in the public API -- Declare structs with `struct x {}` instead of `typedef struct x {} x` +- Declare structs with `struct foo {}` instead of `typedef struct foo {} foo` - In C++ code omit the `struct` keyword whenever it is not necessary > [!NOTE] > This guideline is yet to be applied to the `llama.cpp` codebase. New code should follow this guideline. +- Try to follow the existing patterns in the code (indentation, spaces, etc.). In case of doubt use `clang-format` to format the added code - Tensors store data in row-major order. We refer to dimension 0 as columns, 1 as rows, 2 as matrices - Matrix multiplication is unconventional: [`C = ggml_mul_mat(ctx, A, B)`](https://github.com/ggerganov/llama.cpp/blob/880e352277fc017df4d5794f0c21c44e1eae2b84/ggml.h#L1058-L1064) means $C^T = A B^T \Leftrightarrow C = B A^T.$ -- Try to follow the existing patterns in the code (indentation, spaces, etc.). In case of doubt use `clang-format` to format the added code ![matmul](media/matmul.png) +- Preprocessor directives + - (TODO: add guidelines with examples and apply them to the codebase) + + ```cpp + #ifdef FOO + #endif // FOO + ``` + # Naming guidelines - Use `snake_case` for function, variable and type names From 95d87cbf65d0e94effac01b387f1b5404a58786c Mon Sep 17 00:00:00 2001 From: Georgi Gerganov Date: Sun, 12 Jan 2025 10:05:22 +0200 Subject: [PATCH 10/14] contrib : expand [no ci] --- CONTRIBUTING.md | 35 ++++++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index d35a3ec9ea7b8..bc89731c854c8 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -24,23 +24,25 @@ - Clean-up any trailing whitespaces, use 4 spaces for indentation, brackets on the same line, `void * ptr`, `int & a` - Use sized integer types in the public API - Declare structs with `struct foo {}` instead of `typedef struct foo {} foo` - - In C++ code omit the `struct` keyword whenever it is not necessary + - In C++ code omit optional `struct` and `enum` keyword whenever they are not necessary + ```cpp + // OK + llama_context * ctx; + const llama_rope_type rope_type; + + // not OK + struct llama_context * ctx; + const enum llama_rope_type rope_type; + ``` > [!NOTE] > This guideline is yet to be applied to the `llama.cpp` codebase. New code should follow this guideline. - Try to follow the existing patterns in the code (indentation, spaces, etc.). In case of doubt use `clang-format` to format the added code +- For anything not covered in the current guidelines, refer to the [C++ Core Guidelines](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines) - Tensors store data in row-major order. We refer to dimension 0 as columns, 1 as rows, 2 as matrices - Matrix multiplication is unconventional: [`C = ggml_mul_mat(ctx, A, B)`](https://github.com/ggerganov/llama.cpp/blob/880e352277fc017df4d5794f0c21c44e1eae2b84/ggml.h#L1058-L1064) means $C^T = A B^T \Leftrightarrow C = B A^T.$ ![matmul](media/matmul.png) -- Preprocessor directives - - (TODO: add guidelines with examples and apply them to the codebase) - - ```cpp - #ifdef FOO - #endif // FOO - ``` - # Naming guidelines - Use `snake_case` for function, variable and type names @@ -98,6 +100,21 @@ - (TODO: abbreviations usage) +# Preprocessor directives + +- (TODO: add guidelines with examples and apply them to the codebase) + + ```cpp + #ifdef FOO + #endif // FOO + ``` + +# Documentation + +- Documentation is a community effort +- When you need to look into the source code to figure out implementation details to figure out how to use an API consider adding a short summary to the header file for future reference +- When you notice incorrect or outdated documentation, please update it + # Resources The Github issues, PRs and discussions contain a lot of information that can be useful to get familiar with the codebase. For convenience, some of the more important information is referenced from Github projects: From 7e1950d0bcbaf55c784d580c80ba8aa43e4ab6ce Mon Sep 17 00:00:00 2001 From: Georgi Gerganov Date: Sun, 12 Jan 2025 10:08:46 +0200 Subject: [PATCH 11/14] minor [no ci] --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index bc89731c854c8..3a6ee5ce6f38b 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -46,7 +46,7 @@ # Naming guidelines - Use `snake_case` for function, variable and type names -- Naming usually optimizes for common prefix (see https://github.com/ggerganov/ggml/pull/302#discussion_r1243240963) +- Naming usually optimizes for longest common prefix (see https://github.com/ggerganov/ggml/pull/302#discussion_r1243240963) ```cpp // not OK From d974cae28612e910632fe23532ff9611811ded76 Mon Sep 17 00:00:00 2001 From: Georgi Gerganov Date: Sun, 12 Jan 2025 17:37:36 +0200 Subject: [PATCH 12/14] contrib : clarify `_context` suffix usage [no ci] --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 3a6ee5ce6f38b..b59f2c37defd2 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -84,7 +84,7 @@ - The `get` `` can be omitted - The `` can be omitted if not necessary - - The `_context` suffix of the `` is optional + - The `_context` suffix of the `` is optional. Use it to disambiguate symbols when needed. - Use `init`/`free` for constructor/destructor `` - Use the `_t` suffix when a type is supposed to be opaque to the user - it's not relevant to them if it is a struct or anything else From df65154415db7e25ad07ffd3fa4ad65012e2fdab Mon Sep 17 00:00:00 2001 From: Georgi Gerganov Date: Sun, 12 Jan 2025 19:12:18 +0200 Subject: [PATCH 13/14] contrib : filename guidelines [no ci] --- CONTRIBUTING.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index b59f2c37defd2..207cbd0c410e4 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -98,6 +98,9 @@ > [!NOTE] > This guideline is yet to be applied to the `llama.cpp` codebase. New code should follow this guideline. +- C/C++ filenames are all lowercase with dashes. Headers use the `.h` extension. Source files use the `.c` or `.cpp` extension +- Python filenames are all lowercase with underscores + - (TODO: abbreviations usage) # Preprocessor directives From 34223a21bc55796e6c71849c9b050324d7c9c06c Mon Sep 17 00:00:00 2001 From: Georgi Gerganov Date: Mon, 13 Jan 2025 14:32:55 +0200 Subject: [PATCH 14/14] contrib : fix notes [no ci] --- CONTRIBUTING.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 207cbd0c410e4..a86f00ac6d70e 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -34,8 +34,9 @@ struct llama_context * ctx; const enum llama_rope_type rope_type; ``` - > [!NOTE] - > This guideline is yet to be applied to the `llama.cpp` codebase. New code should follow this guideline. + + _(NOTE: this guideline is yet to be applied to the `llama.cpp` codebase. New code should follow this guideline.)_ + - Try to follow the existing patterns in the code (indentation, spaces, etc.). In case of doubt use `clang-format` to format the added code - For anything not covered in the current guidelines, refer to the [C++ Core Guidelines](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines) - Tensors store data in row-major order. We refer to dimension 0 as columns, 1 as rows, 2 as matrices @@ -84,7 +85,7 @@ - The `get` `` can be omitted - The `` can be omitted if not necessary - - The `_context` suffix of the `` is optional. Use it to disambiguate symbols when needed. + - The `_context` suffix of the `` is optional. Use it to disambiguate symbols when needed - Use `init`/`free` for constructor/destructor `` - Use the `_t` suffix when a type is supposed to be opaque to the user - it's not relevant to them if it is a struct or anything else @@ -95,13 +96,12 @@ enum llama_pooling_type llama_pooling_type(const llama_context_t ctx); ``` - > [!NOTE] - > This guideline is yet to be applied to the `llama.cpp` codebase. New code should follow this guideline. + _(NOTE: this guideline is yet to be applied to the `llama.cpp` codebase. New code should follow this guideline)_ - C/C++ filenames are all lowercase with dashes. Headers use the `.h` extension. Source files use the `.c` or `.cpp` extension - Python filenames are all lowercase with underscores -- (TODO: abbreviations usage) +- _(TODO: abbreviations usage)_ # Preprocessor directives