Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 1 | /* |
Georgios Pinitas | 78c0090 | 2018-01-09 17:33:11 +0000 | [diff] [blame] | 2 | * Copyright (c) 2017-2018 ARM Limited. |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 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 | #ifndef __ARM_COMPUTE_CLWEIGHTSRESHAPEKERNEL_H__ |
| 25 | #define __ARM_COMPUTE_CLWEIGHTSRESHAPEKERNEL_H__ |
| 26 | |
| 27 | #include "arm_compute/core/CL/ICLKernel.h" |
| 28 | |
| 29 | namespace arm_compute |
| 30 | { |
| 31 | class CLWeightsReshapeKernel : public ICLKernel |
| 32 | { |
| 33 | public: |
Gian Marco Iodice | 5cb4c42 | 2017-06-23 10:38:25 +0100 | [diff] [blame] | 34 | /** Constructor.*/ |
| 35 | CLWeightsReshapeKernel(); |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 36 | /** Prevent instances of this class from being copied (As this class contains pointers) */ |
| 37 | CLWeightsReshapeKernel(const CLWeightsReshapeKernel &) = delete; |
| 38 | /** Prevent instances of this class from being copied (As this class contains pointers) */ |
| 39 | CLWeightsReshapeKernel &operator=(const CLWeightsReshapeKernel &) = delete; |
| 40 | /** Allow instances of this class to be moved */ |
| 41 | CLWeightsReshapeKernel(CLWeightsReshapeKernel &&) = default; |
| 42 | /** Allow instances of this class to be moved */ |
| 43 | CLWeightsReshapeKernel &operator=(CLWeightsReshapeKernel &&) = default; |
| 44 | /** Default destructor */ |
| 45 | ~CLWeightsReshapeKernel() = default; |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 46 | /** Set the input and output of the kernel. |
| 47 | * |
| 48 | * @param[in] input The input tensor to convert. Weights are 4D tensor with dimensions [kernel_x, kernel_y, IFM, OFM] if shared, |
Gian Marco | c827990 | 2017-11-27 16:35:28 +0000 | [diff] [blame] | 49 | * and 5D tensor with dimensions [kernel_x, kernel_y, IFM, OFM, num_patches] if unshared. Data types supported: QS8/QS16/QASYMM8/F16/F32 |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 50 | * @param[in] biases The shared biases tensor to append. Bias is 1D tensor with dimensions [OFM] if shared and 2D tensor with |
| 51 | * dimensions [OFM, num_patches] if unshared. Data types supported: Same as @p input |
Chunosov | 5124be5 | 2017-11-22 20:42:13 +0700 | [diff] [blame] | 52 | * @warning Appending biases to weights reshaped matrix is not supported for quantized asymmetric types. |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 53 | * @param[out] output The output tensor. Should be a 2D Tensor. Data types supported: Same as @p input |
| 54 | */ |
| 55 | void configure(const ICLTensor *input, const ICLTensor *biases, ICLTensor *output); |
Georgios Pinitas | 78c0090 | 2018-01-09 17:33:11 +0000 | [diff] [blame] | 56 | /** Static function to check if given info will lead to a valid configuration of @ref CLWeightsReshapeKernel |
| 57 | * |
| 58 | * @param[in] input The input tensor to convert. Weights are 4D tensor with dimensions [kernel_x, kernel_y, IFM, OFM] if shared, |
| 59 | * and 5D tensor with dimensions [kernel_x, kernel_y, IFM, OFM, num_patches] if unshared. Data types supported: QS8/QS16/QASYMM8/F16/F32 |
| 60 | * @param[in] biases The shared biases tensor to append. Bias is 1D tensor with dimensions [OFM] if shared and 2D tensor with |
| 61 | * dimensions [OFM, num_patches] if unshared. Data types supported: Same as @p input |
| 62 | * @warning Appending biases to weights reshaped matrix is not supported for quantized asymmetric types. |
| 63 | * @param[in] output The output tensor. Should be a 2D Tensor. Data types supported: Same as @p input |
| 64 | * |
| 65 | * @return a status |
| 66 | */ |
| 67 | static Status validate(const ITensorInfo *input, const ITensorInfo *biases, const ITensorInfo *output); |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 68 | |
| 69 | // Inherited methods overridden: |
Gian Marco Iodice | 5cb4c42 | 2017-06-23 10:38:25 +0100 | [diff] [blame] | 70 | void run(const Window &window, cl::CommandQueue &queue) override; |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 71 | |
Gian Marco Iodice | 5cb4c42 | 2017-06-23 10:38:25 +0100 | [diff] [blame] | 72 | private: |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 73 | const ICLTensor *_input; |
| 74 | const ICLTensor *_biases; |
| 75 | ICLTensor *_output; |
| 76 | }; |
Gian Marco Iodice | f670a0a | 2017-09-18 12:20:45 +0100 | [diff] [blame] | 77 | } // namespace arm_compute |
Gian Marco Iodice | 13edbff | 2017-06-26 17:20:16 +0100 | [diff] [blame] | 78 | #endif /*__ARM_COMPUTE_CLWEIGHTSRESHAPEKERNEL_H__ */ |