blob: f19ad6dfc56c516a76101dcaa59b76e6d9de1dd1 [file] [log] [blame]
SiCong Lif44bbc52022-08-29 18:25:51 +01001/*
Gunes Bayir3a1e1252023-01-03 21:26:09 +00002 * Copyright (c) 2022-2023 Arm Limited.
SiCong Lif44bbc52022-08-29 18:25:51 +01003 *
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 ARM_COMPUTE_DYNAMIC_FUSION_SKETCH_GPU_GPUWORKLOADSKETCH
25#define ARM_COMPUTE_DYNAMIC_FUSION_SKETCH_GPU_GPUWORKLOADSKETCH
26
27#include "arm_compute/core/TensorInfo.h"
28#include "arm_compute/dynamic_fusion/sketch/gpu/GpuWorkloadContext.h"
29
30#include <memory>
31
32namespace arm_compute
33{
34namespace experimental
35{
36namespace dynamic_fusion
37{
38/** A descriptor of a workload of operators
39 *
40 * A "workload" is a basic unit of computation to schedule and perform. It contains one or more operators that can be "fused" together.
41 * Note that a workload may still contain multiple kernels.
42 */
43class GpuWorkloadSketch
44{
45public:
46 /** Global context used for the creation of a workload */
47 using Context = GpuWorkloadContext;
48 /** Internal opaque implementation */
49 class Implementation;
50
51public:
52 /** Constructor
53 *
54 * @param[in] context Gpu context for the creation of a workload
55 */
56 explicit GpuWorkloadSketch(GpuWorkloadContext *context);
57 /** Destructor */
58 ~GpuWorkloadSketch();
59 /** Get the implementation */
60 Implementation &implementation();
61 /** Get the implementation */
62 const Implementation &implementation() const;
63 /** Get the gpu workload context of this sketch */
64 const GpuWorkloadContext *gpu_context() const;
65 /** Create a @ref TensorInfo associated with the workload sketch.
66 *
67 * @return TensorInfo Newly created tensor info
68 */
69 template <typename... Args>
70 TensorInfo create_tensor_info(Args &&... args)
71 {
72 auto tensor_info = TensorInfo(std::forward<Args>(args)...);
73 tensor_info.set_id(allocate_new_tensor_id());
74 return tensor_info;
75 }
76 /** Create a @ref TensorInfo associated with the workload sketch by copying from an existing tensor info
77 * @note The newly copied tensor will have a different identity within the workload than the one copied from
78 * To copy the identity of @p tensor_info as well, use @ref TensorInfo 's copy constructors instead
79 *
80 * @param[in] tensor_info @ref ITensorInfo to copy from
81 *
82 * @return TensorInfo Newly created tensor info
83 */
84 TensorInfo create_tensor_info(const ITensorInfo &tensor_info);
85 /** Create a default @ref TensorInfo associated with the workload sketch
Gunes Bayir3a1e1252023-01-03 21:26:09 +000086 * It is usually used by user input or output tensors
SiCong Lif44bbc52022-08-29 18:25:51 +010087 *
88 * @return TensorInfo Newly created tensor info
89 */
90 TensorInfo create_tensor_info();
91
92private:
93 ITensorInfo::Id allocate_new_tensor_id();
94 std::unique_ptr<Implementation> _impl; /**< Internal opaque implementation*/
95};
96
97} // namespace dynamic_fusion
98} // namespace experimental
99} // namespace arm_compute
100#endif /* ARM_COMPUTE_DYNAMIC_FUSION_SKETCH_GPU_GPUWORKLOADSKETCH */