Skip to content

Commit 6c2e39c

Browse files
authored
Add LVQ8x0 support to CPP Runtime API (#252)
1 parent d03ac3c commit 6c2e39c

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

bindings/cpp/include/svs/runtime/api_defs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ enum class StorageKind {
100100
FP16,
101101
SQI8,
102102
LVQ4x0,
103+
LVQ8x0,
103104
LVQ4x4,
104105
LVQ4x8,
105106
LeanVec4x4,

bindings/cpp/src/svs_runtime_utils.h

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,8 @@ namespace storage {
9999

100100
// Consolidated storage kind checks using constexpr functions
101101
inline constexpr bool is_lvq_storage(StorageKind kind) {
102-
return kind == StorageKind::LVQ4x0 || kind == StorageKind::LVQ4x4 ||
103-
kind == StorageKind::LVQ4x8;
102+
return kind == StorageKind::LVQ4x0 || kind == StorageKind::LVQ8x0 ||
103+
kind == StorageKind::LVQ4x4 || kind == StorageKind::LVQ4x8;
104104
}
105105

106106
inline constexpr bool is_leanvec_storage(StorageKind kind) {
@@ -129,6 +129,7 @@ SVS_DEFINE_STORAGE_KIND_TAG(FP32);
129129
SVS_DEFINE_STORAGE_KIND_TAG(FP16);
130130
SVS_DEFINE_STORAGE_KIND_TAG(SQI8);
131131
SVS_DEFINE_STORAGE_KIND_TAG(LVQ4x0);
132+
SVS_DEFINE_STORAGE_KIND_TAG(LVQ8x0);
132133
SVS_DEFINE_STORAGE_KIND_TAG(LVQ4x4);
133134
SVS_DEFINE_STORAGE_KIND_TAG(LVQ4x8);
134135
SVS_DEFINE_STORAGE_KIND_TAG(LeanVec4x4);
@@ -235,18 +236,22 @@ struct StorageFactory<SQStorageType> {
235236

236237
// LVQ Storage support
237238
#ifdef SVS_LVQ_HEADER
238-
template <size_t Primary, size_t Residual>
239+
template <size_t Primary, size_t Residual, typename Strategy>
239240
using LVQDatasetType = svs::quantization::lvq::LVQDataset<
240241
Primary,
241242
Residual,
242243
svs::Dynamic,
243-
svs::quantization::lvq::Turbo<16, 8>,
244+
Strategy,
244245
svs::data::Blocked<svs::lib::Allocator<std::byte>>>;
245246

247+
using Sequential = svs::quantization::lvq::Sequential;
248+
using Turbo16x8 = svs::quantization::lvq::Turbo<16, 8>;
249+
246250
// clang-format off
247-
template <> struct StorageType<LVQ4x0Tag> { using type = LVQDatasetType<4, 0>; };
248-
template <> struct StorageType<LVQ4x4Tag> { using type = LVQDatasetType<4, 4>; };
249-
template <> struct StorageType<LVQ4x8Tag> { using type = LVQDatasetType<4, 8>; };
251+
template <> struct StorageType<LVQ4x0Tag> { using type = LVQDatasetType<4, 0, Turbo16x8>; };
252+
template <> struct StorageType<LVQ8x0Tag> { using type = LVQDatasetType<8, 0, Sequential>; };
253+
template <> struct StorageType<LVQ4x4Tag> { using type = LVQDatasetType<4, 4, Turbo16x8>; };
254+
template <> struct StorageType<LVQ4x8Tag> { using type = LVQDatasetType<4, 8, Turbo16x8>; };
250255
// clang-format on
251256

252257
template <svs::quantization::lvq::IsLVQDataset LVQStorageType>
@@ -332,6 +337,8 @@ auto dispatch_storage_kind(StorageKind kind, F&& f, Args&&... args) {
332337
return f(SQI8Tag{}, std::forward<Args>(args)...);
333338
case StorageKind::LVQ4x0:
334339
return f(LVQ4x0Tag{}, std::forward<Args>(args)...);
340+
case StorageKind::LVQ8x0:
341+
return f(LVQ8x0Tag{}, std::forward<Args>(args)...);
335342
case StorageKind::LVQ4x4:
336343
return f(LVQ4x4Tag{}, std::forward<Args>(args)...);
337344
case StorageKind::LVQ4x8:

0 commit comments

Comments
 (0)