-
Notifications
You must be signed in to change notification settings - Fork 639
Warning fixes: unused member, cast, unused function #61
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -633,30 +633,32 @@ void ForEachTensor(const Weights<TConfig>* weights, | |
| c_weights.c_final_norm_scale); | ||
|
|
||
| char name[16]; | ||
| for (size_t layer_idx = 0; layer_idx < TConfig::kLayers; ++layer_idx) { | ||
| Layer<TConfig>* layer = weights ? &weights->layers[layer_idx] : nullptr; | ||
| CompressedLayer<TConfig>* c_layer = c_weights.CLayer(layer_idx); | ||
| for (int layer_idx = 0; layer_idx < static_cast<int>(TConfig::kLayers); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what's the motivation here for having int layer_idx and a size_t idx vs the previous size_t layer_idx?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. snprintf requires an int, but the two functions below want size_t. Making the loop counter size_t would require many casts, one per snprintf. |
||
| ++layer_idx) { | ||
| const size_t idx = static_cast<size_t>(layer_idx); | ||
| Layer<TConfig>* layer = weights ? &weights->layers[idx] : nullptr; | ||
| CompressedLayer<TConfig>* c_layer = c_weights.CLayer(idx); | ||
|
|
||
| snprintf(name, sizeof(name), "pre_ff_ns_%lu", layer_idx); | ||
| snprintf(name, sizeof(name), "pre_ff_ns_%d", layer_idx); | ||
| func(name, layer ? layer->pre_ffw_norm_scale.data() : nullptr, | ||
| c_layer->c_pre_ffw_norm_scale); | ||
|
|
||
| snprintf(name, sizeof(name), "gating_ein_%lu", layer_idx); | ||
| snprintf(name, sizeof(name), "gating_ein_%d", layer_idx); | ||
| func(name, layer ? layer->gating_einsum_w.data() : nullptr, | ||
| c_layer->c_gating_einsum_w); | ||
|
|
||
| snprintf(name, sizeof(name), "linear_w_%lu", layer_idx); | ||
| snprintf(name, sizeof(name), "linear_w_%d", layer_idx); | ||
| func(name, layer ? layer->linear_w.data() : nullptr, c_layer->c_linear_w); | ||
| snprintf(name, sizeof(name), "qkv_ein_%lu", layer_idx); | ||
| snprintf(name, sizeof(name), "qkv_ein_%d", layer_idx); | ||
|
|
||
| func(name, layer ? layer->qkv_einsum_w.data() : nullptr, | ||
| c_layer->c_qkv_einsum_w); | ||
| snprintf(name, sizeof(name), "att_ein_%lu", layer_idx); | ||
| snprintf(name, sizeof(name), "att_ein_%d", layer_idx); | ||
|
|
||
| func(name, layer ? layer->attn_vec_einsum_w.data() : nullptr, | ||
| c_layer->c_attn_vec_einsum_w); | ||
|
|
||
| snprintf(name, sizeof(name), "pre_att_ns_%lu", layer_idx); | ||
| snprintf(name, sizeof(name), "pre_att_ns_%d", layer_idx); | ||
| func(name, layer ? layer->pre_attention_norm_scale.data() : nullptr, | ||
| c_layer->c_pre_attention_norm_scale); | ||
| } | ||
|
|
||
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.
Maybe it would be better to use
HWY_MAYBE_UNUSEDThere 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.
Unfortunately GCC seems to turn that into another warning: