1 /* 2 * Copyright (c) 2018-2019 Arm Limited. 3 * 4 * SPDX-License-Identifier: MIT 5 * 6 * Permission is hereby granted, free of charge, to any person obtaining a copy 7 * of this software and associated documentation files (the "Software"), to 8 * deal in the Software without restriction, including without limitation the 9 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 * sell copies of the Software, and to permit persons to whom the Software is 11 * furnished to do so, subject to the following conditions: 12 * 13 * The above copyright notice and this permission notice shall be included in all 14 * copies or substantial portions of the Software. 15 * 16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 * SOFTWARE. 23 */ 24 #ifndef ARM_COMPUTE_GRAPH_DETAIL_EXECUTION_HELPERS_H 25 #define ARM_COMPUTE_GRAPH_DETAIL_EXECUTION_HELPERS_H 26 27 #include "arm_compute/graph/Types.h" 28 29 namespace arm_compute 30 { 31 namespace graph 32 { 33 // Forward declarations 34 class Graph; 35 class GraphContext; 36 struct ExecutionWorkload; 37 class Tensor; 38 class INode; 39 40 namespace detail 41 { 42 /** Validates all nodes 43 * 44 * @param[in] g Graph to validate 45 */ 46 void validate_all_nodes(Graph &g); 47 /** Configures all nodes of a graph 48 * 49 * @param[in] g Graph to configure 50 */ 51 void configure_all_tensors(Graph &g); 52 /** Allocates all input tensors of a node. 53 * 54 * @param[in] node Node to allocate the input tensor of 55 */ 56 void allocate_all_input_tensors(INode &node); 57 /** Allocates all output tensors of a node. 58 * 59 * @param[in] node Node to allocate the output tensor of 60 */ 61 void allocate_all_output_tensors(INode &node); 62 /** Allocates const tensor of a given graph 63 * 64 * @param[in] g Graph to allocate the tensors 65 */ 66 void allocate_const_tensors(Graph &g); 67 /** Allocates all tensors of a graph 68 * 69 * @param[in] g Graph to allocate the tensors 70 */ 71 void allocate_all_tensors(Graph &g); 72 /** Configures all nodes of graph 73 * 74 * @param[in, out] g Graph to configure the nodes 75 * @param[in] ctx Graph context to use 76 * @param[in] node_order The order to configure the nodes 77 * 78 * @return The execution workload 79 */ 80 ExecutionWorkload configure_all_nodes(Graph &g, GraphContext &ctx, const std::vector<NodeID> &node_order); 81 /** Release the memory of all unused const nodes 82 * 83 * @param[in] g Graph to release the memory from 84 */ 85 void release_unused_tensors(Graph &g); 86 /** Calls accessor of a given tensor 87 * 88 * @param[in] tensor The tensor of which the accessor should be called 89 */ 90 void call_tensor_accessor(Tensor *tensor); 91 /** Call all const node accessors 92 * 93 * @param[in] g Graph containing the const nodes 94 */ 95 void call_all_const_node_accessors(Graph &g); 96 /** Call all input node accessors 97 * 98 * @param[in] workload Workload to execute 99 * 100 * @return True if all the accesses were valid 101 */ 102 bool call_all_input_node_accessors(ExecutionWorkload &workload); 103 /** Call all output node accessors 104 * 105 * @param[in] workload Workload to execute 106 * 107 * @return True if all the accessors expect more data 108 */ 109 bool call_all_output_node_accessors(ExecutionWorkload &workload); 110 /** Prepares all tasks for execution 111 * 112 * @param[in] workload Workload to prepare 113 */ 114 void prepare_all_tasks(ExecutionWorkload &workload); 115 /** Executes all tasks of a workload 116 * 117 * @param[in] workload Workload to execute 118 */ 119 void call_all_tasks(ExecutionWorkload &workload); 120 } // namespace detail 121 } // namespace graph 122 } // namespace arm_compute 123 #endif /* ARM_COMPUTE_GRAPH_DETAIL_EXECUTION_HELPERS_H */ 124