2 * Copyright (c) 2018 Samsung Electronics Co., Ltd. All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 * Copyright (c) 2016-2018 ARM Limited.
20 * SPDX-License-Identifier: MIT
22 * Permission is hereby granted, free of charge, to any person obtaining a copy
23 * of this software and associated documentation files (the "Software"), to
24 * deal in the Software without restriction, including without limitation the
25 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
26 * sell copies of the Software, and to permit persons to whom the Software is
27 * furnished to do so, subject to the following conditions:
29 * The above copyright notice and this permission notice shall be included in all
30 * copies or substantial portions of the Software.
32 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
33 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
34 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
35 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
36 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
37 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
42 * @file CLHashtableLookupKernel.h
43 * @ingroup COM_AI_RUNTIME
44 * @brief This file defines CLHashtableLookupKernel class
47 #ifndef __ARM_COMPUTE_CLHASHTABLELOOKUPKERNEL_H__
48 #define __ARM_COMPUTE_CLHASHTABLELOOKUPKERNEL_H__
50 #include "arm_compute/core/CL/ICLKernel.h"
51 #include "arm_compute/runtime/CL/CLTensor.h"
58 * @brief Class to perform HashtableLookup operation with opencl kernel
60 class CLHashtableLookupKernel : public ICLKernel
64 * @brief Construct a CLHashtableLookupKernel object
66 CLHashtableLookupKernel();
69 * @brief Prevent instances of this class from being copied (As this class contains pointers)
71 CLHashtableLookupKernel(const CLHashtableLookupKernel &) = delete;
74 * @brief Prevent instances of this class from being copied (As this class contains pointers)
76 CLHashtableLookupKernel &operator=(const CLHashtableLookupKernel &) = delete;
79 * @brief Construct a CLHashtableLookupKernel object by using default move constructor
80 * @param[in] CLHashtableLookupKernel object to move
82 CLHashtableLookupKernel(CLHashtableLookupKernel &&) = default;
85 * @brief Move assignment operator
86 * @param[in] CLHashtableLookupKernel object to move
88 CLHashtableLookupKernel &operator=(CLHashtableLookupKernel &&) = default;
91 * @brief Destruct this object
93 ~CLHashtableLookupKernel() = default;
96 * @brief Set the input and output of the kernel
97 * @param[in] lookups Lookups 1D tensor that values are indices into the first dimension of
99 * @param[in] keys Keys 1D tensor. keys and input pair represent a map.
100 * Data types supported: S32
101 * @param[in] input Source tensor.
102 * Data types supported: U8/S8/QASYMM8/U16/S16/U32/S32/F16/F32
103 * @param[out] output Destination tensor. Data types and data layouts supported: Same as @p
105 * @param[out] hits Hits 1D tensor. A boolean tensor that indicates whether the lookup hits
106 * (True) or not (False). Data types supported: U8/QASYMM8
109 void configure(const ICLTensor *lookups, const ICLTensor *keys, const ICLTensor *input,
110 ICLTensor *output, ICLTensor *hits);
113 * @brief Static function to check if given info will lead to a valid configuration of @ref
114 * CLHashtableLookupKernel
115 * @param[in] lookups The lookups tensor info. Data types supported: S32.
116 * @param[in] keys The keys tensor info. keys and input pair represent a map.
117 * Data types supported: S32
118 * @param[in] input The input tensor info.
119 * Data types supported: U8/S8/QASYMM8/U16/S16/U32/S32/F16/F32
120 * @param[out] output The output tensor. Data types and data layouts supported: Same as @p
122 * @param[out] hits The hits tensor info. A boolean tensor that indicates whether the lookup
124 * (True) or not (False). Data types supported: U8/QASYMM8
127 static Status validate(const ITensorInfo *lookups, const ITensorInfo *keys,
128 const ITensorInfo *input, const ITensorInfo *output,
129 const ITensorInfo *hits);
132 * @brief Enqueue the OpenCL kernel to process the given window on the passed OpenCL command
134 * @note The queue is *not* flushed by this method, and therefore the kernel will not have
135 * been executed by the time this method returns.
136 * @param[in] window Region on which to execute the kernel. (Must be a valid region of
137 * the window returned by window()).
138 * @param[in,out] queue Command queue on which to enqueue the kernel.@return N/A
141 void run(const Window &window, cl::CommandQueue &queue) override;
144 const ICLTensor *_lookups{nullptr}; /** Lookups tensor */
145 const ICLTensor *_keys{nullptr}; /** Keys tensor */
146 const ICLTensor *_input{nullptr}; /** Source tensor */
147 ICLTensor *_output{nullptr}; /** Destination tensor */
148 ICLTensor *_hits{nullptr}; /** Hits tensor */
149 std::unique_ptr<CLTensor> _lookup_indices{nullptr}; /** Lookup indices tensor */
151 } // namespace arm_compute
152 #endif /*__ARM_COMPUTE_CLHASHTABLELOOKUPKERNEL_H__ */