Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 1 | /* |
Matthew Bentham | f1aeab9 | 2023-05-30 13:35:34 +0000 | [diff] [blame] | 2 | * Copyright (c) 2017-2019, 2023 Arm Limited. |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [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_TEST_IACCESSOR_H |
| 25 | #define ARM_COMPUTE_TEST_IACCESSOR_H |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 26 | |
| 27 | #include "arm_compute/core/Coordinates.h" |
| 28 | #include "arm_compute/core/Types.h" |
Matthew Bentham | f1aeab9 | 2023-05-30 13:35:34 +0000 | [diff] [blame] | 29 | #include "arm_compute/core/QuantizationInfo.h" |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 30 | |
| 31 | namespace arm_compute |
| 32 | { |
| 33 | namespace test |
| 34 | { |
| 35 | /** Common interface to provide information and access to tensor like |
| 36 | * structures. |
| 37 | */ |
| 38 | class IAccessor |
| 39 | { |
| 40 | public: |
Moritz Pflanzer | d58cec0 | 2017-07-18 15:44:21 +0100 | [diff] [blame] | 41 | /** Virtual destructor. */ |
| 42 | virtual ~IAccessor() = default; |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 43 | |
Alex Gilday | c357c47 | 2018-03-21 13:54:09 +0000 | [diff] [blame] | 44 | /** Shape of the tensor. |
| 45 | * |
| 46 | * @return the shape of the tensor. |
| 47 | */ |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 48 | virtual TensorShape shape() const = 0; |
| 49 | |
Alex Gilday | c357c47 | 2018-03-21 13:54:09 +0000 | [diff] [blame] | 50 | /** Size of each element in the tensor in bytes. |
| 51 | * |
| 52 | * @return the size of each element in the tensor in bytes. |
| 53 | */ |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 54 | virtual size_t element_size() const = 0; |
| 55 | |
Alex Gilday | c357c47 | 2018-03-21 13:54:09 +0000 | [diff] [blame] | 56 | /** Total size of the tensor in bytes. |
| 57 | * |
| 58 | * @return the total size of the tensor in bytes. |
| 59 | */ |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 60 | virtual size_t size() const = 0; |
| 61 | |
Alex Gilday | c357c47 | 2018-03-21 13:54:09 +0000 | [diff] [blame] | 62 | /** Image format of the tensor. |
| 63 | * |
| 64 | * @return the format of the tensor. |
| 65 | */ |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 66 | virtual Format format() const = 0; |
| 67 | |
Alex Gilday | c357c47 | 2018-03-21 13:54:09 +0000 | [diff] [blame] | 68 | /** Data layout of the tensor. |
| 69 | * |
| 70 | * @return the data layout of the tensor. |
| 71 | */ |
Michele Di Giorgio | 4a65b98 | 2018-03-02 11:21:38 +0000 | [diff] [blame] | 72 | virtual DataLayout data_layout() const = 0; |
| 73 | |
Alex Gilday | c357c47 | 2018-03-21 13:54:09 +0000 | [diff] [blame] | 74 | /** Data type of the tensor. |
| 75 | * |
| 76 | * @return the data type of the tensor. |
| 77 | */ |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 78 | virtual DataType data_type() const = 0; |
| 79 | |
Alex Gilday | c357c47 | 2018-03-21 13:54:09 +0000 | [diff] [blame] | 80 | /** Number of channels of the tensor. |
| 81 | * |
| 82 | * @return the number of channels of the tensor. |
| 83 | */ |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 84 | virtual int num_channels() const = 0; |
| 85 | |
Alex Gilday | c357c47 | 2018-03-21 13:54:09 +0000 | [diff] [blame] | 86 | /** Number of elements of the tensor. |
| 87 | * |
| 88 | * @return the number of elements of the tensor. |
| 89 | */ |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 90 | virtual int num_elements() const = 0; |
| 91 | |
Alex Gilday | c357c47 | 2018-03-21 13:54:09 +0000 | [diff] [blame] | 92 | /** Available padding around the tensor. |
| 93 | * |
| 94 | * @return the available padding around the tensor. |
| 95 | */ |
Giorgio Arena | a261181 | 2017-07-21 10:08:48 +0100 | [diff] [blame] | 96 | virtual PaddingSize padding() const = 0; |
| 97 | |
Alex Gilday | c357c47 | 2018-03-21 13:54:09 +0000 | [diff] [blame] | 98 | /** Quantization info in case of asymmetric quantized type |
| 99 | * |
| 100 | * @return |
| 101 | */ |
Chunosov | d621bca | 2017-11-03 17:33:15 +0700 | [diff] [blame] | 102 | virtual QuantizationInfo quantization_info() const = 0; |
| 103 | |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 104 | /** Read only access to the specified element. |
| 105 | * |
| 106 | * @param[in] coord Coordinates of the desired element. |
| 107 | * |
| 108 | * @return A pointer to the desired element. |
| 109 | */ |
| 110 | virtual const void *operator()(const Coordinates &coord) const = 0; |
| 111 | |
| 112 | /** Access to the specified element. |
| 113 | * |
| 114 | * @param[in] coord Coordinates of the desired element. |
| 115 | * |
| 116 | * @return A pointer to the desired element. |
| 117 | */ |
| 118 | virtual void *operator()(const Coordinates &coord) = 0; |
| 119 | }; |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 120 | } // namespace test |
| 121 | } // namespace arm_compute |
Michalis Spyrou | f464337 | 2019-11-29 16:17:13 +0000 | [diff] [blame] | 122 | #endif /* ARM_COMPUTE_TEST_IACCESSOR_H */ |