Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions compression/distortion.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ namespace gcpp {
class DistortionStats {
public:
void Notify(float original, float distorted) {
(void)padding_; // prevent unused member warning
Copy link
Copy Markdown
Contributor

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_UNUSED

Copy link
Copy Markdown
Member

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:

class Test {
    HWY_MAYBE_UNUSED int member;
};
<source>:11:26: warning: 'unused' attribute ignored [-Wattributes]
   11 |     HWY_MAYBE_UNUSED int member;
      |                          ^~~~~~


const double l1 = hwy::ScalarAbs(original - distorted);

if (l1 > max_l1_) {
Expand Down
20 changes: 11 additions & 9 deletions gemma.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The 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?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The 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);
}
Expand Down
2 changes: 1 addition & 1 deletion util/args.h
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ class ArgsBase {
}
};

static bool HasHelp(int argc, char* argv[]) {
static inline HWY_MAYBE_UNUSED bool HasHelp(int argc, char* argv[]) {
// TODO(austinvhuang): handle case insensitivity
if (argc == 1) {
// no arguments - print help
Expand Down