blob: 7e9bcbf1ee558994fb9ec7c50332ea878def01d6 [file] [log] [blame]
Viet-Hoa Do1df9f6e2023-07-24 17:57:12 +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_KERNELARGUMENT_H
26#define CKW_INCLUDE_CKW_KERNELARGUMENT_H
27
28#include "ckw/types/TensorComponentType.h"
29#include "ckw/types/TensorStorageType.h"
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +010030
Viet-Hoa Do1df9f6e2023-07-24 17:57:12 +010031#include <cstdint>
32
33namespace ckw
34{
35
36/** A kernel argument which can be either a tensor storage or a tensor component. */
37class KernelArgument
38{
39public:
40 /** The type of kernel argument. */
41 enum class Type : int32_t
42 {
43 /** The argument that provides the read and/or write access to the tensor data.
44 *
45 * See @ref ckw::TensorStorageType to see the list of supported storage type.
46 */
47 TensorStorage,
48
49 /** The argument that provides extra information about the tensor.
50 *
51 * See @ref ckw::TensorComponentType to see the list of supported component.
52 */
53 TensorComponent,
54 };
55
56 /** Initialize a new instance of kernel argument class for a tensor storage argument. */
57 KernelArgument(int32_t tensor_id, TensorStorageType storage_type);
58
59 /** Initialize a new instance of kernel argument class for a tensor component argument. */
60 KernelArgument(int32_t tensor_id, TensorComponentType component_type);
61
62 /** Get the type of kernel argument. */
63 Type type() const;
64
65 /** Get the argument ID.
66 *
67 * This method can be used to get the tensor info ID of both tensor storage and tensor component arguments.
68 */
69 int32_t id() const;
70
71 /** Get the type of tensor storage.
72 *
73 * This method can only be used for tensor storage argument.
74 */
75 TensorStorageType tensor_storage_type() const;
76
77 /** Get the tensor component type.
78 *
79 * This method can only be used for tensor component argument.
80 */
81 TensorComponentType tensor_component_type() const;
82
83private:
84 Type _type;
85 int32_t _id;
86
87 union SubId
88 {
89 int32_t unknown;
90 TensorStorageType tensor_storage_type;
91 TensorComponentType tensor_component_type;
92 };
93
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +010094 SubId _sub_id{0};
Viet-Hoa Do1df9f6e2023-07-24 17:57:12 +010095};
96
97} // namespace ckw
98
99#endif // CKW_INCLUDE_CKW_KERNELARGUMENT_H