blob: 72aa7892749b987a220fe8f2a99f61979e7134cd [file] [log] [blame]
Georgios Pinitas6f669f02017-09-26 12:32:57 +01001/*
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 Pinitase2c82fe2017-10-02 18:51:47 +010028#include "arm_compute/graph/ITensorObject.h"
Georgios Pinitas6f669f02017-09-26 12:32:57 +010029#include "arm_compute/graph/Tensor.h"
30#include "arm_compute/graph/Types.h"
31#include "support/ToolchainSupport.h"
32
33#include <memory>
34
35namespace arm_compute
36{
37namespace graph
38{
39/** SubTensor class */
Georgios Pinitase2c82fe2017-10-02 18:51:47 +010040class SubTensor final : public ITensorObject
Georgios Pinitas6f669f02017-09-26 12:32:57 +010041{
42public:
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 Pinitase2c82fe2017-10-02 18:51:47 +010059 SubTensor(arm_compute::ITensor *parent, TensorShape tensor_shape, Coordinates coords, TargetHint target);
Georgios Pinitas6f669f02017-09-26 12:32:57 +010060 /** 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 Pinitase2c82fe2017-10-02 18:51:47 +010071 // Inherited methods overriden:
72 bool call_accessor() override;
73 bool has_accessor() const override;
74 arm_compute::ITensor *set_target(TargetHint target) override;
Michalis Spyroued194b12017-10-31 15:04:34 +000075 arm_compute::ITensor *tensor() override;
76 const arm_compute::ITensor *tensor() const override;
77 TargetHint target() const override;
78 void allocate() override;
Georgios Pinitas6f669f02017-09-26 12:32:57 +010079
80private:
81 /** Instantiates a sub-tensor */
82 void instantiate_subtensor();
83
84private:
Georgios Pinitase2c82fe2017-10-02 18:51:47 +010085 TargetHint _target; /**< Target that this tensor is pinned on */
86 TensorShape _tensor_shape; /**< SubTensor shape */
87 Coordinates _coords; /**< SubTensor Coordinates */
88 arm_compute::ITensor *_parent; /**< Parent tensor */
89 std::unique_ptr<arm_compute::ITensor> _subtensor; /**< SubTensor */
Georgios Pinitas6f669f02017-09-26 12:32:57 +010090};
91} // namespace graph
92} // namespace arm_compute
93#endif /* __ARM_COMPUTE_GRAPH_SUBTENSOR_H__ */