| 1079 | } |
| 1080 | |
| 1081 | static void CalcShapValuesForDocumentBlockMulti( |
| 1082 | const TFullModel& model, |
| 1083 | const IFeaturesBlockIterator& featuresBlockIterator, |
| 1084 | int flatFeatureCount, |
| 1085 | const TShapPreparedTrees& preparedTrees, |
| 1086 | const TMaybe<TFixedFeatureParams>& fixedFeatureParams, |
| 1087 | size_t start, |
| 1088 | size_t end, |
| 1089 | NPar::ILocalExecutor* localExecutor, |
| 1090 | TVector<TVector<TVector<double>>>* shapValuesForAllDocuments, |
| 1091 | ECalcTypeShapValues calcType |
| 1092 | ) { |
| 1093 | const size_t documentCount = end - start; |
| 1094 | |
| 1095 | auto binarizedFeaturesForBlock = MakeQuantizedFeaturesForEvaluator(model, featuresBlockIterator, start, end); |
| 1096 | |
| 1097 | TVector<NModelEvaluation::TCalcerIndexType> indices(binarizedFeaturesForBlock->GetObjectsCount() * model.GetTreeCount()); |
| 1098 | model.GetCurrentEvaluator()->CalcLeafIndexes(binarizedFeaturesForBlock.Get(), 0, model.GetTreeCount(), indices); |
| 1099 | |
| 1100 | const int oldShapValuesSize = shapValuesForAllDocuments->size(); |
| 1101 | shapValuesForAllDocuments->resize(oldShapValuesSize + end - start); |
| 1102 | |
| 1103 | NPar::ILocalExecutor::TExecRangeParams blockParams(0, documentCount); |
| 1104 | localExecutor->ExecRange([&] (size_t documentIdxInBlock) { |
| 1105 | TVector<TVector<double>>& shapValues = (*shapValuesForAllDocuments)[oldShapValuesSize + documentIdxInBlock]; |
| 1106 | |
| 1107 | CalcShapValuesForDocumentMulti( |
| 1108 | model, |
| 1109 | preparedTrees, |
| 1110 | binarizedFeaturesForBlock.Get(), |
| 1111 | fixedFeatureParams, |
| 1112 | flatFeatureCount, |
| 1113 | MakeArrayRef(indices.data() + documentIdxInBlock * model.GetTreeCount(), model.GetTreeCount()), |
| 1114 | documentIdxInBlock, |
| 1115 | &shapValues, |
| 1116 | calcType, |
| 1117 | /*documentIdx*/ documentIdxInBlock + start |
| 1118 | ); |
| 1119 | |
| 1120 | }, blockParams, NPar::TLocalExecutor::WAIT_COMPLETE); |
| 1121 | } |
| 1122 | |
| 1123 | static void CalcShapValuesByLeafForTreeBlock( |
| 1124 | const TModelTrees& forest, |
no test coverage detected