aboutsummaryrefslogtreecommitdiffstats
path: root/eval/src/vespa/eval/eval/vm_forest.h
blob: bf2eeff6c44f749c985b633becc590c64a26102a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#pragma once

#include "gbdt.h"

namespace vespalib {
namespace eval {
namespace gbdt {

/**
 * GBDT forest optimizer using a compact tree representation combined
 * with a leaf-node search and aggregate evaluation strategy. This
 * code is very similar to the old VM instruction for MLR expressions.
 **/
class VMForest : public Forest
{
private:
    std::vector<uint32_t> _model;

public:
    VMForest(std::vector<uint32_t> &&model) : _model(std::move(model)) {}
    static Optimize::Result less_only_optimize(const ForestStats &stats,
                                               const std::vector<const nodes::Node *> &trees);
    static double less_only_eval(const Forest *forest, const double *);
    static Optimize::Result general_optimize(const ForestStats &stats,
                                             const std::vector<const nodes::Node *> &trees);
    static double general_eval(const Forest *forest, const double *);
    static Optimize::Chain optimize_chain;
};

} // namespace vespalib::eval::gbdt
} // namespace vespalib::eval
} // namespace vespalib