File tree Expand file tree Collapse file tree 5 files changed +16
-6
lines changed Expand file tree Collapse file tree 5 files changed +16
-6
lines changed Original file line number Diff line number Diff line change 1717#include < stdint.h>
1818
1919#include < algorithm>
20+ #include < array>
2021#include < cmath>
22+ #include < cstdlib>
2123#include < limits>
2224
2325#include " compression/types.h" // GEMMA_DISABLED_TARGETS
Original file line number Diff line number Diff line change @@ -60,6 +60,7 @@ namespace gcpp {
6060 size_t layer_idx, const MatPtr& query_norm_scale, \
6161 AttentionActivationsPtrs& activations, QBatch& qbatch, \
6262 ThreadingContext& ctx); \
63+ \
6364 /* NOLINTNEXTLINE(google-readability-namespace-comments) */ \
6465 } // namespace NAMESPACE
6566
Original file line number Diff line number Diff line change @@ -51,15 +51,16 @@ KVCache KVCache::Copy() {
5151 KVCache copy (kv_cache.Extents (), allocator_);
5252
5353 CopyMat (kv_cache, copy.kv_cache );
54-
5554 return copy;
5655}
5756
5857std::vector<KVCachePtr> ToKVCachePtrs (const hwy::Span<KVCache>& kv_caches) {
5958 std::vector<KVCachePtr> ptrs;
6059 ptrs.reserve (kv_caches.size ());
6160 for (size_t i = 0 ; i < kv_caches.size (); ++i) {
62- ptrs.push_back (KVCachePtr{.kv_cache = kv_caches[i].kv_cache });
61+ ptrs.push_back (KVCachePtr{
62+ .kv_cache = kv_caches[i].kv_cache ,
63+ });
6364 }
6465 return ptrs;
6566}
Original file line number Diff line number Diff line change 1717#define THIRD_PARTY_GEMMA_CPP_GEMMA_KV_CACHE_H_
1818
1919#include < stddef.h>
20+
21+ #include < optional>
2022#include < vector>
2123
22- #include " gemma/configs.h" // ModelConfig
24+ #include " gemma/configs.h" // ModelConfig
2325#include " gemma/gemma_args.h" // InferenceArgs
2426#include " util/basics.h" // BF16
2527#include " util/mat.h"
@@ -31,12 +33,13 @@ using KV_t = float;
3133struct KVCache {
3234 KVCache (const ModelConfig& config, const InferenceArgs& inference_args,
3335 const Allocator& allocator);
34-
3536 // Returns a deep copy of the KVCache. Use explicit function instead of
3637 // copy ctor to make the cost explicit.
3738 KVCache Copy ();
3839
39- size_t SeqLen () const { return kv_cache.Rows (); }
40+ size_t SeqLen () const {
41+ return kv_cache.Rows ();
42+ }
4043
4144 MatStorageT<KV_t> kv_cache; // [seq_len, layers * kv_heads * qkv_dim * 2]
4245
@@ -49,7 +52,9 @@ struct KVCache {
4952
5053// A non-owning view of a KVCache.
5154struct KVCachePtr {
52- size_t SeqLen () const { return kv_cache.Rows (); }
55+ size_t SeqLen () const {
56+ return kv_cache.Rows ();
57+ }
5358 MatPtrT<KV_t> kv_cache;
5459};
5560
Original file line number Diff line number Diff line change 2525#include < cstdint>
2626#include < random>
2727#include < type_traits> // std::enable_if_t
28+ #include < utility>
2829#include < vector>
2930
3031#include " ops/matmul.h"
You can’t perform that action at this time.
0 commit comments