blob: 7020503171a755272970ac9c3e68a0e637ad258d [file] [log] [blame]
Georgios Pinitasd8734b52017-12-22 15:27:52 +00001/*
Michele Di Giorgiod9eaf612020-07-08 11:12:57 +01002 * Copyright (c) 2018-2020 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 */
Georgios Pinitasd9eb2752018-04-03 13:44:29 +010024#include "arm_compute/graph/Workload.h"
Georgios Pinitasd8734b52017-12-22 15:27:52 +000025
Georgios Pinitasd9eb2752018-04-03 13:44:29 +010026#include "arm_compute/graph/INode.h"
27#include "arm_compute/graph/ITensorHandle.h"
Giorgio Arena6e9d0e02020-01-03 15:02:04 +000028#include "arm_compute/graph/nodes/PrintLayerNode.h"
Georgios Pinitasd8734b52017-12-22 15:27:52 +000029
30namespace arm_compute
31{
Georgios Pinitasd9eb2752018-04-03 13:44:29 +010032namespace graph
Georgios Pinitasd8734b52017-12-22 15:27:52 +000033{
34void ExecutionTask::operator()()
35{
Georgios Pinitas5c2fb3f2018-05-01 15:26:20 +010036 TaskExecutor::get().execute_function(*this);
37}
38
39void execute_task(ExecutionTask &task)
40{
41 if(task.task)
Georgios Pinitasd8734b52017-12-22 15:27:52 +000042 {
Georgios Pinitas5c2fb3f2018-05-01 15:26:20 +010043 task.task->run();
Georgios Pinitasd8734b52017-12-22 15:27:52 +000044 }
Giorgio Arena6e9d0e02020-01-03 15:02:04 +000045#ifdef ARM_COMPUTE_ASSERTS_ENABLED
46 // COMPMID-3012 - Hide the printing logic from the execute_task method in the graph API
47 else if(task.node->type() == NodeType::PrintLayer)
48 {
49 auto print_node = dynamic_cast<PrintLayerNode *>(task.node);
50 auto input_handle = print_node->input(0)->handle();
51 auto transform = print_node->transform();
52
53 input_handle->map(true);
54 ITensor *input = transform ? transform(&input_handle->tensor()) : &input_handle->tensor();
55 input->print(print_node->stream(), print_node->format_info());
56 input_handle->unmap();
57 }
58#endif // ARM_COMPUTE_ASSERTS_ENABLED
Georgios Pinitasd8734b52017-12-22 15:27:52 +000059}
Georgios Pinitase0437672018-05-02 14:07:55 +010060
61void ExecutionTask::prepare()
62{
63 if(task)
64 {
65 task->prepare();
66 }
67}
Georgios Pinitas5c2fb3f2018-05-01 15:26:20 +010068
69TaskExecutor::TaskExecutor()
70 : execute_function(execute_task)
71{
72}
73
74TaskExecutor &TaskExecutor::get()
75{
76 static TaskExecutor executor;
77 return executor;
78}
Georgios Pinitasd9eb2752018-04-03 13:44:29 +010079} // namespace graph
Georgios Pinitasd8734b52017-12-22 15:27:52 +000080} // namespace arm_compute