blob: 3a357776e4fdc7162f6c80ee92e85e38b4262ddf [file] [log] [blame]
Georgios Pinitasd8734b52017-12-22 15:27:52 +00001/*
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 Pinitasd9eb2752018-04-03 13:44:29 +010024#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;
36class ExecutionWorkload;
37class 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 *
74 * @param[in] g Graph to configure the nodes
75 * @param[in] ctx Graph context to use
76 *
77 * @return The execution workload
78 */
79ExecutionWorkload configure_all_nodes(Graph &g, GraphContext &ctx);
Georgios Pinitas1562be32018-03-08 19:09:19 +000080/** Release the memory of all unused const nodes
81 *
82 * @param[in] g Graph to release the memory from
83 */
84void release_unused_tensors(Graph &g);
Georgios Pinitasd8734b52017-12-22 15:27:52 +000085/** Calls accessor of a given tensor
86 *
87 * @param[in] tensor The tensor of which the accessor should be called
88 */
89void call_tensor_accessor(Tensor *tensor);
90/** Call all const node accessors
91 *
92 * @param[in] g Graph containing the const nodes
93 */
94void call_all_const_node_accessors(Graph &g);
95/** Call all input node accessors
96 *
97 * @param[in] workload Workload to execute
Georgios Pinitas12be7ab2018-07-03 12:06:23 +010098 *
99 * @return True if all the accesses were valid
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000100 */
Georgios Pinitas12be7ab2018-07-03 12:06:23 +0100101bool call_all_input_node_accessors(ExecutionWorkload &workload);
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000102/** Call all output node accessors
103 *
104 * @param[in] workload Workload to execute
Georgios Pinitas12be7ab2018-07-03 12:06:23 +0100105 *
106 * @return True if all the accessors expect more data
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000107 */
Georgios Pinitas12be7ab2018-07-03 12:06:23 +0100108bool call_all_output_node_accessors(ExecutionWorkload &workload);
Georgios Pinitase0437672018-05-02 14:07:55 +0100109/** Prepares all tasks for execution
110 *
111 * @param[in] workload Workload to prepare
112 */
113void prepare_all_tasks(ExecutionWorkload &workload);
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000114/** Executes all tasks of a workload
115 *
116 * @param[in] workload Workload to execute
117 */
118void call_all_tasks(ExecutionWorkload &workload);
119} // namespace detail
Georgios Pinitasd9eb2752018-04-03 13:44:29 +0100120} // namespace graph
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000121} // namespace arm_compute
Georgios Pinitasd9eb2752018-04-03 13:44:29 +0100122#endif /* __ARM_COMPUTE_GRAPH_DETAIL_EXECUTION_HELPERS_H__ */