24.02.1
GpuKernelComponentStream.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2022-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 SRC_DYNAMIC_FUSION_SKETCH_GPU_GPUKERNELCOMPONENTSTREAM
25
#define SRC_DYNAMIC_FUSION_SKETCH_GPU_GPUKERNELCOMPONENTSTREAM
26
27
#include "
arm_compute/dynamic_fusion/sketch/MemoryDescriptor.h
"
28
29
#include "
src/dynamic_fusion/sketch/gpu/GpuKernelComponentGroup.h
"
30
#include "
src/dynamic_fusion/sketch/gpu/GpuWorkloadSourceCode.h
"
31
32
namespace
arm_compute
33
{
34
namespace
experimental
35
{
36
namespace
dynamic_fusion
37
{
38
class
GpuComponentServices;
39
class
IGpuKernelComponent;
40
41
/** A linear sequence of component groups serialized from the @ref GpuKernelComponentGraph
42
* Each component group in the stream denotes a complete kernel that may consist of multiple components
43
*
44
* The main purposes of this class are:
45
* - Facilitate component fusion algorithm by allowing insertions of new component groups into the stream
46
* - Invoke kernel writer and assemble the final @ref GpuWorkloadSourceCode
47
*/
48
class
GpuKernelComponentStream
49
{
50
public
:
51
/** Constructor
52
*
53
* @param[in] context @ref GpuWorkloadContext to be used throughout the stream
54
* @param[in] services @ref GpuComponentServices to be used throughout the stream
55
* @param[in] mem_map @ref MemoryDescriptor map used to assemble the @ref GpuWorkloadSourceCode
56
*/
57
GpuKernelComponentStream
(
GpuWorkloadContext
*
context
,
58
GpuComponentServices
*services,
59
const
MemoryDescriptorMap
&mem_map);
60
/** Allow instances of this class to be copy constructed */
61
GpuKernelComponentStream
(
const
GpuKernelComponentStream
&stream) =
default
;
62
/** Allow instances of this class to be copied */
63
GpuKernelComponentStream
&
operator=
(
const
GpuKernelComponentStream
&stream) =
default
;
64
/** Allow instances of this class to be move constructed */
65
GpuKernelComponentStream
(
GpuKernelComponentStream
&&stream) =
default
;
66
/** Allow instances of this class to be moved */
67
GpuKernelComponentStream
&
operator=
(
GpuKernelComponentStream
&&stream) =
default
;
68
/** Generate and assemble @ref GpuWorkloadSourceCode from the stream */
69
GpuWorkloadSourceCode
write_workload_code
();
70
/** Insert a new component group in the stream.
71
* Subsequent components are added to this group until end of stream or the next new_component_group is called
72
*/
73
void
new_component_group
();
74
/** Add a component to the previously created component group
75
* Throw an error if no component group is present in the stream
76
*
77
* @param[in] component Component to be inserted
78
*
79
* @return true If the operation is successful
80
* @return false Otherwise
81
*/
82
bool
add_component
(
IGpuKernelComponent
*component);
83
84
private
:
85
GpuWorkloadContext
*_context;
86
GpuComponentServices
*_services;
87
std::vector<GpuKernelComponentGroup> _component_groups{};
88
MemoryDescriptorMap
_mem_map{};
89
};
90
}
// namespace dynamic_fusion
91
}
// namespace experimental
92
}
// namespace arm_compute
93
#endif
/* SRC_DYNAMIC_FUSION_SKETCH_GPU_GPUKERNELCOMPONENTSTREAM */
GpuWorkloadSourceCode.h
GpuKernelComponentGroup.h
arm_compute::experimental::dynamic_fusion::GpuKernelComponentStream
A linear sequence of component groups serialized from the GpuKernelComponentGraph Each component grou...
Definition:
GpuKernelComponentStream.h:48
arm_compute::experimental::dynamic_fusion::GpuKernelComponentStream::write_workload_code
GpuWorkloadSourceCode write_workload_code()
Generate and assemble GpuWorkloadSourceCode from the stream.
Definition:
GpuKernelComponentStream.cpp:43
MemoryDescriptor.h
arm_compute::experimental::dynamic_fusion::GpuKernelComponentStream::new_component_group
void new_component_group()
Insert a new component group in the stream.
Definition:
GpuKernelComponentStream.cpp:61
arm_compute::experimental::dynamic_fusion::GpuWorkloadContext
Provide context necessary for the creation and configuration of a workload e.g.
Definition:
GpuWorkloadContext.h:57
arm_compute::experimental::dynamic_fusion::GpuWorkloadSourceCode
Hold the generated kernel source code and other information required to compile and run the workload.
Definition:
GpuWorkloadSourceCode.h:239
arm_compute::test::validation::context
auto context
Definition:
DirectConv2d.cpp:167
arm_compute::experimental::dynamic_fusion::GpuKernelComponentStream::add_component
bool add_component(IGpuKernelComponent *component)
Add a component to the previously created component group Throw an error if no component group is pre...
Definition:
GpuKernelComponentStream.cpp:66
arm_compute::experimental::dynamic_fusion::GpuKernelComponentStream::operator=
GpuKernelComponentStream & operator=(const GpuKernelComponentStream &stream)=default
Allow instances of this class to be copied.
arm_compute::experimental::dynamic_fusion::GpuKernelComponentStream::GpuKernelComponentStream
GpuKernelComponentStream(GpuWorkloadContext *context, GpuComponentServices *services, const MemoryDescriptorMap &mem_map)
Constructor.
Definition:
GpuKernelComponentStream.cpp:36
arm_compute
Copyright (c) 2017-2024 Arm Limited.
Definition:
introduction.dox:24
arm_compute::experimental::dynamic_fusion::GpuComponentServices
Services that are used throughout the creation phase of workload code.
Definition:
GpuComponentServices.h:37
arm_compute::experimental::dynamic_fusion::IGpuKernelComponent
An abstract interface of a component.
Definition:
IGpuKernelComponent.h:67
arm_compute::experimental::dynamic_fusion::MemoryDescriptorMap
std::map< ITensorInfo::Id, MemoryDescriptor > MemoryDescriptorMap
A map from ITensorInfo to their corresponding MemoryDescriptor.
Definition:
MemoryDescriptor.h:91
src
dynamic_fusion
sketch
gpu
GpuKernelComponentStream.h
Generated on Mon Mar 18 2024 11:32:01 for Compute Library by
1.8.17