aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorramy.elgammal@arm.com <ramy.elgammal@arm.com>2023-07-27 18:23:17 +0100
committerAdnan AlSinan <adnan.alsinan@arm.com>2023-10-04 16:58:44 +0000
commita04ae3e9ecf7765d623a4909089c3224af77f04e (patch)
tree569cd3f65cc5b20128b25b9bedfdb82370fcb77f
parent745153b7ec2b6f3cd08d097b4d746503b0775402 (diff)
downloadComputeLibrary-a04ae3e9ecf7765d623a4909089c3224af77f04e.tar.gz
Port DepthwiseConv2d operator to Ckw
- Only support 1x1 blocks, i.e. n0=1, m0=1. - Dilation not supported yet. Resolves: COMPMID-6258 Signed-off-by: ramy.elgammal@arm.com <ramy.elgammal@arm.com> Change-Id: I1dcfd7640fb40e112736dedc81847f7b1b50dba2 Signed-off-by: Adnan AlSinan <adnan.alsinan@arm.com> Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/10411 Comments-Addressed: Arm Jenkins <bsgcomp@arm.com> Reviewed-by: Gunes Bayir <gunes.bayir@arm.com> Benchmark: Arm Jenkins <bsgcomp@arm.com> Tested-by: Arm Jenkins <bsgcomp@arm.com>
-rw-r--r--Android.bp1
-rw-r--r--compute_kernel_writer/prototype/CMakeLists.txt4
-rw-r--r--docs/user_guide/release_version_and_change_log.dox4
-rw-r--r--filelist.json1
-rw-r--r--src/dynamic_fusion/sketch/gpu/ckw_driver/components/GpuCkwDepthwiseConv2d.cpp265
-rw-r--r--src/dynamic_fusion/sketch/gpu/ckw_driver/components/GpuCkwDepthwiseConv2d.h79
-rw-r--r--src/dynamic_fusion/sketch/gpu/components/cl/ClComponentDepthwiseConv2d.cpp15
-rw-r--r--src/dynamic_fusion/sketch/gpu/components/cl/ClComponentDepthwiseConv2d.h24
-rw-r--r--tests/datasets/DepthwiseConvolutionLayerDataset.h8
-rw-r--r--tests/datasets/DilatedDepthwiseConvolutionLayerDataset.h9
-rw-r--r--tests/validation/dynamic_fusion/gpu/cl/DepthwiseConv2d.cpp12
11 files changed, 401 insertions, 21 deletions
diff --git a/Android.bp b/Android.bp
index e13f2e87af..1bd70c4f36 100644
--- a/Android.bp
+++ b/Android.bp
@@ -636,6 +636,7 @@ cc_library_static {
"src/dynamic_fusion/sketch/gpu/ckw_driver/GpuCkwVariableTable.cpp",
"src/dynamic_fusion/sketch/gpu/ckw_driver/components/GpuCkwActivation.cpp",
"src/dynamic_fusion/sketch/gpu/ckw_driver/components/GpuCkwCast.cpp",
+ "src/dynamic_fusion/sketch/gpu/ckw_driver/components/GpuCkwDepthwiseConv2d.cpp",
"src/dynamic_fusion/sketch/gpu/ckw_driver/components/GpuCkwDirectConv2d.cpp",
"src/dynamic_fusion/sketch/gpu/ckw_driver/components/GpuCkwElementwiseBinary.cpp",
"src/dynamic_fusion/sketch/gpu/ckw_driver/components/GpuCkwPool2d.cpp",
diff --git a/compute_kernel_writer/prototype/CMakeLists.txt b/compute_kernel_writer/prototype/CMakeLists.txt
index 13d1ae8fc4..439dcd3b7e 100644
--- a/compute_kernel_writer/prototype/CMakeLists.txt
+++ b/compute_kernel_writer/prototype/CMakeLists.txt
@@ -42,7 +42,7 @@ target_compile_options(ckw_prototype
${CKW_CXX_FLAGS}
"$<$<CXX_COMPILER_ID:GNU>:${GNU_WARNINGS}>"
"$<$<CONFIG:Debug>:${CKW_ASSERTS_OPTS}>"
- "$<$<BOOL:${CKW_ASSERTS}>:${CKW_ASSERTS_OPTS}>"
+ "$<$<BOOL:${CKW_ENABLE_ASSERTS}>:${CKW_ASSERTS_OPTS}>"
${CMAKE_CXX_FLAGS}
PRIVATE
$<$<CONFIG:Release>:-Os>
@@ -51,7 +51,7 @@ target_compile_options(ckw_prototype
target_compile_definitions(ckw_prototype PUBLIC
$<$<CONFIG:Debug>:COMPUTE_KERNEL_WRITER_DEBUG_ENABLED>
$<$<CONFIG:Debug>:COMPUTE_KERNEL_WRITER_ASSERTS_ENABLED>
- $<$<BOOL:${CKW_ASSERTS}>:COMPUTE_KERNEL_WRITER_ASSERTS_ENABLED>
+ $<$<BOOL:${CKW_ENABLE_ASSERTS}>:COMPUTE_KERNEL_WRITER_ASSERTS_ENABLED>
$<$<BOOL:${CKW_ENABLE_OPENCL}>:COMPUTE_KERNEL_WRITER_OPENCL_ENABLED>
)
diff --git a/docs/user_guide/release_version_and_change_log.dox b/docs/user_guide/release_version_and_change_log.dox
index 04ecc80a19..3e04837c1e 100644
--- a/docs/user_guide/release_version_and_change_log.dox
+++ b/docs/user_guide/release_version_and_change_log.dox
@@ -47,13 +47,13 @@ v23.11 Public major release
- Add support for output data type S64 in NEArgMinMaxLayer and CLArgMinMaxLayer
- Port the following kernels in the experimental Dynamic Fusion interface to use the new Compute Kernel Writer interface:
- @ref experimental::dynamic_fusion::GpuCkwResize
+ - @ref experimental::dynamic_fusion::GpuCkwPool2d
+ - @ref experimental::dynamic_fusion::GpuCkwDepthwiseConv2d
- Add support for OpenCL™ comand buffer with mutable dispatch extension.
- Update OpenCL™ API headers to v2023.04.17.
- Remove legacy PostOps interface. PostOps was the experimental interface for kernel fusion and is replaced by the new Dynamic Fusion interface.
- Performance optimizations:
- Optimize @ref cpu::CpuReshape
- - Port the following kernels in the experimental Dynamic Fusion interface to use the new Compute Kernel Writer interface with support for FP16/FP32 only:
- - @ref experimental::dynamic_fusion::GpuCkwPool2d
- Add new OpenCL™ kernels:
- @ref opencl::kernels::ClMatMulLowpNativeMMULKernel support for QASYMM8 and QASYMM8_SIGNED, with batch support
- Deprecate support for Bfloat16 in @ref cpu::CpuCast.
diff --git a/filelist.json b/filelist.json
index 9c19550340..bb90fcf4bb 100644
--- a/filelist.json
+++ b/filelist.json
@@ -2349,6 +2349,7 @@
"src/dynamic_fusion/sketch/gpu/ckw_driver/GpuCkwDriver.cpp",
"src/dynamic_fusion/sketch/gpu/ckw_driver/components/GpuCkwActivation.cpp",
"src/dynamic_fusion/sketch/gpu/ckw_driver/components/GpuCkwCast.cpp",
+ "src/dynamic_fusion/sketch/gpu/ckw_driver/components/GpuCkwDepthwiseConv2d.cpp",
"src/dynamic_fusion/sketch/gpu/ckw_driver/components/GpuCkwDirectConv2d.cpp",
"src/dynamic_fusion/sketch/gpu/ckw_driver/components/GpuCkwElementwiseBinary.cpp",
"src/dynamic_fusion/sketch/gpu/ckw_driver/components/GpuCkwPool2d.cpp",
diff --git a/src/dynamic_fusion/sketch/gpu/ckw_driver/components/GpuCkwDepthwiseConv2d.cpp b/src/dynamic_fusion/sketch/gpu/ckw_driver/components/GpuCkwDepthwiseConv2d.cpp
new file mode 100644
index 0000000000..1e09c78f47
--- /dev/null
+++ b/src/dynamic_fusion/sketch/gpu/ckw_driver/components/GpuCkwDepthwiseConv2d.cpp
@@ -0,0 +1,265 @@
+/*
+ * Copyright (c) 2023 Arm Limited.
+ *
+ * SPDX-License-Identifier: MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+#include "src/dynamic_fusion/sketch/gpu/ckw_driver/components/GpuCkwDepthwiseConv2d.h"
+
+#include "arm_compute/core/Error.h"
+#include "arm_compute/core/Validate.h"
+#include "ckw/TensorTileSampler.h"
+
+#include "src/core/helpers/WindowHelpers.h"
+#include "src/dynamic_fusion/sketch/gpu/ckw_driver/components/utils/type_converter/Common.h"
+#include "src/dynamic_fusion/sketch/gpu/ckw_driver/components/utils/WriterHelper.h"
+#include "src/dynamic_fusion/sketch/gpu/ckw_driver/GpuCkwKernelWriter.h"
+#include "src/dynamic_fusion/sketch/gpu/ckw_driver/GpuCkwScopedKernelWriter.h"
+#include "src/dynamic_fusion/sketch/gpu/ckw_driver/GpuCkwVariableTable.h"
+#include "src/dynamic_fusion/sketch/gpu/GpuKernelComponentGroup.h"
+
+#include <cstdint>
+#include <string>
+
+using namespace ckw;
+namespace arm_compute
+{
+namespace experimental
+{
+namespace dynamic_fusion
+{
+GpuCkwDepthwiseConv2d::GpuCkwDepthwiseConv2d(ComponentId id,
+ const ArgumentPack<ITensorInfo> &tensors,
+ const Attributes &attributes,
+ const Settings &settings)
+ : IGpuCkwComponentDriver{id, tensors},
+ _src{},
+ _weight{},
+ _bias{},
+ _dst{},
+ _attributes{attributes},
+ _settings{settings}
+{
+ _src = this->tensors().get_const_tensor(TensorType::ACL_SRC_0);
+ _weight = this->tensors().get_const_tensor(TensorType::ACL_SRC_1);
+ if (this->tensors().get_const_tensor(TensorType::ACL_SRC_2))
+ {
+ _bias = this->tensors().get_const_tensor(TensorType::ACL_SRC_2);
+ }
+ _dst = this->tensors().get_const_tensor(TensorType::ACL_DST_0);
+ ARM_COMPUTE_ERROR_ON_NULLPTR(_src, _weight, _bias, _dst);
+}
+
+void GpuCkwDepthwiseConv2d::write_component_code(const ComponentGroup &comp_group,
+ GpuCkwVariableTable &vtable,
+ GpuCkwScopedKernelWriter writer) const
+{
+ // Data Layout is NHWC
+ constexpr int32_t width_idx = 1;
+ constexpr int32_t height_idx = 2;
+
+ const auto root_window = comp_group.get_root_component()->ckw_component_driver()->get_window();
+
+ // Tunable parameters
+ // Currently only m0 and n0 = 1 are supported.
+ const int32_t m0 = root_window.y().step();
+ const int32_t n0 = root_window.x().step();
+ constexpr int32_t m0_a_val = 1;
+ constexpr int32_t n0_a_val = 1;
+ constexpr int32_t m0_b_val = 1;
+
+ GpuCkwComponentArgument *src =
+ vtable.declare_variable(comp_group, writer, _src, TensorStorageType::ClBufferUint8Ptr, "src");
+ GpuCkwComponentArgument *wei =
+ vtable.declare_variable(comp_group, writer, _weight, TensorStorageType::ClBufferUint8Ptr, "wei");
+ GpuCkwComponentArgument *bia = nullptr;
+
+ if (_bias && _bias->has_valid_id())
+ {
+ bia = vtable.declare_variable(comp_group, writer, _bias, TensorStorageType::ClBufferUint8Ptr, "bia");
+ }
+ GpuCkwComponentArgument *dst =
+ vtable.declare_variable(comp_group, writer, _dst, TensorStorageType::ClBufferUint8Ptr, "dst");
+
+ // Constants
+ const auto &const_1 = writer->declare_tile("1", 1);
+ const auto &wei_height = writer->declare_tile("WEI_HEIGHT", static_cast<int32_t>(_weight->dimension(height_idx)));
+ const auto &wei_width = writer->declare_tile("WEI_WIDTH", static_cast<int32_t>(_weight->dimension(width_idx)));
+ const auto &dst_height = writer->declare_tile("DST_HEIGHT", static_cast<int32_t>(_dst->dimension(height_idx)));
+ const auto &stride_x = writer->declare_tile("STRIDE_X", static_cast<int32_t>(_attributes.stride().x()));
+ const auto &stride_y = writer->declare_tile("STRIDE_Y", static_cast<int32_t>(_attributes.stride().y()));
+ const auto &pad_left = writer->declare_tile("PAD_LEFT", static_cast<int32_t>(_attributes.pad().left));
+ const auto &pad_top = writer->declare_tile("PAD_TOP", static_cast<int32_t>(_attributes.pad().top));
+ const auto &depth_multiplier =
+ writer->declare_tile("DEPTH_MULTIPLIER", static_cast<int32_t>(_attributes.depth_multiplier()));
+ auto &const_0 = writer->declare_tile("0", 0);
+ auto &yo = writer->declare_tile("yo", ckw::DataType::Int32);
+
+ auto &gid_0 = writer->declare_tile("gid_0", ckw::DataType::Int32);
+ auto &gid_1 = writer->declare_tile("gid_1", ckw::DataType::Int32);
+ auto &gid_2 = writer->declare_tile("gid_2", ckw::DataType::Int32);
+
+ writer->op_get_global_id(gid_0, 0);
+ writer->op_get_global_id(gid_1, 1);
+ writer->op_get_global_id(gid_2, 2);
+
+ auto &bout = writer->declare_tile("bout", ckw::DataType::Int32);
+ writer->op_binary_expression(bout, gid_2, ckw::BinaryOp::Div, dst_height); // gid_2 / h
+ writer->op_binary_expression(yo, gid_2, ckw::BinaryOp::Mod, dst_height); // gid_2 % h
+
+ const int32_t dst_partial_n0_v = _dst->tensor_shape()[0] % n0;
+ const int32_t dst_partial_m0_v = _dst->tensor_shape()[1] % m0;
+ auto &g_ind_0 = writer->declare_tile("g_ind_0", ckw::DataType::Int32);
+ auto &g_ind_1 = writer->declare_tile("g_ind_1", ckw::DataType::Int32);
+ get_coord(writer, g_ind_0, gid_0, n0, dst_partial_n0_v, "dst_x_", const_0);
+ get_coord(writer, g_ind_1, gid_1, m0, dst_partial_m0_v, "dst_y_", const_0);
+
+ TensorTileSampler src_sampler;
+ src_sampler.width(m0_a_val);
+ src_sampler.height(n0_a_val);
+ src_sampler.format(TensorSamplerFormat::C_W_H);
+ src_sampler.address_mode_x(TensorSamplerAddressModeX::None);
+ src_sampler.address_mode_y(TensorSamplerAddressModeY::Skip);
+ src_sampler.address_mode_z(TensorSamplerAddressModeZ::Skip);
+
+ TensorTileSampler wei_sampler;
+ wei_sampler.width(m0_b_val);
+ wei_sampler.height(n0);
+ wei_sampler.format(TensorSamplerFormat::C_W_H);
+ wei_sampler.address_mode_x(TensorSamplerAddressModeX::None);
+ wei_sampler.address_mode_y(TensorSamplerAddressModeY::None);
+ wei_sampler.address_mode_z(TensorSamplerAddressModeZ::None);
+
+ TensorTileSampler dst_sampler;
+ dst_sampler.width(n0);
+ dst_sampler.height(m0);
+ dst_sampler.format(TensorSamplerFormat::C_W_H);
+ dst_sampler.address_mode_x(TensorSamplerAddressModeX::None);
+ dst_sampler.address_mode_y(TensorSamplerAddressModeY::None);
+ dst_sampler.address_mode_z(TensorSamplerAddressModeZ::Skip);
+ dst_sampler.x(g_ind_0);
+ dst_sampler.y(g_ind_1);
+ dst_sampler.z(yo);
+ dst_sampler.b(bout);
+
+ if (!dst->has_tile())
+ {
+ auto &dst_tile = writer->declare_tile("dst_tile", ckw::TileInfo(to_ckw(_dst->data_type()), m0, n0));
+ dst->init_virtual_tensor(dst_tile, dst_sampler);
+ }
+ auto &dst_tile = dst->tile();
+
+ writer->op_assign(dst_tile, const_0);
+
+ auto &xi = writer->declare_tile("xi", ckw::DataType::Int32);
+ writer->op_binary_expression(xi, g_ind_1, ckw::BinaryOp::Mul, stride_x);
+ writer->op_binary_expression(xi, xi, ckw::BinaryOp::Sub, pad_left);
+
+ auto &yi = writer->declare_tile("yi", ckw::DataType::Int32);
+ writer->op_binary_expression(yi, yo, ckw::BinaryOp::Mul, stride_y);
+ writer->op_binary_expression(yi, yi, ckw::BinaryOp::Sub, pad_top);
+
+ auto &a_x = writer->declare_tile("a_x", ckw::DataType::Int32);
+ writer->op_binary_expression(a_x, g_ind_0, BinaryOp::Div, depth_multiplier);
+
+ // src_tile
+ auto &a = writer->declare_tile("a", ckw::TileInfo(to_ckw(_src->data_type()), m0_a_val, n0_a_val));
+ // wei_tile
+ auto &b = writer->declare_tile("b", ckw::TileInfo(to_ckw(_weight->data_type()), m0_b_val, n0));
+
+ // Loop variables
+ auto &yk = writer->declare_tile("yk", ckw::DataType::Int32);
+ auto &xk = writer->declare_tile("xk", ckw::DataType::Int32);
+
+ // Because 1x1 blocks are being used here, scalar values are being loaded from memory instead of using tiles, since tile vector access currently is not available. Hence the values are loaded in the inner loop.
+ // This loop will be reworked.
+ writer->op_assign(yk, const_0);
+ writer->op_for_loop(yk, BinaryOp::Less, wei_height, yk, AssignmentOp::Increment, const_1,
+ [&]()
+ {
+ // xk = 0
+ writer->op_assign(xk, const_0);
+ writer->op_for_loop(
+ xk, BinaryOp::Less, wei_width, xk, AssignmentOp::Increment, const_1,
+ [&]()
+ {
+ writer->op_assign(b, const_0);
+ writer->op_assign(a, const_0);
+
+ // src_tile loading
+ auto &xi_curr = writer->declare_tile("xi_curr", ckw::DataType::Int32);
+ writer->op_binary_expression(xi_curr, xi, BinaryOp::Add, xk);
+ auto &a_y = writer->declare_tile("a_y", ckw::DataType::Int32);
+ writer->op_binary_expression(a_y, yi, BinaryOp::Add, yk);
+ src_sampler.x(a_x);
+ src_sampler.y(xi_curr);
+ src_sampler.z(a_y);
+ src_sampler.b(bout);
+ writer->op_load(a, src->tensor(), src_sampler);
+
+ // wei_tile loading
+ auto &b_y = writer->declare_tile("b_y", ckw::DataType::Int32);
+ writer->op_binary_expression(b_y, wei_width, BinaryOp::Mul, yk);
+ writer->op_binary_expression(b_y, b_y, BinaryOp::Add, xk);
+ wei_sampler.x(g_ind_0);
+ wei_sampler.y(b_y);
+ wei_sampler.z(const_0);
+ wei_sampler.b(const_0);
+ writer->op_load(b, wei->tensor(), wei_sampler);
+
+ // Do the accumulation
+ auto &mul_result = writer->declare_tile("mul_results", a.data_type());
+ writer->op_binary_expression(mul_result, a, BinaryOp::Mul, b);
+ writer->op_binary_expression(dst_tile, dst_tile, BinaryOp::Add, mul_result);
+ });
+ });
+
+ // Add Bias
+ if (_bias && _bias->has_valid_id())
+ {
+ TensorTileSampler bias_sampler;
+ bias_sampler.width(n0);
+ bias_sampler.height(1);
+ bias_sampler.format(TensorSamplerFormat::C_W_H);
+ bias_sampler.address_mode_x(TensorSamplerAddressModeX::None);
+ bias_sampler.address_mode_y(TensorSamplerAddressModeY::None);
+ bias_sampler.address_mode_z(TensorSamplerAddressModeZ::None);
+ bias_sampler.x(g_ind_0);
+ bias_sampler.y(const_0);
+ bias_sampler.z(const_0);
+ bias_sampler.b(const_0);
+
+ auto &bias_tile = writer->declare_tile("bias_tile", ckw::TileInfo(to_ckw(_bias->data_type()), 1, n0));
+ writer->op_load(bias_tile, bia->tensor(), bias_sampler);
+ writer->op_binary_expression(dst_tile, dst_tile, BinaryOp::Add, bias_tile);
+ }
+}
+
+Window GpuCkwDepthwiseConv2d::get_window() const
+{
+ ARM_COMPUTE_ERROR_ON_MSG(_dst->tensor_shape().total_size() == 0U, "Destination tensor is not initialized");
+ TensorShape output_shape = _dst->tensor_shape();
+ // Currently only m0 and n0 = 1 are supported.
+ Window win = calculate_max_window(output_shape, Steps(1U, 1U));
+ return win.collapse(win, Window::DimZ);
+}
+} // namespace dynamic_fusion
+} // namespace experimental
+} // namespace arm_compute
diff --git a/src/dynamic_fusion/sketch/gpu/ckw_driver/components/GpuCkwDepthwiseConv2d.h b/src/dynamic_fusion/sketch/gpu/ckw_driver/components/GpuCkwDepthwiseConv2d.h
new file mode 100644
index 0000000000..f9bcaabaec
--- /dev/null
+++ b/src/dynamic_fusion/sketch/gpu/ckw_driver/components/GpuCkwDepthwiseConv2d.h
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2023 Arm Limited.
+ *
+ * SPDX-License-Identifier: MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#ifndef ACL_SRC_DYNAMIC_FUSION_SKETCH_GPU_CKW_DRIVER_COMPONENTS_GPUCKWDEPTHWISECONV2D_H
+#define ACL_SRC_DYNAMIC_FUSION_SKETCH_GPU_CKW_DRIVER_COMPONENTS_GPUCKWDEPTHWISECONV2D_H
+
+#include "arm_compute/dynamic_fusion/sketch/attributes/DepthwiseConv2dAttributes.h"
+
+#include "src/core/common/Macros.h"
+#include "src/dynamic_fusion/sketch/gpu/ckw_driver/IGpuCkwComponentDriver.h"
+#include "src/dynamic_fusion/sketch/gpu/components/cl/ClComponentDepthwiseConv2d.h"
+namespace arm_compute
+{
+namespace experimental
+{
+namespace dynamic_fusion
+{
+
+class GpuCkwDepthwiseConv2d : public IGpuCkwComponentDriver
+{
+public:
+ using Attributes = ClComponentDepthwiseConv2d::Attributes;
+ using Settings = ClComponentDepthwiseConv2d::Settings;
+
+ /** Constructor
+ *
+ * For supported configurations please refer to @ref ClComponentDepthwiseConv2d::validate()
+ *
+ * @param[in] id Component id
+ * @param[in] tensors Tensor arguments to the component
+ * @param[in] attributes Component attributes
+ * @param[in] settings Component settings
+ */
+ GpuCkwDepthwiseConv2d(ComponentId id,
+ const ArgumentPack<ITensorInfo> &tensors,
+ const Attributes &attributes,
+ const Settings &settings);
+ ARM_COMPUTE_DISALLOW_COPY_ALLOW_MOVE(GpuCkwDepthwiseConv2d);
+ /** Destructor */
+ ~GpuCkwDepthwiseConv2d() override = default;
+ // Inherited methods overriden:
+ virtual void write_component_code(const ComponentGroup &comp_group,
+ GpuCkwVariableTable &vtable,
+ GpuCkwScopedKernelWriter writer) const override;
+ Window get_window() const override;
+
+private:
+ const ITensorInfo *_src;
+ const ITensorInfo *_weight;
+ const ITensorInfo *_bias;
+ const ITensorInfo *_dst;
+ Attributes _attributes;
+ Settings _settings;
+};
+} // namespace dynamic_fusion
+} // namespace experimental
+} // namespace arm_compute
+#endif // ACL_SRC_DYNAMIC_FUSION_SKETCH_GPU_CKW_DRIVER_COMPONENTS_GPUCKWDEPTHWISECONV2D_H
diff --git a/src/dynamic_fusion/sketch/gpu/components/cl/ClComponentDepthwiseConv2d.cpp b/src/dynamic_fusion/sketch/gpu/components/cl/ClComponentDepthwiseConv2d.cpp
index d95e0be1f2..ca8037c393 100644
--- a/src/dynamic_fusion/sketch/gpu/components/cl/ClComponentDepthwiseConv2d.cpp
+++ b/src/dynamic_fusion/sketch/gpu/components/cl/ClComponentDepthwiseConv2d.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2022 Arm Limited.
+ * Copyright (c) 2022-2023 Arm Limited.
*
* SPDX-License-Identifier: MIT
*
@@ -28,7 +28,11 @@
#include "arm_compute/dynamic_fusion/sketch/attributes/DepthwiseConv2dAttributes.h"
#include "src/core/CL/CLValidate.h"
+#ifndef ACL_INTERNAL_TEST_CKW_IN_DF
#include "src/dynamic_fusion/sketch/gpu/template_writer/cl/ClTemplateDepthwiseConv2d.h"
+#else //ACL_INTERNAL_TEST_CKW_IN_DF
+#include "src/dynamic_fusion/sketch/gpu/ckw_driver/components/GpuCkwDepthwiseConv2d.h"
+#endif //ACL_INTERNAL_TEST_CKW_IN_DF
namespace arm_compute
{
@@ -208,13 +212,22 @@ ClComponentDepthwiseConv2d::ClComponentDepthwiseConv2d(ComponentId
const Attributes &attributes,
const Settings &settings)
: IGpuKernelComponent{id, properties, tensors},
+#ifndef ACL_INTERNAL_TEST_CKW_IN_DF
_component_writer{std::make_unique<ClTemplateDepthwiseConv2d>(id, tensors, attributes, settings)}
+#else //ACL_INTERNAL_TEST_CKW_IN_DF
+ _component_writer{std::make_unique<GpuCkwDepthwiseConv2d>(id, tensors, attributes, settings)}
+#endif //ACL_INTERNAL_TEST_CKW_IN_DF
{
+ ARM_COMPUTE_UNUSED(attributes, settings);
}
ClComponentDepthwiseConv2d::~ClComponentDepthwiseConv2d()
{
}
+#ifndef ACL_INTERNAL_TEST_CKW_IN_DF
const IGpuTemplateComponentWriter *ClComponentDepthwiseConv2d::template_writer() const
+#else //ACL_INTERNAL_TEST_CKW_IN_DF
+const IGpuCkwComponentDriver *ClComponentDepthwiseConv2d::ckw_component_driver() const
+#endif //ACL_INTERNAL_TEST_CKW_IN_DF
{
return _component_writer.get();
}
diff --git a/src/dynamic_fusion/sketch/gpu/components/cl/ClComponentDepthwiseConv2d.h b/src/dynamic_fusion/sketch/gpu/components/cl/ClComponentDepthwiseConv2d.h
index b3e1bd222d..01168e9ded 100644
--- a/src/dynamic_fusion/sketch/gpu/components/cl/ClComponentDepthwiseConv2d.h
+++ b/src/dynamic_fusion/sketch/gpu/components/cl/ClComponentDepthwiseConv2d.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_CL_CLCOMPONENTDEPTHWISECONV2D
-#define SRC_DYNAMIC_FUSION_SKETCH_GPU_COMPONENTS_CL_CLCOMPONENTDEPTHWISECONV2D
+#ifndef ACL_SRC_DYNAMIC_FUSION_SKETCH_GPU_COMPONENTS_CL_CLCOMPONENTDEPTHWISECONV2D_H
+#define ACL_SRC_DYNAMIC_FUSION_SKETCH_GPU_COMPONENTS_CL_CLCOMPONENTDEPTHWISECONV2D_H
#include "arm_compute/core/Error.h"
@@ -43,6 +43,13 @@ template <typename T>
class ArgumentPack;
class DepthwiseConv2dAttributes;
+/** Forward declaration */
+#ifndef ACL_INTERNAL_TEST_CKW_IN_DF
+class ClTemplateDepthwiseConv2d;
+#else //ACL_INTERNAL_TEST_CKW_IN_DF
+class GpuCkwDepthwiseConv2d;
+#endif //ACL_INTERNAL_TEST_CKW_IN_DF
+
/** Component specific settings
*/
class ClComponentDepthwiseConv2dSettings
@@ -155,7 +162,12 @@ public:
/** Allow instances of this class to be moved */
ClComponentDepthwiseConv2d &operator=(ClComponentDepthwiseConv2d &&component) = default;
/** Get template writer for the component */
+#ifndef ACL_INTERNAL_TEST_CKW_IN_DF
const IGpuTemplateComponentWriter *template_writer() const override;
+#else //ACL_INTERNAL_TEST_CKW_IN_DF
+ const IGpuCkwComponentDriver *ckw_component_driver() const override;
+#endif //ACL_INTERNAL_TEST_CKW_IN_DF
+
/** Get component type */
GpuComponentType type() const override
{
@@ -163,9 +175,13 @@ public:
}
private:
+#ifndef ACL_INTERNAL_TEST_CKW_IN_DF
std::unique_ptr<ClTemplateDepthwiseConv2d> _component_writer;
+#else //ACL_INTERNAL_TEST_CKW_IN_DF
+ std::unique_ptr<GpuCkwDepthwiseConv2d> _component_writer;
+#endif //ACL_INTERNAL_TEST_CKW_IN_DF
};
} // namespace dynamic_fusion
} // namespace experimental
} // namespace arm_compute
-#endif /* SRC_DYNAMIC_FUSION_SKETCH_GPU_COMPONENTS_CL_CLCOMPONENTDEPTHWISECONV2D */
+#endif // ACL_SRC_DYNAMIC_FUSION_SKETCH_GPU_COMPONENTS_CL_CLCOMPONENTDEPTHWISECONV2D_H
diff --git a/tests/datasets/DepthwiseConvolutionLayerDataset.h b/tests/datasets/DepthwiseConvolutionLayerDataset.h
index f88cb887fc..0d58e95911 100644
--- a/tests/datasets/DepthwiseConvolutionLayerDataset.h
+++ b/tests/datasets/DepthwiseConvolutionLayerDataset.h
@@ -21,8 +21,8 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
-#ifndef ARM_COMPUTE_TEST_DEPTHWISE_CONVOLUTION_DATASET
-#define ARM_COMPUTE_TEST_DEPTHWISE_CONVOLUTION_DATASET
+#ifndef ACL_TESTS_DATASETS_DEPTHWISECONVOLUTIONLAYERDATASET_H
+#define ACL_TESTS_DATASETS_DEPTHWISECONVOLUTIONLAYERDATASET_H
#include "utils/TypePrinter.h"
@@ -127,7 +127,7 @@ public:
add_config(TensorShape(33U, 27U, 7U), Size2D(5U, 7U), PadStrideInfo(3, 2, 1, 1, 2, 0, DimensionRoundingType::FLOOR));
add_config(TensorShape(33U, 27U, 7U), Size2D(5U, 7U), PadStrideInfo(3, 2, 1, 1, 0, 2, DimensionRoundingType::FLOOR));
// Ceil rounding
- add_config(TensorShape(7U, 8U, 5U, 9U), Size2D(8U, 6U), PadStrideInfo(2, 3, 1, 1, 1, 3, DimensionRoundingType::CEIL), Size2D(1U, 2U));
+ add_config(TensorShape(7U, 8U, 5U, 9U), Size2D(8U, 6U), PadStrideInfo(2, 3, 1, 1, 1, 3, DimensionRoundingType::CEIL));
}
};
@@ -296,4 +296,4 @@ public:
} // namespace datasets
} // namespace test
} // namespace arm_compute
-#endif /* ARM_COMPUTE_TEST_DEPTHWISE_CONVOLUTION_DATASET */
+#endif // ACL_TESTS_DATASETS_DEPTHWISECONVOLUTIONLAYERDATASET_H
diff --git a/tests/datasets/DilatedDepthwiseConvolutionLayerDataset.h b/tests/datasets/DilatedDepthwiseConvolutionLayerDataset.h
index 8ddc71cf5a..2d47e9190a 100644
--- a/tests/datasets/DilatedDepthwiseConvolutionLayerDataset.h
+++ b/tests/datasets/DilatedDepthwiseConvolutionLayerDataset.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019-2021 Arm Limited.
+ * Copyright (c) 2019-2021, 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 ARM_COMPUTE_TEST_DILATED_CONVOLUTION_LAYER_DATASET
-#define ARM_COMPUTE_TEST_DILATED_CONVOLUTION_LAYER_DATASET
+#ifndef ACL_TESTS_DATASETS_DILATEDDEPTHWISECONVOLUTIONLAYERDATASET_H
+#define ACL_TESTS_DATASETS_DILATEDDEPTHWISECONVOLUTIONLAYERDATASET_H
#include "utils/TypePrinter.h"
@@ -48,6 +48,7 @@ public:
add_config(TensorShape(7U, 7U, 1U), Size2D(3U, 2U), PadStrideInfo(1, 1, 0, 0), Size2D(2U, 1U));
add_config(TensorShape(7U, 7U, 1U), Size2D(3U, 2U), PadStrideInfo(2, 1, 0, 0), Size2D(2U, 2U));
add_config(TensorShape(7U, 7U, 1U), Size2D(3U, 2U), PadStrideInfo(2, 2, 0, 0), Size2D(1U, 2U));
+ add_config(TensorShape(7U, 8U, 5U, 9U), Size2D(8U, 6U), PadStrideInfo(2, 3, 1, 1, 1, 3, DimensionRoundingType::CEIL), Size2D(1U, 2U));
add_config(TensorShape(7U, 8U, 1U), Size2D(2U, 3U), PadStrideInfo(1, 2, 0, 0), Size2D(2U, 2U));
add_config(TensorShape(23U, 27U, 5U), Size2D(3U, 5U), PadStrideInfo(2, 1, 0, 0), Size2D(2U, 1U));
@@ -139,4 +140,4 @@ public:
} // namespace datasets
} // namespace test
} // namespace arm_compute
-#endif /* ARM_COMPUTE_TEST_DILATED_CONVOLUTION_LAYER_DATASET */ \ No newline at end of file
+#endif // ACL_TESTS_DATASETS_DILATEDDEPTHWISECONVOLUTIONLAYERDATASET_H
diff --git a/tests/validation/dynamic_fusion/gpu/cl/DepthwiseConv2d.cpp b/tests/validation/dynamic_fusion/gpu/cl/DepthwiseConv2d.cpp
index 71b0114225..aec1306a31 100644
--- a/tests/validation/dynamic_fusion/gpu/cl/DepthwiseConv2d.cpp
+++ b/tests/validation/dynamic_fusion/gpu/cl/DepthwiseConv2d.cpp
@@ -22,7 +22,6 @@
* SOFTWARE.
*/
-#ifndef ACL_INTERNAL_TEST_CKW_IN_DF // Do not include this test if ACL_INTERNAL_TEST_CKW_IN_DF and the op has not been ported to ckw
#include "arm_compute/dynamic_fusion/sketch/gpu/operators/GpuDepthwiseConv2d.h"
#include "tests/CL/CLAccessor.h"
@@ -284,6 +283,7 @@ FIXTURE_DATA_TEST_CASE(RunLarge, DynamicFusionGpuDepthwiseConv2dFixture<half>, f
{
validate(CLAccessor(_target), _reference, tolerance_f16);
}
+#ifndef ACL_INTERNAL_TEST_CKW_IN_DF // Do not include this test as dilation not supported yet in DepthwiseConv2d CKW kernel
TEST_SUITE(Dilation)
FIXTURE_DATA_TEST_CASE(RunSmall, DynamicFusionGpuDepthwiseConv2dFixture<half>, framework::DatasetMode::ALL, combine(combine(combine(datasets::SmallDepthwiseDilatedConvolutionLayerDataset3x3(),
depth_multipliers),
@@ -301,6 +301,7 @@ FIXTURE_DATA_TEST_CASE(RunLarge, DynamicFusionGpuDepthwiseConv2dFixture<half>, f
validate(CLAccessor(_target), _reference, tolerance_f16);
}
TEST_SUITE_END() // Dilation
+#endif // ACL_INTERNAL_TEST_CKW_IN_DF
TEST_SUITE_END() // W3x3
TEST_SUITE(Generic)
@@ -318,7 +319,7 @@ FIXTURE_DATA_TEST_CASE(RunLarge, DynamicFusionGpuDepthwiseConv2dFixture<half>, f
{
validate(CLAccessor(_target), _reference, tolerance_f16, tolerance_num);
}
-
+#ifndef ACL_INTERNAL_TEST_CKW_IN_DF // Do not include this test as dilation not supported yet in DepthwiseConv2d CKW kernel
TEST_SUITE(Dilation)
FIXTURE_DATA_TEST_CASE(RunSmall, DynamicFusionGpuDepthwiseConv2dFixture<half>, framework::DatasetMode::ALL, combine(combine(combine(datasets::SmallDepthwiseDilatedConvolutionLayerDataset(),
depth_multipliers),
@@ -336,6 +337,7 @@ FIXTURE_DATA_TEST_CASE(RunLarge, DynamicFusionGpuDepthwiseConv2dFixture<half>, f
validate(CLAccessor(_target), _reference, tolerance_f16, tolerance_num);
}
TEST_SUITE_END() // Dilation
+#endif // ACL_INTERNAL_TEST_CKW_IN_DF
TEST_SUITE_END() // Generic
TEST_SUITE_END() // FP16
@@ -358,6 +360,7 @@ FIXTURE_DATA_TEST_CASE(RunLarge, DynamicFusionGpuDepthwiseConv2dFixture<float>,
validate(CLAccessor(_target), _reference, tolerance_f32);
}
+#ifndef ACL_INTERNAL_TEST_CKW_IN_DF // Do not include this test as dilation not supported yet in DepthwiseConv2d CKW kernel
TEST_SUITE(Dilation)
FIXTURE_DATA_TEST_CASE(RunSmall, DynamicFusionGpuDepthwiseConv2dFixture<float>, framework::DatasetMode::ALL,
@@ -377,6 +380,7 @@ FIXTURE_DATA_TEST_CASE(RunLarge, DynamicFusionGpuDepthwiseConv2dFixture<float>,
validate(CLAccessor(_target), _reference, tolerance_f32);
}
TEST_SUITE_END() // Dilation
+#endif // ACL_INTERNAL_TEST_CKW_IN_DF
TEST_SUITE_END() // W3x3
TEST_SUITE(Generic)
@@ -407,6 +411,7 @@ FIXTURE_DATA_TEST_CASE(RunLargeKernelSize, DynamicFusionGpuDepthwiseConv2dFixtur
validate(CLAccessor(_target), _reference, tolerance_f32);
}
+#ifndef ACL_INTERNAL_TEST_CKW_IN_DF // Do not include this test as dilation not supported yet in DepthwiseConv2d CKW kernel
TEST_SUITE(Dilation)
FIXTURE_DATA_TEST_CASE(RunSmall, DynamicFusionGpuDepthwiseConv2dFixture<float>, framework::DatasetMode::ALL, combine(combine(combine(datasets::SmallDepthwiseDilatedConvolutionLayerDataset(),
depth_multipliers),
@@ -424,6 +429,7 @@ FIXTURE_DATA_TEST_CASE(RunLarge, DynamicFusionGpuDepthwiseConv2dFixture<float>,
validate(CLAccessor(_target), _reference, tolerance_f32);
}
TEST_SUITE_END() // Dilation
+#endif // ACL_INTERNAL_TEST_CKW_IN_DF
TEST_SUITE_END() // Generic
TEST_SUITE_END() // FP32
TEST_SUITE_END() // Float
@@ -433,5 +439,3 @@ TEST_SUITE_END() // CL
} // namespace validation
} // namespace test
} // namespace arm_compute
-
-#endif // ACL_INTERNAL_TEST_CKW_IN_DF