blob: 01e0f8af7caeb0d77910f346471df1c41cd056b3 [file] [log] [blame]
Anthony Barbier7068f992017-10-26 15:23:08 +01001/*
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
25layout(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 +010026
zhenglin07d40542018-01-04 15:50:59 +080027#include "helpers_cs.h"
Anthony Barbier7068f992017-10-26 15:23:08 +010028
zhenglin07d40542018-01-04 15:50:59 +080029/** Performs a pixelwise multiplication with float scale of float inputs.
Anthony Barbier7068f992017-10-26 15:23:08 +010030 *
zhenglin07d40542018-01-04 15:50:59 +080031 * @param[in] src1_ptr Pointer to the first source tensor. Supported data types: F32
32 * @param[in] src1_attrs The attributes of the first source tensor
33 * @param[in] src2_ptr Pointer to the second source tensor. Supported data types: Same as @p src1_ptr
34 * @param[in] src2_attrs The attributes of the second source tensor
35 * @param[out] dst_ptr Pointer to the destination tensor. Supported data types: Same as @p src1_ptr
36 * @param[in] dst_attrs The attributes of the destination tensor
37 * @param[in] scale Float scaling factor. Supported data types: F32
Anthony Barbier7068f992017-10-26 15:23:08 +010038 */
zhenglin07d40542018-01-04 15:50:59 +080039SHADER_PARAMS_DECLARATION
40{
41 Tensor3DAttributes src1_attrs;
42 Tensor3DAttributes src2_attrs;
43 Tensor3DAttributes dst_attrs;
44};
45TENSOR_DECLARATION(1, src1Buffer, float, src1_ptr, src1_shift, 2, readonly);
46TENSOR_DECLARATION(2, src2Buffer, float, src2_ptr, src2_shift, 2, readonly);
47TENSOR_DECLARATION(3, dstBuffer, float, dst_ptr, dst_shift, 2, writeonly);
48
Anthony Barbier7068f992017-10-26 15:23:08 +010049void main()
50{
51 // Get pixels pointer
zhenglin07d40542018-01-04 15:50:59 +080052 Tensor3DIterator src1_iter = CONVERT_TO_TENSOR3D_ITERATOR(src1_attrs, src1_shift);
53 Tensor3DIterator src2_iter = CONVERT_TO_TENSOR3D_ITERATOR(src2_attrs, src2_shift);
54 Tensor3DIterator dst_iter = CONVERT_TO_TENSOR3D_ITERATOR(dst_attrs, dst_shift);
Anthony Barbier7068f992017-10-26 15:23:08 +010055
zhenglin07d40542018-01-04 15:50:59 +080056 float result = LOAD_CURRENT_ITEM(src1_ptr, src1_iter) * LOAD_CURRENT_ITEM(src2_ptr, src2_iter) * float(SCALE);
57 STORE_CURRENT_ITEM(dst_ptr, dst_iter, result);
Anthony Barbier7068f992017-10-26 15:23:08 +010058}