| 77 | } |
| 78 | |
| 79 | void Initialize(const GraphView& gview, |
| 80 | const Graph* g) { |
| 81 | gv_ = const_cast<GraphView*>(&gview); |
| 82 | g_ = const_cast<Graph*>(g); |
| 83 | |
| 84 | nodes_count_ = gview.num_nodes(); |
| 85 | is_expensive_.resize(gview.num_nodes()); |
| 86 | cost_estimates_ = |
| 87 | absl::make_unique<std::atomic_uint_fast64_t[]>(gview.num_nodes()); |
| 88 | immutable_avg_cost_ = |
| 89 | absl::make_unique<std::atomic<int64_t>[]>(gview.num_nodes()); |
| 90 | node_stats_count_ = |
| 91 | absl::make_unique<std::atomic<int32_t>[]>(gview.num_nodes()); |
| 92 | task_count_ = |
| 93 | absl::make_unique<std::atomic<int32_t>[]>(gview.num_nodes()); |
| 94 | for (int32_t i = 0; i < gview.num_nodes(); ++i) { |
| 95 | if (gview.node(i)) { |
| 96 | is_expensive_[i] = |
| 97 | gview.node(i)->kernel && gview.node(i)->kernel->IsExpensive(); |
| 98 | cost_estimates_[i] = kInitialCostEstimateCycles; |
| 99 | immutable_avg_cost_[i] = 0; |
| 100 | node_stats_count_[i] = 0; |
| 101 | task_count_[i] = 0; |
| 102 | } |
| 103 | } |
| 104 | } |
| 105 | |
| 106 | // Returns true iff the given node is considered "expensive". The |
| 107 | // executor uses this flag to optimize graph execution, for example |
nothing calls this directly
no test coverage detected