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