diff options
author | SiCong Li <sicong.li@arm.com> | 2023-05-16 16:46:34 +0100 |
---|---|---|
committer | SiCong Li <sicong.li@arm.com> | 2023-07-04 09:06:41 +0000 |
commit | 19844f605f5e5b71d05164711dee13f8652adafe (patch) | |
tree | 99aa1242a37aefda01e4284bc48c63f93f625258 /src/dynamic_fusion/sketch/gpu/components | |
parent | 2f0ef00cc092b5eff901debee0c3f5a38114f40a (diff) | |
download | ComputeLibrary-19844f605f5e5b71d05164711dee13f8652adafe.tar.gz |
Add Kernel Writer driver code to dynamic fusion
* Partially port ElementwiseBinary component to ckw (broadcast not
supported yet)
* Port Store component to ckw
* Move KernelArgumentsHelpers to ckw_driver/ as it's only used by the
driver
ckw_driver is a middle layer between dynamic fusion and Compute Kernel
Writer (CKW). It consumes the fused kernel component stream produced by
Dynamic Fusion and uses CKW to write the kernel code complete with all
meta info needed by the runtime to enqueue the kernel.
It consists of two parts:
* Kernel writing: This resides in dynamic_fusion/sketch
* Runtime utilities: This resides in dynamic_fusion/runtime
The integration (separation between DF and CKW) occurs in two places:
* Inside GpuCKWDriver
global driver that coordinates how the
final fused kernel code is assembled together alongwith other meta
info needed by runtime.
* Inside each instantiated IGpuCKWComponentDriver
component driver that drives CKW to write component-specific code
or do component-specific configurations
Partially resolves: COMPMID-5792 COMPMID-6282 COMPMID-6260 COMPMID-6266
Signed-off-by: SiCong Li <sicong.li@arm.com>
Change-Id: Ib57a080a65fe8cfee1a8df1529fe572005a6d2f2
Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/9847
Reviewed-by: Gunes Bayir <gunes.bayir@arm.com>
Tested-by: Arm Jenkins <bsgcomp@arm.com>
Comments-Addressed: Arm Jenkins <bsgcomp@arm.com>
Benchmark: Arm Jenkins <bsgcomp@arm.com>
Diffstat (limited to 'src/dynamic_fusion/sketch/gpu/components')
7 files changed, 42 insertions, 15 deletions
diff --git a/src/dynamic_fusion/sketch/gpu/components/IGpuKernelComponent.h b/src/dynamic_fusion/sketch/gpu/components/IGpuKernelComponent.h index 8bb19155a2..d600956b4f 100644 --- a/src/dynamic_fusion/sketch/gpu/components/IGpuKernelComponent.h +++ b/src/dynamic_fusion/sketch/gpu/components/IGpuKernelComponent.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Arm Limited. + * Copyright (c) 2022-2023 Arm Limited. * * SPDX-License-Identifier: MIT * @@ -21,8 +21,8 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -#ifndef SRC_DYNAMIC_FUSION_SKETCH_GPU_COMPONENTS_IGPUKERNELCOMPONENT -#define SRC_DYNAMIC_FUSION_SKETCH_GPU_COMPONENTS_IGPUKERNELCOMPONENT +#ifndef ACL_SRC_DYNAMIC_FUSION_SKETCH_GPU_COMPONENTS_IGPUKERNELCOMPONENT +#define ACL_SRC_DYNAMIC_FUSION_SKETCH_GPU_COMPONENTS_IGPUKERNELCOMPONENT #include "Types.h" @@ -60,6 +60,7 @@ inline bool operator==(const KernelProperties &config0, const KernelProperties & /** Forward declaration */ class IGpuTemplateComponentWriter; +class IGpuCkwComponentDriver; /** An abstract interface of a component. It enables manipulation by the component graph for purposes like fusion */ @@ -105,6 +106,11 @@ public: } /** Get template writer for the component */ virtual const IGpuTemplateComponentWriter *template_writer() const = 0; + /** Get compute kernel writer driver for the component */ + virtual const IGpuCkwComponentDriver *ckw_component_driver() const + { + return nullptr; + } /** Get component type */ virtual GpuComponentType type() const = 0; @@ -116,4 +122,4 @@ private: } // namespace dynamic_fusion } // namespace experimental } // namespace arm_compute -#endif /* SRC_DYNAMIC_FUSION_SKETCH_GPU_COMPONENTS_IGPUKERNELCOMPONENT */ +#endif /* ACL_SRC_DYNAMIC_FUSION_SKETCH_GPU_COMPONENTS_IGPUKERNELCOMPONENT */ diff --git a/src/dynamic_fusion/sketch/gpu/components/cl/ClComponentActivation.cpp b/src/dynamic_fusion/sketch/gpu/components/cl/ClComponentActivation.cpp index 6eaa45c25d..3e8d256a08 100644 --- a/src/dynamic_fusion/sketch/gpu/components/cl/ClComponentActivation.cpp +++ b/src/dynamic_fusion/sketch/gpu/components/cl/ClComponentActivation.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Arm Limited. + * Copyright (c) 2022-2023 Arm Limited. * * SPDX-License-Identifier: MIT * @@ -32,7 +32,6 @@ namespace experimental { namespace dynamic_fusion { - Status ClComponentActivation::validate(const Properties &properties, const ArgumentPack<ITensorInfo> &tensors, const Attributes &attributes) @@ -70,6 +69,10 @@ ClComponentActivation::ClComponentActivation(ComponentId { } +ClComponentActivation::~ClComponentActivation() +{ +} + const IGpuTemplateComponentWriter *ClComponentActivation::template_writer() const { return _component_writer.get(); diff --git a/src/dynamic_fusion/sketch/gpu/components/cl/ClComponentActivation.h b/src/dynamic_fusion/sketch/gpu/components/cl/ClComponentActivation.h index d1b849ec73..d5013acddf 100644 --- a/src/dynamic_fusion/sketch/gpu/components/cl/ClComponentActivation.h +++ b/src/dynamic_fusion/sketch/gpu/components/cl/ClComponentActivation.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Arm Limited. + * Copyright (c) 2022-2023 Arm Limited. * * SPDX-License-Identifier: MIT * @@ -88,7 +88,7 @@ public: const Attributes &attributes); /** Destructor */ - ~ClComponentActivation() override = default; + ~ClComponentActivation() override; /** Prevent instances of this class from being copy constructed */ ClComponentActivation(const ClComponentActivation &component) = delete; diff --git a/src/dynamic_fusion/sketch/gpu/components/cl/ClComponentElementwiseBinary.cpp b/src/dynamic_fusion/sketch/gpu/components/cl/ClComponentElementwiseBinary.cpp index b21c7c382f..52739e23c0 100644 --- a/src/dynamic_fusion/sketch/gpu/components/cl/ClComponentElementwiseBinary.cpp +++ b/src/dynamic_fusion/sketch/gpu/components/cl/ClComponentElementwiseBinary.cpp @@ -25,6 +25,7 @@ #include "arm_compute/core/Validate.h" #include "src/core/CL/CLValidate.h" +#include "src/dynamic_fusion/sketch/gpu/ckw_driver/components/GpuCkwElementwiseBinary.h" #include "src/dynamic_fusion/sketch/gpu/template_writer/cl/ClTemplateElementwiseBinary.h" namespace arm_compute @@ -111,7 +112,8 @@ ClComponentElementwiseBinary::ClComponentElementwiseBinary( const ArgumentPack<ITensorInfo> &tensors, const Attributes &attributes) : IGpuKernelComponent{ id, properties, tensors }, - _component_writer{ std::make_unique<ClTemplateElementwiseBinary>(id, tensors, attributes) } + _component_writer{ std::make_unique<ClTemplateElementwiseBinary>(id, tensors, attributes) }, + _ckw_driver{ std::make_unique<GpuCkwElementwiseBinary>(id, tensors, attributes) } { } ClComponentElementwiseBinary::~ClComponentElementwiseBinary() @@ -121,6 +123,11 @@ const IGpuTemplateComponentWriter *ClComponentElementwiseBinary::template_writer { return _component_writer.get(); } + +const IGpuCkwComponentDriver *ClComponentElementwiseBinary::ckw_component_driver() const +{ + return _ckw_driver.get(); +} } // namespace dynamic_fusion } // namespace experimental } // namespace arm_compute diff --git a/src/dynamic_fusion/sketch/gpu/components/cl/ClComponentElementwiseBinary.h b/src/dynamic_fusion/sketch/gpu/components/cl/ClComponentElementwiseBinary.h index 02e61019f4..a56dd8b37d 100644 --- a/src/dynamic_fusion/sketch/gpu/components/cl/ClComponentElementwiseBinary.h +++ b/src/dynamic_fusion/sketch/gpu/components/cl/ClComponentElementwiseBinary.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Arm Limited. + * Copyright (c) 2022-2023 Arm Limited. * * SPDX-License-Identifier: MIT * @@ -24,7 +24,6 @@ #ifndef SRC_DYNAMIC_FUSION_SKETCH_GPU_COMPONENTS_CL_CLCOMPONENTELEMENTWISEBINARY #define SRC_DYNAMIC_FUSION_SKETCH_GPU_COMPONENTS_CL_CLCOMPONENTELEMENTWISEBINARY -#include "arm_compute/core/Error.h" #include "src/dynamic_fusion/sketch/gpu/components/IGpuKernelComponent.h" #include "src/dynamic_fusion/sketch/gpu/operators/internal/GpuElementwiseBinaryCommon.h" @@ -42,6 +41,7 @@ class ArgumentPack; /** Forward declaration */ class ClTemplateElementwiseBinary; +class GpuCkwElementwiseBinary; class ClComponentElementwiseBinary final : public IGpuKernelComponent { @@ -103,6 +103,8 @@ public: ClComponentElementwiseBinary &operator=(ClComponentElementwiseBinary &&component) = default; /** Get template writer for the component */ const IGpuTemplateComponentWriter *template_writer() const override; + + const IGpuCkwComponentDriver *ckw_component_driver() const override; /** Get component type */ GpuComponentType type() const override { @@ -111,6 +113,7 @@ public: private: std::unique_ptr<ClTemplateElementwiseBinary> _component_writer; + std::unique_ptr<GpuCkwElementwiseBinary> _ckw_driver; }; } // namespace dynamic_fusion } // namespace experimental diff --git a/src/dynamic_fusion/sketch/gpu/components/cl/ClComponentStore.cpp b/src/dynamic_fusion/sketch/gpu/components/cl/ClComponentStore.cpp index f49f397ec1..a3283b1866 100644 --- a/src/dynamic_fusion/sketch/gpu/components/cl/ClComponentStore.cpp +++ b/src/dynamic_fusion/sketch/gpu/components/cl/ClComponentStore.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Arm Limited. + * Copyright (c) 2022-2023 Arm Limited. * * SPDX-License-Identifier: MIT * @@ -24,6 +24,7 @@ #include "ClComponentStore.h" #include "src/dynamic_fusion/sketch/ArgumentPack.h" +#include "src/dynamic_fusion/sketch/gpu/ckw_driver/components/GpuCkwStore.h" #include "src/dynamic_fusion/sketch/gpu/template_writer/cl/ClTemplateStore.h" #include <memory> @@ -42,7 +43,7 @@ Status ClComponentStore::validate( return Status{}; } ClComponentStore::ClComponentStore(ComponentId id, const Properties &properties, const ArgumentPack<ITensorInfo> &tensors) - : IGpuKernelComponent{ id, properties, tensors }, _component_writer{ std::make_unique<ClTemplateStore>(id, tensors) } + : IGpuKernelComponent{ id, properties, tensors }, _component_writer{ std::make_unique<ClTemplateStore>(id, tensors) }, _ckw_driver{ std::make_unique<GpuCkwStore>(id, tensors) } { } ClComponentStore::~ClComponentStore() @@ -52,6 +53,10 @@ const IGpuTemplateComponentWriter *ClComponentStore::template_writer() const { return _component_writer.get(); } +const IGpuCkwComponentDriver *ClComponentStore::ckw_component_driver() const +{ + return _ckw_driver.get(); +} } // namespace dynamic_fusion } // namespace experimental } // namespace arm_compute diff --git a/src/dynamic_fusion/sketch/gpu/components/cl/ClComponentStore.h b/src/dynamic_fusion/sketch/gpu/components/cl/ClComponentStore.h index bf8c9f031e..f168ccb97e 100644 --- a/src/dynamic_fusion/sketch/gpu/components/cl/ClComponentStore.h +++ b/src/dynamic_fusion/sketch/gpu/components/cl/ClComponentStore.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Arm Limited. + * Copyright (c) 2022-2023 Arm Limited. * * SPDX-License-Identifier: MIT * @@ -24,7 +24,6 @@ #ifndef SRC_DYNAMIC_FUSION_SKETCH_GPU_COMPONENTS_CL_CLCOMPONENTSTORE #define SRC_DYNAMIC_FUSION_SKETCH_GPU_COMPONENTS_CL_CLCOMPONENTSTORE -#include "arm_compute/core/Error.h" #include "src/dynamic_fusion/sketch/gpu/components/IGpuKernelComponent.h" #include "src/dynamic_fusion/sketch/gpu/template_writer/cl/ClTemplateStore.h" #include <memory> @@ -40,6 +39,7 @@ namespace dynamic_fusion /** Forward declaration */ template <typename T> class ArgumentPack; +class GpuCkwStore; class ClComponentStore final : public IGpuKernelComponent { @@ -87,6 +87,8 @@ public: ClComponentStore &operator=(ClComponentStore &&component) = default; /** Get template writer for the component */ const IGpuTemplateComponentWriter *template_writer() const override; + + const IGpuCkwComponentDriver *ckw_component_driver() const override; /** Get component type */ GpuComponentType type() const override { @@ -95,6 +97,7 @@ public: private: std::unique_ptr<ClTemplateStore> _component_writer; + std::unique_ptr<GpuCkwStore> _ckw_driver; }; } // namespace dynamic_fusion } // namespace experimental |