mirror of https://github.com/google/gemma.cpp.git
parent
64178ace38
commit
2441ff01bf
|
|
@ -33,9 +33,7 @@ using KV_t = float;
|
||||||
// A non-owning view of a KVCache.
|
// A non-owning view of a KVCache.
|
||||||
struct KVCachePtr {
|
struct KVCachePtr {
|
||||||
bool IsEmpty() const { return kv_cache.Rows() == 0; }
|
bool IsEmpty() const { return kv_cache.Rows() == 0; }
|
||||||
size_t SeqLen() const {
|
size_t SeqLen() const;
|
||||||
return kv_cache.Rows();
|
|
||||||
}
|
|
||||||
|
|
||||||
MatPtrT<KV_t> kv_cache;
|
MatPtrT<KV_t> kv_cache;
|
||||||
};
|
};
|
||||||
|
|
@ -66,6 +64,10 @@ struct KVCache {
|
||||||
KVCache(const Extents2D& kv_extents, const Allocator& allocator);
|
KVCache(const Extents2D& kv_extents, const Allocator& allocator);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
inline size_t KVCachePtr::SeqLen() const {
|
||||||
|
return kv_cache.Rows();
|
||||||
|
}
|
||||||
|
|
||||||
// Convenience function to create views into KVCaches.
|
// Convenience function to create views into KVCaches.
|
||||||
std::vector<KVCachePtr> ToKVCachePtrs(const hwy::Span<KVCache>& kv_caches);
|
std::vector<KVCachePtr> ToKVCachePtrs(const hwy::Span<KVCache>& kv_caches);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue