Skip to content

Commit 30c457c

Browse files
committed
fix wt_sum warning
1 parent e8e63ab commit 30c457c

2 files changed

Lines changed: 2 additions & 3 deletions

File tree

cpp/src/cluster/detail/kmeans.cuh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1011,8 +1011,7 @@ void kmeans_predict(raft::resources const& handle,
10111011
raft::matrix::fill(handle, weight.view(), DataT(1));
10121012

10131013
if (normalize_weight) {
1014-
DataT wt_sum = weightSum(handle, raft::make_const_mdspan(weight.view()));
1015-
RAFT_EXPECTS(wt_sum > DataT{0}, "invalid parameter (sum of sample weights must be positive)");
1014+
DataT wt_sum = weightSum(handle, raft::make_const_mdspan(weight.view()));
10161015
const DataT rel_tol = n_samples * std::numeric_limits<DataT>::epsilon();
10171016
if (std::abs(wt_sum - n_samples) > rel_tol) {
10181017
RAFT_LOG_DEBUG(

cpp/src/cluster/detail/kmeans_common.cuh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,6 @@ DataT weightSum(
147147
raft::mdspan<const DataT, raft::vector_extent<IndexT>, raft::layout_right, Accessor> weight)
148148
{
149149
auto n_samples = weight.extent(0);
150-
auto ns = static_cast<DataT>(n_samples);
151150

152151
DataT wt_sum = DataT{0};
153152
if constexpr (raft::is_device_mdspan_v<decltype(weight)>) {
@@ -162,6 +161,7 @@ DataT weightSum(
162161
wt_sum += weight(i);
163162
}
164163
}
164+
RAFT_EXPECTS(wt_sum > DataT{0}, "invalid parameter (sum of sample weights must be positive)");
165165
return wt_sum;
166166
}
167167

0 commit comments

Comments
 (0)