• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright 2021 Huawei Technologies Co., Ltd
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 #ifndef MINDSPORE_CCSRC_MINDDATA_DATASET_ENGINE_TREE_ADAPTER_LITE_H_
18 #define MINDSPORE_CCSRC_MINDDATA_DATASET_ENGINE_TREE_ADAPTER_LITE_H_
19 
20 #include <memory>
21 #include <string>
22 #include <unordered_map>
23 #include <utility>
24 #include <vector>
25 
26 #include "minddata/dataset/engine/ir/datasetops/dataset_node.h"
27 
28 namespace mindspore {
29 namespace dataset {
30 
31 class TensorRow;
32 class DatasetNode;
33 
34 class TreeAdapterLite {
35  public:
36   TreeAdapterLite();
37 
38   ~TreeAdapterLite() = default;
39 
40   Status BuildTree(std::shared_ptr<DatasetNode> root_ir);
41 
42   // Get rows equal to num_rows
43   Status GetNextRow(TensorRow *const row);
44 
GetColumnNameMap()45   std::unordered_map<std::string, int32_t> GetColumnNameMap() const { return tree_->root()->column_name_id_map(); }
46 
47  private:
48   // This RECURSIVE function walks the (optimized) IR tree in DFS to build its corresponding Execution tree.
49   Status BuildExecutionTreeRecur(std::shared_ptr<DatasetNode> ir, std::shared_ptr<DatasetOp> *op);
50 
51   std::shared_ptr<DatasetOp> root_;  // current connector capacity of root op, used for profiling
52   std::unique_ptr<ExecutionTree> tree_;
53 };
54 
55 }  // namespace dataset
56 }  // namespace mindspore
57 
58 #endif  // MINDSPORE_CCSRC_MINDDATA_DATASET_ENGINE_TREE_ADAPTER_LITE_H_
59