diff --git a/gemma/weights.h b/gemma/weights.h index d0b8a03..28c0f38 100644 --- a/gemma/weights.h +++ b/gemma/weights.h @@ -310,6 +310,11 @@ struct LayerWeightsPtrs { // after reading weights via `ForEachTensor`. // TODO: update compression/convert_weights to bake this in. void Reshape() { + // We only have/allocate this tensor for Gemma layers. + HWY_ASSERT(att_weights.HasPtr() == + (layer_config.type == LayerAttentionType::kGemma)); + if (!att_weights.HasPtr()) return; + // NUQ is handled by a specialization in weights.cc. HWY_ASSERT(attn_vec_einsum_w.GetType() != Type::kNUQ); @@ -318,7 +323,6 @@ struct LayerWeightsPtrs { const size_t qkv_dim = layer_config.qkv_dim; // Reshape [heads, model_dim, qkv_dim] to [model_dim, heads * qkv_dim]. - HWY_ASSERT(att_weights.HasPtr()); HWY_ASSERT(att_weights.GetType() == attn_vec_einsum_w.GetType()); HWY_ASSERT(att_weights.Rows() == model_dim); HWY_ASSERT(att_weights.Cols() == heads * qkv_dim); diff --git a/io/blob_store.cc b/io/blob_store.cc index 95da0ba..7cc7b96 100644 --- a/io/blob_store.cc +++ b/io/blob_store.cc @@ -105,7 +105,7 @@ class BlobStore { // Returns the end of the directory, including padding, which is also the // start of the first payload. `num_blobs` is `NumBlobs()` if the header is // already available, otherwise the number of blobs to be written. - static constexpr size_t PaddedDirEnd(size_t num_blobs) { + static HWY_CXX17_CONSTEXPR size_t PaddedDirEnd(size_t num_blobs) { HWY_ASSERT(num_blobs < kMaxBlobs); // Per blob, a key and offset/size. return RoundUpToAlign(sizeof(Header) + 2 * kU128Bytes * num_blobs);