blob: f0d6297b7b3b3d5726fb2f014f4d8c660d5097c5 [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 */
24#ifndef __ARM_COMPUTE_GRAPH2_IDEVICEBACKEND_H__
25#define __ARM_COMPUTE_GRAPH2_IDEVICEBACKEND_H__
26
27#include "arm_compute/graph2/ITensorHandle.h"
28#include "arm_compute/graph2/Types.h"
29#include "arm_compute/runtime/IFunction.h"
30#include "arm_compute/runtime/IMemoryManager.h"
31
32#include <memory>
33
34namespace arm_compute
35{
36namespace graph2
37{
38// Forward declarations
39class Graph;
40class GraphContext;
41class Tensor;
42class INode;
43
44namespace backends
45{
46/** Device backend interface */
47class IDeviceBackend
48{
49public:
50 /** Virtual Destructor */
51 virtual ~IDeviceBackend() = default;
52 /** Initializes the backend */
53 virtual void initialize_backend() = 0;
54 /** Setups the given graph context
55 *
56 * @param[in] ctx Graph context
57 */
58 virtual void setup_backend_context(GraphContext &ctx) = 0;
59 /** Create a backend Tensor
60 *
61 * @param[in] tensor The tensor we want to create a backend tensor for
62 *
63 * @return Backend tensor handle
64 */
65 virtual std::unique_ptr<ITensorHandle> create_tensor(const Tensor &tensor) = 0;
66 /** Create a backend Sub-Tensor
67 *
Georgios Pinitasee33ea52018-03-08 16:01:29 +000068 * @param[in] parent Parent sub-tensor handle
69 * @param[in] shape Shape of the sub-tensor
70 * @param[in] coords Starting coordinates of the sub-tensor
71 * @param[in] extend_parent Extends parent shape if true
Georgios Pinitasd8734b52017-12-22 15:27:52 +000072 *
73 * @return Backend sub-tensor handle
74 */
Georgios Pinitasee33ea52018-03-08 16:01:29 +000075 virtual std::unique_ptr<ITensorHandle> create_subtensor(ITensorHandle *parent, TensorShape shape, Coordinates coords, bool extend_parent) = 0;
Georgios Pinitasd8734b52017-12-22 15:27:52 +000076 /** Configure a backend Node
77 *
78 * @note This creates an appropriate configured backend function for the given node
79 *
80 * @param[in] node The node we want to configure
81 * @param[in] ctx Context to use
82 *
83 * @return Backend execution function
84 */
85 virtual std::unique_ptr<arm_compute::IFunction> configure_node(INode &node, GraphContext &ctx) = 0;
86 /** Validate a node
87 *
88 * @param[in] node The node we want to validate
89 *
90 * @return An error status
91 */
Georgios Pinitas28705162018-03-21 20:10:53 +000092 virtual Status validate_node(INode &node) = 0;
Georgios Pinitasd8734b52017-12-22 15:27:52 +000093 /** Create a backend memory manager given its affinity
94 *
95 * @param[in] affinity Memory Manager affinity
96 *
97 * @return Memory manager
98 */
99 virtual std::shared_ptr<arm_compute::IMemoryManager> create_memory_manager(MemoryManagerAffinity affinity) = 0;
100};
101} // namespace backends
102} // namespace graph2
103} // namespace arm_compute
104#endif //__ARM_COMPUTE_GRAPH2_IDEVICEBACKEND_H__