Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

code : normalize enum names #5697

Merged
merged 3 commits into from
Feb 25, 2024
Merged

code : normalize enum names #5697

merged 3 commits into from
Feb 25, 2024

Conversation

ggerganov
Copy link
Owner

I noticed we haven't been very consistent with naming the enums. For example:

    // here we repeat the full enum name and add suffix
    enum llama_token_type {
        LLAMA_TOKEN_TYPE_UNDEFINED    = 0,
        LLAMA_TOKEN_TYPE_NORMAL       = 1,
        LLAMA_TOKEN_TYPE_UNKNOWN      = 2,
        LLAMA_TOKEN_TYPE_CONTROL      = 3,
        LLAMA_TOKEN_TYPE_USER_DEFINED = 4,
        LLAMA_TOKEN_TYPE_UNUSED       = 5,
        LLAMA_TOKEN_TYPE_BYTE         = 6,
    };

    // in contrast, here we omit "_type" from the enum name before adding the suffix
    enum ggml_task_type {
        GGML_TASK_INIT = 0,
        GGML_TASK_COMPUTE,
        GGML_TASK_FINALIZE,
    };

With this PR, I propose that we always follow the convention to suffix the full enum name:

enum some_enum_name {
    SOME_ENUM_NAME_VAL_0, // OK
    SOME_ENUM_VAL_0,      // not OK
};

Is this change worth it? It touches a lot of lines

Copy link
Collaborator

@slaren slaren left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Personally I would prefer to do it the other way around, and remove all the _TYPE _NAME _MODE etc suffixes from the enum values, but ultimately I think that the most important is to be consistent with the style.

@ggerganov ggerganov merged commit ab336a9 into master Feb 25, 2024
57 checks passed
@ggerganov ggerganov deleted the gg/normalize-enums branch February 25, 2024 10:09
jordankanter pushed a commit to jordankanter/llama.cpp that referenced this pull request Mar 13, 2024
* coda : normalize enum names

ggml-ci

* code : cont

* code : cont
hodlen pushed a commit to hodlen/llama.cpp that referenced this pull request Apr 1, 2024
* coda : normalize enum names

ggml-ci

* code : cont

* code : cont
kou added a commit to kou/llama.cpp that referenced this pull request Aug 16, 2024
LLAMA_SPLIT_* were renamed to LLAMA_SPLIT_MODE_* in ggerganov#5697.
kou added a commit to kou/llama.cpp that referenced this pull request Aug 16, 2024
LLAMA_SPLIT_* were renamed to LLAMA_SPLIT_MODE_* in ggerganov#5697.
slaren pushed a commit that referenced this pull request Aug 30, 2024
LLAMA_SPLIT_* were renamed to LLAMA_SPLIT_MODE_* in #5697.
dsx1986 pushed a commit to dsx1986/llama.cpp that referenced this pull request Oct 29, 2024
arthw pushed a commit to arthw/llama.cpp that referenced this pull request Nov 15, 2024
arthw pushed a commit to arthw/llama.cpp that referenced this pull request Nov 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants