Compute Library
 22.11
impl.cpp
Go to the documentation of this file.
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  */
25 namespace arm_compute
26 {
27 class ITensor;
28 class Window;
29 namespace cpu
30 {
31 template <typename T>
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
template void max_unpooling< uint8_t >(const ITensor *input, const ITensor *indices, ITensor *output, const Window &window)
Interface for CPU tensor.
Definition: ITensor.h:36
Copyright (c) 2017-2022 Arm Limited.
void max_unpooling(const ITensor *input, const ITensor *indices, ITensor *output, const Window &window)
Definition: impl.cpp:32
Coordinates of an item.
Definition: Coordinates.h:37
virtual uint8_t * buffer() const =0
Interface to be implemented by the child class to return a pointer to CPU memory. ...
virtual ITensorInfo * info() const =0
Interface to be implemented by the child class to return the tensor&#39;s metadata.
constexpr uint8_t * ptr() const
Return a pointer to the current pixel.
Definition: Helpers.inl:139
template void max_unpooling< float >(const ITensor *input, const ITensor *indices, ITensor *output, const Window &window)
void execute_window_loop(const Window &w, L &&lambda_function, Ts &&... iterators)
Iterate through the passed window, automatically adjusting the iterators and calling the lambda_funct...
Definition: Helpers.inl:77
virtual const Strides & strides_in_bytes() const =0
The strides in bytes for accessing each dimension of the tensor.
Iterator updated by execute_window_loop for each window element.
Definition: Helpers.h:46
Describe a multidimensional execution window.
Definition: Window.h:39
template void max_unpooling< int8_t >(const ITensor *input, const ITensor *indices, ITensor *output, const Window &window)