blob: b3c4da05d4ebcee352be11ba1b3b2ef07a2c6538 [file] [log] [blame]
Michele Di Giorgio56dd7262017-07-27 09:53:49 +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#ifndef __ARM_COMPUTE_CLQUANTIZATIONLAYER_H__
25#define __ARM_COMPUTE_CLQUANTIZATIONLAYER_H__
26
27#include "arm_compute/runtime/IFunction.h"
28
29#include "arm_compute/core/CL/kernels/CLMinMaxLayerKernel.h"
30#include "arm_compute/core/CL/kernels/CLQuantizationLayerKernel.h"
31#include "arm_compute/runtime/CL/CLTensor.h"
32
33namespace arm_compute
34{
35class ICLTensor;
36
37/** Basic function to simulate a quantization layer. This function calls the following CL kernels:
38 *
39 * @note The implementation supports only 3D input tensors.
40 *
41 * -# @ref CLMinMaxLayerKernel
42 * -# @ref CLQuantizationLayerKernel
43 *
44 */
45class CLQuantizationLayer : public IFunction
46{
47public:
48 /** Default constructor */
49 CLQuantizationLayer();
50 /** Set the input and output tensors.
51 *
52 * @param[in] input Source tensor with at least 3 dimensions. The dimensions over the third will be interpreted as batches. Data types supported: F32.
53 * @param[out] output Destination tensor with the same dimensions of input. Output data type must be U8.
54 */
55 void configure(const ICLTensor *input, ICLTensor *output);
56
57 // Inherited methods overridden:
58 void run() override;
59
60private:
61 CLQuantizationLayerKernel _quantize_kernel;
62 CLMinMaxLayerKernel _min_max_kernel;
63 CLTensor _min_max;
64};
65}
66#endif /* __ARM_COMPUTE_CLQUANTIZATIONLAYER_H__ */