1/* 2 * Copyright (c) 2020-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 25#include "helpers.h" 26 27/** Performs max unpooling function with pool size equal to 2. 28 * 29 * @note Datatype must be passed using -DDATA_TYPE e.g. -DDATA_TYPE=float. Supported data types are F16/F32 30 * @note The width of the output tensor must be passed using -DWIDTH_DST e.g. -DWIDTH_DST=24 31 * @note The height of the output tensor must be passed using -DHEIGHT_DST e.g. -DHEIGHT_DST=54 32 * @note The depth of the output tensor must be passed using -DDEPTH_DST e.g. -DDEPTH_DST=32 33 * 34 * @param[in] input_ptr Pointer to the source tensor. Supported data types: F16/F32 35 * @param[in] input_stride_x Stride of the source tensor in X dimension (in bytes) 36 * @param[in] input_step_x input_stride_x * number of elements along X processed per workitem(in bytes) 37 * @param[in] input_stride_y Stride of the source tensor in Y dimension (in bytes) 38 * @param[in] input_step_y input_stride_y * number of elements along Y processed per workitem(in bytes) 39 * @param[in] input_stride_z Stride of the source tensor in Z dimension (in bytes) 40 * @param[in] input_step_z input_stride_z * number of elements along Z processed per workitem(in bytes) 41 * @param[in] input_offset_first_element_in_bytes The offset of the first element in the source tensor 42 * @param[out] output_ptr Pointer to the output tensor. Supported data types: same as @p input_ptr 43 * @param[in] output_stride_x Stride of the output tensor in X dimension (in bytes) 44 * @param[in] output_step_x output_stride_x * number of elements along X processed per workitem(in bytes) 45 * @param[in] output_stride_y Stride of the output tensor in Y dimension (in bytes) 46 * @param[in] output_step_y output_stride_y * number of elements along Y processed per workitem(in bytes) 47 * @param[in] output_stride_z Stride of the output tensor in Z dimension (in bytes) 48 * @param[in] output_step_z output_stride_z * number of elements along Z processed per workitem(in bytes) 49 * @param[in] output_offset_first_element_in_bytes The offset of the first element in the output tensor 50 * @param[in] indices_ptr Pointer to the indices tensor. Supported data types: U32 51 * @param[in] indices_stride_x Stride of the indices tensor in X dimension (in bytes) 52 * @param[in] indices_step_x indices_stride_x * number of elements along X processed per workitem(in bytes) 53 * @param[in] indices_stride_y Stride of the indices tensor in Y dimension (in bytes) 54 * @param[in] indices_step_y indices_stride_y * number of elements along Y processed per workitem(in bytes) 55 * @param[in] indices_stride_z Stride of the indices tensor in Z dimension (in bytes) 56 * @param[in] indices_step_z indices_stride_z * number of elements along Z processed per workitem(in bytes) 57 * @param[in] indices_offset_first_element_in_bytes The offset of the first element in the indices tensor 58 */ 59__kernel void max_unpooling_layer_2( 60 TENSOR3D_DECLARATION(input), 61 TENSOR3D_DECLARATION(output), 62 TENSOR3D_DECLARATION(indices)) 63{ 64 Tensor3D input = CONVERT_TO_TENSOR3D_STRUCT(input); 65 Tensor3D output = CONVERT_TO_TENSOR3D_STRUCT_NO_UPDATE_PTR(output); 66 Tensor3D indices = CONVERT_TO_TENSOR3D_STRUCT(indices); 67 68 unsigned int index = *((__global unsigned int *)indices.ptr); 69 DATA_TYPE value = *((__global DATA_TYPE *)input.ptr); 70 71 *((__global DATA_TYPE *)tensor3D_index2ptr(&output, WIDTH_DST, HEIGHT_DST, DEPTH_DST, index)) = value; 72}