2 * Copyright (c) 2017 ARM Limited.
4 * SPDX-License-Identifier: MIT
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:
13 * The above copyright notice and this permission notice shall be included in all
14 * copies or substantial portions of the Software.
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
24 #ifndef __ARM_COMPUTE_GRAPH_TENSOR_H__
25 #define __ARM_COMPUTE_GRAPH_TENSOR_H__
27 #include "arm_compute/graph/ITensorAccessor.h"
28 #include "arm_compute/graph/Types.h"
29 #include "support/ToolchainSupport.h"
43 * @param[in] info Tensor info to use
45 Tensor(TensorInfo &&info);
48 * @param[in] accessor Tensor accessor
50 template <typename AccessorType>
51 Tensor(std::unique_ptr<AccessorType> accessor)
52 : _target(Hint::DONT_CARE), _info(), _accessor(std::move(accessor)), _tensor(nullptr)
57 * @param[in] accessor Tensor accessor
59 template <typename AccessorType>
60 Tensor(AccessorType &&accessor)
61 : _target(Hint::DONT_CARE), _info(), _accessor(arm_compute::support::cpp14::make_unique<AccessorType>(std::forward<AccessorType>(accessor))), _tensor(nullptr)
66 * @param[in] info Tensor info to use
67 * @param[in] accessor Tensor accessor
69 template <typename AccessorType>
70 Tensor(TensorInfo &&info, AccessorType &&accessor)
71 : _target(Hint::DONT_CARE), _info(info), _accessor(arm_compute::support::cpp14::make_unique<AccessorType>(std::forward<AccessorType>(accessor))), _tensor(nullptr)
74 /** Default Destructor */
78 * @param[in] src Tensor to move
80 Tensor(Tensor &&src) noexcept;
82 /** Sets the given TensorInfo to the tensor
84 * @param[in] info TensorInfo to set
86 void set_info(TensorInfo &&info);
87 /** Calls accessor on tensor
89 * @return True if succeeds else false
92 /** Sets target of the tensor
94 * @param[in] target Target where the tensor should be pinned in
98 ITensor *set_target(Hint target);
99 /** Returns tensor's TensorInfo
101 * @return TensorInfo of the tensor
103 const TensorInfo &info() const;
104 /** Returns a pointer to the internal tensor
109 /** Allocates and fills the tensor if needed */
110 void allocate_and_fill_if_needed();
111 /** Allocates the tensor */
113 /** Return the target that this tensor is pinned on
115 * @return Target of the tensor
120 Hint _target; /**< Target that this tensor is pinned on */
121 TensorInfo _info; /**< Tensor metadata */
122 std::unique_ptr<ITensorAccessor> _accessor; /**< Tensor Accessor */
123 std::unique_ptr<ITensor> _tensor; /**< Tensor */
126 } // namespace arm_compute
127 #endif /* __ARM_COMPUTE_GRAPH_TENSOR_H__ */