Skip to content

Commit 10ef6c1

Browse files
committed
contrib : move coding guidelines to correct section [no ci]
1 parent 7637216 commit 10ef6c1

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

CONTRIBUTING.md

+6-8
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@
2222
- Avoid fancy-looking modern STL constructs, use basic `for` loops, avoid templates, keep it simple
2323
- 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
2424
- Clean-up any trailing whitespaces, use 4 spaces for indentation, brackets on the same line, `void * ptr`, `int & a`
25+
- Use sized integer types in the public API
26+
- Follow the existing code style, in case of doubt use `clang-format` to format the added code
27+
- Declare structs with `struct x {}` instead of `typedef struct x {} x`
28+
- In C++ code omit the `struct` keyword whenever it is not necessary
29+
> [!NOTE]
30+
> This guideline is yet to be applied to the `llama.cpp` codebase. New code should follow this guideline.
2531
- Tensors store data in row-major order. We refer to dimension 0 as columns, 1 as rows, 2 as matrices
2632
- 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.$
2733

@@ -30,7 +36,6 @@
3036
# Naming guidelines
3137

3238
- Use `snake_case` for function, variable and type names
33-
- Use sized integer types in the public API
3439
- Naming usually optimizes for common prefix (see https://github.com/ggerganov/ggml/pull/302#discussion_r1243240963)
3540

3641
```cpp
@@ -72,11 +77,6 @@
7277
- The `_context` suffix of the `<class>` is optional
7378
- Use `init`/`free` for constructor/destructor `<action>`
7479

75-
- Declare structs with `struct x {}` instead of `typedef struct x {} x`
76-
- In C++ code omit the `struct` keyword whenever it is not necessary
77-
> [!NOTE]
78-
> This guideline is yet to be applied to the `llama.cpp` codebase. New code should follow this guideline.
79-
8080
- 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
8181
8282
```cpp
@@ -88,8 +88,6 @@
8888
> [!NOTE]
8989
> This guideline is yet to be applied to the `llama.cpp` codebase. New code should follow this guideline.
9090
91-
- Follow the existing code style, in case of doubt use `clang-format` to format the added code
92-
9391
- (TODO: abbreviations usage)
9492
9593
# Resources

0 commit comments

Comments
 (0)