Viet-Hoa Do | bd4f6b9 | 2023-05-30 09:34:32 +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/TensorTileSampler.h" |
| 26 | #include "ckw/TileOperand.h" |
| 27 | #include "ckw/Types.h" |
| 28 | |
| 29 | namespace ckw |
| 30 | { |
| 31 | |
| 32 | TensorTileSampler::TensorTileSampler() |
| 33 | { |
| 34 | } |
| 35 | |
| 36 | TensorTileSampler::TensorTileSampler( |
| 37 | TileOperand &x, TileOperand &y, TileOperand &z, TileOperand &b, |
| 38 | TensorSamplerFormat format, |
| 39 | TensorSamplerAddressModeX address_mode_x, |
| 40 | TensorSamplerAddressModeY address_mode_y, |
| 41 | TensorSamplerAddressModeZ address_mode_z) |
| 42 | : _x(&x), _y(&y), _z(&z), _b(&b), _height(0), _width(0), _format(format), _address_mode_x(address_mode_x), _address_mode_y(address_mode_y), _address_mode_z(address_mode_z) |
| 43 | { |
| 44 | } |
| 45 | |
| 46 | TensorTileSampler::TensorTileSampler( |
| 47 | TileOperand &x, TileOperand &y, TileOperand &z, TileOperand &b, |
| 48 | int32_t height, int32_t width, |
| 49 | TensorSamplerFormat format, |
| 50 | TensorSamplerAddressModeX address_mode_x, |
| 51 | TensorSamplerAddressModeY address_mode_y, |
| 52 | TensorSamplerAddressModeZ address_mode_z) |
| 53 | : _x(&x), _y(&y), _z(&z), _b(&b), _height(height), _width(width), _format(format), _address_mode_x(address_mode_x), _address_mode_y(address_mode_y), _address_mode_z(address_mode_z) |
| 54 | { |
| 55 | } |
| 56 | |
| 57 | const TileOperand &TensorTileSampler::x() const |
| 58 | { |
| 59 | return *_x; |
| 60 | } |
| 61 | |
| 62 | TensorTileSampler &TensorTileSampler::x(TileOperand &x) |
| 63 | { |
| 64 | _x = &x; |
| 65 | return *this; |
| 66 | } |
| 67 | |
| 68 | const TileOperand &TensorTileSampler::y() const |
| 69 | { |
| 70 | return *_y; |
| 71 | } |
| 72 | |
| 73 | TensorTileSampler &TensorTileSampler::y(TileOperand &y) |
| 74 | { |
| 75 | _y = &y; |
| 76 | return *this; |
| 77 | } |
| 78 | |
| 79 | const TileOperand &TensorTileSampler::z() const |
| 80 | { |
| 81 | return *_z; |
| 82 | } |
| 83 | |
| 84 | TensorTileSampler &TensorTileSampler::z(TileOperand &z) |
| 85 | { |
| 86 | _z = &z; |
| 87 | return *this; |
| 88 | } |
| 89 | |
| 90 | const TileOperand &TensorTileSampler::b() const |
| 91 | { |
| 92 | return *_b; |
| 93 | } |
| 94 | |
| 95 | TensorTileSampler &TensorTileSampler::b(TileOperand &b) |
| 96 | { |
| 97 | _b = &b; |
| 98 | return *this; |
| 99 | } |
| 100 | |
| 101 | int32_t TensorTileSampler::width() const |
| 102 | { |
| 103 | return _width; |
| 104 | } |
| 105 | |
| 106 | TensorTileSampler &TensorTileSampler::width(int32_t width) |
| 107 | { |
| 108 | _width = width; |
| 109 | return *this; |
| 110 | } |
| 111 | |
| 112 | int32_t TensorTileSampler::height() const |
| 113 | { |
| 114 | return _height; |
| 115 | } |
| 116 | |
| 117 | TensorTileSampler &TensorTileSampler::height(int32_t height) |
| 118 | { |
| 119 | _height = height; |
| 120 | return *this; |
| 121 | } |
| 122 | |
| 123 | TensorSamplerFormat TensorTileSampler::format() const |
| 124 | { |
| 125 | return _format; |
| 126 | } |
| 127 | |
| 128 | TensorTileSampler &TensorTileSampler::format(TensorSamplerFormat format) |
| 129 | { |
| 130 | _format = format; |
| 131 | return *this; |
| 132 | } |
| 133 | |
| 134 | TensorSamplerAddressModeX TensorTileSampler::address_mode_x() const |
| 135 | { |
| 136 | return _address_mode_x; |
| 137 | } |
| 138 | |
| 139 | TensorTileSampler &TensorTileSampler::address_mode_x(TensorSamplerAddressModeX address_mode_x) |
| 140 | { |
| 141 | _address_mode_x = address_mode_x; |
| 142 | return *this; |
| 143 | } |
| 144 | |
| 145 | TensorSamplerAddressModeY TensorTileSampler::address_mode_y() const |
| 146 | { |
| 147 | return _address_mode_y; |
| 148 | } |
| 149 | |
| 150 | TensorTileSampler &TensorTileSampler::address_mode_y(TensorSamplerAddressModeY address_mode_y) |
| 151 | { |
| 152 | _address_mode_y = address_mode_y; |
| 153 | return *this; |
| 154 | } |
| 155 | |
| 156 | TensorSamplerAddressModeZ TensorTileSampler::address_mode_z() const |
| 157 | { |
| 158 | return _address_mode_z; |
| 159 | } |
| 160 | |
| 161 | TensorTileSampler &TensorTileSampler::address_mode_z(TensorSamplerAddressModeZ address_mode_z) |
| 162 | { |
| 163 | _address_mode_z = address_mode_z; |
| 164 | return *this; |
| 165 | } |
| 166 | |
| 167 | } // namespace ckw |