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