[catboost/gpu] compute sum of weights for each query, not for each pair (query;document);
[catboost/gpu] compute sum of weights for each query, not for each pair (query;document)
([arc::pullid] 31fa6497-7db57818-b89b2d60-977bf296)
@@ -440,8 +440,15 @@ namespace NCatboostCuda {
cursor,
type,
{top}).front();
- const auto weightsSum = ReduceToHost(weights);
- return MakeSimpleAdditiveStatistic(perQueryNdcgSum, weightsSum);
+ auto queryWeights = TCudaBuffer<float, TMapping>::CopyMapping(samplesGrouping.GetSizes());
+ NDetail::GatherBySizeAndOffset(
+ weights,
+ samplesGrouping.GetSizes(),
+ samplesGrouping.GetBiasedOffsets(),
+ queryWeights,
+ 1);
+ const auto queryWeightsSum = ReduceToHost(queryWeights);
+ return MakeSimpleAdditiveStatistic(perQueryNdcgSum, queryWeightsSum);
}
default: {
CB_ENSURE(false, "Unsupported on GPU querywise metric " << metricType);
