blob: cd924846c5e7acdc251719ab2b344a6bef67d7b8 [file] [log] [blame]
Gian Marco Iodiceebfdb5a2023-07-07 11:25:57 +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#ifndef CKW_SRC_CL_CLTENSORARGUMENT_H
25#define CKW_SRC_CL_CLTENSORARGUMENT_H
26
27#include "src/ITensorArgument.h"
28
29#include <string>
30#include <vector>
31
32namespace ckw
33{
34// Forward declarations
35class TensorInfo;
36
37/** OpenCL specific tensor argument
38 * Internally, the object keeps track of the components and storages used to minimize the number
39 * of kernel arguments required. Therefore, if we create this object but we do not access any components
40 * or storages, the storages() and components() method will return an empty list.
41*/
42class CLTensorArgument : public ITensorArgument, ITensorStorageArgument, ITensorComponentArgument
43{
44public:
45 /** Constructor
46 *
47 * @param[in] name Tensor name
48 * @param[in] info Tensor info
49 * @param[in] return_dims_by_value Flag to return the dimensions by value whenever it is possible.
50 * True, if the dimensions should be returned as value instead as variable.
51 */
52 CLTensorArgument(const std::string &name, const TensorInfo &info, bool return_dims_by_value);
53
54 // Inherited method overridden
55 TensorStorageVariable storage(TensorStorageType x);
56 TileVariable component(TensorComponentType x);
57 std::vector<TensorStorageVariable> storages() const;
58 std::vector<TileVariable> components() const;
59
60private:
61 std::string create_storage_name(TensorStorageType x) const;
62 std::string create_component_name(TensorComponentType x) const;
63
64 bool _return_dims_by_value{ false };
65 std::vector<TensorStorageType> _storages_used{};
66 std::vector<TensorComponentType> _components_used{};
67};
68} // namespace ckw
69
70#endif // CKW_SRC_CL_CLTENSORARGUMENT_H