blob: f289c80d4be05b683831e2b941d3e05ef0960364 [file] [log] [blame]
Viet-Hoa Do29db3d22022-08-10 11:56:49 +01001/*
Michael Tyler7d9a6262023-02-01 16:37:07 +00002 * Copyright (c) 2022-2023 Arm Limited.
Viet-Hoa Do29db3d22022-08-10 11:56:49 +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 "arm_compute/core/Helpers.h"
SiCong Li91295492023-07-21 18:16:13 +010026#include "arm_compute/function_info/ActivationLayerInfo.h"
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +010027
Viet-Hoa Dofd472f02023-03-15 14:05:06 +000028#include "src/cpu/kernels/lut/list.h"
Viet-Hoa Do29db3d22022-08-10 11:56:49 +010029
30namespace arm_compute
31{
32namespace cpu
33{
Viet-Hoa Do66704132022-10-07 15:58:05 +010034#ifdef __aarch64__
Viet-Hoa Do29db3d22022-08-10 11:56:49 +010035void neon_q8_activation_lut(const ITensor *src, ITensor *dst, const ActivationLayerInfo &act_info, const Window &window)
36{
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +010037 ARM_COMPUTE_ERROR_ON(src->info()->data_type() != DataType::QASYMM8 &&
38 src->info()->data_type() != DataType::QASYMM8_SIGNED);
Michael Tyler7d9a6262023-02-01 16:37:07 +000039 const auto window_end_x = window.x().end();
40 Window win_collapsed = window.collapse_if_possible(window, Window::DimZ);
Viet-Hoa Do29db3d22022-08-10 11:56:49 +010041 win_collapsed.set(Window::DimX, Window::Dimension(0, 1, 1));
42 Iterator input(src, win_collapsed);
43 Iterator output(dst, win_collapsed);
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +010044 execute_window_loop(
45 win_collapsed,
46 [&](const Coordinates &)
47 {
48 const auto input_ptr = reinterpret_cast<const uint8_t *>(input.ptr());
49 auto output_ptr = reinterpret_cast<uint8_t *>(output.ptr());
50 lut_u8_neon(act_info.lut().data(), 1u, window_end_x, &input_ptr, &output_ptr);
51 },
52 input, output);
Viet-Hoa Do29db3d22022-08-10 11:56:49 +010053}
Viet-Hoa Do66704132022-10-07 15:58:05 +010054#endif // __aarch64__
Viet-Hoa Do29db3d22022-08-10 11:56:49 +010055} // namespace cpu
56} // namespace arm_compute