| 1 | // |
| 2 | // SPDX-FileCopyrightText: Copyright 2025-2026 Arm Limited and/or its affiliates <open-source-office@arm.com> |
| 3 | // |
| 4 | // SPDX-License-Identifier: Apache-2.0 |
| 5 | // |
| 6 | |
| 7 | #pragma once |
| 8 | |
| 9 | #include <cstddef> |
| 10 | #include <cstdint> |
| 11 | |
| 12 | namespace kai::benchmark { |
| 13 | |
| 14 | // Interface families mirroring matmul style specializations |
| 15 | |
| 16 | // 1) Packed float DWConv with clamp |
| 17 | struct DwConvPackedFloatInterface { |
| 18 | void (*run_dwconv)( |
| 19 | const void* src, const void* rhs_packed, void* dst, size_t in_stride_row, size_t in_stride_col, |
| 20 | size_t dst_stride_row, size_t dst_stride_col, size_t valid_input_rows, size_t valid_dst_rows, size_t pad_left, |
| 21 | size_t pad_top, float pad_value, float clamp_min, float clamp_max); |
| 22 | }; |
| 23 | |
| 24 | // 2) Packed depth-first float DWConv with clamp |
| 25 | struct DwConvPackedDepthfirstFloatInterface { |
| 26 | void (*run_dwconv)( |
| 27 | const void* src, const void* rhs_packed, void* dst, size_t num_channels, size_t src_rows, size_t src_cols, |
| 28 | size_t dst_rows, size_t dst_cols, size_t pad_left, size_t pad_top, size_t in_stride_row, size_t in_stride_col, |
| 29 | size_t dst_stride_row, size_t dst_stride_col, float clamp_min, float clamp_max); |
| 30 | }; |
| 31 | |
| 32 | // 3) Split float DWConv with clamp (weights + bias separate) |
| 33 | struct DwConvSplitFloatInterface { |
| 34 | void (*run_dwconv)( |
| 35 | const void* src, const float* weights, const float* bias, void* dst, size_t in_stride_row, size_t in_stride_col, |
| 36 | size_t dst_stride_row, size_t dst_stride_col, size_t valid_input_rows, size_t valid_dst_rows, size_t pad_left, |
| 37 | size_t pad_top, float pad_value, float clamp_min, float clamp_max); |
| 38 | }; |
| 39 | |
| 40 | // Kernel traits independent of interface family |
| 41 | struct DwConvTraits { |
| 42 | size_t (*get_m_step)(); |
| 43 | size_t (*get_filter_height)(); |
| 44 | size_t (*get_filter_width)(); |
| 45 | size_t (*get_dst_size)(size_t dst_height, size_t dst_width, size_t num_channels); |
| 46 | // Optional for runners that do not use the planar tiling path. |
| 47 | size_t (*get_kr)(); |
| 48 | size_t (*get_dst_offset)(size_t dst_row_idx, size_t dst_stride_row); |
| 49 | size_t (*get_src_offset)(size_t in_row_idx, size_t in_stride_row); |
| 50 | }; |
| 51 | |
| 52 | // RHS description for allocation in benchmark layer |
| 53 | enum class DwConvRhsLayout { Packed, Split }; |
| 54 | |
| 55 | struct DwConvRhsConfig { |
| 56 | DwConvRhsLayout layout{DwConvRhsLayout::Packed}; |
| 57 | // Element types for sizing when using default formulas |
| 58 | int weights_elem_bits{32}; // e.g., 32 for float, 8 for int8 |
| 59 | int bias_elem_bits{32}; // e.g., 32 for float or int32 |
| 60 | // Optional size function for packed layout |
| 61 | size_t (*get_packed_rhs_size)(size_t filter_height, size_t filter_width, size_t num_channels){nullptr}; |
| 62 | }; |
| 63 | |
| 64 | } // namespace kai::benchmark |