Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2017 ARM Limited. |
| 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 | */ |
| 24 | #ifndef __ARM_COMPUTE_TEST_RAW_TENSOR_H__ |
| 25 | #define __ARM_COMPUTE_TEST_RAW_TENSOR_H__ |
| 26 | |
Moritz Pflanzer | a09de0c | 2017-09-01 20:41:12 +0100 | [diff] [blame] | 27 | #include "tests/SimpleTensor.h" |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 28 | |
| 29 | namespace arm_compute |
| 30 | { |
| 31 | namespace test |
| 32 | { |
Moritz Pflanzer | 82e70a1 | 2017-08-08 16:20:45 +0100 | [diff] [blame] | 33 | /** Subclass of SimpleTensor using uint8_t as value type. |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 34 | * |
Moritz Pflanzer | 82e70a1 | 2017-08-08 16:20:45 +0100 | [diff] [blame] | 35 | * Access operations (except for operator[]) will be based on the data type to |
| 36 | * copy the right number of elements. |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 37 | */ |
Moritz Pflanzer | 82e70a1 | 2017-08-08 16:20:45 +0100 | [diff] [blame] | 38 | class RawTensor : public SimpleTensor<uint8_t> |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 39 | { |
| 40 | public: |
| 41 | /** Create an uninitialised tensor of the given @p shape and @p format. |
| 42 | * |
| 43 | * @param[in] shape Shape of the new raw tensor. |
| 44 | * @param[in] format Format of the new raw tensor. |
| 45 | * @param[in] fixed_point_position (Optional) Number of bits for the fractional part of the fixed point numbers |
| 46 | */ |
| 47 | RawTensor(TensorShape shape, Format format, int fixed_point_position = 0); |
| 48 | |
| 49 | /** Create an uninitialised tensor of the given @p shape and @p data type. |
| 50 | * |
| 51 | * @param[in] shape Shape of the new raw tensor. |
| 52 | * @param[in] data_type Data type of the new raw tensor. |
| 53 | * @param[in] num_channels (Optional) Number of channels (default = 1). |
| 54 | * @param[in] fixed_point_position (Optional) Number of bits for the fractional part of the fixed point numbers (default = 0). |
| 55 | */ |
| 56 | RawTensor(TensorShape shape, DataType data_type, int num_channels = 1, int fixed_point_position = 0); |
| 57 | |
| 58 | /** Create a deep copy of the given @p tensor. |
| 59 | * |
| 60 | * @param[in] tensor To be copied tensor. |
| 61 | */ |
| 62 | RawTensor(const RawTensor &tensor); |
| 63 | |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 64 | RawTensor &operator =(RawTensor tensor); |
| 65 | RawTensor(RawTensor &&) = default; |
| 66 | ~RawTensor() = default; |
| 67 | |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 68 | /** Read only access to the specified element. |
| 69 | * |
| 70 | * @param[in] coord Coordinates of the desired element. |
| 71 | * |
| 72 | * @return A pointer to the desired element. |
| 73 | */ |
Moritz Pflanzer | 82e70a1 | 2017-08-08 16:20:45 +0100 | [diff] [blame] | 74 | const void *operator()(const Coordinates &coord) const override; |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 75 | |
| 76 | /** Access to the specified element. |
| 77 | * |
| 78 | * @param[in] coord Coordinates of the desired element. |
| 79 | * |
| 80 | * @return A pointer to the desired element. |
| 81 | */ |
Moritz Pflanzer | 82e70a1 | 2017-08-08 16:20:45 +0100 | [diff] [blame] | 82 | void *operator()(const Coordinates &coord) override; |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 83 | }; |
| 84 | } // namespace test |
| 85 | } // namespace arm_compute |
Anthony Barbier | ac69aa1 | 2017-07-03 17:39:37 +0100 | [diff] [blame] | 86 | #endif /* __ARM_COMPUTE_TEST_RAW_TENSOR_H__ */ |