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 | */ |
| 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 | |
| 34 | namespace arm_compute |
| 35 | { |
| 36 | namespace graph2 |
| 37 | { |
| 38 | // Forward declarations |
| 39 | class Graph; |
| 40 | class GraphContext; |
| 41 | class Tensor; |
| 42 | class INode; |
| 43 | |
| 44 | namespace backends |
| 45 | { |
| 46 | /** Device backend interface */ |
| 47 | class IDeviceBackend |
| 48 | { |
| 49 | public: |
| 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 | * |
| 68 | * @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 | * |
| 72 | * @return Backend sub-tensor handle |
| 73 | */ |
| 74 | virtual std::unique_ptr<ITensorHandle> create_subtensor(ITensorHandle *parent, TensorShape shape, Coordinates coords) = 0; |
| 75 | /** Configure a backend Node |
| 76 | * |
| 77 | * @note This creates an appropriate configured backend function for the given node |
| 78 | * |
| 79 | * @param[in] node The node we want to configure |
| 80 | * @param[in] ctx Context to use |
| 81 | * |
| 82 | * @return Backend execution function |
| 83 | */ |
| 84 | virtual std::unique_ptr<arm_compute::IFunction> configure_node(INode &node, GraphContext &ctx) = 0; |
| 85 | /** Validate a node |
| 86 | * |
| 87 | * @param[in] node The node we want to validate |
| 88 | * |
| 89 | * @return An error status |
| 90 | */ |
| 91 | virtual Status validate_node(const INode &node) = 0; |
| 92 | /** Create a backend memory manager given its affinity |
| 93 | * |
| 94 | * @param[in] affinity Memory Manager affinity |
| 95 | * |
| 96 | * @return Memory manager |
| 97 | */ |
| 98 | virtual std::shared_ptr<arm_compute::IMemoryManager> create_memory_manager(MemoryManagerAffinity affinity) = 0; |
| 99 | }; |
| 100 | } // namespace backends |
| 101 | } // namespace graph2 |
| 102 | } // namespace arm_compute |
| 103 | #endif //__ARM_COMPUTE_GRAPH2_IDEVICEBACKEND_H__ |