Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 1 | /* |
Michele Di Giorgio | d9eaf61 | 2020-07-08 11:12:57 +0100 | [diff] [blame] | 2 | * Copyright (c) 2018-2019 Arm Limited. |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 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 | */ |
Michalis Spyrou | f464337 | 2019-11-29 16:17:13 +0000 | [diff] [blame] | 24 | #ifndef ARM_COMPUTE_GRAPH_DETAIL_EXECUTION_HELPERS_H |
| 25 | #define ARM_COMPUTE_GRAPH_DETAIL_EXECUTION_HELPERS_H |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 26 | |
Georgios Pinitas | d9eb275 | 2018-04-03 13:44:29 +0100 | [diff] [blame] | 27 | #include "arm_compute/graph/Types.h" |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 28 | |
| 29 | namespace arm_compute |
| 30 | { |
Georgios Pinitas | d9eb275 | 2018-04-03 13:44:29 +0100 | [diff] [blame] | 31 | namespace graph |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 32 | { |
| 33 | // Forward declarations |
| 34 | class Graph; |
| 35 | class GraphContext; |
Georgios Pinitas | 879d131 | 2019-09-30 13:25:53 +0100 | [diff] [blame] | 36 | struct ExecutionWorkload; |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 37 | class Tensor; |
Georgios Pinitas | e043767 | 2018-05-02 14:07:55 +0100 | [diff] [blame] | 38 | class INode; |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 39 | |
| 40 | namespace detail |
| 41 | { |
Georgios Pinitas | cac13b1 | 2018-04-27 19:07:19 +0100 | [diff] [blame] | 42 | /** Validates all nodes |
| 43 | * |
| 44 | * @param[in] g Graph to validate |
| 45 | */ |
| 46 | void validate_all_nodes(Graph &g); |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 47 | /** Configures all nodes of a graph |
| 48 | * |
| 49 | * @param[in] g Graph to configure |
| 50 | */ |
| 51 | void configure_all_tensors(Graph &g); |
Georgios Pinitas | e043767 | 2018-05-02 14:07:55 +0100 | [diff] [blame] | 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); |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 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); |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 72 | /** Configures all nodes of graph |
| 73 | * |
Georgios Pinitas | 2a2db59 | 2018-08-15 12:14:46 +0100 | [diff] [blame] | 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 |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 77 | * |
| 78 | * @return The execution workload |
| 79 | */ |
Georgios Pinitas | 2a2db59 | 2018-08-15 12:14:46 +0100 | [diff] [blame] | 80 | ExecutionWorkload configure_all_nodes(Graph &g, GraphContext &ctx, const std::vector<NodeID> &node_order); |
Georgios Pinitas | 1562be3 | 2018-03-08 19:09:19 +0000 | [diff] [blame] | 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); |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 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 |
Georgios Pinitas | 12be7ab | 2018-07-03 12:06:23 +0100 | [diff] [blame] | 99 | * |
| 100 | * @return True if all the accesses were valid |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 101 | */ |
Georgios Pinitas | 12be7ab | 2018-07-03 12:06:23 +0100 | [diff] [blame] | 102 | bool call_all_input_node_accessors(ExecutionWorkload &workload); |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 103 | /** Call all output node accessors |
| 104 | * |
| 105 | * @param[in] workload Workload to execute |
Georgios Pinitas | 12be7ab | 2018-07-03 12:06:23 +0100 | [diff] [blame] | 106 | * |
| 107 | * @return True if all the accessors expect more data |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 108 | */ |
Georgios Pinitas | 12be7ab | 2018-07-03 12:06:23 +0100 | [diff] [blame] | 109 | bool call_all_output_node_accessors(ExecutionWorkload &workload); |
Georgios Pinitas | e043767 | 2018-05-02 14:07:55 +0100 | [diff] [blame] | 110 | /** Prepares all tasks for execution |
| 111 | * |
| 112 | * @param[in] workload Workload to prepare |
| 113 | */ |
| 114 | void prepare_all_tasks(ExecutionWorkload &workload); |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 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 |
Georgios Pinitas | d9eb275 | 2018-04-03 13:44:29 +0100 | [diff] [blame] | 121 | } // namespace graph |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 122 | } // namespace arm_compute |
Michalis Spyrou | f464337 | 2019-11-29 16:17:13 +0000 | [diff] [blame] | 123 | #endif /* ARM_COMPUTE_GRAPH_DETAIL_EXECUTION_HELPERS_H */ |