| 74 | } |
| 75 | |
| 76 | bool GenericEngine::Prerun(exec_handle_t h) |
| 77 | { |
| 78 | GraphTask* graph_task = any_cast<GraphTask*>(*h); |
| 79 | GraphExecutor* graph_executor = graph_task->GetGraphExecutor(); |
| 80 | Graph* graph = graph_task->GetGraph(); |
| 81 | |
| 82 | // call DevAllocator to allocate graph into |
| 83 | |
| 84 | DevAllocator* dev_allocator = nullptr; |
| 85 | |
| 86 | std::string alloc_policy; |
| 87 | |
| 88 | TEngineConfig::Get("dev_allocator", alloc_policy); |
| 89 | |
| 90 | if(alloc_policy.empty() || !DevAllocatorManager::Get(alloc_policy, dev_allocator)) |
| 91 | { |
| 92 | XLOG_ERROR() << "cannot get proper dev allocator\n"; |
| 93 | return false; |
| 94 | } |
| 95 | |
| 96 | std::vector<Subgraph*> sub_graph_list; |
| 97 | |
| 98 | if(!dev_allocator->Allocate(this, graph_executor, graph, sub_graph_list)) |
| 99 | { |
| 100 | XLOG_ERROR() << "dev executor allocator failed\n"; |
| 101 | |
| 102 | for(auto e : sub_graph_list) |
| 103 | delete e; |
| 104 | |
| 105 | return false; |
| 106 | } |
| 107 | |
| 108 | // create SubgraphTask |
| 109 | for(unsigned int i = 0; i < sub_graph_list.size(); i++) |
| 110 | { |
| 111 | Subgraph* sub_graph = sub_graph_list[i]; |
| 112 | SubgraphTask* new_task = new SubgraphTask(sub_graph); |
| 113 | |
| 114 | new_task->Init(graph_task); |
| 115 | graph_task->AddSubgraphTask(new_task); |
| 116 | } |
| 117 | |
| 118 | if(!graph_task->Prerun()) |
| 119 | { |
| 120 | graph_task->ReclaimSubgraphTask(); |
| 121 | return false; |
| 122 | } |
| 123 | |
| 124 | return true; |
| 125 | } |
| 126 | |
| 127 | bool GenericEngine::Run(exec_handle_t h, exec_event_t& event) |
| 128 | { |
nothing calls this directly
no test coverage detected