Debian Codegraph @

arm_compute/runtime/experimental/operators/CpuQuantize.h

raw
1 /*
2 * Copyright (c) 2017-2021, 2024 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 ACL_ARM_COMPUTE_RUNTIME_EXPERIMENTAL_OPERATORS_CPUQUANTIZE_H
25 #define ACL_ARM_COMPUTE_RUNTIME_EXPERIMENTAL_OPERATORS_CPUQUANTIZE_H
26
27 #include "arm_compute/core/ITensorInfo.h"
28 #include "arm_compute/runtime/NEON/INEOperator.h"
29
30 #include "src/cpu/ICpuOperator.h"
31
32 #include <memory>
33
34 /*
35 * A shallow wrapper for arm_compute::cpu::CpuQuantize.
36 * Any new features should be added to arm_compute::cpu::CpuQuantize and
37 * arm_compute::experimental::op::CpuQuantize should remain a shallow wrapper.
38 */
39 namespace arm_compute
40 {
41 namespace experimental
42 {
43 namespace op
44 {
45
46 /** A simple wrapper class which runs cpu::CpuQuantize */
47 class CpuQuantize : public arm_compute::experimental::INEOperator
48 {
49 public:
50 CpuQuantize();
51 /** Default Destructor */
52 ~CpuQuantize();
53 /** Prevent instances of this class from being copied (As this class contains pointers) */
54 CpuQuantize(const CpuQuantize &) = delete;
55 /** Default move constructor */
56 CpuQuantize(CpuQuantize &&) = default;
57 /** Prevent instances of this class from being copied (As this class contains pointers) */
58 CpuQuantize &operator=(const CpuQuantize &) = delete;
59 /** Default move assignment operator */
60 CpuQuantize &operator=(CpuQuantize &&) = default;
61 /** Set the input and output tensors.
62 *
63 * Valid data layouts:
64 * - All
65 *
66 * Valid data type configurations:
67 * |src |dst |
68 * |:------------------|:--------------------------------------|
69 * |QASYMM8 |QASYMM8, QASYMM8_SIGNED, QASYMM16 |
70 * |QASYMM8_SIGNED |QASYMM8, QASYMM8_SIGNED, QASYMM16 |
71 * |F16 |QASYMM8, QASYMM8_SIGNED, QASYMM16 |
72 * |F32 |QASYMM8, QASYMM8_SIGNED, QASYMM16 |
73 *
74 * @param[in] input Source tensor. The dimensions over the third will be interpreted as batches. Data types supported: QASYMM8/QASYMM8_SIGNED/F32/F16.
75 * @param[out] output Destination tensor with the same dimensions of input. Data types supported: QASYMM8/QASYMM8_SIGNED/QASYMM16
76 */
77 void configure(const ITensorInfo *input, ITensorInfo *output);
78 /** Static function to check if given info will lead to a valid configuration of @ref CpuQuantize
79 *
80 * Similar to @ref CpuQuantize::configure()
81 * @return a status
82 */
83 static Status validate(const ITensorInfo *input, const ITensorInfo *output);
84
85 // Inherited methods overridden:
86 void run(ITensorPack &tensors) override;
87
88 private:
89 struct Impl;
90 std::unique_ptr<Impl> impl_;
91 };
92 } // namespace op
93 } // namespace experimental
94 } // namespace arm_compute
95 #endif // ACL_ARM_COMPUTE_RUNTIME_EXPERIMENTAL_OPERATORS_CPUQUANTIZE_H