blob: 347536512e8f61f17534aad8c7714a923d622301 [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
25#ifndef CKW_INCLUDE_CKW_TENSORSAMPLERTYPES_H
26#define CKW_INCLUDE_CKW_TENSORSAMPLERTYPES_H
27
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{
36 Unknown = 0,
37 D0_D1xD2_1 = 1, // Original dimensions 1 and 2 are collapsed onto y-axis
38 D0_D1_D2 = 2 // Original dimensions stays as they're defined. No collapsing.
39};
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> }
50 *
51 * Individual dimensions choose which adddress mode to implement in their respective enum classes.
52 */
53enum class TensorSamplerAddressModeX : int32_t
54{
55 Unknown = 0,
56 None = 1, // The user guarantees that the coordinate is always in-bound
57 OverlappingMin = 2 // (FIXED shapes only) Reduce the load/store length when x == 0 (MIN). The load length will be width % original length
58 // Leftover elements can be handled using overlapping. This involves processing some of the elements in the array twice.
59};
60
61/**
62 * Similar to @ref TensorSamplerAddressModeX
63 */
64enum class TensorSamplerAddressModeY : int32_t
65{
66 Unknown = 0,
67 None = 1,
68 OverlappingMin = 2,
69 ClampToBorderMaxOnly = 3
70};
71
72/**
73 * Similar to @ref TensorSamplerAddressModeX
74 */
75enum class TensorSamplerAddressModeZ : int32_t
76{
77 Unknown = 0,
78 None = 1,
79};
80
81} // namespace ckw
82
83#endif //CKW_INCLUDE_CKW_TENSORSAMPLERTYPES_H