Skip to content

Commit 9062bf5

Browse files
committed
Address code review comments
1 parent fbd8e9d commit 9062bf5

2 files changed

Lines changed: 19 additions & 9 deletions

File tree

bindings/cpp/src/svs_runtime_utils.h

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -159,9 +159,12 @@ template <typename Alloc>
159159
Alloc make_allocator(svs::lib::PowerOfTwo blocksize_bytes)
160160
requires(svs::data::is_blocked_v<Alloc>)
161161
{
162-
assert(
163-
blocksize_bytes.raw() > 0 && "Blocked storage types require a non-zero blocksize"
164-
);
162+
if (blocksize_bytes.raw() == 0) {
163+
throw StatusException(
164+
ErrorCode::INVALID_ARGUMENT,
165+
"Blocked storage types require a non-zero blocksize"
166+
);
167+
}
165168
auto parameters = svs::data::BlockingParameters{.blocksize_bytes = blocksize_bytes};
166169
return Alloc(parameters);
167170
}
@@ -419,7 +422,9 @@ auto dispatch_storage_kind(StorageKind kind, F&& f, Args&&... args) {
419422
SVS_DISPATCH_STORAGE_KIND(LeanVec4x8);
420423
SVS_DISPATCH_STORAGE_KIND(LeanVec8x8);
421424
default:
422-
throw ANNEXCEPTION("not supported SVS storage kind");
425+
throw StatusException(
426+
ErrorCode::INVALID_ARGUMENT, "Unknown or unsupported SVS storage kind"
427+
);
423428
}
424429

425430
#undef SVS_DISPATCH_STORAGE_KIND

bindings/cpp/src/training_impl.h

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,21 +41,26 @@ struct LeanVecTrainingDataImpl {
4141

4242
LeanVecTrainingDataImpl(LeanVecMatricesType&& matrices)
4343
: leanvec_dims_{matrices.view_data_matrix().dimensions()}
44-
, leanvec_matrices_{std::move(matrices)} {}
44+
, leanvec_matrices_{std::move(matrices)} {
45+
if (!svs::detail::lvq_leanvec_enabled()) {
46+
throw StatusException(
47+
ErrorCode::NOT_IMPLEMENTED, "LeanVec is not supported by CPU."
48+
);
49+
}
50+
}
4551

4652
LeanVecTrainingDataImpl(
4753
const svs::data::ConstSimpleDataView<float>& data, size_t leanvec_dims
4854
)
49-
: leanvec_dims_{leanvec_dims}
50-
, leanvec_matrices_{compute_leanvec_matrices(data, leanvec_dims)} {}
55+
: LeanVecTrainingDataImpl(compute_leanvec_matrices(data, leanvec_dims)) {}
5156

5257
LeanVecTrainingDataImpl(
5358
const svs::data::ConstSimpleDataView<float>& data,
5459
const svs::data::ConstSimpleDataView<float>& queries,
5560
size_t leanvec_dims
5661
)
57-
: leanvec_dims_{leanvec_dims}
58-
, leanvec_matrices_{compute_leanvec_matrices_ood(data, queries, leanvec_dims)} {}
62+
: LeanVecTrainingDataImpl(compute_leanvec_matrices_ood(data, queries, leanvec_dims)
63+
) {}
5964

6065
size_t get_leanvec_dims() const { return leanvec_dims_; }
6166
const LeanVecMatricesType& get_leanvec_matrices() const { return leanvec_matrices_; }

0 commit comments

Comments
 (0)