blob: 37892b696338fc7c0c6d177caad172a063de11dc [file] [log] [blame]
ramelg018a164882022-04-07 02:42:52 +01001/*
Michael Tyler8deee9b2023-06-30 11:26:05 +01002 * Copyright (c) 2022-2023 Arm Limited.
ramelg018a164882022-04-07 02:42:52 +01003 *
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#include "depthwise_strategies_common.hpp"
26
27namespace arm_conv {
28namespace depthwise {
29
30unsigned int DepthfirstStrategyUntyped::get_input_rows() const
31{
32 return this->get_kernel_rows() + (this->get_output_rows() - 1) * this->get_stride_rows();
33}
34
35unsigned int DepthfirstStrategyUntyped::get_input_cols() const
36{
37 return this->get_kernel_cols() + (this->get_output_cols() - 1) * this->get_stride_cols();
38}
39
40unsigned int DepthfirstStrategyUntyped::get_n_input_points() const { return this->get_input_rows() * this->get_input_cols(); }
41unsigned int DepthfirstStrategyUntyped::get_n_output_points() const { return this->get_output_rows() * this->get_output_cols(); }
42unsigned int DepthfirstStrategyUntyped::get_n_kernel_points() const { return this->get_kernel_rows() * this->get_kernel_cols(); }
43
Michael Tyler8deee9b2023-06-30 11:26:05 +010044bool DepthfirstStrategyUntyped::uses_premultiply() const { return true; }
45
ramelg018a164882022-04-07 02:42:52 +010046unsigned int DepthfirstStrategyUntyped::get_accumulator_depth_vl() const { return 1; }
47
48bool DepthfirstStrategyUntyped::get_kernel_packing_point(const unsigned int index, unsigned int &x, unsigned int &y) const
49{
50 // Get the kernel point to pack at the given index; return false to
51 // indicate that this index, and all greater indices, is out of range.
52 if (index < (this->get_kernel_cols() * this->get_kernel_rows()))
53 {
54 y = index % this->get_kernel_cols();
55 x = index / this->get_kernel_cols();
56 return true;
57 }
58 return false;
59}
60
61} // namespace depthwise
62} // namespace arm_conv