OmniSciDB  a5dc49c757
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TreeModelPredictionMgr.h
Go to the documentation of this file.
1 /*
2  * Copyright 2023 HEAVY.AI, Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #pragma once
18 
19 #include "DataMgr/MemoryLevel.h"
20 #include "DecisionTreeEntry.h"
21 
22 #include <vector>
23 
24 struct CompilationOptions;
25 
26 namespace Data_Namespace {
27 class DataMgr;
28 class AbstractBuffer;
29 } // namespace Data_Namespace
30 
31 class Executor;
32 
33 namespace llvm {
34 class Value;
35 }
36 
38  public:
40  const Data_Namespace::MemoryLevel memory_level,
41  Executor* executor,
42  const std::vector<std::vector<DecisionTreeEntry>>& decision_trees,
43  const std::vector<int64_t>& decision_tree_offsets,
44  const bool compute_avg);
46 
47  llvm::Value* codegen(const std::vector<llvm::Value*>& regressor_inputs,
48  const CompilationOptions& co) const;
49 
50  private:
52  const std::vector<std::vector<DecisionTreeEntry>>& decision_trees,
53  const std::vector<int64_t>& decision_tree_offsets);
54  void createKernelBuffers();
55 
59  const int device_count_;
60  const int32_t num_trees_;
61  const bool compute_avg_;
66  std::vector<Data_Namespace::AbstractBuffer*> decision_tree_table_device_buffers_;
67  std::vector<Data_Namespace::AbstractBuffer*> decision_tree_offsets_device_buffers_;
68  std::vector<const int8_t*> kernel_decision_tree_tables_;
69  std::vector<const int8_t*> kernel_decision_tree_offsets_;
70 };
TreeModelPredictionMgr(const Data_Namespace::MemoryLevel memory_level, Executor *executor, const std::vector< std::vector< DecisionTreeEntry >> &decision_trees, const std::vector< int64_t > &decision_tree_offsets, const bool compute_avg)
llvm::Value * codegen(const std::vector< llvm::Value * > &regressor_inputs, const CompilationOptions &co) const
std::vector< Data_Namespace::AbstractBuffer * > decision_tree_table_device_buffers_
Data_Namespace::DataMgr * data_mgr_
std::vector< const int8_t * > kernel_decision_tree_tables_
std::vector< Data_Namespace::AbstractBuffer * > decision_tree_offsets_device_buffers_
std::vector< const int8_t * > kernel_decision_tree_offsets_
void allocateAndPopulateHostBuffers(const std::vector< std::vector< DecisionTreeEntry >> &decision_trees, const std::vector< int64_t > &decision_tree_offsets)
const Data_Namespace::MemoryLevel memory_level_