Compute Library
 22.08
ClKernelBuildingAPI.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2022 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 #ifdef ENABLE_EXPERIMENTAL_DYNAMIC_FUSION
25 
29 
30 namespace arm_compute
31 {
32 namespace experimental
33 {
34 namespace dynamic_fusion
35 {
37  : _impl{ std::make_unique<ClKernelBlueprint::Implementation>() }
38 {
39 }
40 
42 
44 {
45  return *_impl;
46 }
48 {
49  return *_impl;
50 }
51 
52 Status add_tensor(ClKernelBlueprint &kernel_blueprint, ITensorInfo *tensor_info, ArgumentID &id, ArgumentID merge_point)
53 {
54  id = kernel_blueprint.impl().add_kernel_tensor(tensor_info, merge_point);
55  return Status{};
56 }
57 
59  ArgumentID src0_id, ArgumentID src1_id, ArgumentID &dst_id)
60 {
61  kernel_blueprint.impl().add_component(
62  std::make_unique<ClElementwiseKernelComponent>(
63  &kernel_blueprint,
64  desc,
66  SharedVarLink{ src1_id, SharedVarIO::Input },
68 
69  return Status{};
70 }
71 
73  ArgumentID src_id, ArgumentID &dst_id)
74 {
75  kernel_blueprint.impl().add_component(
76  std::make_unique<ClFloorKernelComponent>(
77  &kernel_blueprint,
80 
81  return Status{};
82 }
83 
85 {
86  return Status{};
87 }
88 
90  const ClDirectConv2dKernelDescriptor &direct_conv2d_desc,
91  ArgumentID src_id, ArgumentID weight_id, ArgumentID bias_id, ArgumentID &dst_id)
92 {
93  kernel_blueprint.impl().add_component(
94  std::make_unique<ClDirectConvolutionKernelComponent>(
95  &kernel_blueprint,
96  direct_conv2d_desc,
98  SharedVarLink{ weight_id, SharedVarIO::Input },
100  SharedVarLink{ bias_id, SharedVarIO::Input }));
101 
102  return Status{};
103 }
104 
105 Status add_kcomp_store(ClKernelBlueprint &kernel_blueprint, const StoreType &store_type, ArgumentID src_tile, ArgumentID dst_tile)
106 {
107  switch(store_type)
108  {
110  kernel_blueprint.impl().add_component(
111  std::make_unique<ClStoreBlockBoundaryAwareKernelComponent>(
112  &kernel_blueprint,
113  SharedVarLink{ src_tile, SharedVarIO::Input },
114  SharedVarLink{ dst_tile, SharedVarIO::Output }));
115  break;
117  kernel_blueprint.impl().add_component(
118  std::make_unique<ClStoreIndirectWidthSelectKernelComponent>(
119  &kernel_blueprint,
120  SharedVarLink{ src_tile, SharedVarIO::Input },
121  SharedVarLink{ dst_tile, SharedVarIO::Output }));
122  break;
123  default:
124  ARM_COMPUTE_ERROR("Store mode not yet supported.");
125  }
126 
127  return Status{};
128 }
129 
131 {
132  return bp.impl().update_merge_point(t_id, merge_point);
133 }
134 
136 {
137  bp.impl().set_tile_info(tile_info);
138  return Status{};
139 }
141 {
142  kernel_blueprint.impl().finalize();
143  code.name = kernel_blueprint.impl().build_kernel_name();
144  code.code = kernel_blueprint.impl().build_code();
145 
146  code.config_id = kernel_blueprint.impl().build_config_id();
147  code.build_options = kernel_blueprint.impl().build_options();
148  code.window = kernel_blueprint.impl().get_execution_window();
149  code.arguments = kernel_blueprint.impl().get_arguments();
150 
151  return Status{};
152 }
154 {
155  return blueprint.impl().get_graph();
156 }
158 {
159  return Status{};
160 }
161 } // namespace dynamic_fusion
162 } // namespace experimental
163 } // namespace arm_compute
164 #endif /* ENABLE_EXPERIMENTAL_DYNAMIC_FUSION */
The dependency graph of a workload, where the nodes are of 2 types: Tensor or Operator Represented as...
Status tune_static(ClExecutionDescriptor &, const ClKernelCode &)
std::string build_config_id() const
Generate config id of the entire kernel.
Definition: Common.h:642
#define ARM_COMPUTE_ERROR(msg)
Print the given message then throw an std::runtime_error.
Definition: Error.h:352
All information required for building the ClKernelCode.
Status add_kcomp_activation(ClKernelBlueprint &, const ClActivationKernelDescriptor &, ArgumentID, ArgumentID &)
Component: Activation.
Store the tensor&#39;s metadata.
Definition: ITensorInfo.h:40
Status class.
Definition: Error.h:52
DependencyGraph get_dependency_graph(const ClKernelBlueprint &blueprint)
Get dependency graph.
Copyright (c) 2017-2022 Arm Limited.
Status update_merge_point(ClKernelBlueprint &bp, ArgumentID t_id, ArgumentID merge_point)
Update existing merge tensor merge_point to point to t_id.
Intermediate representation of the final, complete kernel source.
Contains kernel code to be compiled and run in a ClUnitWorkload.
Definition: ClWorkload.h:100
Descriptor containing information required to run a single ClWorkload.
Definition: ClWorkload.h:91
Status add_kcomp_eltwise_op(ClKernelBlueprint &kernel_blueprint, const ClElementwiseKernelDescriptor &desc, ArgumentID src0_id, ArgumentID src1_id, ArgumentID &dst_id)
Component: Eltwise Operator.
Status add_kcomp_direct_conv2d(ClKernelBlueprint &kernel_blueprint, const ClDirectConv2dKernelDescriptor &direct_conv2d_desc, ArgumentID src_id, ArgumentID weight_id, ArgumentID bias_id, ArgumentID &dst_id)
Component: Direct Convolution.
Status add_kcomp_floor(ClKernelBlueprint &kernel_blueprint, const ClFloorKernelDescriptor &, ArgumentID src_id, ArgumentID &dst_id)
Component: Floor.
std::string config_id
Generated from blueprint based on complex component.
Definition: ClWorkload.h:109
CLBuildOptions build_options
Kernel build options.
Definition: ClWorkload.h:110
Status build(ClWorkload &workload, const OperatorGraph &op_graph, const ClWorkloadContext &ctx)
Build a ClWorkload from an OperatorGraph.
Definition: ClWorkload.cpp:36
OpTensor add_tensor(OperatorGraph &graph, ITensorInfo &info)
Associate a TensorInfo with a newly created OpTensor in the graph.
Intermediate representation of the final, complete kernel source.
Definition: Common.h:418
ClKernelArgList arguments
Kernel argument descriptors.
Definition: ClWorkload.h:112
Status update_merge_point(ArgumentID t_id, ArgumentID merge_point)
Definition: Common.h:425
Status set_tile_info(ClKernelBlueprint &bp, const TileDescriptor &tile_info)
Status add_kcomp_store(ClKernelBlueprint &kernel_blueprint, const StoreType &store_type, ArgumentID src_tile, ArgumentID dst_tile)
ArgumentID add_kernel_tensor(ITensorInfo *tensor_info, ArgumentID merge_point=DependencyGraph::empty_id())
Definition: Common.h:430