Georgios Pinitas | 6f669f0 | 2017-09-26 12:32:57 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2017 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_GRAPH_SUBTENSOR_H__ |
| 25 | #define __ARM_COMPUTE_GRAPH_SUBTENSOR_H__ |
| 26 | |
| 27 | #include "arm_compute/graph/ITensorAccessor.h" |
Georgios Pinitas | e2c82fe | 2017-10-02 18:51:47 +0100 | [diff] [blame^] | 28 | #include "arm_compute/graph/ITensorObject.h" |
Georgios Pinitas | 6f669f0 | 2017-09-26 12:32:57 +0100 | [diff] [blame] | 29 | #include "arm_compute/graph/Tensor.h" |
| 30 | #include "arm_compute/graph/Types.h" |
| 31 | #include "support/ToolchainSupport.h" |
| 32 | |
| 33 | #include <memory> |
| 34 | |
| 35 | namespace arm_compute |
| 36 | { |
| 37 | namespace graph |
| 38 | { |
| 39 | /** SubTensor class */ |
Georgios Pinitas | e2c82fe | 2017-10-02 18:51:47 +0100 | [diff] [blame^] | 40 | class SubTensor final : public ITensorObject |
Georgios Pinitas | 6f669f0 | 2017-09-26 12:32:57 +0100 | [diff] [blame] | 41 | { |
| 42 | public: |
| 43 | /** Default Constructor */ |
| 44 | SubTensor(); |
| 45 | /** Constructor |
| 46 | * |
| 47 | * @param[in] parent Parent to create sub-tensor from |
| 48 | * @param[in] tensor_shape Sub-tensor shape |
| 49 | * @param[in] coords Starting coordinates of the sub-tensor in the parent tensor |
| 50 | */ |
| 51 | SubTensor(Tensor &parent, TensorShape tensor_shape, Coordinates coords); |
| 52 | /** Constructor |
| 53 | * |
| 54 | * @param[in] parent Parent to create sub-tensor from |
| 55 | * @param[in] tensor_shape Sub-tensor shape |
| 56 | * @param[in] coords Starting coordinates of the sub-tensor in the parent tensor |
| 57 | * @param[in] target Execution target |
| 58 | */ |
Georgios Pinitas | e2c82fe | 2017-10-02 18:51:47 +0100 | [diff] [blame^] | 59 | SubTensor(arm_compute::ITensor *parent, TensorShape tensor_shape, Coordinates coords, TargetHint target); |
Georgios Pinitas | 6f669f0 | 2017-09-26 12:32:57 +0100 | [diff] [blame] | 60 | /** Prevent instances of this class from being copied (As this class contains pointers) */ |
| 61 | SubTensor(const SubTensor &) = delete; |
| 62 | /** Prevent instances of this class from being copied (As this class contains pointers) */ |
| 63 | SubTensor &operator=(const SubTensor &) = delete; |
| 64 | /** Allow instances of this class to be moved */ |
| 65 | SubTensor(SubTensor &&) = default; |
| 66 | /** Allow instances of this class to be moved */ |
| 67 | SubTensor &operator=(SubTensor &&) = default; |
| 68 | /** Default Destructor */ |
| 69 | ~SubTensor() = default; |
| 70 | |
Georgios Pinitas | e2c82fe | 2017-10-02 18:51:47 +0100 | [diff] [blame^] | 71 | // Inherited methods overriden: |
| 72 | bool call_accessor() override; |
| 73 | bool has_accessor() const override; |
| 74 | arm_compute::ITensor *set_target(TargetHint target) override; |
| 75 | arm_compute::ITensor *tensor() override; |
| 76 | TargetHint target() const override; |
| 77 | void allocate() override; |
Georgios Pinitas | 6f669f0 | 2017-09-26 12:32:57 +0100 | [diff] [blame] | 78 | |
| 79 | private: |
| 80 | /** Instantiates a sub-tensor */ |
| 81 | void instantiate_subtensor(); |
| 82 | |
| 83 | private: |
Georgios Pinitas | e2c82fe | 2017-10-02 18:51:47 +0100 | [diff] [blame^] | 84 | TargetHint _target; /**< Target that this tensor is pinned on */ |
| 85 | TensorShape _tensor_shape; /**< SubTensor shape */ |
| 86 | Coordinates _coords; /**< SubTensor Coordinates */ |
| 87 | arm_compute::ITensor *_parent; /**< Parent tensor */ |
| 88 | std::unique_ptr<arm_compute::ITensor> _subtensor; /**< SubTensor */ |
Georgios Pinitas | 6f669f0 | 2017-09-26 12:32:57 +0100 | [diff] [blame] | 89 | }; |
| 90 | } // namespace graph |
| 91 | } // namespace arm_compute |
| 92 | #endif /* __ARM_COMPUTE_GRAPH_SUBTENSOR_H__ */ |