-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
ggml-backend : code style suggestions #551
Conversation
I don't have any strong opinions about the naming conventions, but one of the reasons why I added the typedef'ed |
The best way to prevent from users fiddling with these structs is to have them declared in |
This breaks I am not sure that this can be completely fixed without splitting |
include/ggml/ggml-backend.h
Outdated
|
||
ggml_backend_buffer_context_t context; | ||
|
||
size_t size; // GG: can we absorb the size inside the context? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The size is used by ggml-alloc
, so if this is moved to the context, we would also need to add a function in the interface to get the size. But I am not sure that there is any reason to encapsulate this.
Ok, I see your point. We should implement the backend API separation (user / backend), but we can do this for v2. For now I've moved the structs back to
Modify in the sense of mutating the data of the structs from user code or modifying the actual structs such as adding / removing struct members? I don't think that the typedefs help with future proofing the code. The data is still exposed and nothing prevents the users from accessing it. |
The data from the user code. I want to avoid a situation like The way I think about the |
A bit of the rationale about the
It's true that currently it doesn't hide anything because there still isn't a separation between user and backend API, it is more a declaration of intent at this point. |
Ok, let's give it a try. The change to remove typedefs is always trivial, so we can do it in the future if we think we don't benefit from the extra type indirection |
* Revert 7e53955 (ggml-org#542) Still needs to be fixed properly * Fix linking on mingw32
@slaren I'm still reviewing - will continue after lunch
Here are some suggestions about normalizing the style to be more inline with the core
ggml
implementation.Let me know if you agree.
Main changes are:
ggml_buffer_context_t
->ggml_backend_buffer_context_t
typedef
forstruct *
- I prefer to have the type spelled out