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 CLEmbeddingLookupKernel.h
43 * @ingroup COM_AI_RUNTIME
44 * @brief This file defines CLEmbeddingLookupKernel class
47 #ifndef __ARM_COMPUTE_CLEMBEDDINGLOOKUPKERNEL_H__
48 #define __ARM_COMPUTE_CLEMBEDDINGLOOKUPKERNEL_H__
50 #include "arm_compute/core/CL/ICLKernel.h"
57 * @brief Class to perform EmbeddingLookup operation with opencl kernel
59 class CLEmbeddingLookupKernel : public ICLKernel
63 * @brief Construct a CLEmbeddingLookupKernel object
65 CLEmbeddingLookupKernel();
68 * @brief Prevent instances of this class from being copied (As this class contains pointers)
70 CLEmbeddingLookupKernel(const CLEmbeddingLookupKernel &) = delete;
73 * @brief Prevent instances of this class from being copied (As this class contains pointers)
75 CLEmbeddingLookupKernel &operator=(const CLEmbeddingLookupKernel &) = delete;
78 * @brief Construct a CLEmbeddingLookupKernel object by using default move constructor
79 * @param[in] CLEmbeddingLookupKernel object to move
81 CLEmbeddingLookupKernel(CLEmbeddingLookupKernel &&) = default;
84 * @brief Move assignment operator
85 * @param[in] CLEmbeddingLookupKernel object to move
87 CLEmbeddingLookupKernel &operator=(CLEmbeddingLookupKernel &&) = default;
90 * @brief Destruct this object
92 ~CLEmbeddingLookupKernel() = default;
95 * @brief Set the input and output of the kernel
96 * @param[in] input Source tensor.
97 * Data type supported: U8/S8/QASYMM8/U16/S16/U32/S32/F16/F32
98 * @param[out] output Destination tensor. Data type supported: Same as @p input
99 * @param[in] lookups Lookups are 1D tensor that values are indices into the first
100 * dimension of input.
101 * Data types supported: S32.
104 void configure(const ICLTensor *input, ICLTensor *output, const ICLTensor *lookups);
107 * @brief Static function to check if given info will lead to a valid configuration of @ref
108 * CLEmbeddingLookupKernel
109 * @param[in] input The input tensor info.
110 * Data types supported: U8/S8/QASYMM8/U16/S16/U32/S32/F16/F32
111 * @param[in] output The output tensor info, Data types supported: same as @p input1.
112 * @param[in] lookups Lookups info. Data types supported: S32.
115 static Status validate(const ITensorInfo *input, const ITensorInfo *output,
116 const ITensorInfo *lookups);
119 * @brief Enqueue the OpenCL kernel to process the given window on the passed OpenCL command
121 * @note The queue is *not* flushed by this method, and therefore the kernel will not have
122 * been executed by the time this method returns.
123 * @param[in] window Region on which to execute the kernel. (Must be a valid region of
124 * the window returned by window()).
125 * @param[in,out] queue Command queue on which to enqueue the kernel.@return N/A
128 void run(const Window &window, cl::CommandQueue &queue) override;
131 const ICLTensor *_input; /** Source tensor */
132 ICLTensor *_output; /** Destination tensor */
133 const ICLTensor *_lookups; /** Lookups tensor */
135 } // namespace arm_compute
136 #endif /*__ARM_COMPUTE_CLEMBEDDINGLOOKUPKERNEL_H__ */