File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -736,4 +736,23 @@ AttentionImpl GetAttentionImpl(const std::string& impl_name) {
736736 return AttentionImpl::kFlash ;
737737}
738738
739+ std::string KVEncodingToString (KVEncoding encoding) {
740+ switch (encoding) {
741+ case KVEncoding::kF32 :
742+ return " F32" ;
743+ case KVEncoding::kBF16 :
744+ return " BF16" ;
745+ case KVEncoding::kF32TwoTranspositions :
746+ return " F32TwoTranspositions" ;
747+ case KVEncoding::kBF16TwoTranspositions :
748+ return " BF16TwoTranspositions" ;
749+ case KVEncoding::kInt8 :
750+ return " Int8" ;
751+ case KVEncoding::kInt8TwoTranspositions :
752+ return " Int8TwoTranspositions" ;
753+ default :
754+ return " Unknown" ;
755+ }
756+ }
757+
739758} // namespace gcpp
Original file line number Diff line number Diff line change @@ -92,6 +92,13 @@ enum class KVEncoding {
9292 kInt8TwoTranspositions = 6 ,
9393};
9494
95+ // Returns a string representation of the KVEncoding.
96+ // This representation is should not change and can be used for
97+ // serialization or logging.
98+ // Note that no reverse function exists to convert a string back to a
99+ // KVEncoding.
100+ std::string KVEncodingToString (KVEncoding encoding);
101+
95102enum class AttentionImpl {
96103 kFlash = 0 , // Flash Attention (default)
97104 kFlashTransposedQs ,
You can’t perform that action at this time.
0 commit comments