MCPcopy Create free account
hub / github.com/catboost/catboost / CalcGeneric

Function CalcGeneric

catboost/libs/model/cpu/formula_evaluator.cpp:10–81  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8 template <typename TFloatFeatureAccessor, typename TCatFeatureAccessor,
9 typename TTextFeatureAccessor, typename TEmbeddingFeatureAccessor>
10 inline void CalcGeneric(
11 const TModelTrees& trees,
12 const TModelTrees::TForApplyData& applyData,
13 const TIntrusivePtr<ICtrProvider>& ctrProvider,
14 const TIntrusivePtr<TTextProcessingCollection>& textProcessingCollection,
15 const TIntrusivePtr<TEmbeddingProcessingCollection>& embeddingProcessingCollection,
16 TFloatFeatureAccessor floatFeatureAccessor,
17 TCatFeatureAccessor catFeaturesAccessor,
18 TTextFeatureAccessor textFeatureAccessor,
19 TEmbeddingFeatureAccessor embeddingFeatureAccessor,
20 size_t docCount,
21 size_t treeStart,
22 size_t treeEnd,
23 EPredictionType predictionType,
24 TArrayRef<double> results,
25 const NCB::NModelEvaluation::TFeatureLayout* featureInfo = nullptr
26 ) {
27 const size_t blockSize = Min(FORMULA_EVALUATION_BLOCK_SIZE, docCount);
28 auto calcTrees = GetCalcTreesFunction(trees, blockSize);
29 if (trees.GetTreeCount() == 0) {
30 auto biasRef = trees.GetScaleAndBias().GetBiasRef();
31 if (biasRef.size() == 1) {
32 Fill(results.begin(), results.end(), biasRef[0]);
33 } else {
34 for (size_t idx = 0; idx < results.size();) {
35 for (size_t dim = 0; dim < biasRef.size(); ++dim, ++idx) {
36 results[idx] = biasRef[dim];
37 }
38 }
39 }
40 return;
41 }
42 Fill(results.begin(), results.end(), 0.0);
43 TVector<TCalcerIndexType> indexesVec(blockSize);
44 TEvalResultProcessor resultProcessor(
45 docCount,
46 results,
47 predictionType,
48 trees.GetScaleAndBias(),
49 trees.GetDimensionsCount(),
50 blockSize
51 );
52 ui32 blockId = 0;
53 ProcessDocsInBlocks(
54 trees,
55 ctrProvider,
56 textProcessingCollection,
57 embeddingProcessingCollection,
58 floatFeatureAccessor,
59 catFeaturesAccessor,
60 textFeatureAccessor,
61 embeddingFeatureAccessor,
62 docCount,
63 blockSize,
64 [&] (size_t docCountInBlock, const TCPUEvaluatorQuantizedData* quantizedData) {
65 auto blockResultsView = resultProcessor.GetViewForRawEvaluation(blockId);
66 calcTrees(
67 trees,

Callers 4

CalcFlatTransposedMethod · 0.85
CalcFlatMethod · 0.85
CalcFlatSingleMethod · 0.85
CalcMethod · 0.85

Calls 12

GetCalcTreesFunctionFunction · 0.85
ProcessDocsInBlocksFunction · 0.85
PostprocessBlockMethod · 0.80
MinFunction · 0.50
FillFunction · 0.50
GetTreeCountMethod · 0.45
sizeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
GetDimensionsCountMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected