Gunes Bayir | e421167 | 2023-07-25 10:37:13 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2023 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 | |
| 25 | #include "ckw/TensorSampler.h" |
| 26 | |
| 27 | namespace ckw |
| 28 | { |
| 29 | |
| 30 | TensorSampler::TensorSampler(TensorStorageType storage, |
| 31 | TensorSamplerFormat format, |
| 32 | TensorSamplerAddressModeX address_mode_x, |
| 33 | TensorSamplerAddressModeY address_mode_y, |
| 34 | TensorSamplerAddressModeZ address_mode_z) |
| 35 | : _storage(storage), _format(format), _address_mode_x(address_mode_x), _address_mode_y(address_mode_y), _address_mode_z(address_mode_z) |
| 36 | { |
| 37 | } |
| 38 | |
| 39 | TensorStorageType TensorSampler::storage() const |
| 40 | { |
| 41 | return _storage; |
| 42 | } |
| 43 | |
| 44 | TensorSampler &TensorSampler::storage(TensorStorageType storage) |
| 45 | { |
| 46 | _storage = storage; |
| 47 | return *this; |
| 48 | } |
| 49 | |
| 50 | /** Get the format of the tensor. */ |
| 51 | TensorSamplerFormat TensorSampler::format() const |
| 52 | { |
| 53 | return _format; |
| 54 | } |
| 55 | |
| 56 | /** Set the format of the tensor. */ |
| 57 | TensorSampler &TensorSampler::format(TensorSamplerFormat format) |
| 58 | { |
| 59 | _format = format; |
| 60 | return *this; |
| 61 | } |
| 62 | |
| 63 | /** Get the address mode of the x dimension. */ |
| 64 | TensorSamplerAddressModeX TensorSampler::address_mode_x() const |
| 65 | { |
| 66 | return _address_mode_x; |
| 67 | } |
| 68 | |
| 69 | /** Set the address mode of the x-dimension. */ |
| 70 | TensorSampler &TensorSampler::address_mode_x(TensorSamplerAddressModeX address_mode_x) |
| 71 | { |
| 72 | _address_mode_x = address_mode_x; |
| 73 | return *this; |
| 74 | } |
| 75 | |
| 76 | /** Get the address mode of the y dimension. */ |
| 77 | TensorSamplerAddressModeY TensorSampler::address_mode_y() const |
| 78 | { |
| 79 | return _address_mode_y; |
| 80 | } |
| 81 | |
| 82 | /** Set the address mode of the y dimension. */ |
| 83 | TensorSampler &TensorSampler::address_mode_y(TensorSamplerAddressModeY address_mode_y) |
| 84 | { |
| 85 | _address_mode_y = address_mode_y; |
| 86 | return *this; |
| 87 | } |
| 88 | |
| 89 | /** Get the address mode of the z dimension. */ |
| 90 | TensorSamplerAddressModeZ TensorSampler::address_mode_z() const |
| 91 | { |
| 92 | return _address_mode_z; |
| 93 | } |
| 94 | |
| 95 | /** Set the address mode of the z dimension. */ |
| 96 | TensorSampler &TensorSampler::address_mode_z(TensorSamplerAddressModeZ address_mode_z) |
| 97 | { |
| 98 | _address_mode_z = address_mode_z; |
| 99 | return *this; |
| 100 | } |
| 101 | |
| 102 | } // namespace ckw |