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 25 #pragma once 26 27 #include "src/core/NEON/kernels/arm_gemm/utils.hpp" 28 #include "depthwise.hpp" 29 30 #include <functional> 31 32 namespace arm_conv { 33 namespace depthwise { 34 namespace interleaves { 35 36 struct PackingArguments 37 { 38 const unsigned int kernel_rows; 39 const unsigned int kernel_cols; 40 const size_t weight_element_size; 41 const bool include_bias; 42 const size_t bias_element_size; 43 arm_gemm::VLType vl_type; 44 const size_t accumulator_element_size; 45 const unsigned int accumulator_depth_vl; 46 std::function<bool(unsigned int, unsigned int &, unsigned int &)> get_weight_pos; 47 kernel_pointsarm_conv::depthwise::interleaves::PackingArguments48 unsigned int kernel_points(void) const { return kernel_cols * kernel_rows; } 49 50 PackingArguments( 51 unsigned int kernel_rows, 52 unsigned int kernel_cols, 53 size_t weight_element_size, 54 bool include_bias, 55 size_t bias_element_size, 56 arm_gemm::VLType vl_type, 57 size_t accumulator_element_size, 58 unsigned int accumulator_depth_vl, 59 std::function<bool(unsigned int, unsigned int &, unsigned int &)> get_weight_pos 60 ); 61 }; 62 63 size_t get_storage_size_generic( 64 const PackingArguments &packing_args, 65 const DepthwiseArgs &args 66 ); 67 68 void pack_parameters_generic( 69 const PackingArguments &packing_args, 70 const DepthwiseArgs &args, 71 void *buffer_raw, 72 const void *biases_raw, 73 const void *weights_raw, 74 size_t ld_weight_col, 75 size_t ld_weight_row 76 ); 77 78 } // namespace interleaves 79 } // namespace depthwise 80 } // namespace arm_conv 81