Anthony Barbier | 7068f99 | 2017-10-26 15:23:08 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2017 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 | layout(local_size_x = LOCAL_SIZE_X, local_size_y = LOCAL_SIZE_Y, local_size_z = LOCAL_SIZE_Z) in; |
Anthony Barbier | 7068f99 | 2017-10-26 15:23:08 +0100 | [diff] [blame] | 25 | |
zhenglin | 82588e8 | 2017-12-27 16:08:29 +0800 | [diff] [blame] | 26 | #include "helpers_cs.h" |
Anthony Barbier | 7068f99 | 2017-10-26 15:23:08 +0100 | [diff] [blame] | 27 | |
zhenglin | 82588e8 | 2017-12-27 16:08:29 +0800 | [diff] [blame] | 28 | #if defined(DATA_TYPE_FP16) |
| 29 | precision mediump float; |
| 30 | #endif /*DATA_TYPE_FP16*/ |
Anthony Barbier | 7068f99 | 2017-10-26 15:23:08 +0100 | [diff] [blame] | 31 | |
| 32 | /** This kernel concatenates the input tensor into the output tensor along the third dimension |
| 33 | * |
zhenglin | 82588e8 | 2017-12-27 16:08:29 +0800 | [diff] [blame] | 34 | * @note The data type must be passed at compile time using "#define DATA_TYPE_NAME". e.g. "#define DATA_TYPE_FP32" |
| 35 | * |
| 36 | * @param[in] src_ptr Pointer to the source tensor. Supported data types: F16/F32 |
| 37 | * @param[in] src_attrs The attributes of the source tensor |
| 38 | * @param[out] dst_ptr Pointer to the destination tensor. Supported data types: same as @p src_ptr |
| 39 | * @param[in] dst_attrs The attributes of the destination tensor |
Anthony Barbier | 7068f99 | 2017-10-26 15:23:08 +0100 | [diff] [blame] | 40 | */ |
zhenglin | 82588e8 | 2017-12-27 16:08:29 +0800 | [diff] [blame] | 41 | SHADER_PARAMS_DECLARATION |
| 42 | { |
| 43 | Tensor3DAttributes src_attrs; |
| 44 | Tensor3DAttributes dst_attrs; |
| 45 | }; |
| 46 | |
| 47 | #ifdef DATA_TYPE_FP32 |
| 48 | TENSOR_DECLARATION(1, srcBuffer, float, src_ptr, src_shift, 2, readonly); |
| 49 | TENSOR_DECLARATION(2, dstBuffer, float, dst_ptr, dst_shift, 2, writeonly); |
| 50 | |
Anthony Barbier | 7068f99 | 2017-10-26 15:23:08 +0100 | [diff] [blame] | 51 | void main(void) |
| 52 | { |
zhenglin | 82588e8 | 2017-12-27 16:08:29 +0800 | [diff] [blame] | 53 | Tensor3DIterator src_iter = CONVERT_TO_TENSOR3D_ITERATOR(src_attrs, src_shift); |
| 54 | Tensor3DIterator dst_iter = CONVERT_TO_TENSOR3D_ITERATOR(dst_attrs, dst_shift); |
Anthony Barbier | 7068f99 | 2017-10-26 15:23:08 +0100 | [diff] [blame] | 55 | |
zhenglin | 82588e8 | 2017-12-27 16:08:29 +0800 | [diff] [blame] | 56 | float tmp = LOAD(src_ptr, TENSOR3D_OFFSET(src_iter, -OFFSETS_X, -OFFSETS_Y, 0)); |
| 57 | STORE(dst_ptr, TENSOR_OFFSET_ADVANCE_IN_BYTES(dst_iter, OFFSETS_Z), tmp); |
Anthony Barbier | 7068f99 | 2017-10-26 15:23:08 +0100 | [diff] [blame] | 58 | } |
| 59 | |
| 60 | #elif defined(DATA_TYPE_FP16) |
zhenglin | 82588e8 | 2017-12-27 16:08:29 +0800 | [diff] [blame] | 61 | TENSOR_DECLARATION(1, srcBuffer, uvec2, src_ptr, src_shift, 3, readonly); |
| 62 | TENSOR_DECLARATION(2, dstBuffer, uvec2, dst_ptr, dst_shift, 3, writeonly); |
Anthony Barbier | 7068f99 | 2017-10-26 15:23:08 +0100 | [diff] [blame] | 63 | |
Anthony Barbier | 7068f99 | 2017-10-26 15:23:08 +0100 | [diff] [blame] | 64 | void main(void) |
| 65 | { |
zhenglin | 82588e8 | 2017-12-27 16:08:29 +0800 | [diff] [blame] | 66 | Tensor3DIterator src_iter = CONVERT_TO_TENSOR3D_ITERATOR(src_attrs, src_shift); |
| 67 | Tensor3DIterator dst_iter = CONVERT_TO_TENSOR3D_ITERATOR(dst_attrs, dst_shift); |
Anthony Barbier | 7068f99 | 2017-10-26 15:23:08 +0100 | [diff] [blame] | 68 | |
zhenglin | 82588e8 | 2017-12-27 16:08:29 +0800 | [diff] [blame] | 69 | uvec2 tmp = LOAD(src_ptr, TENSOR3D_OFFSET(src_iter, -OFFSETS_X, -OFFSETS_Y, 0)); |
| 70 | STORE(dst_ptr, TENSOR_OFFSET_ADVANCE_IN_BYTES(dst_iter, OFFSETS_Z), tmp); |
Anthony Barbier | 7068f99 | 2017-10-26 15:23:08 +0100 | [diff] [blame] | 71 | } |
zhenglin | 82588e8 | 2017-12-27 16:08:29 +0800 | [diff] [blame] | 72 | #endif /*DATA_TYPE_FP16*/ |