@@ -175,13 +175,11 @@ weight_t compute_modularity(
175
175
//
176
176
// Sum(Sigma_tot_c^2), over all clusters c
177
177
//
178
- weight_t sum_degree_squared = thrust::transform_reduce (
179
- handle.get_thrust_policy (),
178
+ auto squared_first = thrust::make_transform_iterator (
180
179
cluster_weights.begin (),
181
- cluster_weights.end (),
182
- cuda::proclaim_return_type<weight_t >([] __device__ (weight_t p) -> weight_t { return p * p; }),
183
- weight_t {0 },
184
- thrust::plus<weight_t >());
180
+ cuda::proclaim_return_type<weight_t >([] __device__ (weight_t p) { return p * p; }));
181
+ weight_t sum_degree_squared = thrust::reduce (
182
+ handle.get_thrust_policy (), squared_first, squared_first + cluster_weights.size ());
185
183
186
184
if constexpr (multi_gpu) {
187
185
sum_degree_squared = host_scalar_allreduce (
@@ -199,13 +197,14 @@ weight_t compute_modularity(
199
197
: detail::edge_minor_property_view_t <vertex_t , vertex_t const *>(next_clusters.begin (),
200
198
vertex_t {0 }),
201
199
*edge_weight_view,
202
- [] __device__ (auto , auto , auto src_cluster, auto nbr_cluster, weight_t wt) {
203
- if (src_cluster == nbr_cluster) {
204
- return wt;
205
- } else {
206
- return weight_t {0 };
207
- }
208
- },
200
+ cuda::proclaim_return_type<weight_t >(
201
+ [] __device__ (auto , auto , auto src_cluster, auto nbr_cluster, weight_t wt) {
202
+ if (src_cluster == nbr_cluster) {
203
+ return wt;
204
+ } else {
205
+ return weight_t {0 };
206
+ }
207
+ }),
209
208
weight_t {0 });
210
209
211
210
weight_t Q = sum_internal / total_edge_weight -
0 commit comments