-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Update clip.cpp #9482
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
Closed
Closed
Update clip.cpp #9482
Changes from 1 commit
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
aa9e721
Update clip.cpp
Tejaakshaykumar 28d1c45
Update examples/llava/clip.cpp
Tejaakshaykumar cba0340
Refactored error handling for hyperparameter validation in clip.cpp
Tejaakshaykumar e08b907
Update clip.cpp
Tejaakshaykumar 9bea433
Update clip.cpp by deleting optional logs
Tejaakshaykumar 36d9bbc
Updated examples/llava/clip.cpp
Tejaakshaykumar 46d20e1
Updated clip.cpp
Tejaakshaykumar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -1270,15 +1270,22 @@ struct clip_ctx * clip_model_load(const char * fname, const int verbosity = 1) { | |||||
// load vision model | ||||||
auto & vision_model = new_clip->vision_model; | ||||||
auto & hparams = vision_model.hparams; | ||||||
hparams.hidden_size = get_u32(ctx, format(KEY_N_EMBD, "vision")); | ||||||
hparams.n_head = get_u32(ctx, format(KEY_N_HEAD, "vision")); | ||||||
hparams.n_intermediate = get_u32(ctx, format(KEY_N_FF, "vision")); | ||||||
hparams.n_layer = get_u32(ctx, format(KEY_N_BLOCK, "vision")); | ||||||
hparams.image_size = get_u32(ctx, KEY_IMAGE_SIZE); | ||||||
hparams.patch_size = get_u32(ctx, KEY_PATCH_SIZE); | ||||||
hparams.projection_dim = get_u32(ctx, format(KEY_PROJ_DIM, "vision")); | ||||||
hparams.eps = get_f32(ctx, format(KEY_LAYER_NORM_EPS, "vision")); | ||||||
|
||||||
try{ | ||||||
hparams.hidden_size = get_u32(ctx, format(KEY_N_EMBD, "vision")); | ||||||
hparams.n_head = get_u32(ctx, format(KEY_N_HEAD, "vision")); | ||||||
hparams.n_intermediate = get_u32(ctx, format(KEY_N_FF, "vision")); | ||||||
hparams.n_layer = get_u32(ctx, format(KEY_N_BLOCK, "vision")); | ||||||
hparams.image_size = get_u32(ctx, KEY_IMAGE_SIZE); | ||||||
hparams.patch_size = get_u32(ctx, KEY_PATCH_SIZE); | ||||||
hparams.projection_dim = get_u32(ctx, format(KEY_PROJ_DIM, "vision")); | ||||||
hparams.eps = get_f32(ctx, format(KEY_LAYER_NORM_EPS, "vision")); | ||||||
if (hparams.hidden_size == 0 || hparams.n_head == 0 || hparams.n_layer == 0 || hparams.n_intermediate || hparams.image_size == 0 || hparams.patch_size || hparams.projection_dim || hparams.eps) { | ||||||
throw std::invalid_argument("Invalid hyperparameter values"); | ||||||
} | ||||||
} catch (const std::exception& e) { | ||||||
std::cerr << "Error while loading hyperparameters: " << e.what() << std::endl; | ||||||
|
std::cerr << "Error while loading hyperparameters: " << e.what() << std::endl; | |
fprintf(stderr, "Error while loading hyperparameters: %s\n", e.what()); |
Tejaakshaykumar marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
Tejaakshaykumar marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.