blob: c973e964e4f93664c218a20acab190d2848f346a [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"
Viet-Hoa Dofd472f02023-03-15 14:05:06 +000027#include "src/cpu/kernels/lut/list.h"
Viet-Hoa Do29db3d22022-08-10 11:56:49 +010028
29namespace arm_compute
30{
31namespace cpu
32{
Viet-Hoa Do66704132022-10-07 15:58:05 +010033#ifdef __aarch64__
Viet-Hoa Do29db3d22022-08-10 11:56:49 +010034void neon_q8_activation_lut(const ITensor *src, ITensor *dst, const ActivationLayerInfo &act_info, const Window &window)
35{
Pablo Marquez Tello48cfd5f2023-06-09 11:22:29 +010036 ARM_COMPUTE_ERROR_ON(src->info()->data_type() != DataType::QASYMM8 && src->info()->data_type() != DataType::QASYMM8_SIGNED);
Michael Tyler7d9a6262023-02-01 16:37:07 +000037 const auto window_end_x = window.x().end();
38 Window win_collapsed = window.collapse_if_possible(window, Window::DimZ);
Viet-Hoa Do29db3d22022-08-10 11:56:49 +010039 win_collapsed.set(Window::DimX, Window::Dimension(0, 1, 1));
40 Iterator input(src, win_collapsed);
41 Iterator output(dst, win_collapsed);
42 execute_window_loop(win_collapsed, [&](const Coordinates &)
43 {
44 const auto input_ptr = reinterpret_cast<const uint8_t *>(input.ptr());
45 auto output_ptr = reinterpret_cast<uint8_t *>(output.ptr());
Viet-Hoa Dofd472f02023-03-15 14:05:06 +000046 lut_u8_neon(act_info.lut().data(), 1u, window_end_x, &input_ptr, &output_ptr);
Viet-Hoa Do29db3d22022-08-10 11:56:49 +010047 },
48 input, output);
Viet-Hoa Do29db3d22022-08-10 11:56:49 +010049}
Viet-Hoa Do66704132022-10-07 15:58:05 +010050#endif // __aarch64__
Viet-Hoa Do29db3d22022-08-10 11:56:49 +010051} // namespace cpu
52} // namespace arm_compute