blob: f25cf928ad702752f5936a3f42eceaa12fbd5355 [file] [log] [blame]
Giuseppe Rossinid7647d42018-07-17 18:13:13 +01001/*
Sheri Zhang7e20e292021-02-02 11:49:34 +00002 * Copyright (c) 2018-2021 Arm Limited.
Giuseppe Rossinid7647d42018-07-17 18:13:13 +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 */
Sheri Zhang7e20e292021-02-02 11:49:34 +000024#ifndef ARM_COMPUTE_CL_FILL_KERNEL_H
25#define ARM_COMPUTE_CL_FILL_KERNEL_H
Giuseppe Rossinid7647d42018-07-17 18:13:13 +010026
Sheri Zhang7e20e292021-02-02 11:49:34 +000027#include "src/core/common/Macros.h"
Georgios Pinitas7891a732021-08-20 21:39:25 +010028#include "src/gpu/cl/ClCompileContext.h"
29#include "src/gpu/cl/IClKernel.h"
Giuseppe Rossinid7647d42018-07-17 18:13:13 +010030
31namespace arm_compute
32{
Sheri Zhang7e20e292021-02-02 11:49:34 +000033namespace opencl
34{
35namespace kernels
36{
Giuseppe Rossinid7647d42018-07-17 18:13:13 +010037/** Interface for filling the planes of a tensor */
Teresa Charlin91b7f742021-04-12 13:57:00 +010038class ClFillKernel : public IClKernel
Giuseppe Rossinid7647d42018-07-17 18:13:13 +010039{
40public:
Giorgio Arena4a95bba2021-06-28 11:00:27 +010041 ClFillKernel();
Sheri Zhang7e20e292021-02-02 11:49:34 +000042 ARM_COMPUTE_DISALLOW_COPY_ALLOW_MOVE(ClFillKernel);
Giuseppe Rossinid7647d42018-07-17 18:13:13 +010043 /** Initialise the kernel's tensor and filling value
44 *
Manuel Bottini4c6bd512020-04-08 10:15:51 +010045 * @param[in] compile_context The compile context to be used.
Sheri Zhang7e20e292021-02-02 11:49:34 +000046 * @param[in,out] tensor Input tensor info. Supported data types: All.
Manuel Bottini4c6bd512020-04-08 10:15:51 +010047 * @param[in] constant_value The value used to fill the planes of the tensor
48 * @param[in] window Window to be used in case setting only part of a tensor. Default is nullptr.
49 */
Sheri Zhang7e20e292021-02-02 11:49:34 +000050 void configure(const CLCompileContext &compile_context, ITensorInfo *tensor, const PixelValue &constant_value, Window *window = nullptr);
Georgios Pinitas2eb5d162021-07-02 09:01:49 +010051 /** Static function to check if given info will lead to a valid configuration
Giuseppe Rossinid7647d42018-07-17 18:13:13 +010052 *
Georgios Pinitas2eb5d162021-07-02 09:01:49 +010053 * Similar to @ref ClFillKernel::configure()
Giuseppe Rossinid7647d42018-07-17 18:13:13 +010054 *
55 * @return a status
56 */
George Wort894066d2019-02-15 15:12:52 +000057 static Status validate(const ITensorInfo *tensor, const PixelValue &constant_value, Window *window = nullptr);
Giuseppe Rossinid7647d42018-07-17 18:13:13 +010058
59 // Inherited methods overridden:
Sheri Zhang7e20e292021-02-02 11:49:34 +000060 void run_op(ITensorPack &tensors, const Window &window, cl::CommandQueue &queue) override;
Giuseppe Rossinid7647d42018-07-17 18:13:13 +010061
62private:
Sheri Zhang7e20e292021-02-02 11:49:34 +000063 Window _full_window{};
Giuseppe Rossinid7647d42018-07-17 18:13:13 +010064};
Sheri Zhang7e20e292021-02-02 11:49:34 +000065} // namespace kernels
66} // namespace opencl
Giuseppe Rossinid7647d42018-07-17 18:13:13 +010067} // namespace arm_compute
Georgios Pinitas2eb5d162021-07-02 09:01:49 +010068#endif /* ARM_COMPUTE_CL_FILL_KERNEL_H */