Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 1 | /* |
Michele Di Giorgio | d9eaf61 | 2020-07-08 11:12:57 +0100 | [diff] [blame] | 2 | * Copyright (c) 2018-2020 Arm Limited. |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 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 | */ |
Michalis Spyrou | f464337 | 2019-11-29 16:17:13 +0000 | [diff] [blame] | 24 | #ifndef ARM_COMPUTE_GRAPH_TENSOR_DESCRIPTOR_H |
| 25 | #define ARM_COMPUTE_GRAPH_TENSOR_DESCRIPTOR_H |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 26 | |
Georgios Pinitas | d9eb275 | 2018-04-03 13:44:29 +0100 | [diff] [blame] | 27 | #include "arm_compute/graph/Types.h" |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 28 | |
Sang-Hoon Park | 68dd25f | 2020-10-19 16:00:11 +0100 | [diff] [blame] | 29 | #include "support/ICloneable.h" |
Georgios Pinitas | cac13b1 | 2018-04-27 19:07:19 +0100 | [diff] [blame] | 30 | |
| 31 | #include <memory> |
| 32 | |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 33 | namespace arm_compute |
| 34 | { |
Georgios Pinitas | d9eb275 | 2018-04-03 13:44:29 +0100 | [diff] [blame] | 35 | namespace graph |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 36 | { |
| 37 | /** Tensor metadata class */ |
Georgios Pinitas | cac13b1 | 2018-04-27 19:07:19 +0100 | [diff] [blame] | 38 | struct TensorDescriptor final : public misc::ICloneable<TensorDescriptor> |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 39 | { |
| 40 | /** Default Constructor **/ |
| 41 | TensorDescriptor() = default; |
| 42 | /** Constructor |
| 43 | * |
Georgios Pinitas | cac13b1 | 2018-04-27 19:07:19 +0100 | [diff] [blame] | 44 | * @param[in] tensor_shape Tensor shape |
| 45 | * @param[in] tensor_data_type Tensor data type |
| 46 | * @param[in] tensor_quant_info Tensor quantization info |
| 47 | * @param[in] tensor_data_layout Tensor data layout |
| 48 | * @param[in] tensor_target Target to allocate the tensor for |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 49 | */ |
Georgios Pinitas | cac13b1 | 2018-04-27 19:07:19 +0100 | [diff] [blame] | 50 | TensorDescriptor(TensorShape tensor_shape, |
| 51 | DataType tensor_data_type, |
| 52 | QuantizationInfo tensor_quant_info = QuantizationInfo(), |
| 53 | DataLayout tensor_data_layout = DataLayout::NCHW, |
| 54 | Target tensor_target = Target::UNSPECIFIED) |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 55 | : shape(tensor_shape), |
| 56 | data_type(tensor_data_type), |
| 57 | layout(tensor_data_layout), |
| 58 | quant_info(tensor_quant_info), |
| 59 | target(tensor_target) |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 60 | { |
| 61 | } |
Georgios Pinitas | cac13b1 | 2018-04-27 19:07:19 +0100 | [diff] [blame] | 62 | /** Sets tensor descriptor shape |
| 63 | * |
| 64 | * @param[in] tensor_shape Tensor shape to set |
| 65 | * |
| 66 | * @return This tensor descriptor |
| 67 | */ |
| 68 | TensorDescriptor &set_shape(TensorShape &tensor_shape) |
| 69 | { |
| 70 | shape = tensor_shape; |
| 71 | return *this; |
| 72 | } |
| 73 | /** Sets tensor descriptor data type |
| 74 | * |
| 75 | * @param[in] tensor_data_type Data type |
| 76 | * |
| 77 | * @return This tensor descriptor |
| 78 | */ |
| 79 | TensorDescriptor &set_data_type(DataType tensor_data_type) |
| 80 | { |
| 81 | data_type = tensor_data_type; |
| 82 | return *this; |
| 83 | } |
| 84 | /** Sets tensor descriptor data layout |
| 85 | * |
| 86 | * @param[in] data_layout Data layout |
| 87 | * |
| 88 | * @return This tensor descriptor |
| 89 | */ |
| 90 | TensorDescriptor &set_layout(DataLayout data_layout) |
| 91 | { |
| 92 | layout = data_layout; |
| 93 | return *this; |
| 94 | } |
| 95 | /** Sets tensor descriptor quantization info |
| 96 | * |
| 97 | * @param[in] tensor_quant_info Quantization information |
| 98 | * |
| 99 | * @return This tensor descriptor |
| 100 | */ |
| 101 | TensorDescriptor &set_quantization_info(QuantizationInfo tensor_quant_info) |
| 102 | { |
| 103 | quant_info = tensor_quant_info; |
| 104 | return *this; |
| 105 | } |
| 106 | |
| 107 | // Inherited methods overridden: |
| 108 | std::unique_ptr<TensorDescriptor> clone() const override |
| 109 | { |
Georgios Pinitas | 40f51a6 | 2020-11-21 03:04:18 +0000 | [diff] [blame] | 110 | return std::make_unique<TensorDescriptor>(*this); |
Georgios Pinitas | cac13b1 | 2018-04-27 19:07:19 +0100 | [diff] [blame] | 111 | } |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 112 | |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 113 | TensorShape shape{}; /**< Tensor shape */ |
| 114 | DataType data_type{DataType::UNKNOWN}; /**< Data type */ |
| 115 | DataLayout layout{DataLayout::NCHW}; /**< Data layout */ |
| 116 | QuantizationInfo quant_info{}; /**< Quantization info */ |
| 117 | Target target{Target::UNSPECIFIED}; /**< Target */ |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 118 | }; |
Georgios Pinitas | d9eb275 | 2018-04-03 13:44:29 +0100 | [diff] [blame] | 119 | } // namespace graph |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 120 | } // namespace arm_compute |
Michalis Spyrou | f464337 | 2019-11-29 16:17:13 +0000 | [diff] [blame] | 121 | #endif /* ARM_COMPUTE_GRAPH_TENSOR_DESCRIPTOR_H */ |