1 /*
2 * Copyright (c) 2020-2022 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/cpu/kernels/maxunpool/generic/neon/impl.h"
25 namespace arm_compute
26 {
27 class ITensor;
28 class Window;
29 namespace cpu
30 {
31 template <typename T>
max_unpooling(const ITensor * input,const ITensor * indices,ITensor * output,const Window & window)32 void max_unpooling(const ITensor *input, const ITensor *indices, ITensor *output, const Window &window)
33 {
34 Iterator input_itr(input, window);
35 Iterator indices_itr(indices, window);
36 auto out_ptr = reinterpret_cast<T *>(output->buffer());
37 const int out_stride_w = static_cast<int>(output->info()->strides_in_bytes()[3]);
38 execute_window_loop(window, [&](const Coordinates & id)
39 {
40 auto vindices = reinterpret_cast<uint32_t *>(indices_itr.ptr());
41 auto vinput = reinterpret_cast<T *>(input_itr.ptr());
42 out_ptr[id[3] * out_stride_w / sizeof(T) + *vindices] = *vinput;
43 },
44 input_itr, indices_itr);
45 }
46 template void max_unpooling<float>(const ITensor *input, const ITensor *indices, ITensor *output, const Window &window);
47 template void max_unpooling<int8_t>(const ITensor *input, const ITensor *indices, ITensor *output, const Window &window);
48 template void max_unpooling<uint8_t>(const ITensor *input, const ITensor *indices, ITensor *output, const Window &window);
49
50 #if defined(__ARM_FEATURE_FP16_VECTOR_ARITHMETIC) && defined(ENABLE_FP16_KERNELS)
51 template void max_unpooling<float16_t>(const ITensor *input, const ITensor *indices, ITensor *output, const Window &window);
52 #endif //defined(__ARM_FEATURE_FP16_VECTOR_ARITHMETIC) && defined(ENABLE_FP16_KERNELS)
53 } // namespace cpu
54 } // namespace arm_compute
55