| 1 |
/* |
| 2 |
* Copyright (c) 2022-2023 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 "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 |
const bool premultiply; |
| 44 |
arm_gemm::VLType vl_type; |
| 45 |
const size_t accumulator_element_size; |
| 46 |
const unsigned int accumulator_depth_vl; |
| 47 |
std::function<bool(unsigned int, unsigned int &, unsigned int &)> get_weight_pos; |
| 48 |
|
| 49 |
unsigned int kernel_points(void) const { return kernel_cols * kernel_rows; } |
| 50 |
|
| 51 |
PackingArguments( |
| 52 |
unsigned int kernel_rows, |
| 53 |
unsigned int kernel_cols, |
| 54 |
size_t weight_element_size, |
| 55 |
bool include_bias, |
| 56 |
size_t bias_element_size, |
| 57 |
bool premultiply, |
| 58 |
arm_gemm::VLType vl_type, |
| 59 |
size_t accumulator_element_size, |
| 60 |
unsigned int accumulator_depth_vl, |
| 61 |
std::function<bool(unsigned int, unsigned int &, unsigned int &)> get_weight_pos |
| 62 |
); |
| 63 |
}; |
| 64 |
|
| 65 |
size_t get_storage_size_generic( |
| 66 |
const PackingArguments &packing_args, |
| 67 |
const DepthwiseArgs &args |
| 68 |
); |
| 69 |
|
| 70 |
void pack_parameters_generic( |
| 71 |
const PackingArguments &packing_args, |
| 72 |
const DepthwiseArgs &args, |
| 73 |
void *buffer_raw, |
| 74 |
const void *biases_raw, |
| 75 |
const void *weights_raw, |
| 76 |
size_t ld_weight_col, |
| 77 |
size_t ld_weight_row |
| 78 |
); |
| 79 |
|
| 80 |
} // namespace interleaves |
| 81 |
} // namespace depthwise |
| 82 |
} // namespace arm_conv |