blob: 75faee19ce1c237d6384dd821762db85fcc9de29 [file] [log] [blame]
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001/*
Matthew Benthamf1aeab92023-05-30 13:35:34 +00002 * Copyright (c) 2017-2019, 2023 Arm Limited.
Anthony Barbier6ff3b192017-09-04 18:44:23 +01003 *
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 Spyrouf4643372019-11-29 16:17:13 +000024#ifndef ARM_COMPUTE_TEST_IACCESSOR_H
25#define ARM_COMPUTE_TEST_IACCESSOR_H
Anthony Barbier6ff3b192017-09-04 18:44:23 +010026
27#include "arm_compute/core/Coordinates.h"
28#include "arm_compute/core/Types.h"
Matthew Benthamf1aeab92023-05-30 13:35:34 +000029#include "arm_compute/core/QuantizationInfo.h"
Anthony Barbier6ff3b192017-09-04 18:44:23 +010030
31namespace arm_compute
32{
33namespace test
34{
35/** Common interface to provide information and access to tensor like
36 * structures.
37 */
38class IAccessor
39{
40public:
Moritz Pflanzerd58cec02017-07-18 15:44:21 +010041 /** Virtual destructor. */
42 virtual ~IAccessor() = default;
Anthony Barbier6ff3b192017-09-04 18:44:23 +010043
Alex Gildayc357c472018-03-21 13:54:09 +000044 /** Shape of the tensor.
45 *
46 * @return the shape of the tensor.
47 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +010048 virtual TensorShape shape() const = 0;
49
Alex Gildayc357c472018-03-21 13:54:09 +000050 /** Size of each element in the tensor in bytes.
51 *
52 * @return the size of each element in the tensor in bytes.
53 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +010054 virtual size_t element_size() const = 0;
55
Alex Gildayc357c472018-03-21 13:54:09 +000056 /** Total size of the tensor in bytes.
57 *
58 * @return the total size of the tensor in bytes.
59 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +010060 virtual size_t size() const = 0;
61
Alex Gildayc357c472018-03-21 13:54:09 +000062 /** Image format of the tensor.
63 *
64 * @return the format of the tensor.
65 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +010066 virtual Format format() const = 0;
67
Alex Gildayc357c472018-03-21 13:54:09 +000068 /** Data layout of the tensor.
69 *
70 * @return the data layout of the tensor.
71 */
Michele Di Giorgio4a65b982018-03-02 11:21:38 +000072 virtual DataLayout data_layout() const = 0;
73
Alex Gildayc357c472018-03-21 13:54:09 +000074 /** Data type of the tensor.
75 *
76 * @return the data type of the tensor.
77 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +010078 virtual DataType data_type() const = 0;
79
Alex Gildayc357c472018-03-21 13:54:09 +000080 /** Number of channels of the tensor.
81 *
82 * @return the number of channels of the tensor.
83 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +010084 virtual int num_channels() const = 0;
85
Alex Gildayc357c472018-03-21 13:54:09 +000086 /** Number of elements of the tensor.
87 *
88 * @return the number of elements of the tensor.
89 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +010090 virtual int num_elements() const = 0;
91
Alex Gildayc357c472018-03-21 13:54:09 +000092 /** Available padding around the tensor.
93 *
94 * @return the available padding around the tensor.
95 */
Giorgio Arenaa2611812017-07-21 10:08:48 +010096 virtual PaddingSize padding() const = 0;
97
Alex Gildayc357c472018-03-21 13:54:09 +000098 /** Quantization info in case of asymmetric quantized type
99 *
100 * @return
101 */
Chunosovd621bca2017-11-03 17:33:15 +0700102 virtual QuantizationInfo quantization_info() const = 0;
103
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100104 /** 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 Barbier6ff3b192017-09-04 18:44:23 +0100120} // namespace test
121} // namespace arm_compute
Michalis Spyrouf4643372019-11-29 16:17:13 +0000122#endif /* ARM_COMPUTE_TEST_IACCESSOR_H */