blob: b1662bb82f785fb47c6e24f844a1d47a98132be1 [file] [log] [blame]
Georgios Pinitasd8734b52017-12-22 15:27:52 +00001/*
Michele Di Giorgiod9eaf612020-07-08 11:12:57 +01002 * Copyright (c) 2018-2019 Arm Limited.
Georgios Pinitasd8734b52017-12-22 15:27:52 +00003 *
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 Spyrouf4643372019-11-29 16:17:13 +000024#ifndef ARM_COMPUTE_GRAPH_DETAIL_EXECUTION_HELPERS_H
25#define ARM_COMPUTE_GRAPH_DETAIL_EXECUTION_HELPERS_H
Georgios Pinitasd8734b52017-12-22 15:27:52 +000026
Georgios Pinitasd9eb2752018-04-03 13:44:29 +010027#include "arm_compute/graph/Types.h"
Georgios Pinitasd8734b52017-12-22 15:27:52 +000028
29namespace arm_compute
30{
Georgios Pinitasd9eb2752018-04-03 13:44:29 +010031namespace graph
Georgios Pinitasd8734b52017-12-22 15:27:52 +000032{
33// Forward declarations
34class Graph;
35class GraphContext;
Georgios Pinitas879d1312019-09-30 13:25:53 +010036struct ExecutionWorkload;
Georgios Pinitasd8734b52017-12-22 15:27:52 +000037class Tensor;
Georgios Pinitase0437672018-05-02 14:07:55 +010038class INode;
Georgios Pinitasd8734b52017-12-22 15:27:52 +000039
40namespace detail
41{
Georgios Pinitascac13b12018-04-27 19:07:19 +010042/** Validates all nodes
43 *
44 * @param[in] g Graph to validate
45 */
46void validate_all_nodes(Graph &g);
Georgios Pinitasd8734b52017-12-22 15:27:52 +000047/** Configures all nodes of a graph
48 *
49 * @param[in] g Graph to configure
50 */
51void configure_all_tensors(Graph &g);
Georgios Pinitase0437672018-05-02 14:07:55 +010052/** Allocates all input tensors of a node.
53 *
54 * @param[in] node Node to allocate the input tensor of
55 */
56void 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 */
61void 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 */
66void allocate_const_tensors(Graph &g);
Georgios Pinitasd8734b52017-12-22 15:27:52 +000067/** Allocates all tensors of a graph
68 *
69 * @param[in] g Graph to allocate the tensors
70 */
71void allocate_all_tensors(Graph &g);
Georgios Pinitasd8734b52017-12-22 15:27:52 +000072/** Configures all nodes of graph
73 *
Georgios Pinitas2a2db592018-08-15 12:14:46 +010074 * @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 Pinitasd8734b52017-12-22 15:27:52 +000077 *
78 * @return The execution workload
79 */
Georgios Pinitas2a2db592018-08-15 12:14:46 +010080ExecutionWorkload configure_all_nodes(Graph &g, GraphContext &ctx, const std::vector<NodeID> &node_order);
Georgios Pinitas1562be32018-03-08 19:09:19 +000081/** Release the memory of all unused const nodes
82 *
83 * @param[in] g Graph to release the memory from
84 */
85void release_unused_tensors(Graph &g);
Georgios Pinitasd8734b52017-12-22 15:27:52 +000086/** Calls accessor of a given tensor
87 *
88 * @param[in] tensor The tensor of which the accessor should be called
89 */
90void call_tensor_accessor(Tensor *tensor);
91/** Call all const node accessors
92 *
93 * @param[in] g Graph containing the const nodes
94 */
95void call_all_const_node_accessors(Graph &g);
96/** Call all input node accessors
97 *
98 * @param[in] workload Workload to execute
Georgios Pinitas12be7ab2018-07-03 12:06:23 +010099 *
100 * @return True if all the accesses were valid
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000101 */
Georgios Pinitas12be7ab2018-07-03 12:06:23 +0100102bool call_all_input_node_accessors(ExecutionWorkload &workload);
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000103/** Call all output node accessors
104 *
105 * @param[in] workload Workload to execute
Georgios Pinitas12be7ab2018-07-03 12:06:23 +0100106 *
107 * @return True if all the accessors expect more data
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000108 */
Georgios Pinitas12be7ab2018-07-03 12:06:23 +0100109bool call_all_output_node_accessors(ExecutionWorkload &workload);
Georgios Pinitase0437672018-05-02 14:07:55 +0100110/** Prepares all tasks for execution
111 *
112 * @param[in] workload Workload to prepare
113 */
114void prepare_all_tasks(ExecutionWorkload &workload);
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000115/** Executes all tasks of a workload
116 *
117 * @param[in] workload Workload to execute
118 */
119void call_all_tasks(ExecutionWorkload &workload);
120} // namespace detail
Georgios Pinitasd9eb2752018-04-03 13:44:29 +0100121} // namespace graph
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000122} // namespace arm_compute
Michalis Spyrouf4643372019-11-29 16:17:13 +0000123#endif /* ARM_COMPUTE_GRAPH_DETAIL_EXECUTION_HELPERS_H */