| 250 | |
| 251 | |
| 252 | inline static void CalcStatsKernel( |
| 253 | bool isCaching, |
| 254 | const TCalcScoreFold& fold, |
| 255 | bool isPlainMode, |
| 256 | const TStatsIndexer& indexer, |
| 257 | int depth, |
| 258 | const TCalcScoreFold::TBodyTail& bt, |
| 259 | int dim, |
| 260 | NCB::TIndexRange<int> docIndexRange, |
| 261 | TBucketStats* stats |
| 262 | ) { |
| 263 | Y_ASSERT(!isCaching || depth > 0); |
| 264 | if (isCaching) { |
| 265 | Fill( |
| 266 | stats + indexer.CalcSize(depth - 1), |
| 267 | stats + indexer.CalcSize(depth), |
| 268 | TBucketStats{0, 0, 0, 0} |
| 269 | ); |
| 270 | } else { |
| 271 | Fill(stats, stats + indexer.CalcSize(depth), TBucketStats{0, 0, 0, 0}); |
| 272 | } |
| 273 | |
| 274 | if (bt.TailFinish > docIndexRange.Begin) { |
| 275 | const bool hasPairwiseWeights = !bt.PairwiseWeights.empty(); |
| 276 | const float* weightsData = hasPairwiseWeights ? |
| 277 | GetDataPtr(bt.PairwiseWeights) : GetDataPtr(fold.LearnWeights); |
| 278 | const float* sampleWeightsData = hasPairwiseWeights ? |
| 279 | GetDataPtr(bt.SamplePairwiseWeights) : GetDataPtr(fold.SampleWeights); |
| 280 | |
| 281 | int tailFinishInRange = Min((int)bt.TailFinish, docIndexRange.End); |
| 282 | |
| 283 | if (isPlainMode) { |
| 284 | UpdateWeighted( |
| 285 | indexer, |
| 286 | GetDataPtr(bt.SampleWeightedDerivatives[dim]), |
| 287 | sampleWeightsData, |
| 288 | NCB::TIndexRange<int>(docIndexRange.Begin, tailFinishInRange), |
| 289 | stats |
| 290 | ); |
| 291 | } else { |
| 292 | if (bt.BodyFinish > docIndexRange.Begin) { |
| 293 | UpdateDeltaCount( |
| 294 | indexer, |
| 295 | GetDataPtr(bt.WeightedDerivatives[dim]), |
| 296 | weightsData, |
| 297 | NCB::TIndexRange<int>(docIndexRange.Begin, Min((int)bt.BodyFinish, docIndexRange.End)), |
| 298 | stats |
| 299 | ); |
| 300 | } |
| 301 | if (tailFinishInRange > bt.BodyFinish) { |
| 302 | UpdateWeighted( |
| 303 | indexer, |
| 304 | GetDataPtr(bt.SampleWeightedDerivatives[dim]), |
| 305 | sampleWeightsData, |
| 306 | NCB::TIndexRange<int>(Max((int)bt.BodyFinish, docIndexRange.Begin), tailFinishInRange), |
| 307 | stats |
| 308 | ); |
| 309 | } |
no test coverage detected