blob: 69ac50b4d0ba6b105da400fb5f21864e86e613e0 [file] [log] [blame]
Anthony Barbier7068f992017-10-26 15:23:08 +01001/*
Frank Lei4406fd62018-02-01 14:47:14 +08002 * Copyright (c) 2017-2018 ARM Limited.
Anthony Barbier7068f992017-10-26 15:23:08 +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 */
24layout(local_size_x = LOCAL_SIZE_X, local_size_y = LOCAL_SIZE_Y, local_size_z = LOCAL_SIZE_Z) in;
Anthony Barbier7068f992017-10-26 15:23:08 +010025
zhenglin82588e82017-12-27 16:08:29 +080026#include "helpers_cs.h"
Anthony Barbier7068f992017-10-26 15:23:08 +010027
zhenglin82588e82017-12-27 16:08:29 +080028#if defined(DATA_TYPE_FP16)
29precision mediump float;
30#endif /*DATA_TYPE_FP16*/
Anthony Barbier7068f992017-10-26 15:23:08 +010031
32/** This kernel concatenates the input tensor into the output tensor along the third dimension
33 *
zhenglin82588e82017-12-27 16:08:29 +080034 * @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 Barbier7068f992017-10-26 15:23:08 +010040 */
zhenglin82588e82017-12-27 16:08:29 +080041SHADER_PARAMS_DECLARATION
42{
43 Tensor3DAttributes src_attrs;
44 Tensor3DAttributes dst_attrs;
45};
46
47#ifdef DATA_TYPE_FP32
48TENSOR_DECLARATION(1, srcBuffer, float, src_ptr, src_shift, 2, readonly);
49TENSOR_DECLARATION(2, dstBuffer, float, dst_ptr, dst_shift, 2, writeonly);
50
Anthony Barbier7068f992017-10-26 15:23:08 +010051void main(void)
52{
zhenglin82588e82017-12-27 16:08:29 +080053 Tensor3DIterator src_iter = CONVERT_TO_TENSOR3D_ITERATOR(src_attrs, src_shift);
54 Tensor3DIterator dst_iter = CONVERT_TO_TENSOR3D_ITERATOR(dst_attrs, dst_shift);
Anthony Barbier7068f992017-10-26 15:23:08 +010055
Frank Lei4406fd62018-02-01 14:47:14 +080056 float tmp = LOAD(src_ptr, TENSOR3D_OFFSET(src_iter, -OFFSET_X, -OFFSET_Y, 0));
57 STORE_CURRENT_ITEM(dst_ptr, dst_iter, tmp);
Anthony Barbier7068f992017-10-26 15:23:08 +010058}
59
60#elif defined(DATA_TYPE_FP16)
zhenglin82588e82017-12-27 16:08:29 +080061TENSOR_DECLARATION(1, srcBuffer, uvec2, src_ptr, src_shift, 3, readonly);
62TENSOR_DECLARATION(2, dstBuffer, uvec2, dst_ptr, dst_shift, 3, writeonly);
Anthony Barbier7068f992017-10-26 15:23:08 +010063
Anthony Barbier7068f992017-10-26 15:23:08 +010064void main(void)
65{
zhenglin82588e82017-12-27 16:08:29 +080066 Tensor3DIterator src_iter = CONVERT_TO_TENSOR3D_ITERATOR(src_attrs, src_shift);
67 Tensor3DIterator dst_iter = CONVERT_TO_TENSOR3D_ITERATOR(dst_attrs, dst_shift);
Anthony Barbier7068f992017-10-26 15:23:08 +010068
Frank Lei4406fd62018-02-01 14:47:14 +080069 uvec2 tmp = LOAD(src_ptr, TENSOR3D_OFFSET(src_iter, -OFFSET_X, -OFFSET_Y, 0));
70 STORE_CURRENT_ITEM(dst_ptr, dst_iter, tmp);
Anthony Barbier7068f992017-10-26 15:23:08 +010071}
zhenglin82588e82017-12-27 16:08:29 +080072#endif /*DATA_TYPE_FP16*/