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 | |
| 25 | 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] | 26 | |
zhenglin | 07d4054 | 2018-01-04 15:50:59 +0800 | [diff] [blame] | 27 | #include "helpers_cs.h" |
Anthony Barbier | 7068f99 | 2017-10-26 15:23:08 +0100 | [diff] [blame] | 28 | |
zhenglin | 07d4054 | 2018-01-04 15:50:59 +0800 | [diff] [blame] | 29 | /** Performs a pixelwise multiplication with float scale of float inputs. |
Anthony Barbier | 7068f99 | 2017-10-26 15:23:08 +0100 | [diff] [blame] | 30 | * |
zhenglin | 07d4054 | 2018-01-04 15:50:59 +0800 | [diff] [blame] | 31 | * @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 Barbier | 7068f99 | 2017-10-26 15:23:08 +0100 | [diff] [blame] | 38 | */ |
zhenglin | 07d4054 | 2018-01-04 15:50:59 +0800 | [diff] [blame] | 39 | SHADER_PARAMS_DECLARATION |
| 40 | { |
| 41 | Tensor3DAttributes src1_attrs; |
| 42 | Tensor3DAttributes src2_attrs; |
| 43 | Tensor3DAttributes dst_attrs; |
| 44 | }; |
| 45 | TENSOR_DECLARATION(1, src1Buffer, float, src1_ptr, src1_shift, 2, readonly); |
| 46 | TENSOR_DECLARATION(2, src2Buffer, float, src2_ptr, src2_shift, 2, readonly); |
| 47 | TENSOR_DECLARATION(3, dstBuffer, float, dst_ptr, dst_shift, 2, writeonly); |
| 48 | |
Anthony Barbier | 7068f99 | 2017-10-26 15:23:08 +0100 | [diff] [blame] | 49 | void main() |
| 50 | { |
| 51 | // Get pixels pointer |
zhenglin | 07d4054 | 2018-01-04 15:50:59 +0800 | [diff] [blame] | 52 | 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 Barbier | 7068f99 | 2017-10-26 15:23:08 +0100 | [diff] [blame] | 55 | |
zhenglin | 07d4054 | 2018-01-04 15:50:59 +0800 | [diff] [blame] | 56 | 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 Barbier | 7068f99 | 2017-10-26 15:23:08 +0100 | [diff] [blame] | 58 | } |