1// Copyright 2017 The TensorFlow Authors. All Rights Reserved.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14// =============================================================================
15#ifndef TENSORFLOW_CONTRIB_BOOSTED_TREES_LIB_LEARNER_COMMON_PARTITIONERS_EXAMPLE_PARTITIONER_H_
16#define TENSORFLOW_CONTRIB_BOOSTED_TREES_LIB_LEARNER_COMMON_PARTITIONERS_EXAMPLE_PARTITIONER_H_
17
18#include <vector>
19#include "tensorflow/contrib/boosted_trees/lib/trees/decision_tree.h"
20#include "tensorflow/contrib/boosted_trees/lib/utils/batch_features.h"
21#include "tensorflow/core/lib/core/threadpool.h"
22
23namespace tensorflow {
24namespace boosted_trees {
25namespace learner {
26
27// Partitions examples based on the path through the current tree.
28class ExamplePartitioner {
29 public:
30  // Updates partitions from previous set using the current tree structure by
31  // traversing sub-roots for each example. This method can be optionally
32  // parallelized using the passed thread pool.
33  static void UpdatePartitions(const trees::DecisionTreeConfig& tree_config,
34                               const utils::BatchFeatures& features,
35                               int desired_parallelism,
36                               thread::ThreadPool* const thread_pool,
37                               int32* example_partition_ids);
38
39  // Partitions examples using the current tree structure by traversing from
40  // root for each example. This method can be optionally parallelized using
41  // the passed thread pool.
42  static void PartitionExamples(const trees::DecisionTreeConfig& tree_config,
43                                const utils::BatchFeatures& features,
44                                int desired_parallelism,
45                                thread::ThreadPool* const thread_pool,
46                                int32* example_partition_ids);
47};
48
49}  // namespace learner
50}  // namespace boosted_trees
51}  // namespace tensorflow
52
53#endif  // TENSORFLOW_CONTRIB_BOOSTED_TREES_LIB_LEARNER_COMMON_PARTITIONERS_EXAMPLE_PARTITIONER_H_
54