Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2018 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 | */ |
Georgios Pinitas | d9eb275 | 2018-04-03 13:44:29 +0100 | [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; |
| 36 | class ExecutionWorkload; |
| 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 | * |
| 74 | * @param[in] g Graph to configure the nodes |
| 75 | * @param[in] ctx Graph context to use |
| 76 | * |
| 77 | * @return The execution workload |
| 78 | */ |
| 79 | ExecutionWorkload configure_all_nodes(Graph &g, GraphContext &ctx); |
Georgios Pinitas | 1562be3 | 2018-03-08 19:09:19 +0000 | [diff] [blame] | 80 | /** Release the memory of all unused const nodes |
| 81 | * |
| 82 | * @param[in] g Graph to release the memory from |
| 83 | */ |
| 84 | void release_unused_tensors(Graph &g); |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 85 | /** Calls accessor of a given tensor |
| 86 | * |
| 87 | * @param[in] tensor The tensor of which the accessor should be called |
| 88 | */ |
| 89 | void call_tensor_accessor(Tensor *tensor); |
| 90 | /** Call all const node accessors |
| 91 | * |
| 92 | * @param[in] g Graph containing the const nodes |
| 93 | */ |
| 94 | void call_all_const_node_accessors(Graph &g); |
| 95 | /** Call all input node accessors |
| 96 | * |
| 97 | * @param[in] workload Workload to execute |
Georgios Pinitas | 12be7ab | 2018-07-03 12:06:23 +0100 | [diff] [blame^] | 98 | * |
| 99 | * @return True if all the accesses were valid |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 100 | */ |
Georgios Pinitas | 12be7ab | 2018-07-03 12:06:23 +0100 | [diff] [blame^] | 101 | bool call_all_input_node_accessors(ExecutionWorkload &workload); |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 102 | /** Call all output node accessors |
| 103 | * |
| 104 | * @param[in] workload Workload to execute |
Georgios Pinitas | 12be7ab | 2018-07-03 12:06:23 +0100 | [diff] [blame^] | 105 | * |
| 106 | * @return True if all the accessors expect more data |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 107 | */ |
Georgios Pinitas | 12be7ab | 2018-07-03 12:06:23 +0100 | [diff] [blame^] | 108 | bool call_all_output_node_accessors(ExecutionWorkload &workload); |
Georgios Pinitas | e043767 | 2018-05-02 14:07:55 +0100 | [diff] [blame] | 109 | /** Prepares all tasks for execution |
| 110 | * |
| 111 | * @param[in] workload Workload to prepare |
| 112 | */ |
| 113 | void prepare_all_tasks(ExecutionWorkload &workload); |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 114 | /** Executes all tasks of a workload |
| 115 | * |
| 116 | * @param[in] workload Workload to execute |
| 117 | */ |
| 118 | void call_all_tasks(ExecutionWorkload &workload); |
| 119 | } // namespace detail |
Georgios Pinitas | d9eb275 | 2018-04-03 13:44:29 +0100 | [diff] [blame] | 120 | } // namespace graph |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 121 | } // namespace arm_compute |
Georgios Pinitas | d9eb275 | 2018-04-03 13:44:29 +0100 | [diff] [blame] | 122 | #endif /* __ARM_COMPUTE_GRAPH_DETAIL_EXECUTION_HELPERS_H__ */ |