blob: b9ede12e3d024bfd147641b89669fa5b915c26cd [file] [log] [blame]
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001/*
Georgios Pinitas78c00902018-01-09 17:33:11 +00002 * Copyright (c) 2017-2018 ARM Limited.
Anthony Barbier6ff3b192017-09-04 18:44:23 +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 */
24#ifndef __ARM_COMPUTE_CLWEIGHTSRESHAPEKERNEL_H__
25#define __ARM_COMPUTE_CLWEIGHTSRESHAPEKERNEL_H__
26
27#include "arm_compute/core/CL/ICLKernel.h"
28
29namespace arm_compute
30{
31class CLWeightsReshapeKernel : public ICLKernel
32{
33public:
Gian Marco Iodice5cb4c422017-06-23 10:38:25 +010034 /** Constructor.*/
35 CLWeightsReshapeKernel();
Anthony Barbier6ff3b192017-09-04 18:44:23 +010036 /** 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 Barbier6ff3b192017-09-04 18:44:23 +010046 /** 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 Marcoc8279902017-11-27 16:35:28 +000049 * and 5D tensor with dimensions [kernel_x, kernel_y, IFM, OFM, num_patches] if unshared. Data types supported: QS8/QS16/QASYMM8/F16/F32
Anthony Barbier6ff3b192017-09-04 18:44:23 +010050 * @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
Chunosov5124be52017-11-22 20:42:13 +070052 * @warning Appending biases to weights reshaped matrix is not supported for quantized asymmetric types.
Anthony Barbier6ff3b192017-09-04 18:44:23 +010053 * @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 Pinitas78c00902018-01-09 17:33:11 +000056 /** 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 Barbier6ff3b192017-09-04 18:44:23 +010068
69 // Inherited methods overridden:
Gian Marco Iodice5cb4c422017-06-23 10:38:25 +010070 void run(const Window &window, cl::CommandQueue &queue) override;
Anthony Barbier6ff3b192017-09-04 18:44:23 +010071
Gian Marco Iodice5cb4c422017-06-23 10:38:25 +010072private:
Anthony Barbier6ff3b192017-09-04 18:44:23 +010073 const ICLTensor *_input;
74 const ICLTensor *_biases;
75 ICLTensor *_output;
76};
Gian Marco Iodicef670a0a2017-09-18 12:20:45 +010077} // namespace arm_compute
Gian Marco Iodice13edbff2017-06-26 17:20:16 +010078#endif /*__ARM_COMPUTE_CLWEIGHTSRESHAPEKERNEL_H__ */