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