blob: 512d0b45019cec2ff176d811fcf6ad0060746749 [file] [log] [blame]
Gunes Bayire4211672023-07-25 10:37:13 +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
Gunes Bayird5f9a1c2023-08-17 11:04:02 +010025#ifndef CKW_INCLUDE_CKW_TYPES_TENSORSAMPLERTYPES_H
26#define CKW_INCLUDE_CKW_TYPES_TENSORSAMPLERTYPES_H
Gunes Bayire4211672023-07-25 10:37:13 +010027
28#include <cstdint>
29
30namespace ckw
31{
32
33// This enum class defines how the dimensions of a 3d tensor is mapped into x,y and z coordianates.
34enum class TensorSamplerFormat : int32_t
35{
Gunes Bayir5e842512023-07-25 22:32:05 +010036 Unknown = 0,
37 Dim0_Dim1xDim2_1 = 1, // Original dimensions 1 and 2 are collapsed onto y-axis
38 Dim0_Dim1_Dim2 = 2 // Original dimensions stays as they're defined. No collapsing.
Gunes Bayire4211672023-07-25 10:37:13 +010039};
40
41/** Tensor sampler address mode enum class for X dimension
42 *
43 * The following address modes are available in total:
44 * Unknown
45 * None : The user guarantees that the coordinate is always in-bound
46 * OverlappingMin : (FIXED shapes only) Reduce the load/store length when x == 0 (MIN). The load length will be width % original length
47 * Leftover elements can be handled using overlapping. This involves processing some of the elements in the array twice.
48 * ClampToBorderMaxOnly : Clamp to max value allowed in the corresponding dimension, and construct an if/else guard to prevent out of bound access,
49 * e.g. if( y < size-of-dimension-y ){ <do the operation> }
Gunes Bayird5f9a1c2023-08-17 11:04:02 +010050 * SkipLessThanZero : Skip loading/storing if the index is less than 0
Gunes Bayire4211672023-07-25 10:37:13 +010051 *
52 * Individual dimensions choose which adddress mode to implement in their respective enum classes.
53 */
54enum class TensorSamplerAddressModeX : int32_t
55{
56 Unknown = 0,
Gunes Bayir5e842512023-07-25 22:32:05 +010057 None = 1,
58 OverlappingMin = 2
Gunes Bayire4211672023-07-25 10:37:13 +010059};
60
61/**
62 * Similar to @ref TensorSamplerAddressModeX
63 */
64enum class TensorSamplerAddressModeY : int32_t
65{
66 Unknown = 0,
67 None = 1,
68 OverlappingMin = 2,
Gunes Bayird5f9a1c2023-08-17 11:04:02 +010069 ClampToBorderMaxOnly = 3,
70 SkipLessThanZero = 4
Gunes Bayire4211672023-07-25 10:37:13 +010071};
72
73/**
74 * Similar to @ref TensorSamplerAddressModeX
75 */
76enum class TensorSamplerAddressModeZ : int32_t
77{
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +010078 Unknown = 0,
79 None = 1,
Gunes Bayire4211672023-07-25 10:37:13 +010080};
81
82} // namespace ckw
83
Gunes Bayird5f9a1c2023-08-17 11:04:02 +010084#endif // CKW_INCLUDE_CKW_TYPES_TENSORSAMPLERTYPES_H