blob: 1e8a2a54c9e8853eefef9dfb4649246b4fa4a0ed [file] [log] [blame]
Michele Di Giorgiod02d5ed2021-01-22 09:47:04 +00001/*
2 * Copyright (c) 2021 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#include "src/core/utils/AssemblyUtils.h"
25
26namespace arm_compute
27{
28namespace assembly_utils
29{
30arm_gemm::Activation map_to_arm_gemm_activation(const ActivationLayerInfo &act)
31{
32 arm_gemm::Activation gemm_act;
33
34 // Early exit in case lower bound is other than 0, as it's not yet supported
35 if(act.b() != 0.f)
36 {
37 return gemm_act;
38 }
39
40 switch(act.activation())
41 {
42 case ActivationLayerInfo::ActivationFunction::RELU:
43 gemm_act.type = arm_gemm::Activation::Type::ReLU;
44 break;
45 case ActivationLayerInfo::ActivationFunction::BOUNDED_RELU:
46 gemm_act.type = arm_gemm::Activation::Type::BoundedReLU;
47 gemm_act.param1 = act.a();
48 gemm_act.param2 = 0.f;
49 break;
50 case ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU:
51 gemm_act.type = arm_gemm::Activation::Type::BoundedReLU;
52 gemm_act.param1 = act.a();
53 gemm_act.param2 = act.b();
54 break;
55 default:
56 gemm_act.type = arm_gemm::Activation::Type::None;
57 }
58
59 return gemm_act;
60}
61
62arm_conv::PaddingValues map_to_arm_conv_padding(const PadStrideInfo &pad_stride_info)
63{
64 return arm_conv::PaddingValues{ pad_stride_info.pad_left(),
65 pad_stride_info.pad_top(),
66 pad_stride_info.pad_right(),
67 pad_stride_info.pad_bottom() };
68}
69} // namespace assembly_utils
70} // namespace arm_compute