| 44 | } |
| 45 | |
| 46 | void GraphManager::finalize_graph(Graph &graph, GraphContext &ctx, PassManager &pm, Target target) |
| 47 | { |
| 48 | ARM_COMPUTE_LOG_INFO_WITH_FUNCNAME_ACL("Initiate graph configuration!"); |
| 49 | |
| 50 | // Check if graph has been registered |
| 51 | if (_workloads.find(graph.id()) != std::end(_workloads)) |
| 52 | { |
| 53 | ARM_COMPUTE_ERROR("Graph is already registered!"); |
| 54 | } |
| 55 | |
| 56 | // Apply IR mutating passes |
| 57 | pm.run_type(graph, IGraphMutator::MutationType::IR); |
| 58 | |
| 59 | // Force target to all graph construct |
| 60 | Target forced_target = target; |
| 61 | |
| 62 | // In case CLVK is selected, use the CL backend and |
| 63 | // update config |
| 64 | if (target == Target::CLVK) |
| 65 | { |
| 66 | forced_target = Target::CL; |
| 67 | GraphConfig config = ctx.config(); |
| 68 | config.backend_type = CLBackendType::Clvk; |
| 69 | |
| 70 | ctx.set_config(config); |
| 71 | } |
| 72 | |
| 73 | if (!is_target_supported(target)) |
| 74 | { |
| 75 | forced_target = get_default_target(); |
| 76 | ARM_COMPUTE_LOG_GRAPH_INFO("Switching target from " << target << " to " << forced_target << std::endl); |
| 77 | } |
| 78 | force_target_to_graph(graph, forced_target); |
| 79 | |
| 80 | // Setup backend context |
| 81 | setup_requested_backend_context(ctx, forced_target); |
| 82 | |
| 83 | // Configure all tensors |
| 84 | detail::configure_all_tensors(graph); |
| 85 | |
| 86 | // Apply backend mutating passes |
| 87 | pm.run_type(graph, IGraphMutator::MutationType::Backend); |
| 88 | |
| 89 | // Perform topological sort |
| 90 | std::vector<NodeID> topological_sorted_nodes = dfs(graph); |
| 91 | |
| 92 | // Validate all nodes |
| 93 | detail::validate_all_nodes(graph); |
| 94 | |
| 95 | // Configure all nodes |
| 96 | auto workload = detail::configure_all_nodes(graph, ctx, topological_sorted_nodes); |
| 97 | ARM_COMPUTE_ERROR_ON_MSG(workload.tasks.empty(), "Could not configure all nodes!"); |
| 98 | |
| 99 | // Allocate const tensors and call accessors |
| 100 | detail::allocate_const_tensors(graph); |
| 101 | detail::call_all_const_node_accessors(graph); |
| 102 | |
| 103 | // Prepare graph |
no test coverage detected